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

Updated prints to console

parent 7c16fe5a
...@@ -7,11 +7,8 @@ const Inquirer = require('inquirer') ...@@ -7,11 +7,8 @@ const Inquirer = require('inquirer')
const Program = require('commander') const Program = require('commander')
const Language = require('langs') const Language = require('langs')
const pkg = require('./package.json') const pkg = require('./package.json')
const NodeHun = require('nodehun') const NodeHun = require('nodehun')
const NodeHunSentences = require('nodehun-sentences') const NodeHunSentences = require('nodehun-sentences')
const nspell = require('nspell')
const { exec } = require('child_process') const { exec } = require('child_process')
const parser = util.promisify(PO.load) const parser = util.promisify(PO.load)
...@@ -32,7 +29,7 @@ const printLoading = string => { ...@@ -32,7 +29,7 @@ const printLoading = string => {
} }
const stopPrinting = () => clearInterval(currentPrint) const stopPrinting = () => clearInterval(currentPrint)
const checkSpelling = async (dictionary, translation) => { async function checkSpelling(dictionary, translation){
if(dictionary === null) if(dictionary === null)
return [translation] return [translation]
...@@ -45,7 +42,6 @@ const checkSpelling = async (dictionary, translation) => { ...@@ -45,7 +42,6 @@ const checkSpelling = async (dictionary, translation) => {
return [...options] return [...options]
} }
async function installDict(language){ async function installDict(language){
clear() clear()
...@@ -89,12 +85,18 @@ async function listInstalledDict(){ ...@@ -89,12 +85,18 @@ async function listInstalledDict(){
stopPrinting() stopPrinting()
clear() clear()
println(Chalk.green.bold.underline(`Installed dictionaries`)) if(packages.length === 0) {
println(Chalk.keyword('orange').bold.underline('You have not installed any dictionary yet'))
println()
return
}
println(Chalk.green.bold.underline(`Installed dictionaries`))
for(package of packages){ for(package of packages){
let lang = Language.where("1", package.split('-')[1]) let lang = Language.where("1", package.split('-')[1])
println(Chalk.green.bold(` * ${lang.name}: ${package}`)) println(Chalk.green.bold(` * ${lang.name}: ${package}`))
} }
println()
} }
async function uninstallDict(language){ async function uninstallDict(language){
clear() clear()
...@@ -242,28 +244,19 @@ async function translateFile(file, options) { ...@@ -242,28 +244,19 @@ async function translateFile(file, options) {
} }
Program.version(`${pkg.name} v${pkg.version}`, '-v, --version') Program.version(`${pkg.name} v${pkg.version}`, '-v, --version')
Program.command('install <language>') Program.command('install <language>')
.alias('i')
.description("Install a new dictionary for spell check support") .description("Install a new dictionary for spell check support")
.action(installDict) .action(installDict)
Program.command('uninstall <language>') Program.command('uninstall <language>')
.alias('u')
.description("Uninstall an installed dictionary") .description("Uninstall an installed dictionary")
.action(uninstallDict) .action(uninstallDict)
Program.command('list') Program.command('list')
.alias('l')
.description("List all installed dictionaries") .description("List all installed dictionaries")
.action(listInstalledDict) .action(listInstalledDict)
Program.command('translate <file>') Program.command('translate <file>')
.alias('t')
.description("Translate a gettext file") .description("Translate a gettext file")
.option('-o, --output [destination]', 'Output path for the translations file. If not specified, the program will overwrite the input file.') .option('-o, --output [destination]', 'Output path for the translations file. If not specified, the program will overwrite the input file.')
.action(translateFile) .action(translateFile)
Program.parse(process.argv) Program.parse(process.argv)
if (process.argv.length === 2 || !["install", "uninstall", "list", "translate", "i", "u", "l", "t"].includes(process.argv[2]) ) { if (process.argv.length === 2 || !["install", "uninstall", "list", "translate", "i", "u", "l", "t"].includes(process.argv[2]) ) {
......
{ {
"name": "translator", "name": "POTrans",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true,
"dependencies": { "dependencies": {
"ansi-escapes": { "ansi-escapes": {
"version": "3.0.0", "version": "3.0.0",
...@@ -17,10 +16,7 @@ ...@@ -17,10 +16,7 @@
"ansi-styles": { "ansi-styles": {
"version": "3.2.0", "version": "3.2.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
"integrity": "sha1-wVm41b4PnlpvNG2rlPFs4CIWG4g=", "integrity": "sha1-wVm41b4PnlpvNG2rlPFs4CIWG4g="
"requires": {
"color-convert": "1.9.1"
}
}, },
"array-unique": { "array-unique": {
"version": "0.1.1", "version": "0.1.1",
...@@ -30,20 +26,12 @@ ...@@ -30,20 +26,12 @@
"async": { "async": {
"version": "2.6.0", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz",
"integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw=="
"requires": {
"lodash": "4.17.5"
}
}, },
"chalk": { "chalk": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q=="
"requires": {
"ansi-styles": "3.2.0",
"escape-string-regexp": "1.0.5",
"supports-color": "4.5.0"
}
}, },
"chardet": { "chardet": {
"version": "0.4.2", "version": "0.4.2",
...@@ -53,10 +41,7 @@ ...@@ -53,10 +41,7 @@
"cli-cursor": { "cli-cursor": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz",
"integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU="
"requires": {
"restore-cursor": "2.0.0"
}
}, },
"cli-width": { "cli-width": {
"version": "2.2.0", "version": "2.2.0",
...@@ -66,10 +51,7 @@ ...@@ -66,10 +51,7 @@
"color-convert": { "color-convert": {
"version": "1.9.1", "version": "1.9.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
"integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0=", "integrity": "sha1-wSYRB66y8pTr/+ye2eytUppgl+0="
"requires": {
"color-name": "1.1.3"
}
}, },
"color-name": { "color-name": {
"version": "1.1.3", "version": "1.1.3",
...@@ -81,11 +63,6 @@ ...@@ -81,11 +63,6 @@
"resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz", "resolved": "https://registry.npmjs.org/commander/-/commander-2.14.1.tgz",
"integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw==" "integrity": "sha512-+YR16o3rK53SmWHU3rEM3tPAh2rwb1yPcQX5irVn7mb0gXbwuCCrnkbV5+PBfETdfg1vui07nM6PCG1zndcjQw=="
}, },
"dictionary-es": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/dictionary-es/-/dictionary-es-1.2.1.tgz",
"integrity": "sha1-Y+vJd+wLytzA2Hs1avCwX3Vb3XM="
},
"escape-string-regexp": { "escape-string-regexp": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
...@@ -94,20 +71,12 @@ ...@@ -94,20 +71,12 @@
"external-editor": { "external-editor": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz",
"integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA=="
"requires": {
"chardet": "0.4.2",
"iconv-lite": "0.4.19",
"tmp": "0.0.33"
}
}, },
"figures": { "figures": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI="
"requires": {
"escape-string-regexp": "1.0.5"
}
}, },
"has-flag": { "has-flag": {
"version": "2.0.0", "version": "2.0.0",
...@@ -127,27 +96,7 @@ ...@@ -127,27 +96,7 @@
"inquirer": { "inquirer": {
"version": "5.1.0", "version": "5.1.0",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.1.0.tgz", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-5.1.0.tgz",
"integrity": "sha512-kn7N70US1MSZHZHSGJLiZ7iCwwncc7b0gc68YtlX29OjI3Mp0tSVV+snVXpZ1G+ONS3Ac9zd1m6hve2ibLDYfA==", "integrity": "sha512-kn7N70US1MSZHZHSGJLiZ7iCwwncc7b0gc68YtlX29OjI3Mp0tSVV+snVXpZ1G+ONS3Ac9zd1m6hve2ibLDYfA=="
"requires": {
"ansi-escapes": "3.0.0",
"chalk": "2.3.0",
"cli-cursor": "2.1.0",
"cli-width": "2.2.0",
"external-editor": "2.1.0",
"figures": "2.0.0",
"lodash": "4.17.5",
"mute-stream": "0.0.7",
"run-async": "2.3.0",
"rxjs": "5.5.6",
"string-width": "2.1.1",
"strip-ansi": "4.0.0",
"through": "2.3.8"
}
},
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
}, },
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "2.0.0", "version": "2.0.0",
...@@ -187,30 +136,12 @@ ...@@ -187,30 +136,12 @@
"nodehun-sentences": { "nodehun-sentences": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/nodehun-sentences/-/nodehun-sentences-1.0.4.tgz", "resolved": "https://registry.npmjs.org/nodehun-sentences/-/nodehun-sentences-1.0.4.tgz",
"integrity": "sha1-pK7y13B9fVaBM4BulXpqSrnrkQY=", "integrity": "sha1-pK7y13B9fVaBM4BulXpqSrnrkQY="
"requires": {
"async": "2.6.0",
"in-publish": "2.0.0",
"partial": "0.0.3",
"unique-words": "1.0.0"
}
},
"nspell": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/nspell/-/nspell-1.0.5.tgz",
"integrity": "sha512-mZXwP4r/xaIMISh95eyak1JMTTgB8NeYPMRTFJTf5lkgAxcJzVGSLCzsibvNXR8GEBFtWqmO4hoz17YIpu6mSg==",
"requires": {
"is-buffer": "1.1.6",
"trim": "0.0.1"
}
}, },
"onetime": { "onetime": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz",
"integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ="
"requires": {
"mimic-fn": "1.2.0"
}
}, },
"os-tmpdir": { "os-tmpdir": {
"version": "1.0.2", "version": "1.0.2",
...@@ -230,27 +161,17 @@ ...@@ -230,27 +161,17 @@
"restore-cursor": { "restore-cursor": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",
"integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368="
"requires": {
"onetime": "2.0.1",
"signal-exit": "3.0.2"
}
}, },
"run-async": { "run-async": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz",
"integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA="
"requires": {
"is-promise": "2.1.0"
}
}, },
"rxjs": { "rxjs": {
"version": "5.5.6", "version": "5.5.6",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.6.tgz",
"integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg==", "integrity": "sha512-v4Q5HDC0FHAQ7zcBX7T2IL6O5ltl1a2GX4ENjPXg6SjDY69Cmx9v4113C99a4wGF16ClPv5Z8mghuYorVkg/kg=="
"requires": {
"symbol-observable": "1.0.1"
}
}, },
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
...@@ -260,27 +181,17 @@ ...@@ -260,27 +181,17 @@
"string-width": { "string-width": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw=="
"requires": {
"is-fullwidth-code-point": "2.0.0",
"strip-ansi": "4.0.0"
}
}, },
"strip-ansi": { "strip-ansi": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8="
"requires": {
"ansi-regex": "3.0.0"
}
}, },
"supports-color": { "supports-color": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz",
"integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s="
"requires": {
"has-flag": "2.0.0"
}
}, },
"symbol-observable": { "symbol-observable": {
"version": "1.0.1", "version": "1.0.1",
...@@ -295,23 +206,12 @@ ...@@ -295,23 +206,12 @@
"tmp": { "tmp": {
"version": "0.0.33", "version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
"integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw=="
"requires": {
"os-tmpdir": "1.0.2"
}
},
"trim": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz",
"integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0="
}, },
"unique-words": { "unique-words": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/unique-words/-/unique-words-1.0.0.tgz", "resolved": "https://registry.npmjs.org/unique-words/-/unique-words-1.0.0.tgz",
"integrity": "sha1-QLJqGfmAYWY8gTzZehogp/i1WZA=", "integrity": "sha1-QLJqGfmAYWY8gTzZehogp/i1WZA="
"requires": {
"array-unique": "0.1.1"
}
} }
} }
} }
{ {
"name": "POTrans", "name": "@morrisgallego/potrans",
"version": "1.0.0", "version": "1.0.0",
"description": "CLI tool to translate PO files easily", "description": "CLI tool to translate PO files easily",
"keywords": ["translate", "translator", "translation", "localization", "i18n", "gettext", "po", "pot"], "keywords": [
"translate",
"translator",
"translation",
"localization",
"i18n",
"gettext",
"po",
"pot"
],
"homepage": "potrans.vjgallego.me", "homepage": "potrans.vjgallego.me",
"author": { "author": {
"name": "Víctor José Gallego Fontenla", "name": "Víctor José Gallego Fontenla",
......
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