Download the PHP package lambdadigamma/laravel-api-language without Composer
On this page you can find all versions of the php package lambdadigamma/laravel-api-language. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lambdadigamma/laravel-api-language
More information about lambdadigamma/laravel-api-language
Files in lambdadigamma/laravel-api-language
Package laravel-api-language
Short Description A simple package for making a Laravel API language header aware.
License MIT
Homepage https://github.com/lambdadigamma/laravel-api-language
Informations about the package laravel-api-language
A simple package for making a Laravel API language header aware.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
To use the accept language middleware, register it with your application's middleware.
In Laravel 11 and newer, append it to the API middleware group in bootstrap/app.php:
In older Laravel applications, register it as a global middleware:
Register in a specific middleware group:
The middleware stores the full negotiation result on the request. This is useful for APIs that need to pick resource-specific translations instead of only setting Laravel's application locale:
You can also use the negotiator directly:
Use isAcceptedLocaleExcluded() when checking an explicit positive locale from
acceptedLocales; it honors concrete q=0 ranges without letting *;q=0
reject explicitly accepted languages.
AcceptLanguageMiddleware adds Vary: Accept-Language by default. Disable this
with automatic_vary_header if another layer owns response cache variation.
When prefer_user_locale is enabled for authenticated APIs, make sure those
responses are private/auth-aware in your cache layer because the resolved locale
can also depend on the current user.
ContentLanguageMiddleware is available for single-locale responses. It will not
overwrite an existing Content-Language header.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Lennart Fischer
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-api-language with dependencies
illuminate/contracts Version ^11.0 || ^12.0 || ^13.0
illuminate/http Version ^11.0 || ^12.0 || ^13.0
illuminate/support Version ^11.0 || ^12.0 || ^13.0
spatie/laravel-package-tools Version ^1.16.4 || ^1.93
symfony/http-foundation Version ^7.0 || ^8.0
ext-intl Version *