Class v2.Translate (6.2.7)

With [Google Translate](https://cloud.google.com/translate), you can dynamically translate text between thousands of language pairs.

The Google Cloud Translation API lets websites and programs integrate with Google Translate programmatically.

v2

[Getting Started]https://cloud.google.com/translate/v2/getting_started [Identifying your application to Google]https://cloud.google.com/translate/v2/using_rest#auth

Inheritance

Service > v2.Translate

Package

@google-cloud/translate!

Constructors

(constructor)(options)

constructor(options?: TranslateConfig);
Parameter
NameDescription
options TranslateConfig

Properties

key

key?: string;
Property Value
TypeDescription
string

options

options: TranslateConfig;
Property Value
TypeDescription
TranslateConfig

Methods

detect(input)

detect(input: string): Promise<[DetectResult, Metadata]>;
Parameter
NameDescription
input string
Returns
TypeDescription
Promise<[DetectResult, Metadata]>

detect(input)

detect(input: string[]): Promise<[DetectResult[], Metadata]>;
Parameter
NameDescription
input string[]
Returns
TypeDescription
Promise<[DetectResult[], Metadata]>

detect(input, callback)

detect(input: string, callback: DetectCallback<DetectResult>): void;
Parameters
NameDescription
input string
callback DetectCallback<DetectResult>
Returns
TypeDescription
void

detect(input, callback)

detect(input: string[], callback: DetectCallback<DetectResult[]>): void;
Parameters
NameDescription
input string[]
callback DetectCallback<DetectResult[]>
Returns
TypeDescription
void

getLanguages(target)

getLanguages(target?: string): Promise<[LanguageResult[], Metadata]>;
Parameter
NameDescription
target string
Returns
TypeDescription
Promise<[LanguageResult[], Metadata]>

getLanguages(target, callback)

getLanguages(target: string, callback: GetLanguagesCallback): void;
Parameters
NameDescription
target string
callback GetLanguagesCallback
Returns
TypeDescription
void

getLanguages(callback)

getLanguages(callback: GetLanguagesCallback): void;
Parameter
NameDescription
callback GetLanguagesCallback
Returns
TypeDescription
void

request(reqOpts, callback)

request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;

A custom request implementation. Requests to this API may optionally use an API key for an application, not a bearer token from a service account. This means it is possible to skip the makeAuthenticatedRequest portion of the typical request lifecycle, and manually authenticate the request here.

Parameters
NameDescription
reqOpts DecorateRequestOptions

Request options that are passed to request.

callback BodyResponseCallback

The callback function passed to request.

Returns
TypeDescription
void

translate(input, options)

translate(input: string, options: TranslateRequest): Promise<[string, Metadata]>;
Parameters
NameDescription
input string
options TranslateRequest
Returns
TypeDescription
Promise<[string, Metadata]>

translate(input, options)

translate(input: string[], options: TranslateRequest): Promise<[string[], Metadata]>;
Parameters
NameDescription
input string[]
options TranslateRequest
Returns
TypeDescription
Promise<[string[], Metadata]>

translate(input, to)

translate(input: string, to: string): Promise<[string, Metadata]>;
Parameters
NameDescription
input string
to string
Returns
TypeDescription
Promise<[string, Metadata]>

translate(input, to)

translate(input: string[], to: string): Promise<[string[], Metadata]>;
Parameters
NameDescription
input string[]
to string
Returns
TypeDescription
Promise<[string[], Metadata]>

translate(input, options, callback)

translate(input: string, options: TranslateRequest, callback: TranslateCallback<string>): void;
Parameters
NameDescription
input string
options TranslateRequest
callback TranslateCallback<string>
Returns
TypeDescription
void

translate(input, to, callback)

translate(input: string, to: string, callback: TranslateCallback<string>): void;
Parameters
NameDescription
input string
to string
callback TranslateCallback<string>
Returns
TypeDescription
void

translate(input, options, callback)

translate(input: string[], options: TranslateRequest, callback: TranslateCallback<string[]>): void;
Parameters
NameDescription
input string[]
options TranslateRequest
callback TranslateCallback<string[]>
Returns
TypeDescription
void

translate(input, to, callback)

translate(input: string[], to: string, callback: TranslateCallback<string[]>): void;
Parameters
NameDescription
input string[]
to string
callback TranslateCallback<string[]>
Returns
TypeDescription
void