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