test(i18n): validate nested housekeeping translation groups
This commit is contained in:
1 parent
96d3e3f602
commit
506e14783c
2 files changed
+13
-2
No files matched your search
@@ -87,7 +87,7 @@ describe("dashboard task presentation", () => {
|
|||||||
mkdirSync(output, { recursive: true });
|
mkdirSync(output, { recursive: true });
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
join(output, "tasks.html"),
|
join(output, "tasks.html"),
|
||||||
`<!doctype html><html lang="it"><meta name="viewport" content="width=device-width, initial-scale=1"><style>:root{--color-border:#ddd;--color-primary:#a34023;--color-text-muted:#777;--color-surface:#fff}*{box-sizing:border-box}body{font:16px Arial;background:#f7f5f2;margin:0;padding:20px}main{max-width:1000px;margin:auto}a{color:#943712;text-decoration:none}.p-5{padding:20px}.surface-card{border:1px solid #ddd;border-radius:16px;padding:12px}h3{margin:12px}${css.replaceAll(".tasks", "." + taskClass)}</style><main>${html}<div id="referral-reward">Premio inviti</div></main></html>`,
|
`<!doctype html><html lang="it"><meta name="viewport" content="width=device-width, initial-scale=1"><style>:root{--color-border:#ddd;--color-primary:#a34023;--color-text-muted:#777;--color-surface:#fff}*{box-sizing:border-box}body{font:16px Arial;background:#f7f5f2;margin:0;padding:20px}main{max-width:1000px;margin:auto}a{color:#943712;text-decoration:none}.p-5{padding:20px}.surface-card{border:1px solid #ddd;border-radius:16px;padding:12px}h3{margin:12px}${css.replaceAll(".tasks", `.${taskClass}`)}</style><main>${html}<div id="referral-reward">Premio inviti</div></main></html>`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,17 @@ import { visibleAdminNavigation } from "@/lib/admin-navigation";
|
|||||||
import en from "@/messages/en.json";
|
import en from "@/messages/en.json";
|
||||||
import itMessages from "@/messages/it.json";
|
import itMessages from "@/messages/it.json";
|
||||||
|
|
||||||
|
function leafKeys(messages: Record<string, unknown>, prefix = ""): string[] {
|
||||||
|
return Object.entries(messages).flatMap(([key, value]) => {
|
||||||
|
const path = prefix ? `${prefix}.${key}` : key;
|
||||||
|
return typeof value === "string"
|
||||||
|
? [path]
|
||||||
|
: value && typeof value === "object"
|
||||||
|
? leafKeys(value as Record<string, unknown>, path)
|
||||||
|
: [];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
it.each([
|
it.each([
|
||||||
["en", en],
|
["en", en],
|
||||||
["it", itMessages],
|
["it", itMessages],
|
||||||
@@ -34,7 +45,7 @@ it.each([
|
|||||||
]);
|
]);
|
||||||
for (const key of keys) translate(`pages.admin.nav.${key}`);
|
for (const key of keys) translate(`pages.admin.nav.${key}`);
|
||||||
for (const area of ["actions", "table", "cmsErrors", "workQueue"] as const)
|
for (const area of ["actions", "table", "cmsErrors", "workQueue"] as const)
|
||||||
for (const key of Object.keys(en.pages.admin[area]))
|
for (const key of leafKeys(en.pages.admin[area]))
|
||||||
translate(`pages.admin.${area}.${key}`, {
|
translate(`pages.admin.${area}.${key}`, {
|
||||||
count: 2,
|
count: 2,
|
||||||
action: "Save",
|
action: "Save",
|
||||||
|
|||||||
Reference in new issue
Block a user