Compile and bundle translations in CI

merge-requests/154/head
Eliot Berriot 2018-04-16 22:54:36 +02:00
rodzic fd6ab881a7
commit 35dda16adb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
5 zmienionych plików z 17 dodań i 2 usunięć

2
.gitignore vendored
Wyświetl plik

@ -87,3 +87,5 @@ docs/_build
data/
.env
po/*.po

Wyświetl plik

@ -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"

Wyświetl plik

@ -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) => {
}
}
})

Wyświetl plik

@ -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",

0
po/.gitkeep 100644
Wyświetl plik