niels-numbers/laravel-localizer
Locale-aware routing for Laravel with static, route:cache-ready localized routes. Auto-detects language, redirects to prefixed URLs, and resolves route() to the correct locale. Successor to mcamara/laravel-localization.
/about → /en/about, /de/about). Reduces technical debt by centralizing locale logic in a single package.RedirectLocale middleware and detector chain.mcamara/laravel-localization)./de/datenschutz).hreflang tags) via localizedUrl() helpers.Adopt If:
route:cache (static routes) and Ziggy/Inertia.js for SPA support.route('about') works regardless of locale) and consistency (e.g., RTL/LTR direction handling).Look Elsewhere If:
/locale/code/page instead of /code/page). This package enforces {locale}/route syntax.de.example.com). Use packages like spatie/laravel-localization or custom middleware.App::setLocale()."This package lets us launch a multilingual version of [Product] with minimal engineering effort. Instead of manually creating /en/about, /de/about, etc., we’ll use auto-detection (browser language) and seamless redirection to serve the right locale—without duplicating routes or breaking SEO. It’s used by [X] companies and integrates with our existing stack (Laravel, Inertia.js). The cost? Zero upfront dev time; the benefit? Faster time-to-market for global audiences and compliance with regional requirements."
Key Outcomes:
"Laravel Localizer solves our locale routing pain points cleanly*:
Accept-Language headers to redirect users to /de/about (or /en/about if default) on first visit.@routes Blade directives and client-side routing (no manual JS hacks).<html dir="rtl"> for Arabic/Hebrew locales via Localizer::currentLocaleDirection().route('about') always resolves correctly, even after locale changes. No more route('de.about') sprawl.route:cache and adds negligible overhead (~1ms per request).Trade-offs:
{locale}/route syntax (not /locale=de&route=about).Migration Path:
RedirectLocale + SetLocale.route() calls in Blade/JS to rely on the package’s helpers./EN/about → redirects to /en/about), query string preservation during locale switches.Alternatives Considered:
Recommendation: Adopt for MVP, then extend with custom detectors (e.g., user profile-based locales) or middleware if needed."*
How can I help you explore Laravel packages today?