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 --help

Commands:
  detect <input..>              Detect the language of the provided text or texts
  list [target]                 List available translation languages. To return language names in a language other than
                                English, specify a target language.
  translate <toLang> <input..>  Translate the provided text or texts to the target language, optionally specifying the
                                source language.

Options:
  --apiKey, -k  Your Translate API key. Defaults to the value of the TRANSLATE_API_KEY environment variable.    [string]
  --help        Show help                                                                                      [boolean]

Examples:
  node translate detect "Hello world!"                          Detect the language of "Hello world!".
  node translate detect -k your-api-key "Hello world!"          Detect the language of "Hello world!" and "Goodbye",
  "Goodbye"                                                     supplying the API key inline..
  node translate list -k your-api-key                           List available translation languages with names in
                                                                English, supplying the API key inline..
  node translate list es                                        List available translation languages with names in
                                                                Spanish.
  node translate translate ru "Good morning!"                   Translate "Good morning!" to Russian, auto-detecting the
                                                                source language.
  node translate translate ru "Good morning!" -f en -k          Translate "Good morning!" to Russian from English,
  your-api-key                                                  supplying the API key inline.

For more information, see https://cloud.google.com/translate/docs