- Can I use h2invent/i18n-routing-bundle in a Laravel application?
- No. Despite being listed alongside Laravel packages, this is a Symfony bundle that targets Symfony's Routing, HttpKernel and DependencyInjection components, decorating RouterInterface through a compiler pass and a kernel.request listener. Laravel's RouteCollection, UrlGenerator and RouteRegistrar share no extension points with that design, so integration would mean writing a compatibility shim for a router Laravel does not use. For Laravel, use codezero/laravel-localized-routes, mcamara/laravel-localization, or astrotomic/laravel-translatable with a slug column instead.
- How do I install h2invent/i18n-routing-bundle?
- Run composer require h2invent/i18n-routing-bundle, then register the bundle in config/bundles.php (Symfony Flex projects pick it up automatically). Add a jms_i18n_routing configuration block defining your default locale and supported locales, and leave your existing route definitions in place since the bundle decorates the router rather than replacing route files. Check the Composer constraints against your Symfony and PHP versions first, because the package has only a single 2024 release and no published compatibility matrix.
- Does this bundle work with Symfony 6 and Symfony 7?
- There is no published test matrix against current Symfony or PHP versions, so compatibility is unverified. The most likely breakage point is the typed RouterInterface signatures introduced in newer Symfony releases combined with PHP 8.2+ strictness, which a single-maintainer decorator bundle may not have been updated for. Install it on a throwaway branch and exercise route generation, redirects and the Twig path() helper before committing to it.
- How is this bundle different from Symfony's built-in localized routes?
- Symfony has handled translated path segments natively since 5.3 through localized route paths such as #[Route(path: ['en' => '/about', 'de' => '/ueber-uns'])] and the LocalizedRouteLoader. On a modern Symfony codebase this bundle is largely redundant and risks double-decorating the router. The remaining gaps it can fill are translated route names and a plugin-style route registration model inherited from legacy JMS-era applications.
- How does the bundle generate locale-prefixed URLs automatically?
- It wraps the framework router so generated URLs follow the active locale, producing paths such as /en/contact and /de/kontakt from a single route definition. A kernel.request listener resolves the locale from the incoming URL, and the decorated router uses it during generation, so Twig path() calls keep working unchanged. Your configuration controls the default locale and the list of supported locales.
- Is h2invent/i18n-routing-bundle safe to run in production?
- Treat it as high risk. The repository shows zero stars, zero dependents and a single release dated 2024-05-24, and it is a community revival of the long-abandoned jms/i18n-routing-bundle with no published security policy. Adopting it means accepting abandonment risk, so only proceed if you have a named internal maintainer willing to fork and vendor the code.
- What is the Laravel equivalent of translated path segments?
- codezero/laravel-localized-routes covers translated segments, locale prefixes and hreflang helpers, while mcamara/laravel-localization is the simpler prefix-only option. If translated slugs need to be bound to Eloquent models, pair astrotomic/laravel-translatable with a slug column. All of these have real dependents and active maintenance, unlike this Symfony-only bundle.
- How do I migrate away from this bundle to Symfony's native routing?
- Convert each jms_i18n_routing route entry into a localized #[Route(path: [...])] attribute, remove the router decorator from services.yaml, and delete the kernel.request locale listener in favour of Symfony's LocaleListener. The surface area is small, so a mid-sized route table is roughly a one to two day change. Budget extra time for a regression pass over URL generation, language switching and redirects.
- Does it support translated route names as well as translated paths?
- Yes, localized path segments and localized route names are the bundle's core features, and URL generation follows the active locale automatically. Translated route names matter mainly for legacy URL preservation or when existing templates reference one route name per language. If you only need prefixed URLs such as /en/contact with the same path in every language, plain Symfony locale defaults are enough and no third-party package is required.
- How do I configure supported locales and build a language switcher?
- Supported and default locales live in the bundle's configuration block, and the locale prefix is applied during URL generation based on the active locale. A typical switcher in Twig generates the current route name for each target locale and renders the resulting localized URL. Because the package documentation is thin and unversioned, verify the exact configuration keys against the bundle source before relying on them in a template.