Contents
On this page

Create Translation - Plugixa Testimonial

POST /plugixatestimonial/v1/multilingual/{entity}/{id}/translations

Copy an item into another language, as the starting point of its translation.

Any signed-in user with the plugixa_testimonial_edit capability or WordPress’s edit_posts (Contributors and up, by default).

Note. The copy keeps the source’s text and every other value, status included: the copy of an approved testimonial is approved and shown at once, in the source language until you translate it. A testimonial’s categories and custom field values are copied too. These routes work whether or not WPML or Polylang is active.

Request

POST https://your-site.example/wp-json/plugixatestimonial/v1/multilingual/testimonials/42/translations

Path parameters

Name Type Description
entity string testimonials, categories or custom-fields
id integer The item to copy

Request body

Content type: application/json

Field Type Required Description
language_code string Yes The target language. Not checked against the site languages.

A category’s copy gets the slug {slug}-{language}, made unique when needed. Then edit the copy with the usual update route, such as Update Testimonial.

{
  "language_code": "fr"
}

Responses

200 OK. data.id is the copy.

{
  "success": true,
  "message": "Translation created successfully.",
  "data": {
    "id": 58,
    "language_code": "fr",
    "translation_group": "3f6c1a52-9d2e-4b7a-8c51-0e4f2d9b7a16"
  }
}
Field Type Meaning
data.id integer The copy’s id
data.language_code string Its language
data.translation_group string The group both now share
message string A human-readable confirmation, translated to the site language

Errors

Status Code When
400 rest_error “Invalid entity type.”
404 rest_error “Source item not found.”
409 rest_error A translation in that language already exists; the message names its id.
400 rest_missing_callback_param language_code is missing.
500 rest_error The database refused the insert.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixatestimonial/v1/multilingual/testimonials/42/translations" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"language_code":"fr"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixatestimonial/v1/multilingual/testimonials/42/translations');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'language_code' => 'fr',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixatestimonial/v1/multilingual/testimonials/42/translations', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ language_code: 'fr' }),
});
const { data } = await response.json();

Quick Links

Share