committed by
GitHub
16 changed files with 163 additions and 51 deletions
@ -0,0 +1,13 @@ |
|||
const path = require('path') |
|||
|
|||
module.exports = { |
|||
module: { |
|||
rules: [ |
|||
{ |
|||
test: /\.yml$/, |
|||
loaders: ['json-loader', 'yaml-loader'], |
|||
include: path.resolve(__dirname, '../static/i18n'), |
|||
}, |
|||
], |
|||
}, |
|||
} |
@ -0,0 +1,5 @@ |
|||
module.exports = { |
|||
globals: { |
|||
__DEV__: false, |
|||
}, |
|||
} |
@ -1,41 +0,0 @@ |
|||
// @flow
|
|||
|
|||
import i18n from 'i18next' |
|||
import path from 'path' |
|||
import Backend from 'i18next-node-fs-backend' |
|||
|
|||
import staticPath from 'helpers/staticPath' |
|||
|
|||
i18n.use(Backend).init({ |
|||
ns: [ |
|||
'account', |
|||
'accountsOrder', |
|||
'addAccount', |
|||
'common', |
|||
'dashboard', |
|||
'device', |
|||
'language', |
|||
'receive', |
|||
'send', |
|||
'settings', |
|||
'sidebar', |
|||
'time', |
|||
'transactionsList', |
|||
'update', |
|||
], |
|||
fallbackLng: 'en', |
|||
debug: false, |
|||
backend: { |
|||
loadPath: path.join(staticPath, '/i18n/{{lng}}/{{ns}}.yml'), |
|||
}, |
|||
react: { |
|||
wait: true, |
|||
}, |
|||
}) |
|||
|
|||
i18n.services.pluralResolver.addRule('en', { |
|||
numbers: [0, 1, 'plural'], |
|||
plurals: n => Number(n >= 2 ? 2 : n), |
|||
}) |
|||
|
|||
export default i18n |
@ -0,0 +1,11 @@ |
|||
// @flow
|
|||
|
|||
import path from 'path' |
|||
import FSBackend from 'i18next-node-fs-backend' |
|||
|
|||
import staticPath from 'helpers/staticPath' |
|||
import { createWithBackend } from './instanciate' |
|||
|
|||
export default createWithBackend(FSBackend, { |
|||
loadPath: path.join(staticPath, '/i18n/{{lng}}/{{ns}}.yml'), |
|||
}) |
@ -0,0 +1,49 @@ |
|||
import i18n from 'i18next' |
|||
|
|||
const commonConfig = { |
|||
ns: [ |
|||
'account', |
|||
'accountsOrder', |
|||
'addAccount', |
|||
'common', |
|||
'dashboard', |
|||
'device', |
|||
'language', |
|||
'receive', |
|||
'send', |
|||
'settings', |
|||
'sidebar', |
|||
'time', |
|||
'transactionsList', |
|||
'update', |
|||
], |
|||
fallbackLng: 'en', |
|||
debug: false, |
|||
react: { |
|||
wait: true, |
|||
}, |
|||
} |
|||
|
|||
function addPluralRule(i18n) { |
|||
i18n.services.pluralResolver.addRule('en', { |
|||
numbers: [0, 1, 'plural'], |
|||
plurals: n => Number(n >= 2 ? 2 : n), |
|||
}) |
|||
return i18n |
|||
} |
|||
|
|||
export function createWithBackend(backend, backendOpts) { |
|||
i18n.use(backend).init({ |
|||
...commonConfig, |
|||
backend: backendOpts, |
|||
}) |
|||
return addPluralRule(i18n) |
|||
} |
|||
|
|||
export function createWithResources(resources) { |
|||
i18n.init({ |
|||
...commonConfig, |
|||
resources, |
|||
}) |
|||
return addPluralRule(i18n) |
|||
} |
@ -0,0 +1,20 @@ |
|||
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'), |
|||
transactionsList: require('../../../static/i18n/en/transactionsList.yml'), |
|||
update: require('../../../static/i18n/en/update.yml'), |
|||
} |
|||
|
|||
export default createWithResources({ en: resources }) |
Loading…
Reference in new issue