Looking to hire Laravel developers? Try LaraJobs

laravel-api-language maintained by lambdadigamma

Description
A simple package for making a Laravel API language header aware.
Last update
2026/03/19 17:54 (dev-main)
License
Downloads
598

Comments
comments powered by Disqus

A simple package for making a Laravel API language header aware.

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads


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.