Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@
"notes": "메모",
"custom": "커스텀 필드",
"deals": "딜",
"tags": "태그",
"noTags": "태그 없음",
"noDeals": "딜 없음",
"addNotePlaceholder": "메모 추가..."
Expand Down Expand Up @@ -1500,6 +1501,7 @@
"appearance": "화면 설정",
"whatsapp": "WhatsApp",
"templates": "템플릿",
"quick-replies": "빠른 답장",
"fields": "필드 & 태그",
"deals": "딜 & 통화",
"members": "팀원",
Expand Down
45 changes: 45 additions & 0 deletions src/i18n/messages.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { describe, expect, it } from 'vitest';

// Locale dictionaries are hand-maintained. English is the source of
// truth (src/i18n/request.ts falls back to en.json only when a whole
// locale file is missing — there is no per-key fallback), so a key
// that lands in en.json and not in a translation renders as a raw
// keypath for users on that locale. This guards the parity.

const MESSAGES_DIR = join(process.cwd(), 'messages');
const SOURCE_LOCALE = 'en';
const TRANSLATED_LOCALES = ['ko'];

function loadKeys(locale: string): Set<string> {
const raw = readFileSync(join(MESSAGES_DIR, `${locale}.json`), 'utf8');
const out = new Set<string>();
const walk = (node: unknown, path: string) => {
if (node && typeof node === 'object' && !Array.isArray(node)) {
for (const [k, v] of Object.entries(node)) {
walk(v, path ? `${path}.${k}` : k);
}
return;
}
out.add(path);
};
walk(JSON.parse(raw), '');
return out;
}

describe('message catalogue parity', () => {
const source = loadKeys(SOURCE_LOCALE);

it.each(TRANSLATED_LOCALES)('%s.json covers every en.json key', (locale) => {
const translated = loadKeys(locale);
const missing = [...source].filter((k) => !translated.has(k)).sort();
expect(missing, `${locale}.json is missing these keys`).toEqual([]);
});

it.each(TRANSLATED_LOCALES)('%s.json has no orphaned keys', (locale) => {
const translated = loadKeys(locale);
const orphaned = [...translated].filter((k) => !source.has(k)).sort();
expect(orphaned, `${locale}.json has keys absent from en.json`).toEqual([]);
});
});
Loading