Skip to content

Node.js based forum software built for the modern web

test(i18n): add validation for language code and dir fields

Julian Lamff4fb69067c6
diff --git a/public/language/hy/language.json b/public/language/hy/language.json
index a7fff8f30a..044778a899 100644
--- a/public/language/hy/language.json
+++ b/public/language/hy/language.json
@@ -1,5 +1,5 @@
{
"name": "Հայերեն",
"code": "hy",
- "dir": "Itr"
+ "dir": "ltr"
}
\ No newline at end of file
diff --git a/test/i18n.js b/test/i18n.js
index f2abe4f17a..cc81997a70 100644
--- a/test/i18n.js
+++ b/test/i18n.js
@@ -124,6 +124,18 @@ describe('i18n', () => {
assert(sourceFiles.includes(relativePath), `${relativePath.slice(1)} was found in language "${language}" but there is no source file for it (likely removed from en-GB)`);
});
});
+
+ it('language.json code should match the folder name', () => {
+ const langFile = path.resolve(__dirname, `../public/language/${language}/language.json`);
+ const langData = require(langFile);
+ assert.strictEqual(langData.code, language, `language.code "${langData.code}" does not match folder name "${language}"`);
+ });
+
+ it('language.json dir should be either "ltr" or "rtl"', () => {
+ const langFile = path.resolve(__dirname, `../public/language/${language}/language.json`);
+ const langData = require(langFile);
+ assert(['ltr', 'rtl'].includes(langData.dir), `language.dir "${langData.dir}" is not "ltr" or "rtl"`);
+ });
});
describe(`"${language}" file contents`, () => {