With the Google Translate API, you can dynamically translate text between thousands of language pairs.
-
Read Prerequisites and How to run a sample first.
-
Install dependencies:
npm install
View the documentation or the source code.
Usage: node translate.js --help
Commands:
detect <input..> Detects the language of one or more strings.
list [target] Lists available translation languages. To return language names in a
language other than English, specify a target language.
translate <toLang> <input..> Translates one or more strings into the target language.
translate-with-model <toLang> <model> <input..> Translates one or more strings into the target language using the
specified model.
Options:
--help Show help [boolean]
Examples:
node translate.js detect "Hello world!" Detects the language of a string.
node translate.js detect "Hello world!" "Goodbye" Detects the languages of multiple strings.
node translate.js list Lists available translation languages with names in
English.
node translate.js list es Lists available translation languages with names in
Spanish.
node translate.js translate ru "Good morning!" Translates a string into Russian.
node translate.js translate ru "Good morning!" "Good night!" Translates multiple strings into Russian.
node translate.js translate-with-model ru nmt "Good Translates multiple strings into Russian using the
morning!" "Good night!" Premium model.
For more information, see https://cloud.google.com/translate/docs