Skip to content

Conversation

@gassan
Copy link
Contributor

@gassan gassan commented Oct 27, 2025

Title:
Localized routes work only for DashboardController, not for CrudControllers when using prefix-based locale configuration


Description:

I'm trying to control the current Symfony _locale using the prefix configuration in easyadmin.routes:

easyadmin:
    resource: .
    type: easyadmin.routes
    prefix:
        en: '/en'
        de: ''

However, with this setup, localized links are generated only for the DashboardControllers, while CrudControllers do not get the proper locale prefixes.

When I change the defaultLocale parameter to null via a CompilerPass, all routes are generated correctly and everything works as expected.

CompierPass

use EasyCorp\Bundle\EasyAdminBundle\Router\AdminRouteGenerator;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class AllowLocaleInPrefixRoutesForEasyAdminPass implements CompilerPassInterface
{
    public function process(ContainerBuilder $container): void
    {
        $container->findDefinition(AdminRouteGenerator::class)
            ->setArgument(5, null)
        ;
    }
}

Note:
There is probably a more correct way to handle this, but this workaround works for now.

@andersonamuller
Copy link
Contributor

Related to #6954

@gassan gassan force-pushed the locale-from-prefix branch 3 times, most recently from 9779363 to 3a751a0 Compare November 4, 2025 20:12
@gassan gassan force-pushed the locale-from-prefix branch from 3a751a0 to 4283216 Compare November 6, 2025 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants