mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
parent
13cc1f0aa6
commit
fc6c9a19d9
3 changed files with 993 additions and 937 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { langs } from '$lib/constants';
|
||||
import messages from '$lib/i18n/en.json';
|
||||
import { exec as execCallback } from 'node:child_process';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
type Messages = { [key: string]: string | Messages };
|
||||
|
|
@ -30,4 +32,24 @@ describe('i18n', () => {
|
|||
// Only translations directly using the store seem to get extracted
|
||||
expect({ ...extractedMessages, ...existingMessages }).toEqual(existingMessages);
|
||||
});
|
||||
|
||||
describe('loaders', () => {
|
||||
const languageFiles = readdirSync('src/lib/i18n').sort();
|
||||
for (const filename of languageFiles) {
|
||||
test(`${filename} should have a loader`, async () => {
|
||||
const code = filename.replaceAll('.json', '');
|
||||
const item = langs.find((lang) => lang.weblateCode === code || lang.code === code);
|
||||
expect(item, `${filename} has no loader`).toBeDefined();
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
// verify it loads the right file
|
||||
const module: { default?: unknown } = await item.loader();
|
||||
const translations = JSON.stringify(module.default, null, 2).trim();
|
||||
const content = readFileSync(`src/lib/i18n/${filename}`).toString().trim();
|
||||
expect(translations === content, `${item.name} did not load ${filename}`).toEqual(true);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue