From d946abf82ca34dcab3f0240e1797f74a52a5103a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Tue, 3 Apr 2018 14:02:12 +0200 Subject: [PATCH 1/3] Rework Receive modal --- src/components/DeviceMonitNew/index.js | 5 +- src/components/base/Button/index.js | 4 +- src/components/modals/AddAccount/index.js | 6 +- .../modals/Receive/01-step-account.js | 23 +++ src/components/modals/Receive/index.js | 161 +++++++++++------- ...connect-device.js => StepConnectDevice.js} | 20 ++- src/styles/theme.js | 2 +- static/i18n/en/receive.yml | 13 +- 8 files changed, 156 insertions(+), 78 deletions(-) create mode 100644 src/components/modals/Receive/01-step-account.js rename src/components/modals/{AddAccount/02-step-connect-device.js => StepConnectDevice.js} (64%) diff --git a/src/components/DeviceMonitNew/index.js b/src/components/DeviceMonitNew/index.js index 1a3bec92..56fa2d1f 100644 --- a/src/components/DeviceMonitNew/index.js +++ b/src/components/DeviceMonitNew/index.js @@ -88,7 +88,7 @@ class DeviceMonit extends PureComponent { let options = null - if (account && account.currency) { + if (account) { options = { accountPath: account.path, accountAddress: account.address, @@ -134,11 +134,12 @@ class DeviceMonit extends PureComponent { } render() { + const { coinType, account, devices, deviceSelected, render } = this.props const { status } = this.state - const { devices, deviceSelected, render } = this.props if (render) { return render({ + coinType: (account && account.coinType) || coinType, status, devices, deviceSelected: status === 'connected' ? deviceSelected : null, diff --git a/src/components/base/Button/index.js b/src/components/base/Button/index.js index 47436049..7d5670cd 100644 --- a/src/components/base/Button/index.js +++ b/src/components/base/Button/index.js @@ -12,7 +12,7 @@ import fontFamily from 'styles/styled/fontFamily' const Base = styled.button.attrs({ ff: 'Museo Sans|Regular', fontSize: 3, - px: p => (p.primary ? (p.small ? 2 : 4) : 1), + px: p => (p.primary ? (p.small ? 2 : 3) : 1), })` ${space}; ${color}; @@ -22,7 +22,7 @@ const Base = styled.button.attrs({ border-radius: ${p => p.theme.radii[1]}px; border: none; cursor: ${p => (p.disabled ? 'default' : 'pointer')}; - height: ${p => (p.small ? 30 : 40)}px; + height: ${p => (p.small ? 30 : 36)}px; outline: none; &:hover { diff --git a/src/components/modals/AddAccount/index.js b/src/components/modals/AddAccount/index.js index 9fee169e..1f415e06 100644 --- a/src/components/modals/AddAccount/index.js +++ b/src/components/modals/AddAccount/index.js @@ -22,12 +22,12 @@ import { addAccount, updateAccount } from 'actions/accounts' import { fetchCounterValues } from 'actions/counterValues' import Box from 'components/base/Box' -import Button from 'components/base/Button' import Breadcrumb from 'components/Breadcrumb' +import Button from 'components/base/Button' import Modal, { ModalContent, ModalTitle, ModalFooter, ModalBody } from 'components/base/Modal' +import StepConnectDevice from 'components/modals/StepConnectDevice' import StepCurrency from './01-step-currency' -import StepConnectDevice from './02-step-connect-device' import StepImport from './03-step-import' const GET_STEPS = t => [ @@ -362,7 +362,7 @@ class AddAccountModal extends PureComponent { {t('addAccount:title')} - + {this.renderStep()} {stepIndex !== 2 && ( diff --git a/src/components/modals/Receive/01-step-account.js b/src/components/modals/Receive/01-step-account.js new file mode 100644 index 00000000..4413d06b --- /dev/null +++ b/src/components/modals/Receive/01-step-account.js @@ -0,0 +1,23 @@ +// @flow + +import React from 'react' + +import type { Account } from '@ledgerhq/wallet-common/lib/types' +import type { T } from 'types/common' + +import Box from 'components/base/Box' +import Label from 'components/base/Label' +import SelectAccount from 'components/SelectAccount' + +type Props = { + account: Account | null, + onChangeAccount: Function, + t: T, +} + +export default (props: Props) => ( + + + + +) diff --git a/src/components/modals/Receive/index.js b/src/components/modals/Receive/index.js index 1a16aca3..3622d83c 100644 --- a/src/components/modals/Receive/index.js +++ b/src/components/modals/Receive/index.js @@ -1,105 +1,140 @@ // @flow -import React, { PureComponent, Fragment } from 'react' +import React, { PureComponent } from 'react' import { translate } from 'react-i18next' -import type { Account as AccountType } from '@ledgerhq/wallet-common/lib/types' - import get from 'lodash/get' +import type { Account } from '@ledgerhq/wallet-common/lib/types' + +import type { T, Device } from 'types/common' import { MODAL_RECEIVE } from 'config/constants' import Box from 'components/base/Box' -import Label from 'components/base/Label' import Button from 'components/base/Button' -import Modal, { ModalBody, ModalTitle, ModalFooter, ModalContent } from 'components/base/Modal' -import ReceiveBox from 'components/ReceiveBox' -import RequestAmount from 'components/RequestAmount' -import SelectAccount from 'components/SelectAccount' +import Breadcrumb from 'components/Breadcrumb' +import Modal, { ModalBody, ModalTitle, ModalContent, ModalFooter } from 'components/base/Modal' +import StepConnectDevice from 'components/modals/StepConnectDevice' -import type { T } from 'types/common' +import StepAccount from './01-step-account' type Props = { t: T, } type State = { - account: AccountType | null, - amount: Object, + deviceSelected: Device | null, + stepIndex: number, + account: Account | null, } -const defaultState = { +const GET_STEPS = t => [ + { label: t('receive:steps.chooseAccount.title'), Comp: StepAccount }, + { label: t('receive:steps.connectDevice.title'), Comp: StepConnectDevice }, +] + +const INITIAL_STATE = { account: null, - amount: { - left: 0, - right: 0, - }, + deviceSelected: null, + stepIndex: 0, } -class ReceiveModal extends PureComponent { - state = { - ...defaultState, +class SendModal extends PureComponent { + state = INITIAL_STATE + + _steps = GET_STEPS(this.props.t) + + canNext = acc => { + const { stepIndex } = this.state + + if (stepIndex === 0) { + return acc !== null + } + + return false } - getAccount(data) { - const { account } = this.state + handleReset = () => this.setState(INITIAL_STATE) - return account || get(data, 'account') + handleNextStep = () => { + const { stepIndex } = this.state + if (stepIndex >= this._steps.length - 1) { + return + } + this.setState({ stepIndex: stepIndex + 1 }) } - handleChangeInput = key => value => - this.setState({ - [key]: value, - }) + handleChangeDevice = d => this.setState({ deviceSelected: d }) - handleHide = () => - this.setState({ - ...defaultState, - }) + handleChangeAccount = account => this.setState({ account }) - _steps = [ - 'receiveModal:Infos', - 'receiveModal:ConnectDevice', - 'receiveModal:SecureValidation', - 'receiveModal:Confirmation', - ].map(v => ({ label: this.props.t(v) })) + renderStep = acc => { + const { deviceSelected, stepIndex } = this.state + const { t } = this.props + const step = this._steps[stepIndex] + if (!step) { + return null + } + const { Comp } = step + + const props = (predicate, props) => (predicate ? props : {}) + + const stepProps = { + t, + account: acc, + ...props(stepIndex === 0, { + onChangeAccount: this.handleChangeAccount, + }), + ...props(stepIndex === 1, { + deviceSelected, + onChangeDevice: this.handleChangeDevice, + }), + } + + return + } + + renderButton = acc => { + const { t } = this.props + const { stepIndex } = this.state + + let onClick + + switch (stepIndex) { + default: + onClick = this.handleNextStep + } + + const props = { + primary: true, + disabled: !this.canNext(acc), + onClick, + children: t('common:next'), + } + + return + + + {this.renderButton(acc)} + ) @@ -109,4 +144,4 @@ class ReceiveModal extends PureComponent { } } -export default translate()(ReceiveModal) +export default translate()(SendModal) diff --git a/src/components/modals/AddAccount/02-step-connect-device.js b/src/components/modals/StepConnectDevice.js similarity index 64% rename from src/components/modals/AddAccount/02-step-connect-device.js rename to src/components/modals/StepConnectDevice.js index fed49b45..61e8756e 100644 --- a/src/components/modals/AddAccount/02-step-connect-device.js +++ b/src/components/modals/StepConnectDevice.js @@ -2,28 +2,29 @@ import React from 'react' -import type { Currency } from '@ledgerhq/currencies/lib/types' - +import type { Account, Currency } from '@ledgerhq/currencies/lib/types' import type { Device } from 'types/common' import DeviceConnect from 'components/DeviceConnect' import DeviceMonit from 'components/DeviceMonitNew' type Props = { - currency: Currency | null, + account?: Account, + currency?: Currency | null, deviceSelected: Device | null, onChangeDevice: Function, onStatusChange: Function, } -export default (props: Props) => ( +const StepConnectDevice = (props: Props) => ( ( + render={({ coinType, status, devices, deviceSelected }) => ( ( )} /> ) + +StepConnectDevice.defaultProps = { + account: undefined, + currency: undefined, +} + +export default StepConnectDevice diff --git a/src/styles/theme.js b/src/styles/theme.js index 8dc6e5c7..ddc0b732 100644 --- a/src/styles/theme.js +++ b/src/styles/theme.js @@ -77,7 +77,7 @@ export const colors = { lightGrey: '#f9f9f9', positiveGreen: '#66be54', smoke: '#666666', - wallet: '#4b84ff', + wallet: '#6490f1', white: '#ffffff', } diff --git a/static/i18n/en/receive.yml b/static/i18n/en/receive.yml index f12a73f0..e24c60f8 100644 --- a/static/i18n/en/receive.yml +++ b/static/i18n/en/receive.yml @@ -1 +1,12 @@ -title: Receive +title: Receive funds + +steps: + chooseAccount: + title: Choose Account + label: Account + connectDevice: + title: Connect Device + confirmAddress: + title: Confirm Address + receiveFunds: + title: Receive Funds From 605a7cd96bc5f7aed5176c388751cbc53ea132c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Tue, 3 Apr 2018 14:46:43 +0200 Subject: [PATCH 2/3] Fix DeviceConnect for multi device --- src/components/DeviceConnect/index.js | 2 +- src/components/DeviceMonitNew/index.js | 51 +++++++++++----------- src/components/modals/AddAccount/index.js | 10 ++--- src/components/modals/Receive/index.js | 17 ++++++-- src/components/modals/StepConnectDevice.js | 12 ++--- static/i18n/en/deviceConnect.yml | 2 +- 6 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/components/DeviceConnect/index.js b/src/components/DeviceConnect/index.js index c661067a..17622339 100644 --- a/src/components/DeviceConnect/index.js +++ b/src/components/DeviceConnect/index.js @@ -206,7 +206,7 @@ class DeviceConnect extends PureComponent { {hasMultipleDevices && ( - {t('deviceConnect:step1.choose', { devicesCount: devices.length })} + {t('deviceConnect:step1.choose', { count: devices.length })} {devices.map(d => { diff --git a/src/components/DeviceMonitNew/index.js b/src/components/DeviceMonitNew/index.js index 56fa2d1f..7d7f8b93 100644 --- a/src/components/DeviceMonitNew/index.js +++ b/src/components/DeviceMonitNew/index.js @@ -14,29 +14,28 @@ const mapStateToProps = state => ({ devices: getDevices(state), }) -type DeviceStatus = - | 'unconnected' - | 'connected' - | 'appOpened.success' - | 'appOpened.fail' - | 'appOpened.progress' +type DeviceStatus = 'unconnected' | 'connected' + +type AppStatus = 'success' | 'fail' | 'progress' type Props = { coinType: number, devices: Devices, deviceSelected: Device | null, account?: Account, - onStatusChange?: DeviceStatus => void, + onStatusChange?: (DeviceStatus, AppStatus) => void, render?: Function, } type State = { - status: DeviceStatus, + deviceStatus: DeviceStatus, + appStatus: AppStatus, } class DeviceMonit extends PureComponent { state = { - status: this.props.deviceSelected ? 'connected' : 'unconnected', + appStatus: 'progress', + deviceStatus: this.props.deviceSelected ? 'connected' : 'unconnected', } componentDidMount() { @@ -47,19 +46,18 @@ class DeviceMonit extends PureComponent { } componentWillReceiveProps(nextProps) { - const { status } = this.state + const { deviceStatus } = this.state const { deviceSelected, devices } = this.props const { devices: nextDevices, deviceSelected: nextDeviceSelected } = nextProps - if (status === 'unconnected' && !deviceSelected && nextDeviceSelected) { - this.handleStatusChange('connected') + if (deviceStatus === 'unconnected' && !deviceSelected && nextDeviceSelected) { + this.handleStatusChange('connected', 'progress') } - if (status !== 'unconnected' && devices !== nextDevices) { + if (deviceStatus !== 'unconnected' && devices !== nextDevices) { const isConnected = nextDevices.find(d => d === nextDeviceSelected) if (!isConnected) { - this.handleStatusChange('unconnected') - clearTimeout(this._timeout) + this.handleStatusChange('unconnected', 'progress') } } } @@ -69,7 +67,7 @@ class DeviceMonit extends PureComponent { const { deviceSelected: prevDeviceSelected } = prevProps if (prevDeviceSelected !== deviceSelected) { - this.handleStatusChange('appOpened.progress') + this.handleStatusChange('connected', 'progress') this._timeout = setTimeout(this.checkAppOpened, 250) } } @@ -109,13 +107,15 @@ class DeviceMonit extends PureComponent { _timeout: any = null - handleStatusChange = status => { + handleStatusChange = (deviceStatus, appStatus) => { const { onStatusChange } = this.props - this.setState({ status }) - onStatusChange && onStatusChange(status) + clearTimeout(this._timeout) + this.setState({ deviceStatus, appStatus }) + onStatusChange && onStatusChange(deviceStatus, appStatus) } handleMsgEvent = (e, { type, data }) => { + const { deviceStatus } = this.state const { deviceSelected } = this.props if (deviceSelected === null) { @@ -123,26 +123,27 @@ class DeviceMonit extends PureComponent { } if (type === 'wallet.checkIfAppOpened.success' && deviceSelected.path === data.devicePath) { - clearTimeout(this._timeout) - this.handleStatusChange('appOpened.success') + this.handleStatusChange(deviceStatus, 'success') + this._timeout = setTimeout(this.checkAppOpened, 1e3) } if (type === 'wallet.checkIfAppOpened.fail' && deviceSelected.path === data.devicePath) { - this.handleStatusChange('appOpened.fail') + this.handleStatusChange(deviceStatus, 'fail') this._timeout = setTimeout(this.checkAppOpened, 1e3) } } render() { const { coinType, account, devices, deviceSelected, render } = this.props - const { status } = this.state + const { appStatus, deviceStatus } = this.state if (render) { return render({ + appStatus, coinType: (account && account.coinType) || coinType, - status, devices, - deviceSelected: status === 'connected' ? deviceSelected : null, + deviceSelected: deviceStatus === 'connected' ? deviceSelected : null, + deviceStatus, }) } diff --git a/src/components/modals/AddAccount/index.js b/src/components/modals/AddAccount/index.js index 1f415e06..5287335f 100644 --- a/src/components/modals/AddAccount/index.js +++ b/src/components/modals/AddAccount/index.js @@ -67,7 +67,7 @@ type State = { deviceSelected: Device | null, fetchingCounterValues: boolean, selectedAccounts: Array, - status: null | string, + appStatus: null | string, stepIndex: number, } @@ -77,7 +77,7 @@ const INITIAL_STATE = { deviceSelected: null, fetchingCounterValues: false, selectedAccounts: [], - status: null, + appStatus: null, stepIndex: 0, } @@ -148,8 +148,8 @@ class AddAccountModal extends PureComponent { } if (stepIndex === 1) { - const { deviceSelected, status } = this.state - return deviceSelected !== null && status === 'appOpened.success' + const { deviceSelected, appStatus } = this.state + return deviceSelected !== null && appStatus === 'success' } if (stepIndex === 3) { @@ -225,7 +225,7 @@ class AddAccountModal extends PureComponent { handleChangeCurrency = (currency: Currency) => this.setState({ currency }) - handleChangeStatus = status => this.setState({ status }) + handleChangeStatus = (deviceStatus, appStatus) => this.setState({ appStatus }) handleImportAccount = () => { const { archivedAccounts, updateAccount } = this.props diff --git a/src/components/modals/Receive/index.js b/src/components/modals/Receive/index.js index 3622d83c..095241a1 100644 --- a/src/components/modals/Receive/index.js +++ b/src/components/modals/Receive/index.js @@ -22,9 +22,10 @@ type Props = { } type State = { + account: Account | null, deviceSelected: Device | null, + appStatus: null | string, stepIndex: number, - account: Account | null, } const GET_STEPS = t => [ @@ -35,10 +36,11 @@ const GET_STEPS = t => [ const INITIAL_STATE = { account: null, deviceSelected: null, + appStatus: null, stepIndex: 0, } -class SendModal extends PureComponent { +class ReceiveModal extends PureComponent { state = INITIAL_STATE _steps = GET_STEPS(this.props.t) @@ -50,6 +52,11 @@ class SendModal extends PureComponent { return acc !== null } + if (stepIndex === 1) { + const { deviceSelected, appStatus } = this.state + return deviceSelected !== null && appStatus === 'success' + } + return false } @@ -67,6 +74,8 @@ class SendModal extends PureComponent { handleChangeAccount = account => this.setState({ account }) + handleChangeStatus = (deviceStatus, appStatus) => this.setState({ appStatus }) + renderStep = acc => { const { deviceSelected, stepIndex } = this.state const { t } = this.props @@ -85,8 +94,10 @@ class SendModal extends PureComponent { onChangeAccount: this.handleChangeAccount, }), ...props(stepIndex === 1, { + accountName: acc ? acc.name : undefined, deviceSelected, onChangeDevice: this.handleChangeDevice, + onStatusChange: this.handleChangeStatus, }), } @@ -144,4 +155,4 @@ class SendModal extends PureComponent { } } -export default translate()(SendModal) +export default translate()(ReceiveModal) diff --git a/src/components/modals/StepConnectDevice.js b/src/components/modals/StepConnectDevice.js index 61e8756e..da703333 100644 --- a/src/components/modals/StepConnectDevice.js +++ b/src/components/modals/StepConnectDevice.js @@ -2,13 +2,15 @@ import React from 'react' -import type { Account, Currency } from '@ledgerhq/currencies/lib/types' +import type { Account } from '@ledgerhq/wallet-common/lib/types' +import type { Currency } from '@ledgerhq/currencies/lib/types' import type { Device } from 'types/common' import DeviceConnect from 'components/DeviceConnect' import DeviceMonit from 'components/DeviceMonitNew' type Props = { + accountName?: string, account?: Account, currency?: Currency | null, deviceSelected: Device | null, @@ -22,12 +24,11 @@ const StepConnectDevice = (props: Props) => ( coinType={props.currency && props.currency.coinType} deviceSelected={props.deviceSelected} onStatusChange={props.onStatusChange} - render={({ coinType, status, devices, deviceSelected }) => ( + render={({ coinType, appStatus, devices, deviceSelected }) => ( ( StepConnectDevice.defaultProps = { account: undefined, + accountName: undefined, currency: undefined, } diff --git a/static/i18n/en/deviceConnect.yml b/static/i18n/en/deviceConnect.yml index 480ce992..62e367e3 100644 --- a/static/i18n/en/deviceConnect.yml +++ b/static/i18n/en/deviceConnect.yml @@ -1,6 +1,6 @@ step1: connect: Connect your <0>Ledger device to your computer and enter your <1>PIN code on your device - choose: We detected {{devicesCount}} devices connected, please select one: + choose_plural: We detected {{count}} devices connected, please select one: step2: open: Open <0>{{appName}} App on your device From cf8aabf20f50961c13cdd27155897e44f496648f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Tue, 3 Apr 2018 15:21:12 +0200 Subject: [PATCH 3/3] Fix i18n --- src/components/DeviceConnect/index.js | 16 ++++++++----- src/components/DeviceConnect/stories.js | 4 ++-- src/renderer/i18n/electron.js | 12 +++++++++- src/renderer/i18n/instanciate.js | 20 ++--------------- src/renderer/i18n/storybook.js | 30 +++++++++++-------------- static/i18n/en/deviceConnect.yml | 8 +++---- 6 files changed, 42 insertions(+), 48 deletions(-) diff --git a/src/components/DeviceConnect/index.js b/src/components/DeviceConnect/index.js index 17622339..84f6c328 100644 --- a/src/components/DeviceConnect/index.js +++ b/src/components/DeviceConnect/index.js @@ -197,8 +197,11 @@ class DeviceConnect extends PureComponent { - Connect your Ledger device to your computer and enter your{' '} - PIN code on your device + {'Connect your '} + Ledger device + {' to your computer and enter your '} + PIN code + {' on your device'} @@ -240,8 +243,9 @@ class DeviceConnect extends PureComponent { - {/* $FlowFixMe */} - Open {{ appName }} App on your device + {'Open '} + {appName} + {' App on your device'} @@ -254,8 +258,8 @@ class DeviceConnect extends PureComponent { - {/* $FlowFixMe */} - You must use the device associated to the account {{ accountName }} + {'You must use the device associated to the account '} + {accountName} diff --git a/src/components/DeviceConnect/stories.js b/src/components/DeviceConnect/stories.js index 2efa7a79..4b729e3d 100644 --- a/src/components/DeviceConnect/stories.js +++ b/src/components/DeviceConnect/stories.js @@ -36,9 +36,9 @@ const devices = [ stories.add('DeviceConnect', () => ( diff --git a/src/renderer/i18n/electron.js b/src/renderer/i18n/electron.js index 928a92a5..afbc541b 100644 --- a/src/renderer/i18n/electron.js +++ b/src/renderer/i18n/electron.js @@ -1,11 +1,21 @@ // @flow +import fs from 'fs' import path from 'path' import FSBackend from 'i18next-node-fs-backend' import staticPath from 'helpers/staticPath' import { createWithBackend } from './instanciate' +const ns = p => + fs + .readdirSync(p) + .filter(f => !fs.statSync(path.join(p, f)).isDirectory()) + .map(file => file.split('.yml')[0]) + export default createWithBackend(FSBackend, { - loadPath: path.join(staticPath, '/i18n/{{lng}}/{{ns}}.yml'), + ns: ns(path.join(staticPath, '/i18n/en')), + backend: { + loadPath: path.join(staticPath, '/i18n/{{lng}}/{{ns}}.yml'), + }, }) diff --git a/src/renderer/i18n/instanciate.js b/src/renderer/i18n/instanciate.js index 3088da6c..d8a6eec8 100644 --- a/src/renderer/i18n/instanciate.js +++ b/src/renderer/i18n/instanciate.js @@ -1,22 +1,6 @@ import i18n from 'i18next' const commonConfig = { - ns: [ - 'account', - 'accountsOrder', - 'addAccount', - 'common', - 'dashboard', - 'device', - 'language', - 'receive', - 'send', - 'settings', - 'sidebar', - 'time', - 'operationsList', - 'update', - ], fallbackLng: 'en', debug: false, react: { @@ -35,7 +19,7 @@ function addPluralRule(i18n) { export function createWithBackend(backend, backendOpts) { i18n.use(backend).init({ ...commonConfig, - backend: backendOpts, + ...backendOpts, }) return addPluralRule(i18n) } @@ -43,7 +27,7 @@ export function createWithBackend(backend, backendOpts) { export function createWithResources(resources) { i18n.init({ ...commonConfig, - resources, + ...resources, }) return addPluralRule(i18n) } diff --git a/src/renderer/i18n/storybook.js b/src/renderer/i18n/storybook.js index 01302f00..6cb73406 100644 --- a/src/renderer/i18n/storybook.js +++ b/src/renderer/i18n/storybook.js @@ -1,20 +1,16 @@ import { createWithResources } from './instanciate' -const resources = { - account: require('../../../static/i18n/en/account.yml'), - accountsOrder: require('../../../static/i18n/en/accountsOrder.yml'), - addAccount: require('../../../static/i18n/en/addAccount.yml'), - common: require('../../../static/i18n/en/common.yml'), - dashboard: require('../../../static/i18n/en/dashboard.yml'), - device: require('../../../static/i18n/en/device.yml'), - language: require('../../../static/i18n/en/language.yml'), - receive: require('../../../static/i18n/en/receive.yml'), - send: require('../../../static/i18n/en/send.yml'), - settings: require('../../../static/i18n/en/settings.yml'), - sidebar: require('../../../static/i18n/en/sidebar.yml'), - time: require('../../../static/i18n/en/time.yml'), - operationsList: require('../../../static/i18n/en/operationsList.yml'), - update: require('../../../static/i18n/en/update.yml'), -} +const req = require.context('../../../static/i18n/en', true, /.yml$/) -export default createWithResources({ en: resources }) +const resources = req.keys().reduce((result, file) => { + const [, fileName] = file.match(/\.\/(.*)\.yml/) + result[fileName] = req(file) + return result +}, {}) + +export default createWithResources({ + ns: Object.keys(resources), + resources: { + en: resources, + }, +}) diff --git a/static/i18n/en/deviceConnect.yml b/static/i18n/en/deviceConnect.yml index 62e367e3..5757e748 100644 --- a/static/i18n/en/deviceConnect.yml +++ b/static/i18n/en/deviceConnect.yml @@ -1,8 +1,8 @@ step1: - connect: Connect your <0>Ledger device to your computer and enter your <1>PIN code on your device - choose_plural: We detected {{count}} devices connected, please select one: + connect: Connect your <1>Ledger device to your computer and enter your <3>PIN code on your device + choose: "We detected {{count}} devices connected, please select one:" step2: - open: Open <0>{{appName}} App on your device + open: Open <1><0>{{appName}} App on your device -info: You must use the device associated to the account <0>{{accountName}} +info: You must use the device associated to the account <1><0>{{accountName}}