shaunthegeek/laravel-locale-setter

detect Accept-Language, setLocale for Laravel

Installs: 60

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 1

Open Issues: 1

pkg:composer/shaunthegeek/laravel-locale-setter

v2.0.0 2026-01-05 12:14 UTC

This package is auto-updated.

Last update: 2026-01-05 14:34:12 UTC


README

Automatically scanning the lang directory for locales, detecting the HTTP Accept-Language header, and setting the Laravel locale — all are handled seamlessly by this package.

Installation

composer require shaunthegeek/laravel-locale-setter

Add Middleware

// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(remove: [
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ]);
    $middleware->web(append: [
        ShaunTheGeek\LaravelLocaleSetter\Middleware\DetectLocale::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ]);
})

Optional

If you wish to modify the configuration, please publish it first.

php artisan vendor:publish --tag=locale-config