Skip to content

Resolve locale

GET
/wp-json/wp2tutor-forms/i18n/v1/locale
curl --request GET \
--url 'https://example.com/wp-json/wp2tutor-forms/i18n/v1/locale?locale=ru'

Publicly (permission_callback = true) selects the runner locale pack from Locale/locales/{locale}.json. This is not the form UI translation (/translation) and not the post meta l10n. Query locale is optional. If omitted, PHP uses the Accept-Language header, otherwise get_locale(). The value is trimmed after ; and , (Accept-Language), and _ is replaced with -. PHP looks up the locale file, then the prefix before -; if missing, it falls back to en.json. No file (including no en.json) is HTTP 404 with body null, not a WP_Error. A 200 body is the JSON file: locale code, text direction, language/country names, month/day dictionaries, and date/number formats.

locale
string

Requested locale tag (ru, ru_RU, ru-RU). Optional. PHP falls back to Accept-Language, then get_locale(). From Accept-Language it takes the first tag (before ; and ,).

Example
ru

Locale pack from locales/{locale}.json (for example ru.json).

Media typeapplication/json
object
locale

Pack code from the JSON file (ru in ru.json).

string
domain

Locale domain in the file (ru for ru).

string
direction

Text direction (ltr / rtl).

string
countryCode

Country code, if present in the file. Empty string in ru.json.

string
country

Country name. Empty string in ru.json.

string
countryNative

Country name in the locale language. Empty string in ru.json.

string
language

English language name (Russian in ru.json).

string
languageNative

Language name in that language (русский in ru.json).

string
translations

Runner dictionaries from the file: months (formatted/nominative × abbreviated/narrow/wide), days (+ short), time (AM/PM).

object
key
additional properties
any
formats

Patterns from the file: date, time, dateTime, numbers (decimals/grouping/minus).

object
key
additional properties
any
Example
{
"locale": "ru",
"domain": "ru",
"direction": "ltr",
"countryCode": "",
"country": "",
"countryNative": "",
"language": "Russian",
"languageNative": "русский",
"translations": {
"time": {
"AM": "AM",
"PM": "PM"
}
},
"formats": {
"numbers": {
"decimals": ",",
"grouping": " ",
"minus": "-"
}
}
}

Locale::process returned null — no locales/{locale}.json and no fallback en.json. PHP returns WP_REST_Response(null, 404), not a WP_Error.

Media typeapplication/json

Body is null.

nullable
Examplegenerated
example