Update for new API in react-sdk

We now get multiple languages from the browser as there may be
a whole preference list
pull/4035/head
David Baker 2017-05-25 16:47:12 +01:00
parent 7636212bed
commit 003238c1e7
1 changed files with 15 additions and 3 deletions

View File

@ -313,9 +313,21 @@ async function loadApp() {
}
async function loadLanguage() {
const lang = UserSettingsStore.getLocalSetting('language', languageHandler.getLanguageFromBrowser());
const languages = languageHandler.getNormalizedLanguageKeys(lang);
languageHandler.setLanguage(languages);
const prefLang = UserSettingsStore.getLocalSetting('language');
let langs = [];
if (!prefLang) {
languageHandler.getLanguagesFromBrowser().forEach((l) => {
langs.push(...languageHandler.getNormalizedLanguageKeys(l));
});
} else {
langs = [prefLang];
}
try {
await languageHandler.setLanguage(langs);
} catch (e) {
console.error("Unable to set language", e);
}
}
loadApp();