lambdadigamma / laravel-api-language
A simple package for making a Laravel API language header aware.
Fund package maintenance!
LambdaDigamma
Requires
- php: ^8.0
- ext-intl: *
- illuminate/contracts: ^10.0 || ^11.0
- spatie/laravel-package-tools: ^1.16.4
Requires (Dev)
- nunomaduro/collision: v8.1.1
- orchestra/testbench: v9.1.0
- pestphp/pest: ^v2.34.7
- spatie/laravel-ray: ^1.23
- vimeo/psalm: ^5.24.0
README
Installation
You can install the package via composer:
composer require lambdadigamma/laravel-api-language
You can publish the config file with:
php artisan vendor:publish --provider="Lambdadigamma\LaravelApiLanguage\LaravelApiLanguageServiceProvider" --tag="api-language-config"
This is the contents of the published config file:
return [ 'supported_locales' => ['en'], 'use_autoscan_lang_folder' => false ];
Usage
To use the accept language middleware, just register it in your application's HTTP kernel.
Register it as a global middleware:
protected $middleware = [ ... \Lambdadigamma\LaravelApiLanguage\Http\Middleware\AcceptLanguageMiddleware::class, ];
Register in a specific middleware group:
protected $middlewareGroups = [ 'api' => [ ... \Lambdadigamma\LaravelApiLanguage\Http\Middleware\AcceptLanguageMiddleware::class, ] ];
Testing
composer test
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
License
The MIT License (MIT). Please see License File for more information.