Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refs #901 Load translation json directly instead of i18next-sync-fs-backend #1149

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions .electron-vue/webpack.main.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand All @@ -42,6 +40,12 @@ let mainConfig = {
{
test: /\.node$/,
use: 'node-loader'
},
{
test: /\.json$/,
exclude: /node_modules/,
use: 'json-loader',
type: 'javascript/auto'
}
]
},
Expand Down Expand Up @@ -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, '\\\\')}"`
})
)
}
Expand Down
6 changes: 6 additions & 0 deletions .electron-vue/webpack.renderer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ let rendererConfig = {
name: 'fonts/[name]--[folder].[ext]'
}
}
},
{
test: /\.json$/,
exclude: /node_modules/,
use: 'json-loader',
type: 'javascript/auto'
}
]
},
Expand Down
42 changes: 9 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
66 changes: 54 additions & 12 deletions src/config/i18n.ts
Original file line number Diff line number Diff line change
@@ -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