Browse Source

Fix i18n

master
Loëck Vézien 7 years ago
parent
commit
cf8aabf20f
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 16
      src/components/DeviceConnect/index.js
  2. 4
      src/components/DeviceConnect/stories.js
  3. 12
      src/renderer/i18n/electron.js
  4. 20
      src/renderer/i18n/instanciate.js
  5. 30
      src/renderer/i18n/storybook.js
  6. 8
      static/i18n/en/deviceConnect.yml

16
src/components/DeviceConnect/index.js

@ -197,8 +197,11 @@ class DeviceConnect extends PureComponent<Props> {
</StepIcon>
<Box grow shrink>
<Trans i18nKey="deviceConnect:step1.connect" parent="div">
Connect your <strong>Ledger device</strong> to your computer and enter your{' '}
<strong>PIN code</strong> on your device
{'Connect your '}
<strong>Ledger device</strong>
{' to your computer and enter your '}
<strong>PIN code</strong>
{' on your device'}
</Trans>
</Box>
<StepCheck checked={hasDevice} />
@ -240,8 +243,9 @@ class DeviceConnect extends PureComponent<Props> {
</StepIcon>
<Box grow shrink>
<Trans i18nKey="deviceConnect:step2.open" parent="div">
{/* $FlowFixMe */}
Open <strong>{{ appName }} App</strong> on your device
{'Open '}
<strong>{appName}</strong>
{' App on your device'}
</Trans>
</Box>
<StepCheck checked={appState.success} hasErrors={appState.fail} />
@ -254,8 +258,8 @@ class DeviceConnect extends PureComponent<Props> {
</Box>
<Box>
<Trans i18nKey="deviceConnect:info" parent="div">
{/* $FlowFixMe */}
You must use the device associated to the account <strong>{{ accountName }}</strong>
{'You must use the device associated to the account '}
<strong>{accountName}</strong>
</Trans>
</Box>
</Info>

4
src/components/DeviceConnect/stories.js

@ -36,9 +36,9 @@ const devices = [
stories.add('DeviceConnect', () => (
<DeviceConnect
accountName={boolean('withAccount', true) ? text('accountName', 'Test Account') : null}
coinType={select('coinType', [0, 1, 145, 156, 2, 3, 5], 0)}
coinType={Number(select('coinType', [0, 1, 145, 156, 2, 3, 5], '0'))}
appOpened={select('appOpened', ['', 'success', 'fail'], '')}
devices={devices.slice(0, select('devices', [0, 1, 2, 3], 0))}
devices={devices.slice(0, Number(select('devices', [0, 1, 2, 3], '0')))}
deviceSelected={devices[select('deviceSelected', ['', 0, 1, 2], '')] || null}
onChangeDevice={action('onChangeDevice')}
/>

12
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'),
},
})

20
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)
}

30
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,
},
})

8
static/i18n/en/deviceConnect.yml

@ -1,8 +1,8 @@
step1:
connect: Connect your <0>Ledger device</0> to your computer and enter your <1>PIN code</1> on your device
choose_plural: We detected {{count}} devices connected, please select one:
connect: Connect your <1>Ledger device</1> to your computer and enter your <3>PIN code</3> on your device
choose: "We detected {{count}} devices connected, please select one:"
step2:
open: Open <0>{{appName}}</0> App on your device
open: Open <1><0>{{appName}}</0></1> App on your device
info: You must use the device associated to the account <0>{{accountName}}</0>
info: You must use the device associated to the account <1><0>{{accountName}}</0></1>

Loading…
Cancel
Save