Localization plugin for PayloadCms.
A plugin for Payload CMS that automatically adds UI components to manage content localizations at the level of a single localizable field without having to change the document display language every time.
- Payload version 2.28.0 or higher is required.
npm i @websolutespa/payload-plugin-localization
import { buildConfig } from 'payload/config';
import { localization } from '@websolutespa/payload-plugin-localization';
import '@websolutespa/payload-plugin-localization/dist/index.css';
export default buildConfig({
plugins: [
localization(),
// The rest of your plugins config goes here
],
});
Option | Type | Description |
---|---|---|
autoTranslationAdapter | AutoTranslationAdapter | If defined, a button "Autotranslate" will be visibile in the translation modal. When clicked the adapter will be executed to retrieve the translation |
The plugin only affects fields configured via the Payload collections configuration with localized: true
and automatically adds:
- A sticky component at the top of document with the locale selector to easily switch locales (for all collections even if they do not contain localized fields).
- A "Change localization" button to instantly understand which field are localized and access the localization feature.
- A modal that allows you to edit the existing localizations and insert new ones. The localization in the reference language (current document locale) is always visible to facilitate the translation. You can save all changed localizations at once as drafts or publish them directly.
- An "Autotranslate" function to generate automatic translations (available only when an autotranslation adapter is configured)
Note: In order to open the localization modal the document must be saved at least once. Before that, the message "Save document to enable localizations" will appear on the modal opening button.