Skip to content

Allow defaultLocale to be null#7184

Closed
gassan wants to merge 1 commit intoEasyCorp:4.xfrom
gassan:locale-from-prefix
Closed

Allow defaultLocale to be null#7184
gassan wants to merge 1 commit intoEasyCorp:4.xfrom
gassan:locale-from-prefix

Conversation

@gassan
Copy link
Copy Markdown
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
Copy Markdown
Contributor

Related to #6954

@gassan gassan force-pushed the locale-from-prefix branch 4 times, most recently from 3a751a0 to 4283216 Compare November 6, 2025 11:21
@gassan gassan force-pushed the locale-from-prefix branch from 4283216 to 3e449a4 Compare November 26, 2025 09:04
@gassan gassan force-pushed the locale-from-prefix branch from 3e449a4 to 47aa85f Compare December 9, 2025 09:11
@gassan gassan force-pushed the locale-from-prefix branch from 47aa85f to f0896f0 Compare January 9, 2026 10:21
@gassan gassan force-pushed the locale-from-prefix branch from f0896f0 to b0ba384 Compare February 19, 2026 10:33
@gassan gassan closed this Mar 12, 2026
@gassan gassan deleted the locale-from-prefix branch March 12, 2026 08:41
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