payload-crowdin-sync
v0.46.1
Published
Reorganise nested Payload CMS documents into compact HTML and JSON files for Crowdin translators. Groups, arrays, and Lexical blocks inside rich text become a small set of files. Fields that are not translatable stay in Payload.
Maintainers
Readme
payload-crowdin-sync
Reorganise nested Payload CMS documents into compact HTML and JSON files for Crowdin translators.
Documentation: thompsonsj.github.io/payload-crowdin-sync
Nested Payload documents, including blocks embedded in Lexical rich text, become HTML and JSON in Crowdin. File count stays low: one fields.json, one HTML file per rich text field, and a small folder per Lexical block. Numbers, selects, dates, uploads, relationships, and fields you exclude stay in Payload. Translations are written back into the same nested structure.
Features
- Uploads localized fields from collections and globals on save, sending only the fields that changed.
- Converts Slate and Lexical rich text to HTML and back, including Lexical blocks, uploads, relationships and tables.
- Handles localized fields nested in groups, arrays, blocks, tabs, collapsibles and rows.
- Leaves numbers, selects, dates, uploads and relationships in Payload, and lets you exclude individual text fields.
- Loads translations from a checkbox in the admin panel, from REST endpoints with a dry-run review, or from Payload jobs.
- Skips translations that are missing required fields, and reports the validation errors.
- Recreates files and folders that were deleted in Crowdin.
Requirements
- Payload 3
- A Crowdin project and a personal access token
Install
npm install payload-crowdin-syncQuick start
import { buildConfig } from 'payload';
import { crowdinSync } from 'payload-crowdin-sync';
export default buildConfig({
plugins: [
crowdinSync({
projectId: 323731,
token: process.env.CROWDIN_TOKEN ?? '',
sourceLocale: 'en',
localeMap: {
de_DE: { crowdinId: 'de' },
fr_FR: { crowdinId: 'fr' },
},
// Optional: limit the plugin to some collections and globals.
// Leave undefined to enable it wherever there are localized fields.
// collections: ['posts'],
// globals: ['nav'],
}),
],
});The plugin adds three collections to your database (crowdin-files, crowdin-article-directories and crowdin-collection-directories) It also adds Sync translations and Sync all translations checkboxes to each enabled document, which appear after its first upload to Crowdin.
