mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 06:32:03 +00:00
fix(i18n): translate the illness labels left in English
The illness screens showed "Weight", "Pulse", "Recovery" and "Day" in English in German, French, Spanish, Italian and Polish: the four keys had been copied from English into those catalogs, while their neighbours were translated. The same copy left the medication wizard's "Name" step in French, Spanish, Italian and Polish and the dashboard layout's "Chart" column in German in English. A test now holds the illness keys translated in every locale.
This commit is contained in:
1 parent
aa29d1b432
commit
d77fe9aa7d
6 files changed
+80
-25
No files matched your search
@@ -0,0 +1,55 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { resolveKey } from "@/lib/i18n/resolve-key";
|
||||
|
||||
/**
|
||||
* The illness screens name the vital that drives a recovery gap and label the
|
||||
* day picker of the log sheet through these keys. They were once copied from
|
||||
* English into five catalogs, so a German reader saw "Weight", "Pulse",
|
||||
* "Recovery" and "Day" among translated neighbours. The English leak guard
|
||||
* skips single words, so it cannot see this; the pin below can.
|
||||
*/
|
||||
const MESSAGES_DIR = join(__dirname, "../../../../messages");
|
||||
|
||||
function catalog(locale: string): Record<string, unknown> {
|
||||
return JSON.parse(
|
||||
readFileSync(join(MESSAGES_DIR, `${locale}.json`), "utf8"),
|
||||
) as Record<string, unknown>;
|
||||
}
|
||||
|
||||
const KEYS = [
|
||||
"illness.vital.WEIGHT",
|
||||
"illness.vital.PULSE",
|
||||
"illness.vital.RECOVERY_SCORE",
|
||||
"illness.sheet.day",
|
||||
] as const;
|
||||
|
||||
const english = catalog("en");
|
||||
|
||||
describe("illness labels", () => {
|
||||
for (const locale of [
|
||||
"de",
|
||||
"fr",
|
||||
"es",
|
||||
"it",
|
||||
"pl",
|
||||
"nl",
|
||||
"pt-BR",
|
||||
"ko",
|
||||
"ru",
|
||||
]) {
|
||||
it(`are translated in ${locale}`, () => {
|
||||
const messages = catalog(locale);
|
||||
for (const key of KEYS) {
|
||||
const value = resolveKey(messages, key);
|
||||
expect(value, `${locale} ${key}`).toBeTruthy();
|
||||
expect(value, `${locale} ${key} is still English`).not.toBe(
|
||||
resolveKey(english, key),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user