mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
Refactor flash message handling to use translatable messages
Replaced raw translations with Symfony's TranslatableMessage for flash messages in the controller. Updated Twig templates to use the `|trans` filter for consistency in rendering translations. This ensures better handling of multilingual content across the application.
This commit is contained in:
@@ -32,6 +32,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use Symfony\Component\Translation\TranslatableMessage;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
final readonly class SavedExportController
|
||||
@@ -64,7 +65,7 @@ final readonly class SavedExportController
|
||||
|
||||
$session = $request->getSession();
|
||||
if ($session instanceof Session) {
|
||||
$session->getFlashBag()->add('success', $this->translator->trans('saved_export.Export is deleted'));
|
||||
$session->getFlashBag()->add('success', new TranslatableMessage('saved_export.Export is deleted'));
|
||||
}
|
||||
|
||||
return new RedirectResponse(
|
||||
@@ -111,7 +112,7 @@ final readonly class SavedExportController
|
||||
$this->entityManager->flush();
|
||||
|
||||
if (($session = $request->getSession()) instanceof Session) {
|
||||
$session->getFlashBag()->add('success', $this->translator->trans('saved_export.Saved export is saved!'));
|
||||
$session->getFlashBag()->add('success', new TranslatableMessage('saved_export.Saved export is saved!'));
|
||||
}
|
||||
|
||||
return new RedirectResponse(
|
||||
@@ -144,7 +145,7 @@ final readonly class SavedExportController
|
||||
$this->entityManager->flush();
|
||||
|
||||
if (($session = $request->getSession()) instanceof Session) {
|
||||
$session->getFlashBag()->add('success', $this->translator->trans('saved_export.Saved export is saved!'));
|
||||
$session->getFlashBag()->add('success', new TranslatableMessage('saved_export.Saved export is saved!'));
|
||||
}
|
||||
|
||||
return new RedirectResponse(
|
||||
@@ -157,8 +158,8 @@ final readonly class SavedExportController
|
||||
'@ChillMain/SavedExport/edit.html.twig',
|
||||
[
|
||||
'form' => $form->createView(),
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -194,8 +195,8 @@ final readonly class SavedExportController
|
||||
[
|
||||
'grouped_exports' => $exportsGrouped,
|
||||
'total' => \count($exports),
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user