feat(cms): English translation status with a public gate (MITHOME-113)
Every page global and legal page gets a shared "English translation status" sidebar field (none / AI draft awaiting review / approved). The content adapter reads through readGated(): an English page renders English text only when its translation is approved, otherwise the Hungarian text of the same page, while links keep resolving to /en/... Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0eb6594acc
commit
32b6643fbc
@@ -2,6 +2,7 @@ import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { stringArrayField } from './fields/stringArray'
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
import { translationStatusField } from './fields/translationStatus'
|
||||
|
||||
/** Mirrors AboutPageContent (proto/src/content/types.ts) — MITHOME-87. */
|
||||
export const About: GlobalConfig = {
|
||||
@@ -71,5 +72,6 @@ export const About: GlobalConfig = {
|
||||
{ name: 'button', type: 'text', required: true, localized: true },
|
||||
],
|
||||
},
|
||||
translationStatusField(),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
import { translationStatusField } from './fields/translationStatus'
|
||||
|
||||
/**
|
||||
* Mirrors CommonContent (proto/src/content/types.ts) — MITHOME-87.
|
||||
@@ -82,5 +83,6 @@ export const Common: GlobalConfig = {
|
||||
{ name: 'closeMenu', type: 'text', required: true, localized: true },
|
||||
],
|
||||
},
|
||||
translationStatusField(),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
import { translationStatusField } from './fields/translationStatus'
|
||||
|
||||
/**
|
||||
* Mirrors ContactPageContent (proto/src/content/types.ts) — MITHOME-87.
|
||||
@@ -141,5 +142,6 @@ export const Contact: GlobalConfig = {
|
||||
},
|
||||
],
|
||||
},
|
||||
translationStatusField(),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { GlobalConfig } from 'payload'
|
||||
import { stringArrayField } from './fields/stringArray'
|
||||
import { ctaLinkGroup } from './fields/ctaLink'
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
import { translationStatusField } from './fields/translationStatus'
|
||||
|
||||
/**
|
||||
* Mirrors HomePageContent (proto/src/content/types.ts) — MITHOME-87.
|
||||
@@ -96,5 +97,6 @@ export const Home: GlobalConfig = {
|
||||
type: 'group',
|
||||
fields: [{ name: 'title', type: 'text', required: true, localized: true }],
|
||||
},
|
||||
translationStatusField(),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { GlobalConfig } from 'payload'
|
||||
|
||||
import { stringArrayField } from './fields/stringArray'
|
||||
import { globalVersions } from '../lib/payload-versions'
|
||||
import { translationStatusField } from './fields/translationStatus'
|
||||
|
||||
/** Mirrors ServicesPageContent (proto/src/content/types.ts) — MITHOME-87. */
|
||||
export const Services: GlobalConfig = {
|
||||
@@ -80,5 +81,6 @@ export const Services: GlobalConfig = {
|
||||
{ name: 'secondaryButton', type: 'text', required: true, localized: true },
|
||||
],
|
||||
},
|
||||
translationStatusField(),
|
||||
],
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { SelectField, SelectFieldSingleValidation } from 'payload'
|
||||
|
||||
import { EN_TRANSLATION_STATUSES, type EnTranslationStatus } from '../../lib/translation-gate'
|
||||
|
||||
const LABELS: Record<EnTranslationStatus, string> = {
|
||||
none: 'Nincs fordítás',
|
||||
'ai-draft': 'AI-draft, átnézésre vár',
|
||||
approved: 'Jóváhagyva',
|
||||
}
|
||||
|
||||
/**
|
||||
* MITHOME-113: English translation status of a page, shown in the admin
|
||||
* sidebar. The public English page only shows English content once this is
|
||||
* "approved" (src/lib/translation-gate.ts); until then it shows Hungarian.
|
||||
*
|
||||
* WHY not localized: only English has a translation status — a localized
|
||||
* field would show a meaningless value in the Hungarian (source) view.
|
||||
* `validate` lets LegalPages add its multi-model validation rule.
|
||||
*/
|
||||
export function translationStatusField(validate?: SelectFieldSingleValidation): SelectField {
|
||||
return {
|
||||
name: 'enTranslationStatus',
|
||||
label: 'Angol fordítás állapota',
|
||||
type: 'select',
|
||||
defaultValue: 'none',
|
||||
options: EN_TRANSLATION_STATUSES.map((value) => ({ label: LABELS[value], value })),
|
||||
...(validate ? { validate } : {}),
|
||||
admin: {
|
||||
position: 'sidebar',
|
||||
description:
|
||||
'Az angol oldal csak „Jóváhagyva” állapotban jelenik meg; addig a látogatók a magyar szöveget látják. ' +
|
||||
'Az AI-draft gépi fordítás: jóváhagyás előtt ellenőrizni és szükség szerint javítani kell.',
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user