# Translations

> Translate or reword every message that the package sends to clients, from the English lines it ships under the rest namespace.

Every message that the package writes for a client is a translation line under the `rest` namespace: its validation texts, the caps of an action, the default denial and the conflict messages. The package ships these lines in English only, and answers in the locale of the request.

```json [409 Conflict]
{
  "message": "The record was changed by another request.",
  "conflicts": [{"reason": "version", "path": "mutate.0", "key": 2, "version": "2026-03-01T10:00:00.000000Z"}]
}
```

## The lines

<table>
<thead>
  <tr>
    <th>
      File
    </th>
    
    <th>
      Holds
    </th>
    
    <th>
      Example
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        rest::validation
      </code>
    </td>
    
    <td>
      the validation texts of the package: totals, depths, unknown and not writable keys, include aliases, the values of <code>
        with
      </code>
    </td>
    
    <td>
      <code>
        validation.filters_total
      </code>
      
      : <code>
        The :attribute field goes over the limit of :max filters in one search.
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rest::actions
      </code>
    </td>
    
    <td>
      the caps of an action on a search
    </td>
    
    <td>
      <code>
        actions.row_cap
      </code>
      
      : <code>
        This action can be run on at most :max resources; narrow the search.
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rest::errors
      </code>
    </td>
    
    <td>
      the default denial, the version conflict and the sync conflict
    </td>
    
    <td>
      <code>
        errors.unauthorized
      </code>
      
      : <code>
        This action is unauthorized.
      </code>
    </td>
  </tr>
</tbody>
</table>

```php
__('rest::errors.version_conflict'); // The record was changed by another request.
```

- The texts that Laravel's own rules give, such as `The search.filters field must not have more than 100 items.`, stay Laravel's lines: translate them in `lang/<locale>/validation.php`.
- A field is named by its path in the request, such as `search.filters`, unless `label()` or `attributes()` names it. See [Validation](/resources/validation).
- Exception messages meant for developers, such as `InvalidResourceException`, stay in English.

## Translating the messages

Publish the files to `lang/vendor/rest`:

```bash
php artisan vendor:publish --tag=rest-lang
```

Then translate the lines in a folder per locale, such as `lang/vendor/rest/de`, with the same files and keys as `lang/vendor/rest/en`:

```php [lang/vendor/rest/de/errors.php]
return [
    'version_conflict' => 'Der Datensatz wurde von einer anderen Anfrage geändert.',
    // ...
];
```

```php
__('rest::errors.version_conflict', locale: 'de'); // Der Datensatz wurde von einer anderen Anfrage geändert.
```

- The published lines replace the lines of the package, key by key. A key that a locale leaves out falls back to `app.fallback_locale`.
- A request in a locale without lines gets the English line when `app.fallback_locale` is `en`, and otherwise the key itself, such as `rest::validation.utf8`.
- Keep `lang/vendor/rest/en` only for the English lines that you reword. A copy of every English line would keep the wording of the version that you published, and hide the rewordings of later versions.
- A new release can add keys: the [upgrade guide](/getting-started/upgrade-guide) lists them, so that you add them to each locale.

## Rewording a message

Edit the line in `lang/vendor/rest/en`, and delete the other lines of that file, so that the package keeps the wording of the lines you did not change:

```php [lang/vendor/rest/en/errors.php]
return [
    'unauthorized' => 'You cannot do this.',
];
```

<note>

A line of a JSON translation file that matches an English text of the package, such as `"This action is unauthorized."`, does not apply to the messages of the package. Move it to the published `rest` files.

</note>
