Commit 3be7d689 authored by Ana Gelez's avatar Ana Gelez

Make translation compilation actually work

parent e7b06ab5
......@@ -75,6 +75,7 @@ api/static
api/.pytest_cache
# Front
front/static/translations
front/node_modules/
front/dist/
front/npm-debug.log*
......
......@@ -13,6 +13,7 @@ services:
- "${WEBPACK_DEVSERVER_PORT-8080}:${WEBPACK_DEVSERVER_PORT-8080}"
volumes:
- './front:/app'
- './po:/po'
postgres:
env_file:
......
......@@ -14,6 +14,8 @@ var webpackConfig = process.env.NODE_ENV === 'testing'
? require('./webpack.prod.conf')
: require('./webpack.dev.conf')
require('./i18n')
// default port where dev server listens for incoming traffic
var port = process.env.PORT || config.dev.port
var host = process.env.HOST || config.dev.host
......
......@@ -2,8 +2,14 @@ const fs = require('fs');
const path = require('path');
const { gettextToI18next } = require('i18next-conv');
const poDir = path.join(__dirname, '..', '..', 'po')
const outDir = path.join(__dirname, '..', 'static', 'translations')
if (!fs.existsSync(outDir) || !fs.statSync(outDir).isDirectory()) {
fs.mkdirSync(outDir)
}
// Convert .po files to i18next files
fs.readdir(path.join(__dirname, '..', '..', 'po'), (err, files) => {
fs.readdir(poDir, (err, files) => {
if (err) {
return console.log(err)
}
......@@ -11,8 +17,8 @@ fs.readdir(path.join(__dirname, '..', '..', 'po'), (err, files) => {
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) => {
const output = path.join(outDir, `${lang}.json`)
fs.readFile(path.join(poDir, file), (err, content) => {
if (err) {
return console.log(err)
}
......@@ -21,6 +27,8 @@ fs.readdir(path.join(__dirname, '..', '..', 'po'), (err, files) => {
fs.writeFile(output, res, err => {
if (err) {
console.log(err)
} else {
console.log(`Wrote translation file: ${output}`)
}
})
})
......
......@@ -18,6 +18,7 @@
"axios": "^0.17.1",
"dateformat": "^2.0.0",
"django-channels": "^1.1.6",
"i18next-conv": "^6.0.0",
"js-logger": "^1.3.0",
"jwt-decode": "^2.2.0",
"lodash": "^4.17.4",
......@@ -70,7 +71,6 @@
"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",
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment