diff --git a/.gitignore b/.gitignore index ee2ed95e258ab9743032d4c73c8b1f8e50c6f848..548cfd7b3753f07e48f7004df68f9138fa1e5976 100644 --- a/.gitignore +++ b/.gitignore @@ -87,3 +87,5 @@ docs/_build data/ .env + +po/*.po diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94b40bed3b7ca63cd52ae3d492b19cd211fef6d6..217047794ba8c2974dd1fa69396674cd11aea726 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -68,6 +68,8 @@ build_front: script: - yarn install + - yarn run i18n-extract + - yarn run i18n-compile - yarn run build cache: key: "$CI_PROJECT_ID__front_dependencies" diff --git a/front/build/i18n.js b/front/build/i18n.js index 8739d06d2f84e5eb53cad890eba4d878aa325d81..ef31070c7d913acd8ebe769ac1a10a6faf558288 100644 --- a/front/build/i18n.js +++ b/front/build/i18n.js @@ -29,6 +29,17 @@ fs.readdir(poDir, (err, files) => { console.log(err) } else { console.log(`Wrote translation file: ${output}`) + if (lang === 'en') { + // for english, we need to specify that json values are equal to the keys. + // otherwise we end up with empty strings on the front end for english + var contents = fs.readFileSync(output) + var jsonContent = JSON.parse(contents) + var finalContent = {} + Object.keys(jsonContent).forEach(function(key) { + finalContent[key] = key + }) + fs.writeFile(output, JSON.stringify(finalContent)) + } } }) }) @@ -36,4 +47,3 @@ fs.readdir(poDir, (err, files) => { } } }) - diff --git a/front/package.json b/front/package.json index 02fffe45e6db6131f39374197176d6081056ef4c..8844e8bee53c05c4436ec6e8783ca405972162ae 100644 --- a/front/package.json +++ b/front/package.json @@ -8,7 +8,8 @@ "dev": "node build/dev-server.js", "start": "node build/dev-server.js", "build": "node build/build.js", - "i18n-extract": "find src/ -name '*.vue' | xargs vendor/vue-i18n-xgettext/index.js", + "i18n-extract": "find src/ -name '*.vue' | xargs vendor/vue-i18n-xgettext/index.js > ../po/en.po", + "i18n-compile": "node build/i18n.js", "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", "unit-watch": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js", "e2e": "node test/e2e/runner.js", diff --git a/po/.gitkeep b/po/.gitkeep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391