translations

This commit is contained in:
Matt Hill
2026-02-16 00:34:41 -07:00
parent bb68c3b91c
commit 5ba68a3124
5 changed files with 161 additions and 80 deletions

View File

@@ -89,6 +89,43 @@ if (errors.length > 0) {
console.error(` ${rel}:${line} "${key}"`)
}
console.error()
}
// Check that all numeric keys in en.ts exist in every non-English dictionary
const enNumericKeys = new Set()
for (const match of enSource.matchAll(/^\s+'[^']+?':\s*(\d+)/gm)) {
enNumericKeys.add(Number(match[1]))
}
const dictDir = join(root, 'projects/shared/src/i18n/dictionaries')
const otherLangs = ['de', 'es', 'fr', 'pl']
const dictErrors = []
for (const lang of otherLangs) {
const dictPath = join(dictDir, `${lang}.ts`)
const dictSource = readFileSync(dictPath, 'utf-8')
const dictKeys = new Set()
for (const match of dictSource.matchAll(/^\s*(\d+):/gm)) {
dictKeys.add(Number(match[1]))
}
const missing = [...enNumericKeys].filter(k => !dictKeys.has(k)).sort((a, b) => a - b)
if (missing.length > 0) {
dictErrors.push({ lang, missing })
}
}
if (dictErrors.length > 0) {
console.error(`\nMissing i18n dictionary keys:\n`)
for (const { lang, missing } of dictErrors) {
console.error(` ${lang}.ts is missing keys: ${missing.join(', ')}`)
}
console.error()
}
if (errors.length > 0 || dictErrors.length > 0) {
process.exit(1)
} else {
console.log('All i18n keys are valid.')