test(i18n): enforce catalogue key placeholder and nonblank parity
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { translations } from './i18n/translations';
|
||||
|
||||
const placeholders = (text: string) => [...new Set(text.match(/\{\w+\}/g) ?? [])].sort();
|
||||
|
||||
test('English and Bokmål expose the same UI message keys', () => {
|
||||
expect(Object.keys(translations.nb).sort()).toEqual(Object.keys(translations.en).sort());
|
||||
});
|
||||
|
||||
test('Bokmål preserves every English substitution variable', () => {
|
||||
const mismatches = Object.entries(translations.en).filter(([key, text]) =>
|
||||
JSON.stringify(placeholders(text)) !== JSON.stringify(placeholders(translations.nb[key as keyof typeof translations.en]))
|
||||
).map(([key]) => key);
|
||||
expect(mismatches).toEqual([]);
|
||||
});
|
||||
|
||||
test('supported UI catalogues contain no blank messages', () => {
|
||||
const blanks = Object.entries(translations).flatMap(([language, messages]) =>
|
||||
Object.entries(messages).filter(([, text]) => !text.trim()).map(([key]) => `${language}.${key}`)
|
||||
);
|
||||
expect(blanks).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user