Resolve locale
const url = 'https://example.com/wp-json/wp2tutor-forms/i18n/v1/locale?locale=ru';const options = {method: 'GET'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”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
ruResponses
Section titled “Responses”Locale pack from locales/{locale}.json (for example ru.json).
object
Pack code from the JSON file (ru in ru.json).
Locale domain in the file (ru for ru).
Text direction (ltr / rtl).
Country code, if present in the file. Empty string in ru.json.
Country name. Empty string in ru.json.
Country name in the locale language. Empty string in ru.json.
English language name (Russian in ru.json).
Language name in that language (русский in ru.json).
Runner dictionaries from the file: months (formatted/nominative × abbreviated/narrow/wide), days (+ short), time (AM/PM).
object
Patterns from the file: date, time, dateTime, numbers (decimals/grouping/minus).
object
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.
Body is null.
Examplegenerated
example