Contents
On this page

Create Translation - Plugixa FAQ

POST /plugixa-faq/v1/multilingual/{entity}/{id}/translations

Copy an item into another language and link the copy to it. You then translate the copy with the normal update endpoint.

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

Note. The copy takes every column of the source as is, including status and the view and vote counters of a FAQ; its slug gets -<language> appended. Custom field values of a FAQ are not copied. language_code is not checked against the site’s languages.

Request

POST https://your-site.example/wp-json/plugixa-faq/v1/multilingual/faqs/42/translations

Path parameters

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

Request body

Content type: application/json

Field Type Required Description
language_code string Yes The language of the copy, such as fr.
{
  "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": "9b2f6c1e-4d1a-4c55-a0de-3f7f1b2c8e10"
  }
}
Field Type Meaning
data.id integer The copy’s id
data.translation_group string The group both items share. Created for the source if it had none

Errors

Status Code When
400 rest_error “Invalid entity type.”
404 rest_error No item with that id.
409 rest_error The group already has an item in that language; the message gives its id.
400 rest_missing_callback_param language_code is missing.
500 rest_error The database refused the copy.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-faq/v1/multilingual/faqs/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/plugixa-faq/v1/multilingual/faqs/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/plugixa-faq/v1/multilingual/faqs/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