From 34b4e6d069b714e3ec2fdad818cbd55e04909974 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 20 Feb 2025 12:39:56 +0200 Subject: [PATCH] feat(test): ensure frontend translations are valid JSON --- src/services/i18n.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/services/i18n.spec.ts diff --git a/src/services/i18n.spec.ts b/src/services/i18n.spec.ts new file mode 100644 index 000000000..03b4fad62 --- /dev/null +++ b/src/services/i18n.spec.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from "vitest"; +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"; + const locales = i18n.getLocales(); + + for (const locale of locales) { + const translationPath = path.join(translationDir, locale.id, "translation.json"); + const translationFile = fs.readFileSync(translationPath, { encoding: "utf-8" }); + expect(() => { + JSON.parse(translationFile); + }, `JSON error while parsing locale '${locale.id}' at "${translationPath}"`).not.toThrow(); + } + }); +});