2018-09-16 13:57:18 +01:00
|
|
|
/* global it, describe */
|
2020-06-01 15:54:23 +03:00
|
|
|
const assert = require('assert');
|
2020-02-26 16:23:35 +00:00
|
|
|
const fs = require('fs');
|
2018-09-16 13:57:18 +01:00
|
|
|
|
|
|
|
describe('Localization', () => {
|
|
|
|
it('has all keys in all locales', async () => {
|
2020-06-01 15:54:23 +03:00
|
|
|
const en = require('../../loc/en');
|
2020-02-26 16:23:35 +00:00
|
|
|
let issues = 0;
|
2020-06-01 15:54:23 +03:00
|
|
|
for (const key1 of Object.keys(en)) {
|
|
|
|
for (const key2 of Object.keys(en[key1])) {
|
2018-09-16 13:57:18 +01:00
|
|
|
// iterating all keys and subkeys in EN locale, which is main
|
2020-06-01 15:54:23 +03:00
|
|
|
const files = fs.readdirSync('./loc/');
|
2020-02-26 16:23:35 +00:00
|
|
|
|
2020-06-01 15:54:23 +03:00
|
|
|
for (const lang of files) {
|
2020-02-26 16:23:35 +00:00
|
|
|
if (lang === 'en.js') continue; // iteratin all locales except EN
|
|
|
|
if (lang === 'index.js') continue;
|
2018-09-16 13:57:18 +01:00
|
|
|
|
2020-06-01 15:54:23 +03:00
|
|
|
const locale = require('../../loc/' + lang);
|
2018-09-16 13:57:18 +01:00
|
|
|
|
|
|
|
if (typeof locale[key1] === 'undefined') {
|
|
|
|
console.error('Missing: ' + lang + '.' + key1);
|
2020-02-26 16:23:35 +00:00
|
|
|
issues++;
|
2018-09-16 13:57:18 +01:00
|
|
|
} else if (typeof locale[key1][key2] === 'undefined') {
|
|
|
|
console.error('Missing: ' + lang + '.' + key1 + '.' + key2);
|
2020-02-26 16:23:35 +00:00
|
|
|
issues++;
|
2018-09-16 13:57:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// level 1 & 2 done, doing level 3 (if it exists):
|
|
|
|
|
|
|
|
if (typeof en[key1][key2] !== 'string') {
|
2020-06-01 15:54:23 +03:00
|
|
|
for (const key3 of Object.keys(en[key1][key2])) {
|
2018-09-16 13:57:18 +01:00
|
|
|
if (typeof locale[key1][key2][key3] === 'undefined') {
|
|
|
|
console.error('Missing: ' + lang + '.' + key1 + '.' + key2 + '.' + key3);
|
2020-02-26 16:23:35 +00:00
|
|
|
issues++;
|
2018-09-16 13:57:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-26 16:23:35 +00:00
|
|
|
assert.ok(issues === 0, 'Some localizations are missing keys. Total issues: ' + issues);
|
2018-09-16 13:57:18 +01:00
|
|
|
});
|
|
|
|
});
|