Browse Source

whitelist the langs & introduce LEDGER_DEBUG_ALL_LANGS

master
Gaëtan Renaudeau 7 years ago
parent
commit
851833645f
  1. 17
      src/components/SettingsPage/sections/Display.js
  2. 6
      src/config/languages.js

17
src/components/SettingsPage/sections/Display.js

@ -9,6 +9,7 @@ import type { Settings, T } from 'types/common'
import Select from 'components/base/Select' import Select from 'components/base/Select'
import RadioGroup from 'components/base/RadioGroup' import RadioGroup from 'components/base/RadioGroup'
import IconDisplay from 'icons/Display' import IconDisplay from 'icons/Display'
import languageKeys from 'config/languages'
import regionsByKey from 'helpers/regions.json' import regionsByKey from 'helpers/regions.json'
@ -55,13 +56,6 @@ class TabProfile extends PureComponent<Props, State> {
cachedRegion: this.props.settings.region, 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() { getMarketIndicators() {
const { t } = this.props const { t } = this.props
return [ return [
@ -84,7 +78,7 @@ class TabProfile extends PureComponent<Props, State> {
}) })
} }
handleChangeLanguage = (languageKey: string) => { handleChangeLanguage = ({ key: languageKey }: *) => {
const { i18n, saveSettings } = this.props const { i18n, saveSettings } = this.props
this.setState({ cachedLanguageKey: languageKey }) this.setState({ cachedLanguageKey: languageKey })
window.requestIdleCallback(() => { window.requestIdleCallback(() => {
@ -121,7 +115,8 @@ class TabProfile extends PureComponent<Props, State> {
cachedCounterValue, cachedCounterValue,
cachedRegion, cachedRegion,
} = this.state } = 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 currentLanguage = languages.find(l => l.key === cachedLanguageKey)
const regionsFiltered = regions.filter(({ language }) => cachedLanguageKey === language) const regionsFiltered = regions.filter(({ language }) => cachedLanguageKey === language)
const currentRegion = const currentRegion =
@ -142,7 +137,7 @@ class TabProfile extends PureComponent<Props, State> {
<Select <Select
style={{ minWidth: 250 }} style={{ minWidth: 250 }}
small small
onChange={item => this.handleChangeCounterValue(item)} onChange={this.handleChangeCounterValue}
itemToString={item => (item ? item.name : '')} itemToString={item => (item ? item.name : '')}
renderSelected={item => item && item.name} renderSelected={item => item && item.name}
items={fiats} items={fiats}
@ -153,7 +148,7 @@ class TabProfile extends PureComponent<Props, State> {
<Select <Select
style={{ minWidth: 250 }} style={{ minWidth: 250 }}
small small
onChange={item => this.handleChangeLanguage(item.key)} onChange={this.handleChangeLanguage}
renderSelected={item => item && item.name} renderSelected={item => item && item.name}
value={currentLanguage} value={currentLanguage}
items={languages} items={languages}

6
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
Loading…
Cancel
Save