diff --git a/packages/core/src/Stores/client-store.js b/packages/core/src/Stores/client-store.js index 12a4d03fe9e1..d1170d7f4db1 100644 --- a/packages/core/src/Stores/client-store.js +++ b/packages/core/src/Stores/client-store.js @@ -38,6 +38,7 @@ import moment from 'moment'; import { setDeviceDataCookie } from './Helpers/device'; const LANGUAGE_KEY = 'i18n_language'; +const DEFAULT_LANGUAGE = 'EN'; const storage_key = 'client.accounts'; const store_name = 'client_store'; const eu_shortcode_regex = new RegExp('^(maltainvest|malta|iom)$'); @@ -409,13 +410,11 @@ export default class ClientStore extends BaseStore { () => [this.account_settings], () => { const { trading_hub } = this.account_settings; - const lang_from_url = window.location.search.slice(-2); + const lang_from_url = new URLSearchParams(window.location.search).get('lang') || DEFAULT_LANGUAGE; this.is_pre_appstore = !!trading_hub; localStorage.setItem('is_pre_appstore', !!trading_hub); - if (lang_from_url) { - this.setPreferredLanguage(lang_from_url); - localStorage.setItem(LANGUAGE_KEY, lang_from_url); - } + this.setPreferredLanguage(lang_from_url); + LocalStore.set(LANGUAGE_KEY, lang_from_url); } ); // TODO: Remove this after setting trading_hub enabled for all users