Commit 39225422 authored by Víctor Gallego Fontenla's avatar Víctor Gallego Fontenla 🏉

Initial commit

parents
const PO = require('pofile')
const util = require('util')
const input = require('readline-sync')
const parser = util.promisify(PO.load)
async function processFile(file) {
const content = await parser(file)
const strings = content.items
for(item of strings){
if(item.msgstr[0].trim() === ""){
process.stdout.write('\033c')
console.log(`Translating file ${file}`)
console.log()
console.log('***************************************************************')
console.log(`- Message ID * ${item.msgid}`)
console.log(`- Context * ${item.msgctxt}`)
console.log('***************************************************************')
console.log()
const translation = input.question("Translation: ")
item.msgstr[0] = translation
process.stdout.write('\033c')
console.log("Continue translation?")
console.log()
console.log("If you want to save now, write 'save' or 's'.")
console.log("If you want to continue translating without saving write 'next' or 'n'")
console.log("If you want to save and exit write 'quit' or 'q'")
console.log("If you want to exit without saving write 'discard' or 'd'")
console.log()
const option = input.question("What do you want to do? ")
switch(option[0]){
case 's':
content.save(`${file}`)
break
case 'q':
content.save(`${file}`)
return
case 'd':
return
}
}
}
console.log("All translations done!")
console.log()
let option2
while(option2 !== 'q' && option2 !== 'd'){
console.log("If you want to save and exit write 'quit' or 'q'")
console.log("If you want to exit without saving write 'discard' or 'd'")
console.log()
option2 = input.question("What do you want to do? ")
switch(option2[0]){
case 'q':
content.save(`${file}`)
return
case 'd':
return
default:
console.log("Unrecognized option")
}
}
}
processFile(process.argv[2])
{
"name": "translator",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"any-promise": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz",
"integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8="
},
"hunspell-spellcheck": {
"version": "0.0.4",
"resolved": "https://registry.npmjs.org/hunspell-spellcheck/-/hunspell-spellcheck-0.0.4.tgz",
"integrity": "sha1-y9CS4h+gAs9MhuBIKwTBcyrBwes="
},
"nan": {
"version": "2.8.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz",
"integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo="
},
"pofile": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/pofile/-/pofile-1.0.10.tgz",
"integrity": "sha1-UD3alJlAOYToP/RIm6LYCvJ2Fyo="
},
"readline-sync": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/readline-sync/-/readline-sync-1.4.8.tgz",
"integrity": "sha1-Ljspb6ZKNbKwEadU5GojXUaYXeg="
},
"request": {
"version": "2.9.152",
"resolved": "https://registry.npmjs.org/request/-/request-2.9.152.tgz",
"integrity": "sha1-EAz/zZoBJVb+3MkW5kepzR4rv0M="
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"spellchecker": {
"version": "3.4.4",
"resolved": "https://registry.npmjs.org/spellchecker/-/spellchecker-3.4.4.tgz",
"integrity": "sha512-l0s86YZs5+PzATeFbqD0sTSMEF7bgzqUYgxrU8+nBSw3V19tzRYKMi+hDGG6v8MskWeG2dRK0Q79sqs1eGIKwQ==",
"requires": {
"any-promise": "1.3.0",
"nan": "2.8.0"
}
},
"teacher": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/teacher/-/teacher-0.1.0.tgz",
"integrity": "sha1-t2IRIj57VO1BI008c27bjEmxzB4=",
"requires": {
"request": "2.9.152",
"xml2js": "0.1.13"
}
},
"typo-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/typo-js/-/typo-js-1.0.3.tgz",
"integrity": "sha1-VNjrx5SfGngQkItgAsaEFSbJnVo="
},
"xml2js": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.1.13.tgz",
"integrity": "sha1-Q4/zsdhaUa1ln/wuvoNAPhDJhyI=",
"requires": {
"sax": "1.2.4"
}
}
}
}
{
"name": "translator",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"hunspell-spellcheck": "0.0.4",
"pofile": "^1.0.10",
"readline-sync": "^1.4.8",
"spellchecker": "^3.4.4",
"teacher": "^0.1.0",
"typo-js": "^1.0.3"
}
}
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