dovc/translation-route-bundle
dovc/translation-route-bundle) appears to be a Symfony bundle for Laravel (via Symfony Bridge), enabling multi-language route handling (e.g., /en/about, /fr/about). It aligns well with modular Laravel architectures where i18n is a cross-cutting concern but may introduce complexity in microservices or headless APIs where routing is decoupled.TranslationRouteBundle under the hood. This could introduce abstraction overhead if Laravel’s native i18n (e.g., App::setLocale()) is already in use./about → /en/about)./:locale/about).TranslationRouteBundle patterns.php artisan route:clear on locale changes).VerifyCsrfToken).translated:json attributes) would require separate handling (e.g., spatie/laravel-translatable).TranslationRouteBundle evolves./{locale} vs. /en/{route}).TranslationRouteBundle? If yes, integration is smoother.App::setLocale()) already implemented? Overlap may cause conflicts./old-route vs. /en/new-route)./about → /en/about vs. redirect to /en)?composer require symfony/translation).TranslationRouteBundle (reduces learning curve)./blog/{post} → /{locale}/blog/{post}).composer require dovc/translation-route-bundle
php artisan vendor:publish --provider="Dovc\TranslationRouteBundle\TranslationRouteBundle"
config/translation_route.php:
'locales' => ['en', 'fr'],
'default_locale' => 'en',
'prefix' => '{locale}', // or 'none' for subdomains
'fallback_locale' => true,
routes/web.php to use locale-aware routes:
TranslationRoute::domain('{locale}.example.com')->group(function () {
Route::get('/about', [AboutController::class, 'index']);
});
TranslationRoute::prefix('{locale}')->group(function () {
Route::get('/about', [AboutController::class, 'index']);
});
App\Http\Middleware\SetLocale (or equivalent) runs after locale resolution:
// app/Http/Kernel.php
'web' => [
// ...
\Dovc\TranslationRouteBundle\Http\Middleware\Locale::class,
\App\Http\Middleware\SetLocale::class,
],
/about → /en/about).php artisan route:clear may be needed).symfony/translation, symfony/http-foundation.route:cache) may need exclusion for dynamic locales.TranslationRouteBundle.spatie/laravel-localization (better docs, community).spatie/laravel-translatable) may require indexing for locale-specificHow can I help you explore Laravel packages today?