Adds a localized translations collection to Payload so editors can manage UI microcopy such as buttons and labels from the admin panel. Provides cached server-side lookups with Next.js tag revalidation on change, a client provider with a translation hook, and a REST endpoint. Works standalone or as a message source for next-intl. Requires Payload 3.90 or newer and Next.js 15 or 16.
A Payload CMS v3 plugin that moves static frontend translation keys into the database, enabling content editors to manage UI translations with full localization support.
Installation
npm i payload-plugin-dictionary3
Stars
0
Forks
0
Open Issues
1 months ago
Last Updated
15
Weekly Downloads
v1.0.1
npm Version
466.1 KB
Unpacked Size
0
Dependencies
3+3 since Oct 11
| Date | Stars |
|---|---|
| Dec 5, 2026 | 3 |
| Dec 4, 2026 | 3 |
| Dec 3, 2026 | 3 |
| Dec 2, 2026 | 3 |
| Dec 1, 2026 | 3 |
| Nov 30, 2026 | 3 |
| Nov 29, 2026 | 3 |
| Nov 28, 2026 | 3 |
| Nov 27, 2026 | 3 |
| Nov 26, 2026 | 3 |
| Nov 25, 2026 | 3 |
| Nov 24, 2026 | 3 |
| Nov 23, 2026 | 3 |
| Nov 22, 2026 | 3 |
| Nov 21, 2026 | 3 |
| Nov 20, 2026 | 3 |
| Nov 19, 2026 | 3 |
| Nov 18, 2026 | 3 |
| Nov 17, 2026 | 3 |
| Nov 16, 2026 | 3 |
| Nov 15, 2026 | 3 |
| Nov 14, 2026 | 3 |
| Nov 13, 2026 | 3 |
| Nov 12, 2026 | 3 |
| Nov 11, 2026 | 3 |
| Nov 10, 2026 | 3 |
| Nov 9, 2026 | 3 |
| Nov 8, 2026 | 3 |
| Nov 7, 2026 | 3 |
| Nov 6, 2026 | 3 |
| Nov 5, 2026 | 3 |
| Nov 4, 2026 | 3 |
| Nov 3, 2026 | 3 |
| Nov 2, 2026 | 3 |
| Nov 1, 2026 | 3 |
| Oct 31, 2026 | 3 |
| Oct 30, 2026 | 3 |
| Oct 29, 2026 | 3 |
| Oct 28, 2026 | 3 |
| Oct 27, 2026 | 3 |
| Oct 26, 2026 | 3 |
| Oct 25, 2026 | 3 |
| Oct 24, 2026 | 3 |
| Oct 23, 2026 | 3 |
| Oct 22, 2026 | 3 |
| Oct 21, 2026 | 3 |
| Oct 20, 2026 | 3 |
| Oct 19, 2026 | 3 |
| Oct 18, 2026 | 3 |
| Oct 17, 2026 | 3 |
| Oct 16, 2026 | 3 |
| Oct 15, 2026 | 2 |
| Oct 14, 2026 | 2 |
| Oct 13, 2026 | 2 |
| Oct 12, 2026 | 0 |
| Oct 11, 2026 | 0 |
11−244 since Oct 15
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 11 |
| Dec 4, 2026 | 11 |
| Dec 3, 2026 | 10 |
| Dec 2, 2026 | 25 |
| Dec 1, 2026 | 30 |
| Nov 30, 2026 | 32 |
| Nov 29, 2026 | 32 |
| Nov 28, 2026 | 31 |
| Nov 27, 2026 | 29 |
| Nov 26, 2026 | 28 |
| Nov 25, 2026 | 14 |
| Nov 24, 2026 | 11 |
| Nov 23, 2026 | 13 |
| Nov 22, 2026 | 14 |
| Nov 21, 2026 | 15 |
| Nov 20, 2026 | 21 |
| Nov 19, 2026 | 22 |
| Nov 18, 2026 | 20 |
| Nov 17, 2026 | 20 |
| Nov 16, 2026 | 17 |
| Nov 15, 2026 | 15 |
| Nov 14, 2026 | 14 |
| Nov 13, 2026 | 13 |
| Nov 12, 2026 | 18 |
| Nov 11, 2026 | 21 |
| Nov 10, 2026 | 25 |
| Nov 9, 2026 | 31 |
| Nov 8, 2026 | 34 |
| Nov 7, 2026 | 41 |
| Nov 6, 2026 | 38 |
| Nov 5, 2026 | 35 |
| Nov 4, 2026 | 34 |
| Nov 3, 2026 | 37 |
| Nov 2, 2026 | 50 |
| Nov 1, 2026 | 63 |
| Oct 31, 2026 | 216 |
| Oct 30, 2026 | 218 |
| Oct 29, 2026 | 214 |
| Oct 28, 2026 | 212 |
| Oct 27, 2026 | 208 |
| Oct 26, 2026 | 191 |
| Oct 25, 2026 | 182 |
| Oct 24, 2026 | 35 |
| Oct 23, 2026 | 30 |
| Oct 22, 2026 | 58 |
| Oct 21, 2026 | 313 |
| Oct 20, 2026 | 308 |
| Oct 19, 2026 | 305 |
| Oct 18, 2026 | 297 |
| Oct 17, 2026 | 283 |
| Oct 16, 2026 | 283 |
| Oct 15, 2026 | 255 |
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/1415671952-root)<a href="https://payloaddirectory.dev/plugins/1415671952-root"><img src="https://payloaddirectory.dev/badge/1415671952-root.svg" alt="Payload Directory"></a>README
A high-performance Payload CMS v3 plugin that migrates static front-end translation keys (en.json, ar.json, fr.json) into your database. Empower content editors to manage UI microcopy—such as buttons, navigation labels, headers, and error messages—directly within the Payload Admin panel, with instant on-demand cache revalidation and zero required third-party frontend dependencies.
🌐 Website & Documentation: https://mhmod-hsn.github.io/payload-plugin-dictionary/
Traditional Static i18n (en.json) | With payload-plugin-dictionary |
|---|---|
| Hardcoded in Git repository | Managed in Payload Admin Panel |
| Copy changes require Pull Requests & redeployments | Instant updates with zero downtime |
| Content editors cannot modify microcopy | Content editors have full localized control |
| Often requires bulky client bundles | Next.js Server Components with automatic cache eviction |
translations collection with native localization support.unstable_cache and tagged with 'payload-translations', ensuring database queries are cached and served in milliseconds.t('key') functions for React Server Components and Client Components (<DictionaryProvider> + useTranslations()).next-intl & i18next Compatibility: Easily acts as the dynamic message provider for existing i18n libraries.GET /api/dictionary/:namespace?locale=:locale with HTTP caching headers.npx payload-dictionary generate to generate TypeScript types directly from database keys for full IDE autocompletion.auth.login_button) and ensures composite uniqueness across (namespace, key) pairs.# Using pnpm
pnpm add payload-plugin-dictionary
# Using npm
npm install payload-plugin-dictionary
# Using yarn
yarn add payload-plugin-dictionary
payload: ^3.90.0next: ^15.0.0 || ^16.0.0react: ^19.0.0 (optional; only needed if using client <DictionaryProvider> or useTranslations)Add dictionaryPlugin to your payload.config.ts:
import { buildConfig } from 'payload'
import { dictionaryPlugin } from 'payload-plugin-dictionary'
export default buildConfig({
localization: {
locales: ['en', 'ar', 'fr'],
defaultLocale: 'en',
fallback: true,
},
plugins: [
dictionaryPlugin({
namespaces: ['common', 'auth', 'marketing'],
defaultNamespace: 'common',
}),
],
// ... your remaining Payload configuration
})
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
namespaces | string[] | Yes | — | Array of permitted namespaces (e.g. ['common', 'auth']). |
defaultNamespace | string | No | namespaces[0] | Default namespace selected when creating new translation documents. |
You can use this plugin in two ways:
getTranslations, <DictionaryProvider>, and useTranslations() hook.next-intl): Supplying the dictionary messages directly to next-intl.In any React Server Component, call getTranslations():
// app/[locale]/page.tsx
import { getTranslations } from 'payload-plugin-dictionary/cache'
export default async function HomePage({ params }: { params: Promise<{ locale: string }> }) {
const { locale } = await params
const t = await getTranslations('common', locale)
return (
<main>
{/* 1. Basic lookup */}
<h1>{t('home.title')}</h1>
{/* 2. Variable interpolation */}
<p>{t('welcome.user', { name: 'Sarah' })}</p>
{/* 3. Safe fallback if key is missing */}
<button>{t('button.submit', 'Submit')}</button>
</main>
)
}
To use translations inside 'use client' components, fetch the dictionary in your Server Layout and wrap the children with <DictionaryProvider>:
// app/[locale]/layout.tsx (Server Component)
import { getDictionary } from 'payload-plugin-dictionary/cache'
import { DictionaryProvider } from 'payload-plugin-dictionary/client'
export default async function LocaleLayout({
children,
params,
}: {
children: React.ReactNode
params: Promise<{ locale: string }>
}) {
const { locale } = await params
// Fetch raw dictionary for the client provider
const dictionary = await getDictionary('common', locale)
return (
<html lang={locale}>
<body>
<DictionaryProvider dictionary={dictionary}>{children}</DictionaryProvider>
</body>
</html>
)
}
Now call useTranslations() in any Client Component anywhere in the tree:
// components/CounterButton.tsx
'use client'
import { useTranslations } from 'payload-plugin-dictionary/client'
import { useState } from 'react'
export function CounterButton() {
const t = useTranslations()
const [count, setCount] = useState(0)
return (
<div>
<button onClick={() => setCount((c) => c + 1)}>
{t('button.click_me')} ({count})
</button>
{/* Interpolation in client components */}
<p>{t('items.count', { count })}</p>
{/* Fallback support */}
<button onClick={() => setCount(0)}>{t('button.reset', 'Reset Counter')}</button>
</div>
)
}
The t function returned by getTranslations() and useTranslations() provides:
| Signature | Description | Example |
|---|---|---|
t(key) | Looks up key; returns key string if missing | t('button.submit') |
t(key, params) | Replaces {var} placeholders with values | t('greeting', { name: 'Alex' }) |
t(key, fallback) | Returns fallback text if key is missing | t('button.save', 'Save Changes') |
t(key, params, fallback) | Replaces placeholders with fallback text if key is missing | t('hello', { name: 'Alex' }, 'Hello Alex') |
t.has(key) | Returns true if key exists in dictionary | if (t.has('banner.alert')) ... |
t.raw(key) | Returns raw uninterpolated string or undefined | t.raw('welcome') |
t.dictionary | Direct reference to Record<string, string> map | Object.keys(t.dictionary) |
next-intlIf your project already uses next-intl, payload-plugin-dictionary integrates seamlessly as the message source.
Configure i18n/request.ts:
// i18n/request.ts
import { getRequestConfig } from 'next-intl/server'
import { getDictionary } from 'payload-plugin-dictionary/cache'
export default getRequestConfig(async ({ requestLocale }) => {
const locale = (await requestLocale) || 'en'
// Fetch from Payload database with automatic Next.js caching
const messages = await getDictionary('common', locale)
return {
locale,
messages,
}
})
Consume in your components using standard next-intl APIs:
import { useTranslations } from 'next-intl'
export function Header() {
const t = useTranslations()
return <h1>{t('nav.home')}</h1>
}
The plugin automatically registers an HTTP REST endpoint on your Payload server:
GET /api/dictionary/:namespace?locale=:locale
GET /api/dictionary/common?locale=ar
{
"button.submit": "إرسال",
"button.cancel": "إلغاء",
"nav.home": "الرئيسية",
"footer.copyright": "جميع الحقوق محفوظة © 2026"
}
Content-Type: application/jsonCache-Control: public, s-maxage=3600, stale-while-revalidate=86400Generate strongly-typed TypeScript definitions from your database keys for IDE autocompletion:
# Run the generator
npx payload-dictionary generate
dictionary.d.ts)/**
* Auto-generated by payload-dictionary. Do not edit manually.
*/
export type CommonTranslationKeys = 'button.submit' | 'button.cancel' | 'home.title'
export type AuthTranslationKeys = 'login.button' | 'error.invalid_credentials'
export type AllTranslationKeys = `common:${CommonTranslationKeys}` | `auth:${AuthTranslationKeys}`
sequenceDiagram
autonumber
actor Admin as Content Editor
participant Payload as Payload Admin Panel
participant DB as Database
participant NextCache as Next.js Data Cache
actor User as Frontend User
Admin->>Payload: Updates "button.submit" to "Save"
Payload->>DB: Saves localized document
Payload->>NextCache: revalidateTag('payload-translations', 'max')
User->>NextCache: Requests page
NextCache->>DB: Cache miss -> fetches updated dictionary
NextCache-->>User: Returns updated translation ("Save")
afterChange and afterDelete hooks.| Subpath | Target | Use Case |
|---|---|---|
payload-plugin-dictionary | src/index.ts | Plugin initialization & root types |
payload-plugin-dictionary/cache | src/cache/getDictionary.ts | getTranslations(), getDictionary() (Server-only) |
payload-plugin-dictionary/client | src/client/index.tsx | <DictionaryProvider>, useTranslations(), useDictionary() (Client) |
The repository includes complete integration and end-to-end tests:
# Run unit & integration tests (Vitest)
pnpm test:int
# Run admin panel E2E tests (Playwright)
pnpm test:e2e
# Run linter
pnpm lint
# Build production bundle
pnpm build
MIT © Mahmoud Hassan
payload translations
Manage front-end UI translations in a Payload global with a t() helper and automatic revalidation
3934/wk4v3
strings
Generates a localized global of developer-defined UI strings with scoped tabs and a typed translator helper
6212/wk0v4
better localized fields
Adds locale tabs to every localized field so editors can view each locale's value in place
50262/wk335v3
payload plugin translator
Translate localized Payload content with an AI provider from the admin panel via background jobs
713.9k/wk37v3
language pt pt
European Portuguese (pt-PT) admin translations for Payload CMS with optional overrides
67575/wk0v3
payload auto translate
Automatic content translation for localized Payload collections using a LibreTranslate instance
6348/wk2v3