Skip to content

Latest commit

 

History

History
 
 

translate

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Google Cloud Platform logo

Google Translate API Node.js Samples

With the Google Translate API, you can dynamically translate text between thousands of language pairs.

Table of Contents

Setup

  1. Read Prerequisites and How to run a sample first.

  2. Install dependencies:

     npm install
    

Samples

Translate

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