Detects the language of a given text and returns structured locale metadata.
Request#
text
POST /process/recognize| Parameter | Type | Description |
|---|---|---|
text | string | The text to analyze |
labelLocale | string (optional) | Locale for the human-readable label (default: en) |
json
{
"text": "Bonjour le monde",
"labelLocale": "en"
}Response#
json
{
"locale": "fr",
"language": "fr",
"region": null,
"script": null,
"label": "French",
"direction": "ltr"
}| Field | Type | Description |
|---|---|---|
locale | string | BCP-47 locale code at the most specific level of confidence |
language | string | ISO 639 language subtag |
region | string | null | ISO 3166 region subtag, or null if indistinguishable |
script | string | null | ISO 15924 script subtag, or null if default for the language |
label | string | Human-readable locale name in the requested labelLocale |
direction | "ltr" | "rtl" | Text direction |
Examples#
javascript
const response = await fetch(
"https://api.lingo.dev/process/recognize",
{
method: "POST",
headers: {
"X-API-Key": "your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
text: "Bonjour le monde",
labelLocale: "en",
}),
}
);
const result = await response.json();
// { locale: "fr", language: "fr", label: "French", direction: "ltr", ... }When regional markers are present in the text (e.g., Brazilian Portuguese vocabulary), the response includes the full tag (pt-BR). When the regional variant is indistinguishable, only the language subtag is returned (pt).
