v2

v2

Source:

Classes

Translate

Type Definitions

ClientConfig :object

Properties:
Name Type Attributes Default Description
projectId string <optional>

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 string <optional>

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

keyFilename string <optional>

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 string <optional>

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

credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
autoRetry boolean <optional>
true

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 number <optional>
3

Maximum number of automatic retries attempted before returning the error.

promise Constructor <optional>

Custom promise module to use instead of native Promises.

Source:

DetectCallback(errnullable, results, apiResponse)

Parameters:
Name Type Attributes Description
err Error <nullable>

Request error, if any.

results object | Array.<object>

The detection results.

Properties
Name Type Attributes Description
language string

The language code matched from the input.

confidence number <optional>

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.

Source:

DetectResult :object

Properties:
Name Type Attributes Description
0.language string

The language code matched from the input.

0.confidence number <optional>

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.

Source:

GetLanguagesCallback(errnullable, results, apiResponse)

Parameters:
Name Type Attributes Description
err Error <nullable>

Request error, if any.

results Array.<object>

The languages supported by the API.

Properties
Name Type Description
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.

Source:

LanguageResult :object

Properties:
Name Type Description
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.

Source:

TranslateCallback(errnullable, translations, apiResponse)

Parameters:
Name Type Attributes Description
err Error <nullable>

Request error, if any.

translations object | Array.<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.

Source:

TranslateRequest :object

Translate request options.

Properties:
Name Type Attributes Description
format string <optional>

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 string <optional>

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

model string <optional>

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.

Source: