-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
26 lines (21 loc) · 856 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const core = require("./lib/core.js");
var fs = require('fs');
// write response back to the translation file
var cliArgs = process.argv.slice(2);
const translationFile = cliArgs[0];
const targetLang = cliArgs[1];
console.log("Going to convert "+ translationFile +" into "+ targetLang);
core.tempRequest.TargetLanguageCode = targetLang;
fs.readFile(translationFile, (err, data) => {
if (err) throw err;
translations = JSON.parse(data);
const sourceTranslations = core.getSourceTranslation(translations);
core.parseTranslation(sourceTranslations).then(function(){
console.log("Done the translations - updating the file "+ translationFile);
let strTranslations = JSON.stringify(translations, null, 2);
fs.writeFile(translationFile, strTranslations, (err) => {
if (err) throw err;
console.log('Translations updated');
});
});
});