Skip to content

Upload and sync localized fields from the default locale to Crowdin.

Notifications You must be signed in to change notification settings

thompsonsj/payload-crowdin-sync

Repository files navigation

Payload Crowdin Sync

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.

Quick start

npm install payload-crowdin-sync

Add the plugin to your Payload configuration.

import { crowdinSync } from "payload-crowdin-sync";

export default buildConfig({
  plugins: [
    crowdinSync({
      projectId: 323731,
      token: process.env.CROWDIN_TOKEN,
      localeMap: {
        de_DE: {
          crowdinId: "de",
        },
        fr_FR: {
          crowdinId: "fr",
        },
      },
      sourceLocale: "en",
    }),
  ],
  // The rest of your config goes here
});

On save draft or publish, content from localized fields in Collections and/or globals is organised into directories and files within a Payload CMS directory (configurable) in your Crowdin project.

Screenshot 2024-02-06 at 22 02 38

To load translations into Payload CMS, check the Sync all translations checkbox on a given collection document/global and save draft (loads translations as draft) or publish.

Screenshot 2024-02-06 at 22 08 48

Monorepo scripts

Test

Run all tests.

  • The plugin package contains unit tests.
  • Both the dev and dev-alternative-config packages contain integration tests run against Payload installations.
npm run test

Release

Build the plugin, change to the plugin directory and run npm publish.

npm run release