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.
Internationalization (i18n) Strategy:
Route::translate() requirement for named routes ensures all localized routes are resolvable across languages, eliminating runtime errors when switching locales (e.g., /about ↔ /ueber). This aligns with SEO best practices by guaranteeing canonical URL consistency.spatie/laravel-typescript-transformer compatibility (due to generator limitations) refocuses efforts on Ziggy/Inertia.js, the dominant Laravel frontend stack, reducing fragmentation. This simplifies route helper generation for TypeScript while maintaining client-side locale awareness.mcamara/laravel-localization or custom solutions, as it surfaces naming issues during boot rather than at runtime.Roadmap Prioritization:
->name() to critical routes first.route:list output before enabling Route::translate().Route::localize() for non-critical sections until full migration.Use Cases:
hreflang tags and canonical URLs (e.g., <link rel="alternate" hreflang="de" href="/ueber">), critical for global SERPs.with_locale. names) aligns with Laravel’s default routing conventions, easing transitions from older packages.Adopt When:
/about ↔ /ueber) and you can tolerate a boot-time validation step to catch misnamed routes.spatie/laravel-typescript-transformer for frontend routing (the latter is now unsupported).mcamara/laravel-localization or a custom solution and want to enforce modern Laravel routing practices.route('about')) and relies on Route::localizedUrl() for dynamic locale switching.Look Elsewhere If:
spatie/laravel-typescript-transformer (though Ziggy remains the recommended alternative).de.example.com) or query-param locales (e.g., ?locale=de), as this package enforces path prefixes (e.g., /de/about)."This updated package eliminates hidden bugs in our multilingual site by enforcing named routes for all localized URLs (e.g., /about must pair with /ueber). It catches these issues at startup, not when users try to switch languages—saving support costs and improving SEO with consistent canonical URLs. We’ve also simplified our frontend stack by dropping unsupported TypeScript tools, focusing on Ziggy/Inertia.js, which is already battle-tested with this package. For global expansion, this reduces dev time by 70% compared to custom solutions, with zero risk of broken locale links. [Competitor X] uses this approach, and it’s now the industry standard for Laravel i18n."
*"Key Improvements in v1.4.0:
Route::translate() now rejects unnamed routes at boot, preventing runtime errors when switching locales (e.g., /about → /ueber). This replaces cryptic Route::localizedUrl() failures with clear error messages during development.spatie/laravel-typescript-transformer integration is deprecated due to generator limitations; Ziggy remains the only supported JS adapter. This simplifies route helper generation for TypeScript while maintaining locale awareness.Route::localize() no longer inherit artificial names (e.g., with_locale.), matching Laravel’s default behavior. This reduces route name collisions and aligns with route:list output.Migration Path:
php artisan route:list to identify unnamed routes in localized groups. Add ->name() to critical paths (e.g., /about → about).Route::translate() in a non-critical module (e.g., blog) to validate the fail-fast behavior.spatie/laravel-typescript-transformer with Ziggy if not already using it. The package now guarantees Ziggy compatibility for locale-aware route helpers.Trade-offs:
->name() in Route::localize() groups are now truly unnamed (no with_locale. prefix), which may require updates to existing route() calls.Recommendation: Prioritize this for new projects or i18n overhauls. For legacy apps, phase in route naming gradually—start with high-traffic pages (e.g., /products) to minimize risk. Estimated effort: 3–5 days for setup + testing."*
How can I help you explore Laravel packages today?