From 851833645fc3fa4fc9404bab5b4e48a6e7d72f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Sun, 6 May 2018 20:08:51 +0200 Subject: [PATCH] whitelist the langs & introduce LEDGER_DEBUG_ALL_LANGS --- src/components/SettingsPage/sections/Display.js | 17 ++++++----------- src/config/languages.js | 6 ++++++ 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 src/config/languages.js diff --git a/src/components/SettingsPage/sections/Display.js b/src/components/SettingsPage/sections/Display.js index e14430f0..df8b1b01 100644 --- a/src/components/SettingsPage/sections/Display.js +++ b/src/components/SettingsPage/sections/Display.js @@ -9,6 +9,7 @@ import type { Settings, T } from 'types/common' import Select from 'components/base/Select' import RadioGroup from 'components/base/RadioGroup' import IconDisplay from 'icons/Display' +import languageKeys from 'config/languages' import regionsByKey from 'helpers/regions.json' @@ -55,13 +56,6 @@ class TabProfile extends PureComponent { cachedRegion: this.props.settings.region, } - getDatas() { - const { t } = this.props - return { - languages: [{ key: 'en', name: t('language:en') }, { key: 'fr', name: t('language:fr') }], - } - } - getMarketIndicators() { const { t } = this.props return [ @@ -84,7 +78,7 @@ class TabProfile extends PureComponent { }) } - handleChangeLanguage = (languageKey: string) => { + handleChangeLanguage = ({ key: languageKey }: *) => { const { i18n, saveSettings } = this.props this.setState({ cachedLanguageKey: languageKey }) window.requestIdleCallback(() => { @@ -121,7 +115,8 @@ class TabProfile extends PureComponent { cachedCounterValue, cachedRegion, } = this.state - const { languages } = this.getDatas() + + const languages = languageKeys.map(key => ({ key, name: t(`language:${key}`) })) const currentLanguage = languages.find(l => l.key === cachedLanguageKey) const regionsFiltered = regions.filter(({ language }) => cachedLanguageKey === language) const currentRegion = @@ -142,7 +137,7 @@ class TabProfile extends PureComponent { this.handleChangeLanguage(item.key)} + onChange={this.handleChangeLanguage} renderSelected={item => item && item.name} value={currentLanguage} items={languages} diff --git a/src/config/languages.js b/src/config/languages.js new file mode 100644 index 00000000..96e3d3a9 --- /dev/null +++ b/src/config/languages.js @@ -0,0 +1,6 @@ +// @flow + +const allLanguages = ['en', 'fr'] +const prodStableLanguages = ['en'] +const languages = process.env.LEDGER_DEBUG_ALL_LANGS ? allLanguages : prodStableLanguages +export default languages