i18n: .po compilation
This commit is contained in:
parent
69a3f34784
commit
e7b06ab509
6 changed files with 60 additions and 0 deletions
31
front/build/i18n.js
Normal file
31
front/build/i18n.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { gettextToI18next } = require('i18next-conv');
|
||||
|
||||
// Convert .po files to i18next files
|
||||
fs.readdir(path.join(__dirname, '..', '..', 'po'), (err, files) => {
|
||||
if (err) {
|
||||
return console.log(err)
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
if (file.endsWith('.po')) {
|
||||
const lang = file.replace(/\.po$/, '')
|
||||
const output = path.join(__dirname, '..', 'static', 'translations', `${lang}.json`)
|
||||
fs.readFile(path.join(__dirname, '..', '..', 'po', file), (err, content) => {
|
||||
if (err) {
|
||||
return console.log(err)
|
||||
}
|
||||
|
||||
gettextToI18next(lang, content).then(res => {
|
||||
fs.writeFile(output, res, err => {
|
||||
if (err) {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -70,6 +70,7 @@
|
|||
"friendly-errors-webpack-plugin": "^1.1.3",
|
||||
"html-webpack-plugin": "^2.28.0",
|
||||
"http-proxy-middleware": "^0.17.3",
|
||||
"i18next-conv": "^6.0.0",
|
||||
"inject-loader": "^3.0.0",
|
||||
"karma": "^1.4.1",
|
||||
"karma-coverage": "^1.1.1",
|
||||
|
|
|
|||
1
front/static/translations/en.json
Normal file
1
front/static/translations/en.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
1
front/static/translations/fr.json
Normal file
1
front/static/translations/fr.json
Normal file
|
|
@ -0,0 +1 @@
|
|||
{}
|
||||
Loading…
Add table
Add a link
Reference in a new issue