Adds a translate action to the admin UI for enabled collections and globals, filling localized fields from another locale. Resolvers perform the work, with built-in copy, Google Translate, OpenAI and LibreTranslate options, plus support for custom ones. It also exposes a Local API operation for use in hooks. Requires Payload 3.1 or later with localization enabled.
Installation
npm i @payload-enchants/translator335
Stars
28
Forks
28
Open Issues
1 years ago
Last Updated
1.5k
Weekly Downloads
v1.3.0
npm Version
157.5 KB
Unpacked Size
2
Dependencies
335+2 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 335 |
| Dec 5, 2026 | 335 |
| Dec 4, 2026 | 335 |
| Dec 3, 2026 | 335 |
| Dec 2, 2026 | 335 |
| Dec 1, 2026 | 335 |
| Nov 30, 2026 | 335 |
| Nov 29, 2026 | 335 |
| Nov 28, 2026 | 335 |
| Nov 27, 2026 | 335 |
| Nov 26, 2026 | 335 |
| Nov 25, 2026 | 335 |
| Nov 24, 2026 | 335 |
| Nov 23, 2026 | 335 |
| Nov 22, 2026 | 335 |
| Nov 21, 2026 | 335 |
| Nov 20, 2026 | 335 |
| Nov 19, 2026 | 336 |
| Nov 18, 2026 | 336 |
| Nov 17, 2026 | 335 |
| Nov 16, 2026 | 335 |
| Nov 15, 2026 | 335 |
| Nov 14, 2026 | 335 |
| Nov 13, 2026 | 335 |
| Nov 12, 2026 | 335 |
| Nov 11, 2026 | 335 |
| Nov 10, 2026 | 335 |
| Nov 9, 2026 | 335 |
| Nov 8, 2026 | 335 |
| Nov 7, 2026 | 335 |
| Nov 6, 2026 | 335 |
| Nov 5, 2026 | 335 |
| Nov 4, 2026 | 335 |
| Nov 3, 2026 | 335 |
| Nov 2, 2026 | 335 |
| Nov 1, 2026 | 335 |
| Oct 31, 2026 | 335 |
| Oct 30, 2026 | 335 |
| Oct 29, 2026 | 335 |
| Oct 28, 2026 | 335 |
| Oct 27, 2026 | 335 |
| Oct 26, 2026 | 335 |
| Oct 25, 2026 | 335 |
| Oct 24, 2026 | 334 |
| Oct 23, 2026 | 334 |
| Oct 22, 2026 | 334 |
| Oct 21, 2026 | 334 |
| Oct 20, 2026 | 334 |
| Oct 19, 2026 | 334 |
| Oct 18, 2026 | 334 |
| Oct 17, 2026 | 334 |
| Oct 16, 2026 | 334 |
| Oct 15, 2026 | 334 |
| Oct 14, 2026 | 334 |
| Oct 13, 2026 | 334 |
| Oct 12, 2026 | 334 |
| Oct 11, 2026 | 333 |
| Oct 10, 2026 | 333 |
| Oct 9, 2026 | 333 |
| Oct 8, 2026 | 333 |
| Oct 7, 2026 | 333 |
| Oct 6, 2026 | 333 |
| Oct 5, 2026 | 333 |
| Oct 4, 2026 | 333 |
| Oct 3, 2026 | 333 |
| Oct 2, 2026 | 333 |
| Oct 1, 2026 | 333 |
| Sep 30, 2026 | 333 |
| Sep 29, 2026 | 333 |
| Sep 28, 2026 | 333 |
| Sep 27, 2026 | 333 |
| Sep 26, 2026 | 333 |
| Sep 25, 2026 | 333 |
| Sep 24, 2026 | 333 |
| Sep 23, 2026 | 333 |
| Sep 22, 2026 | 333 |
| Sep 21, 2026 | 333 |
| Sep 20, 2026 | 333 |
| Sep 19, 2026 | 333 |
| Sep 18, 2026 | 333 |
| Sep 17, 2026 | 333 |
| Sep 16, 2026 | 333 |
| Sep 15, 2026 | 333 |
| Sep 14, 2026 | 333 |
| Sep 13, 2026 | 333 |
| Sep 12, 2026 | 333 |
| Sep 11, 2026 | 333 |
| Sep 10, 2026 | 333 |
| Sep 9, 2026 | 333 |
| Sep 8, 2026 | 333 |
| Sep 7, 2026 | 333 |
Shared by 7 plugins in r1tsuu/payload-enchants.
1.5K−2.5K since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 1,484 |
| Dec 5, 2026 | 1,408 |
| Dec 4, 2026 | 1,805 |
| Dec 3, 2026 | 2,878 |
| Dec 2, 2026 | 3,304 |
| Dec 1, 2026 | 3,300 |
| Nov 30, 2026 | 3,521 |
| Nov 29, 2026 | 4,419 |
| Nov 28, 2026 | 4,849 |
| Nov 27, 2026 | 4,627 |
| Nov 26, 2026 | 4,257 |
| Nov 25, 2026 | 3,635 |
| Nov 24, 2026 | 3,650 |
| Nov 23, 2026 | 3,514 |
| Nov 22, 2026 | 3,064 |
| Nov 21, 2026 | 3,219 |
| Nov 20, 2026 | 3,943 |
| Nov 19, 2026 | 3,639 |
| Nov 18, 2026 | 3,997 |
| Nov 17, 2026 | 4,014 |
| Nov 16, 2026 | 4,067 |
| Nov 15, 2026 | 3,833 |
| Nov 14, 2026 | 3,714 |
| Nov 13, 2026 | 3,223 |
| Nov 12, 2026 | 3,422 |
| Nov 11, 2026 | 3,244 |
| Nov 10, 2026 | 3,268 |
| Nov 9, 2026 | 3,095 |
| Nov 8, 2026 | 3,757 |
| Nov 7, 2026 | 4,125 |
| Nov 6, 2026 | 3,934 |
| Nov 5, 2026 | 3,525 |
| Nov 4, 2026 | 3,511 |
| Nov 3, 2026 | 3,495 |
| Nov 2, 2026 | 3,629 |
| Nov 1, 2026 | 3,170 |
| Oct 31, 2026 | 2,786 |
| Oct 30, 2026 | 2,615 |
| Oct 29, 2026 | 2,159 |
| Oct 28, 2026 | 1,697 |
| Oct 27, 2026 | 1,790 |
| Oct 26, 2026 | 1,801 |
| Oct 25, 2026 | 1,879 |
| Oct 24, 2026 | 2,019 |
| Oct 23, 2026 | 1,711 |
| Oct 22, 2026 | 2,324 |
| Oct 21, 2026 | 3,083 |
| Oct 20, 2026 | 3,076 |
| Oct 19, 2026 | 3,028 |
| Oct 18, 2026 | 2,443 |
| Oct 17, 2026 | 1,864 |
| Oct 16, 2026 | 2,088 |
| Oct 15, 2026 | 2,035 |
| Oct 14, 2026 | 1,775 |
| Oct 13, 2026 | 1,645 |
| Oct 12, 2026 | 1,555 |
| Oct 11, 2026 | 1,661 |
| Oct 10, 2026 | 2,620 |
| Oct 9, 2026 | 3,080 |
| Oct 8, 2026 | 3,228 |
| Oct 7, 2026 | 3,876 |
| Oct 6, 2026 | 4,440 |
| Oct 5, 2026 | 5,191 |
| Oct 4, 2026 | 7,360 |
| Oct 3, 2026 | 8,749 |
| Oct 2, 2026 | 14,647 |
| Oct 1, 2026 | 20,512 |
| Sep 30, 2026 | 23,725 |
| Sep 29, 2026 | 24,428 |
| Sep 28, 2026 | 25,308 |
| Sep 27, 2026 | 23,449 |
| Sep 26, 2026 | 22,139 |
| Sep 25, 2026 | 16,747 |
| Sep 24, 2026 | 11,994 |
| Sep 23, 2026 | 8,439 |
| Sep 22, 2026 | 7,439 |
| Sep 21, 2026 | 6,118 |
| Sep 20, 2026 | 11,905 |
| Sep 19, 2026 | 13,962 |
| Sep 18, 2026 | 13,855 |
| Sep 17, 2026 | 13,150 |
| Sep 16, 2026 | 12,760 |
| Sep 15, 2026 | 13,921 |
| Sep 14, 2026 | 14,192 |
| Sep 13, 2026 | 8,396 |
| Sep 12, 2026 | 5,758 |
| Sep 11, 2026 | 5,420 |
| Sep 10, 2026 | 4,839 |
| Sep 9, 2026 | 4,872 |
| Sep 8, 2026 | 3,763 |
| Sep 7, 2026 | 3,984 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/684372049-translator)<a href="https://payloaddirectory.dev/plugins/684372049-translator"><img src="https://payloaddirectory.dev/badge/684372049-translator.svg" alt="Payload Directory"></a>README
pnpm add @payload-enchants/translator
import { buildConfig } from 'payload/config';
import {
translator,
copyResolver,
googleResolver,
openAIResolver,
libreResolver,
} from '@payload-enchants/translator';
export default buildConfig({
plugins: [
translator({
// collections with the enabled translator in the admin UI
collections: ['posts', 'small-posts'],
// globals with the enabled translator in the admin UI
globals: [],
// add resolvers that you want to include, examples on how to write your own in ./plugin/src/resolvers
resolvers: [
copyResolver(),
googleResolver({
apiKey: process.env.GOOGLE_API_KEY!,
}),
openAIResolver({
apiKey: process.env.OPENAI_KEY!,
}),
libreResolver({
apiKey: process.env.LIBRE_KEY!,
}),
],
}),
],
});
export type OpenAIResolverConfig = {
apiKey: string; // API key
chunkLength?: number; // How many texts to include into 1 request, default: 100
model?: string; // model, default: 'gpt-3.5-turbo'
promt?: OpenAIPrompt; // custom prompt
};
export type OpenAIPrompt = (args: {
localeFrom: string;
localeTo: string;
texts: string[];
}) => string;
// Default
const defaultPromt: OpenAIPrompt = ({ localeFrom, localeTo, texts }) => {
return `Translate me the following array: ${JSON.stringify(texts)} in locale=${localeFrom} to locale ${localeTo}, respond me with the same array structure`;
};
export type GoogleResolverConfig = {
apiKey: string; // API key
chunkLength?: number; / /How many texts to include into 1 request, default: 100
};
import type { TranslateResolver } from '@payload-enchants/translator/resolvers/types';
const myResolver: TranslateResolver = {
key: 'my',
resolve: async (args) => {
const { localeFrom, localeTo, req, texts } = args;
// here you can apply any kind of transformation to incoming texts, could be as well API call to a service.
const transformed = texts.map((each) => `${each} translated to ${localeTo}`);
return {
success: true,
translatedTexts: transformed,
};
},
};
export default buildConfig({
plugins: [
payloadPluginTranslator({
collections: ['posts', 'small-posts'],
globals: [],
resolvers: [myResolver],
}),
],
// apply translations that will be used for your resolver in the admin UI
i18n: {
supportedLanguages: { en },
translations: {
en: {
'plugin-translator': {
resolver_my_buttonLabel: 'Google Translate',
resolver_my_errorMessage: 'An error occurred when trying to translate the data',
resolver_my_modalTitle: 'Choose the locale to translate from',
resolver_my_submitButtonLabelEmpty: 'Translate only empty fields',
resolver_my_submitButtonLabelFull: 'Translate all',
resolver_my_successMessage: 'Successfully translated. Press "Save" to apply the changes.',
},
},
},
},
});
import { translateOperation } from '@payload-enchants/translator';
const translateResult = await translateOperation({
collectionSlug: 'posts', // or globalSlug if globals,
emptyOnly: false, // optional, should translate all the fields values or only fields that are empty, by default false.
id: postDefaultLocale.id, // pass the doc id if it's a collection
locale: 'de', // locale to translate to
localeFrom: 'en', // locale to translate from
payload, // payload instance, you can get it with getPayload or req.payload in hooks
req, // PayloadRequest, can be used instead of payload, more appreciable than payload if you have it
overrideAccess: false, //
resolver: 'copy', // pass resolver key
update: true, // optional, should update immediately or just return the translated result, default false
data: {}, // Optional, if you want to translate from your data passed here instead of the current doc, should be in "localeFrom" locale, for example { title: "Hello" }
});
import type { CollectionAfterChangeHook } from 'payload/types';
import { translateOperation } from '@payload-enchants/translator';
export const copyOtherLocales: CollectionAfterChangeHook = async ({
collection,
doc,
operation,
req,
}) => {
if (operation !== 'create') return;
const locale = req.locale;
if (!locale || !req.payload.config.localization) return;
const otherLocales = req.payload.config.localization.locales.filter(
(each) => each.code !== locale,
);
const { id } = doc;
for (const { code } of otherLocales) {
await translateOperation({
collectionSlug: collection.slug,
data: doc,
id,
locale: code,
localeFrom: locale,
req,
resolver: 'copy',
update: true,
});
}
};
To omit a specific field for translation, simply add custom.translatorSkip = true to the field's config.
const field = {
custom: {
translatorSkip: true,
},
localized: true,
name: 'skip',
type: 'text',
};
payload plugin translator
AI translation of localized fields in collections and globals, saved as drafts without overwriting hand-edited text
74356/wk1v3
payload auto translate
Automatic content translation for localized Payload collections using a LibreTranslate instance
6348/wk2v3
payload plugin translator
Translate localized Payload content with an AI provider from the admin panel via background jobs
713.9k/wk37v3
payload plugin ai localization
Auto-translate localized fields from the default locale using OpenAI from the Payload admin
4334/wk26v3
payload plugin polyglot
Automatic content translation on publish and in sweeps, with translation memory and protection for human-reviewed text
68836/wk0v3
payload crowdin sync
Sync localized Payload fields to Crowdin as compact HTML and JSON files and write translations back
2614v3