Merge pull request #1149 from h3poteto/iss-901
refs #901 Load translation json directly instead of i18next-sync-fs-backend
This commit is contained in:
commit
5c9f486302
|
@ -13,9 +13,7 @@ let mainConfig = {
|
|||
entry: {
|
||||
main: path.join(__dirname, '../src/main/index.ts')
|
||||
},
|
||||
externals: [
|
||||
...Object.keys(dependencies || {})
|
||||
],
|
||||
externals: [...Object.keys(dependencies || {})],
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
|
@ -42,6 +40,12 @@ let mainConfig = {
|
|||
{
|
||||
test: /\.node$/,
|
||||
use: 'node-loader'
|
||||
},
|
||||
{
|
||||
test: /\.json$/,
|
||||
exclude: /node_modules/,
|
||||
use: 'json-loader',
|
||||
type: 'javascript/auto'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -81,7 +85,7 @@ let mainConfig = {
|
|||
if (process.env.NODE_ENV !== 'production') {
|
||||
mainConfig.plugins.push(
|
||||
new webpack.DefinePlugin({
|
||||
'__static': `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
|
||||
__static: `"${path.join(__dirname, '../static').replace(/\\/g, '\\\\')}"`
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
|
@ -117,6 +117,12 @@ let rendererConfig = {
|
|||
name: 'fonts/[name]--[folder].[ext]'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.json$/,
|
||||
exclude: /node_modules/,
|
||||
use: 'json-loader',
|
||||
type: 'javascript/auto'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -6395,7 +6395,7 @@
|
|||
"dependencies": {
|
||||
"resolve": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
|
||||
"resolved": "http://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz",
|
||||
"integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=",
|
||||
"dev": true
|
||||
}
|
||||
|
@ -13049,36 +13049,6 @@
|
|||
"resolved": "https://registry.npmjs.org/i18next/-/i18next-12.1.0.tgz",
|
||||
"integrity": "sha512-AexmwGkKxwKfo5fGeXTWEY4xqzRPigQ1S/0InOUUVziGO54cd4fKyYK8ED1Thx9fd+WA3fRSZ+1iekvFQMbsFw=="
|
||||
},
|
||||
"i18next-sync-fs-backend": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/i18next-sync-fs-backend/-/i18next-sync-fs-backend-1.1.1.tgz",
|
||||
"integrity": "sha512-IoJCGid/NLqPFp+2qsumwOy1hG6jENKSIW9BozHL/3ZsjunH0P7iZLRMADljIuFntKlA63suPIPJWGR2SkxLIg==",
|
||||
"requires": {
|
||||
"js-yaml": "3.13.1",
|
||||
"json5": "0.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.13.1",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
|
||||
"integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"json5": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-0.5.0.tgz",
|
||||
"integrity": "sha1-myBxWwJsvjd4/Xae3M2CLYMypbI="
|
||||
}
|
||||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
|
@ -15618,6 +15588,12 @@
|
|||
"integrity": "sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=",
|
||||
"dev": true
|
||||
},
|
||||
"json-loader": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz",
|
||||
"integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==",
|
||||
"dev": true
|
||||
},
|
||||
"json-parse-better-errors": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
|
||||
|
@ -16524,7 +16500,7 @@
|
|||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
@ -16539,7 +16515,7 @@
|
|||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
|
|
@ -183,7 +183,6 @@
|
|||
"hawk": "^7.0.10",
|
||||
"hoek": "^6.1.3",
|
||||
"i18next": "^12.1.0",
|
||||
"i18next-sync-fs-backend": "^1.1.1",
|
||||
"lodash": "^4.17.15",
|
||||
"megalodon": "2.0.1",
|
||||
"moment": "^2.21.0",
|
||||
|
@ -266,6 +265,7 @@
|
|||
"html-webpack-plugin": "^3.2.0",
|
||||
"jest": "^24.5.0",
|
||||
"jsdom": "^15.2.1",
|
||||
"json-loader": "^0.5.7",
|
||||
"listr": "^0.14.3",
|
||||
"mini-css-extract-plugin": "^0.4.5",
|
||||
"node-loader": "^0.6.0",
|
||||
|
|
|
@ -1,24 +1,66 @@
|
|||
import * as path from 'path'
|
||||
import i18next, { InitOptions } from 'i18next'
|
||||
import Backend from 'i18next-sync-fs-backend'
|
||||
import cs from '~/src/config/locales/cs/translation.json'
|
||||
import de from '~/src/config/locales/de/translation.json'
|
||||
import en from '~/src/config/locales/en/translation.json'
|
||||
import es_es from '~/src/config/locales/es_es/translation.json'
|
||||
import fr from '~/src/config/locales/fr/translation.json'
|
||||
import ja from '~/src/config/locales/it/translation.json'
|
||||
import ko from '~/src/config/locales/ko/translation.json'
|
||||
import no from '~/src/config/locales/no/translation.json'
|
||||
import pl from '~/src/config/locales/pl/translation.json'
|
||||
import pt_pt from '~/src/config/locales/pt_pt/translation.json'
|
||||
import ru from '~/src/config/locales/ru/translation.json'
|
||||
import sv_se from '~/src/config/locales/sv_se/translation.json'
|
||||
import zh_cn from '~/src/config/locales/zh_cn/translation.json'
|
||||
|
||||
const options: InitOptions = {
|
||||
initImmediate: false,
|
||||
lng: 'en',
|
||||
fallbackLng: 'en',
|
||||
saveMissing: true,
|
||||
backend: {
|
||||
// path where resources get loaded from
|
||||
loadPath: path.resolve(__dirname, './locales/{{lng}}/{{ns}}.json'),
|
||||
|
||||
// path to post missing resources
|
||||
addPath: path.resolve(__dirname, './locales/en/{{ns}}.json'),
|
||||
|
||||
// jsonIndent to use when storing json files
|
||||
jsonIndent: 2
|
||||
resources: {
|
||||
cs: {
|
||||
translation: cs
|
||||
},
|
||||
de: {
|
||||
translation: de
|
||||
},
|
||||
en: {
|
||||
translation: en
|
||||
},
|
||||
es_es: {
|
||||
translation: es_es
|
||||
},
|
||||
fr: {
|
||||
translation: fr
|
||||
},
|
||||
ja: {
|
||||
translation: ja
|
||||
},
|
||||
ko: {
|
||||
translation: ko
|
||||
},
|
||||
no: {
|
||||
translation: no
|
||||
},
|
||||
pl: {
|
||||
translation: pl
|
||||
},
|
||||
pt_pt: {
|
||||
translation: pt_pt
|
||||
},
|
||||
ru: {
|
||||
translation: ru
|
||||
},
|
||||
sv_se: {
|
||||
translation: sv_se
|
||||
},
|
||||
zh_cn: {
|
||||
translation: zh_cn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i18next.use(Backend).init(options)
|
||||
i18next.init(options)
|
||||
|
||||
export default i18next
|
||||
|
|
Loading…
Reference in New Issue