Skip to content
Permalink
Browse files

Merge pull request LedgerHQ#1965 from valpinkman/feat/experimental-la…

…nguages

adds experimental language flags
  • Loading branch information...
gre committed May 3, 2019
2 parents fd1a731 + 3c425b4 commit faba9e17e4dd7a58fa61b7ccb37448fa59d42aaa
@@ -82,12 +82,13 @@ DEBUG_ACTION=1
DEBUG_TAB_KEY=1
DEBUG_LIBCORE=1
DEBUG_WS=1
LEDGER_DEBUG_ALL_LANGS=1
SKIP_GENUINE=1
SKIP_ONBOARDING=1
SHOW_LEGACY_NEW_ACCOUNT=1
HIGHLIGHT_I18N=1
EXPERIMENTAL_WS_EXPORT=0
EXPERIMENTAL_LANGUAGES=1
EXPERIMENTAL_EXPLORERS=1
## constants
GET_CALLS_TIMEOUT=30000
@@ -37,16 +37,16 @@
}
},
"dependencies": {
"@ledgerhq/devices": "^4.54.0",
"@ledgerhq/devices": "^4.55.0",
"@ledgerhq/electron-updater": "~3.3.0",
"@ledgerhq/errors": "^4.54.0",
"@ledgerhq/hw-app-btc": "^4.54.0",
"@ledgerhq/hw-app-eth": "^4.54.0",
"@ledgerhq/hw-app-xrp": "^4.54.0",
"@ledgerhq/hw-transport": "^4.54.0",
"@ledgerhq/hw-transport-node-hid": "^4.54.0",
"@ledgerhq/errors": "^4.55.0",
"@ledgerhq/hw-app-btc": "^4.55.0",
"@ledgerhq/hw-app-eth": "^4.55.0",
"@ledgerhq/hw-app-xrp": "^4.55.0",
"@ledgerhq/hw-transport": "^4.55.0",
"@ledgerhq/hw-transport-node-hid": "^4.55.0",
"@ledgerhq/ledger-core": "^2.2.1-rc",
"@ledgerhq/live-common": "^5.0.0-alpha.18",
"@ledgerhq/live-common": "^5.3.0",
"animated": "^0.2.2",
"async": "^2.6.2",
"axios": "^0.18.0",
@@ -7,8 +7,12 @@ import {
fromTokenAccountRaw,
} from '@ledgerhq/live-common/lib/account'
import signAndBroadcast from '@ledgerhq/live-common/lib/libcore/signAndBroadcast'
import type { Transaction } from '@ledgerhq/live-common/lib/libcore/buildTransaction'
import type { AccountRaw, TokenAccountRaw, OperationRaw } from '@ledgerhq/live-common/lib/types'
import type {
Transaction,
AccountRaw,
TokenAccountRaw,
OperationRaw,
} from '@ledgerhq/live-common/lib/types'
import { createCommand, Command } from 'helpers/ipc'

type Input = {
@@ -1,15 +1,16 @@
// @flow

import React, { Fragment, PureComponent } from 'react'
import React from 'react'
import moment from 'moment'
import { translate } from 'react-i18next'
import type { T } from 'types/common'
import { connect } from 'react-redux'
import { setLanguage } from 'actions/settings'
import { langAndRegionSelector } from 'reducers/settings'
import languageKeys from 'config/languages'
import { allLanguages, prodStableLanguages } from 'config/languages'
import Track from 'analytics/Track'
import Select from 'components/base/Select'
import useEnv from 'hooks/useEnv'

type Props = {
t: T,
@@ -19,52 +20,52 @@ type Props = {
i18n: Object,
}

class LanguageSelect extends PureComponent<Props> {
languageLabels = {
en: 'English',
fr: 'Français',
es: 'Español',
ko: '한국어',
zh: '简体中文',
ja: '日本語',
ru: 'Русский',
}
const languageLabels = {
en: 'English',
fr: 'Français',
es: 'Español',
ko: '한국어',
zh: '简体中文',
ja: '日本語',
ru: 'Русский',
}

const LanguageSelect = ({ i18n, setLanguage, language, useSystem, t }: Props) => {
const debugLanguage = useEnv('EXPERIMENTAL_LANGUAGES')

const languages = [{ value: null, label: t(`language.system`) }].concat(
(debugLanguage ? allLanguages : prodStableLanguages).map(key => ({
value: key,
label: languageLabels[key],
})),
)

const currentLanguage = useSystem ? languages[0] : languages.find(l => l.value === language)

handleChangeLanguage = ({ value: languageKey }: *) => {
const { i18n, setLanguage } = this.props
const handleChangeLanguage = ({ value: languageKey }: *) => {
i18n.changeLanguage(languageKey)
moment.locale(languageKey)
setLanguage(languageKey)
}

languages = [{ value: null, label: this.props.t(`language.system`) }].concat(
languageKeys.map(key => ({ value: key, label: this.languageLabels[key] })),
return (
<>
<Track
onUpdate
event="LanguageSelect"
currentRegion={currentLanguage && currentLanguage.value}
/>
<Select
small
minWidth={250}
isSearchable={false}
onChange={handleChangeLanguage}
renderSelected={item => item && item.name}
value={currentLanguage}
options={languages}
/>
</>
)

render() {
const { language, useSystem } = this.props
const currentLanguage = useSystem
? this.languages[0]
: this.languages.find(l => l.value === language)
return (
<Fragment>
<Track
onUpdate
event="LanguageSelect"
currentRegion={currentLanguage && currentLanguage.value}
/>
<Select
small
minWidth={250}
isSearchable={false}
onChange={this.handleChangeLanguage}
renderSelected={item => item && item.name}
value={currentLanguage}
options={this.languages}
/>
</Fragment>
)
}
}

export default translate()(
@@ -74,7 +74,6 @@ export const DEBUG_TAB_KEY = boolFromEnv('DEBUG_TAB_KEY')
export const DEBUG_LIBCORE = boolFromEnv('DEBUG_LIBCORE')
export const DEBUG_WS = boolFromEnv('DEBUG_WS')
export const DEBUG_SYNC = boolFromEnv('DEBUG_SYNC')
export const LEDGER_DEBUG_ALL_LANGS = boolFromEnv('LEDGER_DEBUG_ALL_LANGS')
export const SKIP_GENUINE = boolFromEnv('SKIP_GENUINE')
export const SKIP_ONBOARDING = boolFromEnv('SKIP_ONBOARDING')
export const SHOW_LEGACY_NEW_ACCOUNT = boolFromEnv('SHOW_LEGACY_NEW_ACCOUNT')
@@ -1,7 +1,7 @@
// @flow
import { LEDGER_DEBUG_ALL_LANGS } from 'config/constants'
import { getEnv } from '@ledgerhq/live-common/lib/env'

const allLanguages = ['en', 'es', 'fr', 'ja', 'ko', 'ru', 'zh']
const prodStableLanguages = ['en']
const languages = LEDGER_DEBUG_ALL_LANGS ? allLanguages : prodStableLanguages
export default languages
export const allLanguages = ['en', 'es', 'fr', 'ja', 'ko', 'ru', 'zh']
export const prodStableLanguages = ['en']
export const getLanguages = () =>
getEnv('EXPERIMENTAL_LANGUAGES') ? allLanguages : prodStableLanguages
@@ -19,6 +19,18 @@ export type FeatureToggle = {
export type Feature = FeatureCommon & FeatureToggle

export const experimentalFeatures: Feature[] = [
{
type: 'toggle',
name: 'EXPERIMENTAL_LANGUAGES',
title: 'Translation testing',
description: 'Adds unreleased languages to the language list in the general settings tab.',
},
{
type: 'toggle',
name: 'EXPERIMENTAL_EXPLORERS',
title: 'Experimental nodes',
description: "Connect to Ledger's new blockchain nodes.",
},
{
type: 'toggle',
name: 'MANAGER_DEV_MODE',
@@ -39,13 +51,6 @@ export const experimentalFeatures: Feature[] = [
description:
'Alternative USB implementation that might help solve USB issues. Enabling this feature might create UI glitches.',
},
{
shadow: true,
type: 'toggle',
name: 'EXPERIMENTAL_EXPLORERS',
title: 'Experimental nodes',
description: "Connect to Ledger's new blockchain nodes.",
},
{
shadow: true,
type: 'toggle',
@@ -6,7 +6,7 @@ import {
getCryptoCurrencyById,
getFiatCurrencyByTicker,
} from '@ledgerhq/live-common/lib/currencies'
import languages from 'config/languages'
import { getLanguages } from 'config/languages'
import { createSelector } from 'reselect'
import type { InputSelector as Selector } from 'reselect'
import type { CryptoCurrency, Currency, Account } from '@ledgerhq/live-common/lib/types'
@@ -176,6 +176,7 @@ export const lastUsedVersionSelector = (state: State): string => state.settings.
export const langAndRegionSelector = (
state: State,
): { language: string, region: ?string, useSystem: boolean } => {
const languages = getLanguages()
let { language, region } = state.settings
if (language && languages.includes(language)) {
return { language, region, useSystem: false }
Oops, something went wrong.

0 comments on commit faba9e1

Please sign in to comment.
You can’t perform that action at this time.