2022-02-19 09:47:49 +01:00
|
|
|
import chai from "chai"
|
|
|
|
import i18nAll from "../dist/index.js"
|
2018-11-22 16:06:17 +01:00
|
|
|
|
2022-02-19 09:47:49 +01:00
|
|
|
const expect = chai.expect
|
|
|
|
const i18n = i18nAll.strings
|
|
|
|
|
|
|
|
const languages = [
|
2018-11-22 16:06:17 +01:00
|
|
|
{
|
|
|
|
name: "English",
|
|
|
|
strings: i18n.en
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "German",
|
|
|
|
strings: i18n.de
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Spanish",
|
|
|
|
strings: i18n.es
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "French",
|
|
|
|
strings: i18n.fr
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "Dutch",
|
|
|
|
strings: i18n.nl
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
function checkTranslations(from, to) {
|
2022-02-19 09:47:49 +01:00
|
|
|
const originals = Object.keys(from.strings);
|
|
|
|
const translated = to.strings;
|
2018-11-22 16:06:17 +01:00
|
|
|
for (let string of originals) {
|
|
|
|
if (typeof translated[string] === "undefined") {
|
2022-02-19 09:47:49 +01:00
|
|
|
console.log(`String ${string} in ${from.name} is not available in ${to.name}`)
|
2018-11-22 16:06:17 +01:00
|
|
|
expect(typeof translated[string]).to.equal("string");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let language of languages) {
|
|
|
|
if (language.name !== "English") {
|
|
|
|
it(`All English strings should be translated to ${language.name}`, () => {
|
|
|
|
checkTranslations(languages[0], language);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let language of languages) {
|
|
|
|
if (language.name !== "English") {
|
|
|
|
it(`All ${language.name} strings should be available in English`, () => {
|
|
|
|
checkTranslations(language, languages[0]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|