The Cloud Translation API, can dynamically translate text between thousands of language pairs. The Cloud Translation API lets websites and programs integrate with the translation service programmatically. The Cloud Translation API is part of the larger Cloud Machine Learning API family.
-
Read Prerequisites and How to run a sample first.
-
Install dependencies:
With npm:
npm install
With yarn:
yarn install
View the documentation or the source code.
Usage: node translate.js --help
Commands:
detect <text..> Detects the language of one or more strings.
list [target] Lists available translation languages. To language names in a language
other than English, specify a target language.
translate <toLang> <text..> Translates one or more strings into the target language.
translate-with-model <toLang> <model> <text..> 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
-
Set the GCLOUD_PROJECT and GOOGLE_APPLICATION_CREDENTIALS environment variables.
-
Run the tests:
With npm:
npm test
With yarn:
yarn test