Taalbestanden: statische teksten van de site naar src/i18n/nl (landing, shared, era), getypte t()-helper; prerender-uitvoer byte-identiek

Hero en CMS-data blijven buiten scope.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 17:28:58 +01:00
co-authored by Claude Sonnet 5.5
parent 425c59c445
commit 6c6fd771dd
34 changed files with 470 additions and 151 deletions
+39
View File
@@ -0,0 +1,39 @@
import { describe, expect, it } from 'vitest';
import { nl, t, tList } from './index';
function leaves(node: unknown, path = ''): { path: string; value: unknown }[] {
if (typeof node === 'string' || Array.isArray(node)) {
return [{ path, value: node }];
}
if (node && typeof node === 'object') {
return Object.entries(node).flatMap(([key, child]) =>
leaves(child, path ? `${path}.${key}` : key),
);
}
return [];
}
describe('i18n texts', () => {
const all = leaves(nl);
it('has no empty texts', () => {
const empty = all.filter(({ value }) =>
Array.isArray(value)
? value.some((v) => typeof v !== 'string' || v.trim() === '')
: typeof value !== 'string' || value.trim() === '',
);
expect(empty.map((e) => e.path)).toEqual([]);
});
it('has only plain `{name}` placeholders', () => {
const odd = all.filter(
({ value }) => typeof value === 'string' && /\{[^}\w]|\{\}|\{\w*$/.test(value),
);
expect(odd.map((e) => e.path)).toEqual([]);
});
it('falls back to the key for unknown keys', () => {
expect(t('unknown.key' as never)).toBe('unknown.key');
expect(tList('unknown.list' as never)).toEqual([]);
});
});