Увійти Реєстрація
Блог Серії
Кар'єра
Вакансії Компанії
Навчання
Документація Співбесіди Тестування Відео
Екосистема
Пакети Ресурси Проєкти Інструменти Події
Інше
Про нас Реклама

Laravel Localizer

niels-numbers/laravel-localizer
v1.4.0 13 32 23k 5 червня 2026
На GitHub

Пакет автоматично визначає найбільш підходящу мову користувача та перенаправляє його на локалізований URL відповідно до його переваг.

7

README

Laravel Localizer

Tests PHP Laravel License

Laravel can already prefix routes with /{locale}. What it does not do: detect a visitor's language, redirect them there, remember the choice, and keep route('about') returning the right URL. This package adds exactly that.

Documentation: localizer.adam-nielsen.de

Successor to mcamara/laravel-localization. Coming from there? See the migration guide.

What you get

Wrap your routes once:

Route::localize(function () {
    Route::get('/about', AboutController::class)->name('about');
});

The page is now reachable in every configured language:

URL Language
/about en (default, prefix hidden)
/de/about de
/fr/about fr

The default language has no prefix because hide_default_locale is on by default. Turn it off and every URL carries a prefix: /about then redirects to /en/about.

route('about') keeps working as before and returns the URL for the current language: in Blade, controllers, jobs, mails and, with the JavaScript route helpers, in your Vue or React frontend.

Want /de/ueber and /fr/a-propos instead of /de/about? See Translated URL Paths.

What happens on a visit

  1. First visit: someone opens /about. The package reads their browser language (or your own detectors) and redirects them, for example to /de/about. English visitors stay on /about.
  2. From then on the URL decides: /de/about shows German and remembers it in session and cookie. A link to plain /about sends that visitor back to /de/about.
  3. One canonical URL per page: the default language has no prefix, so /en/about redirects to /about.

A language switcher is one helper call per language: Route::localizedSwitcherUrl('fr'). See Language Switcher.

Install

composer require niels-numbers/laravel-localizer

Then set your locales, register two middlewares and wrap your routes. The setup guide walks through the three steps.

Coming from mcamara/laravel-localization?

Same job, different wiring. Every localized route is a plain, static Laravel route, so php artisan route:cache works, translated routes switch reliably and Livewire works out of the box. The migration guide covers the differences step by step.

Not sure you need this package at all? See when to use it and how it compares to mcamara/laravel-localization, codezero-be/laravel-localized-routes and spatie/laravel-translatable.

License & credits

MIT licensed. Created by Adam Nielsen, building on prior work by @mcamara (original laravel-localization), @codezero-be (deprecated laravel-localized-routes, whose static-route ideas inspired this rewrite) and @jordyvanderhaegen (current maintainer of the original, whose issue #921 motivated this package).

Коментарі

Увійдіть, щоб залишити коментар

Будьте першим, хто залишить коментар!

Схожі пакети

Lang

laravel-lang/lang

Список 126 мов для Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark та Laravel UI.

7,779 15.37.4 12

Laravel Localization

mcamara/laravel-localization

Простий інструмент для локалізації Laravel-додатків, що полегшує управління мовними версіями та перекладами.

3,558 v2.4.2 13 7

Laravel Translatable

spatie/laravel-translatable

Трейт для збереження перекладів у моделях Eloquent.

2,461 6.14.1 13 8

Laravel Translatable

astrotomic/laravel-translatable

Пакет для роботи з багатомовними моделями в Laravel, що дозволяє легко керувати перекладами даних на різні мови.

1,427 v11.17.1 13 7

Laravel Translation Loader

spatie/laravel-translation-loader

Пакет дозволяє зберігати мовні рядки в базі даних, YAML або інших джерелах замість традиційних файлів локалізації.

857 2.8.3 7

Laravel Translations

mohmmedashraf/laravel-translations

Керуйте перекладами Laravel за допомогою красивого інтерфейсу. Легко додавайте, редагуйте, видаляйте, імпортуйте та експортуйте переклади.

821 v2.1.1 13 14