feat(test): ensure backend translations are valid JSON

This commit is contained in:
Elian Doran 2025-02-20 12:42:42 +02:00
parent c255af67c9
commit f6b6b2e740
No known key found for this signature in database

View File

@ -3,17 +3,24 @@ import * as i18n from "./i18n.js";
import path from "path";
import fs from "fs";
describe("i18n", () => {
it("frontend translations are valid JSON", () => {
const translationDir = "src/public/translations";
function checkTranslations(translationDir: string, translationFileName: string) {
const locales = i18n.getLocales();
for (const locale of locales) {
const translationPath = path.join(translationDir, locale.id, "translation.json");
const translationPath = path.join(translationDir, locale.id, translationFileName);
const translationFile = fs.readFileSync(translationPath, { encoding: "utf-8" });
expect(() => {
JSON.parse(translationFile);
}, `JSON error while parsing locale '${locale.id}' at "${translationPath}"`).not.toThrow();
}
}
describe("i18n", () => {
it("frontend translations are valid JSON", () => {
checkTranslations("src/public/translations", "translation.json");
});
it("backend translations are valid JSON", () => {
checkTranslations("translations", "server.json");
});
});