linguist
v0.2.1
Published
Translate strings or whole JSON files
Downloads
128
Readme
linguist
Translate strings or JSON (e.g. internationalisation resource files) from Node.js or the command line.
Command line
Install
$ npm install -g linguist
Usage
$ translate [--from <string>] [--to <string>] <text> <text> ...
$ translate [--from <string>] [--to <string>] --input <filename> --output <filename>
-f, --from The language to translate from (default: 'en')
-t, --to The language to translate to (default: 'en')
-i, --input A valid JSON file to translate
-o, --output The output JSON file with input JSON values (but not keys) translated
-h, --help Print usage instructions
translate text at the command line
$ translate --from en --to it "hello, how are you" "this is a nice cat"
ciao, come stai
questo è un bel gatto
$ translate "I would like the rabbit please" -t cs
Já bych králíka prosím
translate the values in a json file
An input file like this:
{
"content": {
"Terms": "Terms and Conditions",
"More": {
"Account": "Some Account",
"Products": {
"One": "Some Product"
}
}
}
}
...and this command:
$ translate --input input.json --output output.json --from en --to it
...would produce this output file:
{
"content": {
"Terms": "Termini e Condizioni",
"More": {
"Account": "Alcuni Account",
"Products": {
"One": "Alcune Prodotto"
}
}
}
}
Library
Install
$ npm install linguist --save
Usage
var linguist = require("linguist");
linguist.translate("hello, how are you", "en", "it", function(translation){
console.log(translation);
});
Supported Languages
© 2014-21 Lloyd Brookes <[email protected]>.
Tested by test-runner.