mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 12:00:44 +00:00
test lang_code and filename mismatch (#1441)
## Description: Ensure that each lang_code matches its corresponding filename in language JSON files. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
describe("LangCode Filename Check", () => {
|
||||
const langDir = path.join(__dirname, "../resources/lang");
|
||||
|
||||
test("lang_code matches filename", () => {
|
||||
const files = fs
|
||||
.readdirSync(langDir)
|
||||
.filter((file) => file.endsWith(".json"));
|
||||
|
||||
if (files.length === 0) {
|
||||
console.log("No resources/lang/*.json files found. Skipping check.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
const filePath = path.join(langDir, file);
|
||||
const jsonData = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
||||
|
||||
const fileNameWithoutExt = path.basename(file, ".json");
|
||||
const langCode = jsonData.lang?.lang_code;
|
||||
|
||||
expect(fileNameWithoutExt).toBe(langCode);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user