Preserve locale in REST and AJAX requests

REST and AJAX requests do not always carry the visible page path. POM Translate handles only supported routes, methods, actions, and fields unless an integration extends the public allowlists.

REST integration

Use:

  • pom_translate_rest_route_allowlist to add a route pattern;
  • pom_translate_rest_method_allowlist to permit methods for a route;
  • pom_translate_rest_field_allowlist or pom_translate_json_field_allowlist to identify textual response fields;
  • pom_translate_should_handle_rest_request for the final request decision.

AJAX integration

Use:

  • pom_translate_ajax_action_allowlist to add a public action;
  • pom_translate_ajax_field_allowlist or pom_translate_json_field_allowlist for textual payload fields;
  • pom_translate_should_handle_ajax_request for the final decision.

Pass an explicit enabled locale using the request convention already used by the calling page. Never trust a submitted locale for authorization; validate permissions and nonces independently.

Only allowlist fields that contain public human-readable text. IDs, prices, tokens, HTML selectors, URLs, and control values must not be translated as prose.

Verify JSON shape, status codes, headers, and every allowed field in base and target locales. Translation must not alter keys, numeric values, private data, or REST mutation semantics.