⚙️ Script pour générer le fichier d'externalisation
parent
eb77c12302
commit
d74f1c4f06
File diff suppressed because it is too large
Load Diff
|
@ -102,6 +102,7 @@
|
|||
},
|
||||
"scripts": {
|
||||
"start": "node source/server.js",
|
||||
"externalize": "node source/externalize.js",
|
||||
"compile": "NODE_ENV='production' webpack --config source/webpack.config.js",
|
||||
"test": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\"",
|
||||
"test-watch": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\" --watch",
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
var yaml = require('js-yaml')
|
||||
var fs = require('fs')
|
||||
|
||||
rules = yaml.safeLoad(fs.readFileSync('source/règles/base.yaml','utf-8'))
|
||||
|
||||
externalized = rules.map(
|
||||
rule => {
|
||||
let externalizeProp = (rule, prop, result) => {
|
||||
if (rule[prop]) {
|
||||
result[prop+".fr"] = result[prop+".en"] = rule[prop]
|
||||
}
|
||||
}
|
||||
|
||||
// Toujours traduire le nom via titre
|
||||
if (!rule["titre"]) rule["titre"] = rule["nom"]
|
||||
|
||||
var result = {
|
||||
"cible": rule.espace ?
|
||||
rule.espace + " . " + rule.nom :
|
||||
rule.nom
|
||||
}
|
||||
externalizeProp(rule,"titre",result)
|
||||
externalizeProp(rule,"description",result)
|
||||
externalizeProp(rule,"question",result)
|
||||
externalizeProp(rule,"sous-question",result)
|
||||
externalizeProp(rule,"alias",result)
|
||||
return result
|
||||
}
|
||||
)
|
||||
|
||||
fs.writeFileSync('externalized.yam', yaml.safeDump(externalized))
|
Loading…
Reference in New Issue