i18n: fallback to french

This commit is contained in:
Jean-Baptiste Pasquier 2020-10-21 17:19:02 +02:00
parent 6e2738bd97
commit c279bffcaf
2 changed files with 11 additions and 4 deletions

View File

@ -16,7 +16,7 @@ class JsI18n {
this.setLocale(localStorage.getItem('language') || window.navigator.language.slice(0, 2));
} else {
console.error('Language not found');
this.setLocale('en');
this.setLocale('fr');
}
};
@ -105,14 +105,21 @@ class JsI18n {
result.json().then(e => {
this.addLocale(locale, e);
this.processPage();
}).catch(() => {
if (locale != "fr") {
console.warn(`Locale not found: ${locale}, fallback to french`);
this.setLocale("fr");
} else {
console.error("Language not found");
}
});
}
});
this.locale = locale;
} catch {
if (locale != "en") {
console.warn(`Locale not found: ${locale}, fallback to english`);
this.setLocale("en");
if (locale != "fr") {
console.warn(`Locale not found: ${locale}, fallback to french`);
this.setLocale("fr");
} else {
console.error("Language not found");
}