Form UI translation
const url = 'https://example.com/wp-json/wp2tutor-forms/i18n/v1/translation?language=ru_RU&context=wp2tutor-form';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/translation?language=ru_RU&context=wp2tutor-form'Public gettext pack for the form UI (not the month/day locale pack and not post meta l10n). File Locale/languages/{context}-{locale}.json.
Query language is optional: otherwise Accept-Language, otherwise get_locale(). - becomes _; ru becomes ru_RU; without _ PHP appends _ + upper(language). en is always null (source strings, no file) → 404. Query context is optional, default wp2tutor-form. Prefixes @wp2tutor-form/, @tripetto/, and tripetto- are rewritten to wp2tutor-form-; after that context must match ^[a-z0-9-]+$, otherwise null/404.
Files on disk include wp2tutor-form-ru_RU.json and wp2tutor-form-runner-{autoscroll|chat|classic}-ru_RU.json. A 200 body is json_decode of the file: an array with one object ("" is catalog headers, msgid → [null, "translation"]). Missing file is HTTP 404 with body null, not a WP_Error.
Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Language code (ru, ru_RU, ru-RU). Optional. PHP falls back to Accept-Language, then get_locale(). Value en yields 404 (no translation file).
Example
ru_RUTranslation file context. PHP default is wp2tutor-form. After normalization it is the filename suffix: wp2tutor-form, wp2tutor-form-runner-autoscroll, and so on.
Example
wp2tutor-formResponses
Section titled “Responses”Gettext JSON from languages/{context}-{locale}.json (array with a msgid catalog).
Json_decode of gettext JSON (WP-CLI jed). Usually an array of one object: key "" is catalog headers (language, content-type, …); other keys are msgid, value [null, "translation"] or plural forms.
object
Example
[ { "": { "language": "ru_RU", "content-type": "text/plain; charset=UTF-8" }, "All good!": [ null, "Всё хорошо!" ] }]Translation::process returned null — missing file, language=en, invalid context, or invalid locale tag. PHP returns WP_REST_Response(null, 404), not a WP_Error.
Body is null.
Examplegenerated
example