Files
bookorbit/client/scripts/locale-protected-terms.mjs
T
neon 11cb1e0f89 i18n(client): preserve protected technical terms during crowdin sync
Define a list of protected technical terms that must retain their English source text in target
catalogs.

Enforce protected term parity in validate-locales.mjs and restore protected terms automatically
during Crowdin synchronization, recording any corrected translations in the sync report.
2026-08-21 16:18:35 +00:00

25 lines
1.1 KiB
JavaScript

// Terms that stay in English in their software context. Scoped per locale because only these
// locales have been reviewed: several others translate the term deliberately, for example zh
// renders the OIDC slug as an identifier, and that is a Crowdin decision rather than a defect.
export const PROTECTED_SOURCE_TERMS = [
{ key: 'settings.oidc.form.slug', locales: ['es', 'fr', 'it', 'pl'] },
{ key: 'annotations.hub.exportMarkdown', locales: ['es', 'fr', 'it', 'pl'] },
]
export function findProtectedTermDrift({ catalogs, terms = PROTECTED_SOURCE_TERMS }) {
const reference = catalogs.get('en')
if (!reference) throw new Error('English reference catalog is required')
const drift = []
for (const { key, locales } of terms) {
const source = reference.get(key)
if (source === undefined) throw new Error(`Protected term ${key} is missing from the English catalog`)
for (const locale of locales) {
const message = catalogs.get(locale)?.get(key)
if (message !== undefined && message !== source) drift.push({ locale, key, message, source })
}
}
return drift
}