From ffd12e316a33f8ffc55f50f657082757615a0540 Mon Sep 17 00:00:00 2001 From: Tomas Vondracek Date: Sun, 25 Oct 2026 08:51:03 +0100 Subject: [PATCH] fix(translations): stop translating two admin messages twice The secure preview link in the content edit dropdown passed an already translated label to macro.buttonlink(), which translates it again. The login-required flash message was translated in the "security" domain in AuthenticationEntryPointRedirector, and _flash_messages.html.twig translated the result again in "messages". The second lookup uses the translated text as a key, so it is reported as a missing translation, and php-translation's auto_add_missing_translations writes it into the project's translation files. Pass the translation key to the macro, and add the flash message as an untranslated key like the other backend flash messages. The translation catalogue changes are made separately for 6.2. --- src/Security/AuthenticationEntryPointRedirector.php | 4 +--- templates/content/_buttons.html.twig | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Security/AuthenticationEntryPointRedirector.php b/src/Security/AuthenticationEntryPointRedirector.php index 34a8455ae7..3f1363faef 100644 --- a/src/Security/AuthenticationEntryPointRedirector.php +++ b/src/Security/AuthenticationEntryPointRedirector.php @@ -8,12 +8,10 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; -use Symfony\Contracts\Translation\TranslatorInterface; class AuthenticationEntryPointRedirector implements AuthenticationEntryPointInterface { public function __construct( - private readonly TranslatorInterface $translator, private readonly UrlGeneratorInterface $urlGenerator ) { } @@ -23,7 +21,7 @@ public function start(Request $request, ?AuthenticationException $authException // add a custom flash message and redirect to the login page /** @var Session $session */ $session = $request->getSession(); - $session->getFlashBag()->add('warning', $this->translator->trans('You have to login in order to access this page.', [], 'security')); + $session->getFlashBag()->add('warning', 'You have to login in order to access this page.'); return new RedirectResponse($this->urlGenerator->generate('bolt_login')); } diff --git a/templates/content/_buttons.html.twig b/templates/content/_buttons.html.twig index 4aa14d8232..7010b56a04 100644 --- a/templates/content/_buttons.html.twig +++ b/templates/content/_buttons.html.twig @@ -31,7 +31,7 @@