feat(cms): localize translatable Globals fields with lossless migration (MITHOME-111)
Mark every translatable text/textarea field of the Home, About, Services,
Contact and Common globals as localized. Icons, row ids, the external
flag and the postal address stay shared; CTA hrefs are localized because
internal routes differ per locale. String lists (paragraphs, bullets,
features, spec items) are localized at array level so locales can have
different item counts; structured rows share order/icons and localize
only their inner text.
Existing data is not re-seeded (that would overwrite admin edits): a
Payload migration wraps legacy values into { hu: value } on the published
global and every draft/version record, idempotently, and runs on
production startup via prodMigrations. Paths are derived from the Global
configs themselves so the migration cannot drift from the schema.
OpenSpec change: openspec/changes/localize-globals-mithome-111
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9b5ca94030
commit
829f543962
+27
-21
@@ -10,6 +10,12 @@ import { globalVersions } from '../lib/payload-versions'
|
||||
* beágyazott lista, de a Payload oldalon önálló `Partners` collection lesz
|
||||
* (logó = Media upload reference) — lásd MITHOME-89. Itt szándékosan
|
||||
* kihagyjuk, nehogy két, egymásnak ellentmondó forrás legyen.
|
||||
*
|
||||
* MITHOME-111 lokalizáció: minden fordítható szöveg `localized: true`; az
|
||||
* `icon`, a sor-`id` és az `external` közös. WHY a `cta.*.href` is
|
||||
* lokalizált: a belső útvonal nyelvenként eltér (/hu/kapcsolat vs
|
||||
* /en/contact, lásd PAGE_SLUGS). A string-listák (trustBullets, features)
|
||||
* tömb-szinten lokalizáltak — nyelvenként eltérő elemszám lehet.
|
||||
*/
|
||||
export const Home: GlobalConfig = {
|
||||
slug: 'home',
|
||||
@@ -22,10 +28,10 @@ export const Home: GlobalConfig = {
|
||||
name: 'hero',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'subtitle', type: 'text', required: true },
|
||||
{ name: 'description', type: 'textarea', required: true },
|
||||
stringArrayField('trustBullets', 'Trust bullets'),
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'subtitle', type: 'text', required: true, localized: true },
|
||||
{ name: 'description', type: 'textarea', required: true, localized: true },
|
||||
stringArrayField('trustBullets', 'Trust bullets', { localized: true }),
|
||||
{
|
||||
name: 'cta',
|
||||
type: 'group',
|
||||
@@ -34,8 +40,8 @@ export const Home: GlobalConfig = {
|
||||
name: 'primary',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'text', type: 'text', required: true },
|
||||
{ name: 'href', type: 'text', required: true },
|
||||
{ name: 'text', type: 'text', required: true, localized: true },
|
||||
{ name: 'href', type: 'text', required: true, localized: true },
|
||||
{ name: 'external', type: 'checkbox', defaultValue: false },
|
||||
],
|
||||
},
|
||||
@@ -43,8 +49,8 @@ export const Home: GlobalConfig = {
|
||||
name: 'secondary',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'text', type: 'text', required: true },
|
||||
{ name: 'href', type: 'text', required: true },
|
||||
{ name: 'text', type: 'text', required: true, localized: true },
|
||||
{ name: 'href', type: 'text', required: true, localized: true },
|
||||
{ name: 'external', type: 'checkbox', defaultValue: false },
|
||||
],
|
||||
},
|
||||
@@ -56,14 +62,14 @@ export const Home: GlobalConfig = {
|
||||
name: 'about',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{
|
||||
name: 'usps',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{ name: 'id', type: 'text', required: true },
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'description', type: 'textarea', required: true },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'description', type: 'textarea', required: true, localized: true },
|
||||
{ name: 'icon', type: 'text', required: true },
|
||||
],
|
||||
},
|
||||
@@ -73,18 +79,18 @@ export const Home: GlobalConfig = {
|
||||
name: 'services',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'subtitle', type: 'text', required: true },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'subtitle', type: 'text', required: true, localized: true },
|
||||
{
|
||||
name: 'items',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{ name: 'id', type: 'text', required: true },
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'description', type: 'textarea', required: true },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'description', type: 'textarea', required: true, localized: true },
|
||||
{ name: 'icon', type: 'text', required: true },
|
||||
stringArrayField('features', 'Features'),
|
||||
{ name: 'ctaText', type: 'text', required: true },
|
||||
stringArrayField('features', 'Features', { localized: true }),
|
||||
{ name: 'ctaText', type: 'text', required: true, localized: true },
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -93,15 +99,15 @@ export const Home: GlobalConfig = {
|
||||
name: 'cta',
|
||||
type: 'group',
|
||||
fields: [
|
||||
{ name: 'title', type: 'text', required: true },
|
||||
{ name: 'subtitle', type: 'textarea', required: true },
|
||||
{ name: 'button', type: 'text', required: true },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'subtitle', type: 'textarea', required: true, localized: true },
|
||||
{ name: 'button', type: 'text', required: true, localized: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'serviceFeatures',
|
||||
type: 'group',
|
||||
fields: [{ name: 'title', type: 'text', required: true }],
|
||||
fields: [{ name: 'title', type: 'text', required: true, localized: true }],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user