feat: Auto detect language on login page access (#2338)

* feat: Auto detect language on login page access

* fix: Apply tommoor suggested changes

* fix: QOL improvements for translators

* fix: consistency fix provider -> authProviderName

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
falleng0d
2021-07-28 16:00:02 -03:00
committed by GitHub
parent e53bb8bfbc
commit 37c02a572b
6 changed files with 76 additions and 26 deletions

View File

@ -5,3 +5,11 @@ export function detectLanguage() {
const region = (r || ln).toUpperCase();
return `${ln}_${region}`;
}
export function changeLanguage(toLanguageString, i18n) {
if (toLanguageString && i18n.language !== toLanguageString) {
// Languages are stored in en_US format in the database, however the
// frontend translation framework (i18next) expects en-US
i18n.changeLanguage(toLanguageString.replace("_", "-"));
}
}