Skip to content

Commit

Permalink
fix: typo renaming (#84)
Browse files Browse the repository at this point in the history
* fix: typo renaming

* Rename CrowdInArticleDirectories.ts to CrowdinArticleDirectories.ts

* Rename CrowdInFiles.ts to CrowdinFiles.ts

* Rename CrowdInCollectionDirectories.ts to CrowdinCollectionDirectories.ts

* fix(schema): regenerate

---------

Co-authored-by: Steven Thompson <[email protected]>
Co-authored-by: Steven Thompson <[email protected]>
  • Loading branch information
3 people authored Jul 27, 2023
1 parent dcdb42c commit 3cf30ce
Show file tree
Hide file tree
Showing 26 changed files with 264 additions and 264 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ All notable changes to this project will be documented in this file. See [standa
### Features

- **plugin:** add sourceLocale option ([#78](https://github.com/thompsonsj/payload-crowdin-sync/issues/78)) ([95943a7](https://github.com/thompsonsj/payload-crowdin-sync/commit/95943a786c50984c96008391d2af7ef4d11e2611))
- **translations:** move endpoints, send id and blockType to CrowdIn for arrays and blocks ([#80](https://github.com/thompsonsj/payload-crowdin-sync/issues/80)) ([2c0fcbd](https://github.com/thompsonsj/payload-crowdin-sync/commit/2c0fcbdfb19a7890ddf06a11f2564d7abb4bf762))
- **translations:** move endpoints, send id and blockType to Crowdin for arrays and blocks ([#80](https://github.com/thompsonsj/payload-crowdin-sync/issues/80)) ([2c0fcbd](https://github.com/thompsonsj/payload-crowdin-sync/commit/2c0fcbdfb19a7890ddf06a11f2564d7abb4bf762))
- **translations:** update fn works with json and html ([#82](https://github.com/thompsonsj/payload-crowdin-sync/issues/82)) ([78c2adc](https://github.com/thompsonsj/payload-crowdin-sync/commit/78c2adcb56d180fd1cafd71eb586bb39eb6e65a9))

### Bug Fixes

- **translations:** update translations with new CrowdIn JSON structure ([#81](https://github.com/thompsonsj/payload-crowdin-sync/issues/81)) ([6ef4331](https://github.com/thompsonsj/payload-crowdin-sync/commit/6ef43316881f52e466eee4dd40ffbd3b6ae343e0))
- **translations:** update translations with new Crowdin JSON structure ([#81](https://github.com/thompsonsj/payload-crowdin-sync/issues/81)) ([6ef4331](https://github.com/thompsonsj/payload-crowdin-sync/commit/6ef43316881f52e466eee4dd40ffbd3b6ae343e0))

## [0.12.1](https://github.com/thompsonsj/payload-crowdin-sync/compare/v0.12.0...v0.12.1) (2023-07-08)

Expand Down Expand Up @@ -55,7 +55,7 @@ All notable changes to this project will be documented in this file. See [standa

### Features

- **files:** store fileData sent to CrowdIn ([#61](https://github.com/thompsonsj/payload-crowdin-sync/issues/61)) ([7f28a47](https://github.com/thompsonsj/payload-crowdin-sync/commit/7f28a47f530eba7119b5015b5de9f1426e547133))
- **files:** store fileData sent to Crowdin ([#61](https://github.com/thompsonsj/payload-crowdin-sync/issues/61)) ([7f28a47](https://github.com/thompsonsj/payload-crowdin-sync/commit/7f28a47f530eba7119b5015b5de9f1426e547133))

## [0.8.2](https://github.com/thompsonsj/payload-crowdin-sync/compare/v0.8.1...v0.8.2) (2023-07-03)

Expand All @@ -80,7 +80,7 @@ All notable changes to this project will be documented in this file. See [standa

### Features

- delete CrowdIn files if empty, ensure `fields.json` is non-empty ([#46](https://github.com/thompsonsj/payload-crowdin-sync/issues/46)) ([b681bef](https://github.com/thompsonsj/payload-crowdin-sync/commit/b681bef3334ee7f58d1c05c6f2f486c652e49495))
- delete Crowdin files if empty, ensure `fields.json` is non-empty ([#46](https://github.com/thompsonsj/payload-crowdin-sync/issues/46)) ([b681bef](https://github.com/thompsonsj/payload-crowdin-sync/commit/b681bef3334ee7f58d1c05c6f2f486c652e49495))
- support blocks field type ([#47](https://github.com/thompsonsj/payload-crowdin-sync/issues/47)) ([6a8d4a9](https://github.com/thompsonsj/payload-crowdin-sync/commit/6a8d4a9aea9799c537f0e1452132b827a714e87b))

### Bug Fixes
Expand Down Expand Up @@ -131,7 +131,7 @@ All notable changes to this project will be documented in this file. See [standa
- **payload:** support nested json fields on translation update ([#13](https://github.com/thompsonsj/payload-crowdin-sync/issues/13)) ([4225b83](https://github.com/thompsonsj/payload-crowdin-sync/commit/4225b83d4cd6ed9f999b6412a493e0f693d40b08))
- **plugin:** support globals ([#6](https://github.com/thompsonsj/payload-crowdin-sync/issues/6)) ([80559ee](https://github.com/thompsonsj/payload-crowdin-sync/commit/80559ee4437f15a5b3fe1eda848a484a541979af))
- support collapsible fields, complete richText update support ([#18](https://github.com/thompsonsj/payload-crowdin-sync/issues/18)) ([3e37aba](https://github.com/thompsonsj/payload-crowdin-sync/commit/3e37abae34011e504af182ca2264a7929730c8ae))
- support updating group and array fields on CrowdIn ([#8](https://github.com/thompsonsj/payload-crowdin-sync/issues/8)) ([2401499](https://github.com/thompsonsj/payload-crowdin-sync/commit/2401499e8d5527aee2e4cc8357dd225a2eab4805))
- support updating group and array fields on Crowdin ([#8](https://github.com/thompsonsj/payload-crowdin-sync/issues/8)) ([2401499](https://github.com/thompsonsj/payload-crowdin-sync/commit/2401499e8d5527aee2e4cc8357dd225a2eab4805))

### Bug Fixes

Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Payload CrowdIn Sync Plugin
# Payload Crowdin Sync Plugin

Automatically upload/sync localized fields from the default locale to CrowdIn. Make these fields read-only in other locales and update them using CrowdIn translations.
Automatically upload/sync localized fields from the default locale to Crowdin. Make these fields read-only in other locales and update them using Crowdin translations.

Note: This plugin is still in development. A todo list is maintained at [/docs/development.md](/docs/development.md).

Expand All @@ -21,18 +21,18 @@ yarn add payload-crowdin-sync
Add the plugin to your Payload configuration.

```ts
import { crowdInSync, crowdinClient } from "payload-crowdin-sync";
import { crowdinSync, crowdinClient } from "payload-crowdin-sync";

export default buildConfig({
plugins: [
crowdInSync({
/* Required: Your CrowdIn project ID. */
crowdinSync({
/* Required: Your Crowdin project ID. */
projectId: 323731,
/* Optional: CrowdIn directory ID to store translations. */
/* Optional: Crowdin directory ID to store translations. */
directoryId: 1169,
/* Optional: Your CrowdIn API token. If empty, changes to files are disabled. */
/* Optional: Your Crowdin API token. If empty, changes to files are disabled. */
token: process.env.CROWDIN_TOKEN,
/* Required: Map your Payload locales to CrowdIn locale ids. */
/* Required: Map your Payload locales to Crowdin locale ids. */
localeMap: {
de_DE: {
crowdinId: "de",
Expand All @@ -41,7 +41,7 @@ export default buildConfig({
crowdinId: "fr",
},
},
/* Required: The Payload locale that syncs to source translations (files) on CrowdIn. */
/* Required: The Payload locale that syncs to source translations (files) on Crowdin. */
sourceLocale: "en",
}),
],
Expand All @@ -51,20 +51,20 @@ export default buildConfig({

### Environment variables

Set `PAYLOAD_CROWDIN_SYNC_ALWAYS_UPDATE=true` to update all localized fields in CrowdIn when an article is created/updated.
Set `PAYLOAD_CROWDIN_SYNC_ALWAYS_UPDATE=true` to update all localized fields in Crowdin when an article is created/updated.

By default, updates will only be sent to CrowdIn in the following scenarios.
By default, updates will only be sent to Crowdin in the following scenarios.

- At least one of the localized text fields has changed: any change to a localized `text` field updates the compiled `fields.json` that is sent to CrowdIn.
- A `richText` field is changed. Individual `richText` fields will only be updated on CrowdIn if the content has changed - each field has its own file on CrowdIn.
- At least one of the localized text fields has changed: any change to a localized `text` field updates the compiled `fields.json` that is sent to Crowdin.
- A `richText` field is changed. Individual `richText` fields will only be updated on Crowdin if the content has changed - each field has its own file on Crowdin.

It is useful to have a convenient way of forcing all localized fields to update at once. For example, if the plugin is activated on an existing install, it is convenient to trigger all updates on CrowdIn for a given article without having to change every `richText` field or one of the `text` fields.
It is useful to have a convenient way of forcing all localized fields to update at once. For example, if the plugin is activated on an existing install, it is convenient to trigger all updates on Crowdin for a given article without having to change every `richText` field or one of the `text` fields.

## Details

### CrowdIn collections
### Crowdin collections

By default, files are uploaded to CrowdIn using the following folder/file structure.
By default, files are uploaded to Crowdin using the following folder/file structure.

```
"Payload CMS" > [collectionSlug] > [articleSlug] > [fieldSlug]
Expand All @@ -77,18 +77,18 @@ For each entry in a collection that contains localized fields, an additonal fiel

When a localized field is changed, a file is created/updated in the `crowdin-files` collection for that field. Details of the file are stored in Payload so that this file can be updated or deleted in the future. Each entry in the `crowdin-files` collection has a one-to-one relationship with the appropriate entry in the `crowdin-article-directories` collection.

- `richText` fields have their own CrowdIn file. e.g. `content.html`. For ease-of-editing in CrowdIn, Slate JSON is converted to HTML. When translated HTML is synced back into Payload, it is converted back to Slate JSON.
- All other fields are compiled into a single `fields.json` file for ease-of-editing in CrowdIn.
- `richText` fields have their own Crowdin file. e.g. `content.html`. For ease-of-editing in Crowdin, Slate JSON is converted to HTML. When translated HTML is synced back into Payload, it is converted back to Slate JSON.
- All other fields are compiled into a single `fields.json` file for ease-of-editing in Crowdin.

Each entry in the `crowdin-article-directories` collection has a one-to-one relationship with an entry in the `crowdin-collection-directories` collection.

One-to-one relationships help preserve database integrity and simplify the operations needed to perform CRUD operations on all related entries.

All of the collections created by this plugin are designed to emulate the structure of API calls needed to communicate with crowdIn. Each directory/file is created in a single API operation on cRowdIn, and it is necessary to keep track of the details of each directory and file for future interactions.
All of the collections created by this plugin are designed to emulate the structure of API calls needed to communicate with crowdin. Each directory/file is created in a single API operation on cRowdIn, and it is necessary to keep track of the details of each directory and file for future interactions.

### Sync translations

Translation synchronisation refers to the process of loading translations from CrowdIn into Payload CMS. If [drafts](https://payloadcms.com/docs/versions/drafts) are enabled, this will create a new version in Payload CMS for each locale. The source locale (e.g. `en`) is not affected.
Translation synchronisation refers to the process of loading translations from Crowdin into Payload CMS. If [drafts](https://payloadcms.com/docs/versions/drafts) are enabled, this will create a new version in Payload CMS for each locale. The source locale (e.g. `en`) is not affected.

**A UI has not been developed for this feature yet**. To perform updates now, use custom REST API endpoints that are made available by this plugin.

Expand All @@ -112,8 +112,8 @@ A JSON object is returned that allows you to review what will be updated in the
- `translations`
- `<locale>` e.g. `es_ES`
- `currentTranslations` all current localized fields and values.
- `currentTranslations` localized fields populated with values from CrowdIn.
- `changed` boolean to indicate whether any changes have been made in CrowdIn.
- `currentTranslations` localized fields populated with values from Crowdin.
- `changed` boolean to indicate whether any changes have been made in Crowdin.

#### Update

Expand Down
54 changes: 27 additions & 27 deletions dev/src/generated-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ type CrowdinArticleDirectory {
id: String
name: String
crowdinCollectionDirectory(locale: LocaleInputType, fallbackLocale: FallbackLocaleInputType): CrowdinCollectionDirectory
crowdInFiles(locale: LocaleInputType, fallbackLocale: FallbackLocaleInputType): [CrowdinFile!]
crowdinFiles(locale: LocaleInputType, fallbackLocale: FallbackLocaleInputType): [CrowdinFile!]
createdAt: DateTime
updatedAt: DateTime
originalId: Float
Expand Down Expand Up @@ -3354,7 +3354,7 @@ type CrowdinArticleDirectories {
input CrowdinArticleDirectory_where {
name: CrowdinArticleDirectory_name_operator
crowdinCollectionDirectory: CrowdinArticleDirectory_crowdinCollectionDirectory_operator
crowdInFiles: CrowdinArticleDirectory_crowdInFiles_operator
crowdinFiles: CrowdinArticleDirectory_crowdinFiles_operator
createdAt: CrowdinArticleDirectory_createdAt_operator
updatedAt: CrowdinArticleDirectory_updatedAt_operator
originalId: CrowdinArticleDirectory_originalId_operator
Expand Down Expand Up @@ -3386,7 +3386,7 @@ input CrowdinArticleDirectory_crowdinCollectionDirectory_operator {
exists: Boolean
}

input CrowdinArticleDirectory_crowdInFiles_operator {
input CrowdinArticleDirectory_crowdinFiles_operator {
equals: String
not_equals: String
in: [String]
Expand Down Expand Up @@ -3475,7 +3475,7 @@ input CrowdinArticleDirectory_id_operator {
input CrowdinArticleDirectory_where_or {
name: CrowdinArticleDirectory_name_operator
crowdinCollectionDirectory: CrowdinArticleDirectory_crowdinCollectionDirectory_operator
crowdInFiles: CrowdinArticleDirectory_crowdInFiles_operator
crowdinFiles: CrowdinArticleDirectory_crowdinFiles_operator
createdAt: CrowdinArticleDirectory_createdAt_operator
updatedAt: CrowdinArticleDirectory_updatedAt_operator
originalId: CrowdinArticleDirectory_originalId_operator
Expand All @@ -3488,7 +3488,7 @@ input CrowdinArticleDirectory_where_or {
input CrowdinArticleDirectory_where_and {
name: CrowdinArticleDirectory_name_operator
crowdinCollectionDirectory: CrowdinArticleDirectory_crowdinCollectionDirectory_operator
crowdInFiles: CrowdinArticleDirectory_crowdInFiles_operator
crowdinFiles: CrowdinArticleDirectory_crowdinFiles_operator
createdAt: CrowdinArticleDirectory_createdAt_operator
updatedAt: CrowdinArticleDirectory_updatedAt_operator
originalId: CrowdinArticleDirectory_originalId_operator
Expand All @@ -3509,7 +3509,7 @@ type crowdin_article_directoriesDocAccess {
type CrowdinArticleDirectoriesDocAccessFields {
name: CrowdinArticleDirectoriesDocAccessFields_name
crowdinCollectionDirectory: CrowdinArticleDirectoriesDocAccessFields_crowdinCollectionDirectory
crowdInFiles: CrowdinArticleDirectoriesDocAccessFields_crowdInFiles
crowdinFiles: CrowdinArticleDirectoriesDocAccessFields_crowdinFiles
createdAt: CrowdinArticleDirectoriesDocAccessFields_createdAt
updatedAt: CrowdinArticleDirectoriesDocAccessFields_updatedAt
originalId: CrowdinArticleDirectoriesDocAccessFields_originalId
Expand Down Expand Up @@ -3564,26 +3564,26 @@ type CrowdinArticleDirectoriesDocAccessFields_crowdinCollectionDirectory_Delete
permission: Boolean!
}

type CrowdinArticleDirectoriesDocAccessFields_crowdInFiles {
create: CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Create
read: CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Read
update: CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Update
delete: CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Delete
type CrowdinArticleDirectoriesDocAccessFields_crowdinFiles {
create: CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Create
read: CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Read
update: CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Update
delete: CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Delete
}

type CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Create {
type CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Create {
permission: Boolean!
}

type CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Read {
type CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Read {
permission: Boolean!
}

type CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Update {
type CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Update {
permission: Boolean!
}

type CrowdinArticleDirectoriesDocAccessFields_crowdInFiles_Delete {
type CrowdinArticleDirectoriesDocAccessFields_crowdinFiles_Delete {
permission: Boolean!
}

Expand Down Expand Up @@ -5878,7 +5878,7 @@ type crowdin_article_directoriesAccess {
type CrowdinArticleDirectoriesFields {
name: CrowdinArticleDirectoriesFields_name
crowdinCollectionDirectory: CrowdinArticleDirectoriesFields_crowdinCollectionDirectory
crowdInFiles: CrowdinArticleDirectoriesFields_crowdInFiles
crowdinFiles: CrowdinArticleDirectoriesFields_crowdinFiles
createdAt: CrowdinArticleDirectoriesFields_createdAt
updatedAt: CrowdinArticleDirectoriesFields_updatedAt
originalId: CrowdinArticleDirectoriesFields_originalId
Expand Down Expand Up @@ -5933,26 +5933,26 @@ type CrowdinArticleDirectoriesFields_crowdinCollectionDirectory_Delete {
permission: Boolean!
}

type CrowdinArticleDirectoriesFields_crowdInFiles {
create: CrowdinArticleDirectoriesFields_crowdInFiles_Create
read: CrowdinArticleDirectoriesFields_crowdInFiles_Read
update: CrowdinArticleDirectoriesFields_crowdInFiles_Update
delete: CrowdinArticleDirectoriesFields_crowdInFiles_Delete
type CrowdinArticleDirectoriesFields_crowdinFiles {
create: CrowdinArticleDirectoriesFields_crowdinFiles_Create
read: CrowdinArticleDirectoriesFields_crowdinFiles_Read
update: CrowdinArticleDirectoriesFields_crowdinFiles_Update
delete: CrowdinArticleDirectoriesFields_crowdinFiles_Delete
}

type CrowdinArticleDirectoriesFields_crowdInFiles_Create {
type CrowdinArticleDirectoriesFields_crowdinFiles_Create {
permission: Boolean!
}

type CrowdinArticleDirectoriesFields_crowdInFiles_Read {
type CrowdinArticleDirectoriesFields_crowdinFiles_Read {
permission: Boolean!
}

type CrowdinArticleDirectoriesFields_crowdInFiles_Update {
type CrowdinArticleDirectoriesFields_crowdinFiles_Update {
permission: Boolean!
}

type CrowdinArticleDirectoriesFields_crowdInFiles_Delete {
type CrowdinArticleDirectoriesFields_crowdinFiles_Delete {
permission: Boolean!
}

Expand Down Expand Up @@ -6586,7 +6586,7 @@ input mutationCrowdinCollectionDirectoryUpdateInput {
input mutationCrowdinArticleDirectoryInput {
name: String
crowdinCollectionDirectory: String
crowdInFiles: [String]
crowdinFiles: [String]
createdAt: String
updatedAt: String
originalId: Float
Expand All @@ -6603,7 +6603,7 @@ enum CrowdinArticleDirectory_excludeLocales_MutationInput {
input mutationCrowdinArticleDirectoryUpdateInput {
name: String
crowdinCollectionDirectory: String
crowdInFiles: [String]
crowdinFiles: [String]
createdAt: String
updatedAt: String
originalId: Float
Expand Down
2 changes: 1 addition & 1 deletion dev/src/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface CrowdinArticleDirectory {
id: string;
name?: string;
crowdinCollectionDirectory?: string | CrowdinCollectionDirectory;
crowdInFiles?: string[] | CrowdinFile[];
crowdinFiles?: string[] | CrowdinFile[];
createdAt: string;
updatedAt: string;
originalId?: number;
Expand Down
4 changes: 2 additions & 2 deletions dev/src/payload.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Tags from "./collections/Tags";
import Users from "./collections/Users";
import { resolve } from "path";

import { crowdInSync } from "../../dist";
import { crowdinSync } from "../../dist";

import dotenv from "dotenv";

Expand All @@ -32,7 +32,7 @@ export default buildConfig({
user: Users.slug,
},
plugins: [
crowdInSync({
crowdinSync({
projectId: 323731,
directoryId: 1169,
token: process.env.CROWDIN_TOKEN,
Expand Down
Loading

0 comments on commit 3cf30ce

Please sign in to comment.