seo: the translations option is merged but never read, so the panel is hardcoded English
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- backend, internationalization
Direzione di ricerca
Start with packages/payload-plugin-seo/src/translations/en.ts and src/utils/config/mergeTranslations.ts, then trace string rendering in the components and engine areas named in the issue. Run the package tests with bun run test; extend the merge and component tests to cover nested overrides, legacy keys, language fallback, and rendered strings. Done means all listed strings use Payload translations, English remains unchanged, and the acceptance criteria pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
The README documents translations as the way to "Override the English UI strings (merged with defaults)" (README.md#L226-L227), and the plugin merges it into Payload's i18n (plugin.ts#L43-L51). No component reads it back: there is no useTranslation or t() call under src, and 217 user-facing strings in 39 files are literals. Passing translations changes nothing on screen, and an admin switched to another language still shows the SEO button, drawer and field components in English.
It also blocks a common setup. A host that labels the mapped fields in its own words, say "Search title" and "Search description" for meta.title and meta.description, still gets check rows named "SEO title width" and "Meta description length" (labels.ts#L52-L59), so an editor looks for fields that do not exist under those names, and there is no config to rename them.
Expected
Every string the plugin renders comes from Payload's i18n under a seo namespace, the translations option overrides any of them per language, and a language with no overrides shows the English defaults rather than raw keys.
Reproduction
apps/cms installs the plugin on page and posts with meta.title and meta.description mapped (plugins/index.ts#L236-L264) and enables en and es in the admin (payload.config.ts#L87-L89).
- In
apps/cms, fill.envfrom.env.example(DATABASE_URL,PAYLOAD_SECRET) and runbun run dev(port 3333) - Open an existing post and click the gauge button next to the document controls. The drawer reads "SEO Analytics", with tabs "Keyphrase", "On-page SEO" and so on
- Switch your account's admin language to Español. The rest of the admin turns Spanish, the drawer stays English
- Add
translations: { en: { "seo:title": "SEO" } }to theseoAnalysisPluginoptions and restart. The heading still reads "SEO Analytics"
apps/dev also installs the plugin, but its collection entry has no extractContentPath (payload.config.ts#L158-L175), so the plugin skips registration there (plugin.ts#L23-L38). The steps above are read from the config and the source, not clicked through.
Root cause
- Components render literals: the drawer heading and close button (Header.tsx#L21-L27), the button's aria-label and tooltip (SeoButtonInner.tsx#L82-L91), the tab names (TabsNav/constants.ts#L4-L11), every check name and tooltip in
LABELS(labels.ts#L3-L101), whichCheckRowrenders as is (CheckRow/index.tsx#L17-L42), and the status pills (statuses.ts#L3-L7) - The analysis engine builds English sentences outside React and hands them over as strings, for example the recommendation line under each check (recommendations.ts#L10-L64)
- The shipped defaults are flat keys,
"seo:title"as one property (en.ts#L3-L15). Payload'st()splits a key on:and walks nested objects (init.ts#L33) and returns the key itself when nothing matches (init.ts#L68-L72), so event("seo:title")would printseo:title. The comments plugin in this repo uses the nested shape Payload expects (comments en.ts#L3-L4, read witht("comments:label")in Header.tsx#L18) mergeTranslationsmerges one level per language (mergeTranslations.ts#L3-L11), so a nested override would replace the whole namespace, and the defaults are registered underenonly. Payload merges custom translations for the active language only (init.ts#L146-L154), so anesadmin would print raw keys once the components callt()
Fix
src/translations/en.ts: nest the defaults underseo, keep the existing keys (seo:title,seo:tab:keyphraseand the rest) and add one key per string. Data-driven strings key on the id the code already has:seo:check:<checkId>:nameand:tip,seo:status:<good|warn|bad>,seo:recommendation:<checkId>:<status>. Everything else goes under one area per component folder (seo:keyphrase:*,seo:headings:*,seo:field:*and so on). The close button reuses Payload'sgeneral:close. Counts use Payload's_oneand_othersuffixes with{{count}}. Export the shape asSeoTranslationssrc/utils/config/mergeTranslations.ts: for every language ini18n.supportedLanguages(Payload's default isen) plus every language in the option, deep-merge the host's translations with{ seo: en.seo + option[language] }, usingdeepMergeSimplefrompayload/shared. Normalise legacy flat keys such as"seo:title"into the nested shape, so configs written against the README keep working- Option type:
translations?: Record<string, DeepPartial<SeoTranslations>>, keyed by language, values without theseowrapper, the same contract as the comments plugin, plus the legacy flat form - Components:
const { t } = useTranslation()from@payloadcms/ui, every literal replaced.CheckRowkeeps today's fallback for a check id with no key: render the id - Engine: return
{ key, vars }instead of sentences for recommendations, inclusive category names, drill-down nouns, units and captions, and translate where they render. The engine types are not exported from the package (index.ts#L1-L11), so no public type changes
Existing users see no change: every English default is today's literal, word for word. Minor version bump.
Acceptance criteria
- Every string in the brief's inventory (217, linked below) renders through
t(), and the English panel is unchanged word for word -
translations: { en: { check: { titleWidth: { name: "Search title width" } } } }renames that one row, and every other check name keeps its default - The legacy
translations: { en: { "seo:title": "SEO" } }changes the drawer heading to "SEO" - With the admin in
esand no Spanish strings passed, the panel shows the English defaults and no rawseo:key anywhere - With
translations: { es: { title: "Analítica SEO" } }, the heading reads "Analítica SEO" in the Spanish admin and "SEO Analytics" in the English one - Recommendation lines, inclusive category names and drill-down labels follow the admin language the same way
- A host's own translations in other namespaces (the
ssostrings inapps/cms) still resolve
Test plan
- Unit tests in
packages/payload-plugin-seo/tests(vitest,bun run test). Extendtests/utils/mergeTranslations.test.ts: an override of one check name keeps the others, flat keys are normalised, English is seeded into every supported language, a host's other namespace survives. Add a test that runs Payload's owntfrom@payloadcms/translationsagainst the merged object for one key per area, so a wrong shape fails in CI rather than in the browser - Component tests mock
@payloadcms/ui(for exampletests/components/Header.test.tsx). AdduseTranslationto those mocks through one shared helper that resolves keys fromen, so the existing English assertions keep passing unchanged, plus oneHeadertest with an override - Manual in
apps/cms: reproduction steps 2 to 4, then the Spanish admin with and without anesoverride
Seen on 1.10.1, unchanged on main at b645ef0c.
The long-form brief lists every hardcoded string by file and line with its proposed key, and carries the merge sketch and the edge cases.
- Lingua principale
- TypeScript
- Stelle
- 34
- Fork
- 5
- Merge medio
- 2g 4h
- PR unite (30g)
- 41
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di focusreactive/payload-plugins
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
focusreactive/payload-plugins#279 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
focusreactive/payload-plugins#263 ·
I maintainer di solito rispondono entro 1 giorno
-
comments, seo, analytics, and presets publish ESM that fails to load in Node.js (follow-up to #149)Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
focusreactive/payload-plugins#240 ·
I maintainer di solito rispondono entro 1 giorno
-
released released on @next
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
focusreactive/payload-plugins#210 · 10 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[translator] Re-extract the traversal engine into its own packageForse di nuovo libera @SearheiParkhamchuk l’ha presa 41 giorni fa e non c’è nessuna pull request aperta. Apertachore low priority translator
focusreactive/payload-plugins#203 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di focusreactive/payload-plugins
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nicobailon/pi-subagents#3420 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
openwatersio/slackwater.xyz#309 ·
I maintainer di solito rispondono entro 1 giorno
-
Mer utskriftsvennlig stylingAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
navikt/nav-enonicxp-frontend#3122 ·
I maintainer di solito rispondono entro 1 giorno
-
complexity → simple frontend performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opencollective/opencollective#9200 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno