mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
translations
This commit is contained in:
@@ -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.')
|
||||
|
||||
Reference in New Issue
Block a user