# Translations

The `Translations` API provides endpoints for translating plain text or entity fields into any supported language. These endpoints are typically used to automate or assist with content localization throughout the application.

## Translate Text

Translate an array of text strings into a target language.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/translations/translate-text`

**Request Keys**

| Key                 | Type    | Default | Description                                                    |
| ------------------- | ------- | ------- | -------------------------------------------------------------- |
| `target_lang_id` \* | string  | -       | The ID of the target [Language](/api-reference/languages.md).  |
| `text` \*           | array   | -       | Array of strings to translate (up to 50 per request).          |
| `is_html`           | boolean | `false` | If `true`, the text is treated as HTML and tags are preserved. |

Keys with `*` are required.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/translations/translate-text', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'target_lang_id' => 'fr-FR',
        'text' => [
            'Hello world!',
            'This is a test.',
            '<strong>Bold text</strong>'
        ],
        'is_html' => true
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "text": [
      "Bonjour à tous !",
      "Il s'agit d'un test.",
      "<strong>Texte en gras</strong>"
    ]
  }
}
```

## Translate Entities

Translate fields of one or more entities into a target language.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/translations/translate-entities`

**Request Keys**

| Key                                    | Type    | Default    | Description                                                                       |
| -------------------------------------- | ------- | ---------- | --------------------------------------------------------------------------------- |
| `target_lang_id` \*                    | string  | -          | The ID of the target [Language](/api-reference/languages.md).                     |
| `translatables` \*                     | array   | -          | Array of objects describing the entities and fields to translate.                 |
| `translatables.*.translatable_type` \* | string  | -          | The entity type (e.g. `infoboardPost`).                                           |
| `translatables.*.translatable_id` \*   | integer | -          | The ID of the entity to translate.                                                |
| `translatables.*.translatable_fields`  | array   | All fields | Array of field names to translate (if omitted, all translatable fields are used). |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/translations/translate-entities', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'target_lang_id' => 'es-ES',
        'translatables' => [
            [
                'translatable_type' => 'infoboardPost',
                'translatable_id' => 10
            ]
        ]
    ]
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": [
    {
      "id": 1,
      "user_id": 2,
      "lang_id": "es-ES",
      "translatable_type": "infoboardPost",
      "translatable_id": 10,
      "translatable_field": "title",
      "translatable_field_value": "¡Por fin abierto de nuevo!",
      "created_at": "2025-05-15 12:00:00",
      "updated_at": "2025-05-15 12:00:00",
      "deleted_at": null
    },
    {
      "id": 2,
      "user_id": 2,
      "lang_id": "es-ES",
      "translatable_type": "infoboardPost",
      "translatable_id": 10,
      "translatable_field": "text",
      "translatable_field_value": "<p>Por fin han concluido las obras de remodelación de nuestra sucursal: ¡a partir de la semana que viene volveremos a abrir en Limburgo!</p><p></p><p>Como de costumbre, encontrará la rotación actual en su carpeta de archivos.</p>",
      "created_at": "2025-05-15 12:00:00",
      "updated_at": "2025-05-15 12:00:00",
      "deleted_at": null
    }
  ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.api.intratool.de/api-reference/translations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
