mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
11cb1e0f89
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.
25 lines
1.1 KiB
JavaScript
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
|
|
}
|