From 615470c8fab618606c67b3a368e2cec714b68946 Mon Sep 17 00:00:00 2001 From: Stephan Hoffmann Date: Tue, 30 Jul 2024 09:08:03 +0200 Subject: [PATCH] Locale fix --- src/Factory/AdminContextFactory.php | 4 ++-- src/Router/AdminUrlGenerator.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Factory/AdminContextFactory.php b/src/Factory/AdminContextFactory.php index 493cd7f7c4..fd0c24879a 100644 --- a/src/Factory/AdminContextFactory.php +++ b/src/Factory/AdminContextFactory.php @@ -78,8 +78,8 @@ private function getDashboardDto(Request $request, DashboardControllerInterface foreach ($dashboardControllerRoutes as $routeName => $controller) { if ($controller === $dashboardController) { // if present, remove the suffix of i18n route names (it's a two-letter locale at the end - // of the route name; e.g. 'dashboard.en' -> remove '.en', 'admin.index.es' -> remove '.es') - $dashboardRouteName = preg_replace('~\.\w{2}$~', '', $routeName); + // of the route name; e.g. 'dashboard.en' -> remove '.en', 'admin.index.en_US' -> remove '.en_US') + $dashboardRouteName = preg_replace('~\.[a-z]{2}(_[A-Z]{2})?$~', '', $routeName); break; } diff --git a/src/Router/AdminUrlGenerator.php b/src/Router/AdminUrlGenerator.php index ae6afbbd13..88176e5951 100644 --- a/src/Router/AdminUrlGenerator.php +++ b/src/Router/AdminUrlGenerator.php @@ -295,8 +295,8 @@ public function generateUrl(): string } // if present, remove the suffix of i18n route names (it's a two-letter locale at the end - // of the route name; e.g. 'dashboard.en' -> remove '.en', 'admin.index.es' -> remove '.es') - $this->dashboardRoute = preg_replace('~\.\w{2}$~', '', $this->dashboardRoute); + // of the route name; e.g. 'dashboard.en' -> remove '.en', 'admin.index.en_US' -> remove '.en_US') + $this->dashboardRoute = preg_replace('~\.[a-z]{2}(_[A-Z]{2})?$~', '', $this->dashboardRoute); // this removes any parameter with a NULL value $routeParameters = array_filter(