Globals

Abstract types

ClientConfig

object

Properties

Parameter

projectId

Optional

string

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

key

Optional

string

An API key. You should prefer using a Service Account key file instead of an API key.

keyFilename

Optional

string

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option above is not necessary. NOTE: .pem and .p12 require you to specify the email option as well.

email

Optional

string

Account email address. Required when using a .pem or .p12 keyFilename.

credentials

Optional

object

Credentials object.

Values in credentials have the following properties:

Parameter

client_email

Optional

string

private_key

Optional

string

autoRetry

Optional

boolean

Automatically retry requests if the response is related to rate limits or certain intermittent server errors. We will exponentially backoff subsequent requests by default.

maxRetries

Optional

number

Maximum number of automatic retries attempted before returning the error.

promise

Optional

Constructor

Custom promise module to use instead of native Promises.

DetectCallback

DetectCallback(err, results, apiResponse)

Parameter

err

Error

Request error, if any.

Value may be null.

results

(object or Array of object)

The detection results.

Values in results have the following properties:

Parameter

language

string

The language code matched from the input.

confidence

Optional

number

A float 0 - 1. The higher the number, the higher the confidence in language detection. Note, this is not always returned from the API.

apiResponse

object

The full API response.

DetectResponse

array

Properties

Parameter

0

(object or Array of object)

The detection results.

Values in 0 have the following properties:

Parameter

language

string

The language code matched from the input.

confidence

Optional

number

A float 0 - 1. The higher the number, the higher the confidence in language detection. Note, this is not always returned from the API.

1

object

The full API response.

GetLanguagesCallback

GetLanguagesCallback(err, results, apiResponse)

Parameter

err

Error

Request error, if any.

Value may be null.

results

Array of object

The languages supported by the API.

Values in results have the following properties:

Parameter

code

string

The ISO 639-1 language code.

name

string

The language name. This can be translated into your preferred language with the target option.

apiResponse

object

The full API response.

GetLanguagesResponse

array

Properties

Parameter

0

Array of object

The languages supported by the API.

Values in 0 have the following properties:

Parameter

code

string

The ISO 639-1 language code.

name

string

The language name. This can be translated into your preferred language with the target option.

1

object

The full API response.

TranslateCallback

TranslateCallback(err, translations, apiResponse)

Parameter

err

Error

Request error, if any.

Value may be null.

translations

(object or Array of object)

If a single string input was given, a single translation is given. Otherwise, it is an array of translations.

apiResponse

object

The full API response.

TranslateRequest

object

Translate request options.

Properties

Parameter

format

Optional

string

Set the text's format as html or text. If not provided, we will try to auto-detect if the text given is HTML. If not, we set the format as text.

from

Optional

string

The ISO 639-1 language code the source input is written in.

model

Optional

string

Set the model type requested for this translation. Please refer to the upstream documentation for possible values.

to

string

The ISO 639-1 language code to translate the input to.

TranslateResponse

array

Properties

Parameter

0

(object or Array of object)

If a single string input was given, a single translation is given. Otherwise, it is an array of translations.

1

object

The full API response.