Recognize
Max Prilutskiy·Updatedabout 2 months ago·2 min read
Detects the language of a given text and returns structured locale metadata.
Request#
POST /process/recognize
| Parameter | Type | Description |
|---|---|---|
text |
string | The text to analyze |
labelLocale |
string (optional) | Locale for the human-readable label (default: en) |
{
"text": "Bonjour le monde",
"labelLocale": "en"
}
Response#
{
"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 |
script |
string | null |
label |
string | Human-readable locale name in the requested labelLocale |
direction |
"ltr" |
"rtl" |
Examples#
Node.js
Python
PHP
Java
C#
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).