Translates input text, returning translated text.
HTTP request
POST https://translation.googleapis.com/language/translate/v2
The URL uses Google API HTTP annotation syntax.
Query parameters
Parameters | |
---|---|
q |
Required The input text to translate. Provide an array of strings to translate multiple phrases. The maximum number of strings is 128. |
target |
Required The language to use for translation of the input text, set to one of the language codes listed in Language Support. |
format |
The format of the source text, in either HTML (default) or plain-text. A
value of |
source |
The language of the source text, set to one of the language codes listed in Language Support. If the source language is not specified, the API will attempt to detect the source language automatically and return it within the response. |
model |
The translation model. Cloud Translation - Basic offers
only the If the model is |
key |
A valid API key to handle requests for this API. If you are using OAuth 2.0 service account credentials (recommended), do not supply this parameter. |
Response body
If successful, the response body contains data with the following structure:
JSON representation | |
---|---|
{
"data": {
object( |
Fields | |
---|---|
data |
The list of language translation responses. This list contains a language translation response for each query (q) sent in the language translation request. |
Authorization
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-translation
https://www.googleapis.com/auth/cloud-platform
For more information, see the Auth Guide.
TranslateTextResponseList
A response list contains a list of separate language translation responses.
JSON representation | |
---|---|
{ "translations": [ array ], } |
Fields | |
---|---|
translations[] |
Contains list of translation results of the supplied text. |
TranslateTextResponseTranslation
Contains a list of translation results for the requested text.
JSON representation | |
---|---|
{ "detectedSourceLanguage": string, "model": string, "translatedText": string, } |
Fields | |
---|---|
detectedSourceLanguage |
The source language of the initial request, detected automatically, if no source language was passed within the initial request. If the source language was passed, auto-detection of the language will not occur and this field will be omitted. |
model |
The translation model. Cloud Translation - Basic offers
only the If you did not include a |
translatedText |
Text translated into the target language. |