Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Localization Laravel Package

shureban/laravel-localization

Laravel middleware that auto-sets the application locale from the HTTP Accept-Language header. Install via Composer, register the service provider, and add the Localization middleware globally, per group, or per route.

View on GitHub
Deep Wiki
Context7

laravel-localization

Laravel middleware for automatically setting application locale based on HTTP "Accept-Language" header

Installation

Require this package with composer using the following command:

composer require shureban/laravel-localization

Add the following class to the providers array in config/app.php:

Shureban\LaravelLocalization\LocalizationServiceProvider::class,

You can also publish the config file to change implementations (i.e. interface to specific class).

php artisan vendor:publish --provider="Shureban\LaravelLocalization\LocalizationServiceProvider"

Usage

Register \Shureban\LaravelLocalization\Localization::class middleware in application's HTTP Kernel.

You can install it as global middleware in Kernel's $middleware property:

protected $middleware = [
    ...
    \Shureban\LaravelLocalization\Localization::class
];

You can install it to specific middleware groups in Kernel's $middlewareGroups property:

protected $middlewareGroups = [
    'web' => [
        ...
        \Shureban\LaravelLocalization\Localization::class
    ]
];

Or you can install is as route middleware in Kernel's $routeMiddleware and use it manually in routes:

Kernel:

protected $routeMiddleware = [
    ...
    'localization' => \Shureban\LaravelLocalization\Localization::class
];

Route file

Route::middleware(['localization'])->get('/', [AnyController::class, 'method']);

License

The MIT License (MIT). Please see License File for more information.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui