Translations
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.
{
"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
| File | Holds | Example |
|---|---|---|
rest::validation | the validation texts of the package: totals, depths, unknown and not writable keys, include aliases, the values of with | validation.filters_total: The :attribute field goes over the limit of :max filters in one search. |
rest::actions | the caps of an action on a search | actions.row_cap: This action can be run on at most :max resources; narrow the search. |
rest::errors | the default denial, the version conflict and the sync conflict | errors.unauthorized: This action is unauthorized. |
__('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 inlang/<locale>/validation.php. - A field is named by its path in the request, such as
search.filters, unlesslabel()orattributes()names it. See Validation. - Exception messages meant for developers, such as
InvalidResourceException, stay in English.
Translating the messages
Publish the files to lang/vendor/rest:
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:
return [
'version_conflict' => 'Der Datensatz wurde von einer anderen Anfrage geändert.',
// ...
];
__('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_localeisen, and otherwise the key itself, such asrest::validation.utf8. - Keep
lang/vendor/rest/enonly 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 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:
return [
'unauthorized' => 'You cannot do this.',
];
"This action is unauthorized.", does not apply to the messages of the package. Move it to the published rest files.Use with AI
Give coding assistants the current Laravel Rest Api docs with the Laravel Boost skill, llms.txt, Markdown copies of every page, GitMCP and Context7.
Extensions
Add behavior to every resource from one class, registered by an app or a package, with a name, a list of kinds and checks at registration.