From 003238c1e73127b83d537fb1ddaa9e2a9a2c31c5 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 25 May 2017 16:47:12 +0100 Subject: [PATCH] Update for new API in react-sdk We now get multiple languages from the browser as there may be a whole preference list --- src/vector/index.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 193738e2..14f8bb4b 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -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();