Skip to content

LambdaDigamma/laravel-api-language

Repository files navigation

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.

About

Make your Laravel API language header aware

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Languages