Method: projects.locations.detectLanguage

Detects the language of text within a request.

HTTP request

POST https://translation.googleapis.com/v3beta1/{parent=projects/*/locations/*}:detectLanguage

The URL uses gRPC Transcoding syntax.

Path parameters

Parameters
parent

string

Required. Location to make a regional or global call.

Format: projects/{project-id}/locations/{location-id}.

For global calls, use projects/{project-id}/locations/global.

Only models within the same location-id can be used. Otherwise 400 is returned.

Request body

The request body contains data with the following structure:

JSON representation
{
  "model": string,
  "mimeType": string,
  "content": string
}
Fields
model

string

Optional. The language detection model to be used.

Format: projects/{project-id}/locations/{location-id}/models/language-detection/{model-id}

Only one language detection model is currently supported: projects/{project-id}/locations/{location-id}/models/language-detection/default.

If not specified, the default model will be used.

Authorization requires the following Google IAM permission on the specified resource model:

  • cloudtranslate.languageDetectionModels.predict

mimeType

string

Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type is assumed to be "text/html".

content

string

The content of the input stored as a string.

Response body

If successful, the response body contains data with the following structure:

The response message for language detection.

JSON representation
{
  "languages": [
    {
      object (DetectedLanguage)
    }
  ]
}
Fields
languages[]

object (DetectedLanguage)

A list of detected languages sorted by detection confidence in descending order. The most probable language first.

Authorization Scopes

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 Authentication Overview.

DetectedLanguage

The response message for language detection.

JSON representation
{
  "languageCode": string,
  "confidence": number
}
Fields
languageCode

string

The BCP-47 language code of source content in the request, detected automatically.

confidence

number

The confidence of the detection result for this language.

Var denne side nyttig? Giv os en anmeldelse af den:

Send feedback om...

Cloud Translation
Har du brug for hjælp? Besøg vores supportside.