79417520

Date: 2025-02-06 10:29:16
Score: 0.5
Natty:
Report link

In Symfony 6.1, the LocaleSwitcher has been added for this use case.

use Symfony\Component\Translation\LocaleSwitcher;
...
$this->localeSwitcher->setLocale($documentData->getLocale());
try {
    $html = $this->templating->render('admin/request/pdf/document.pdf.twig', [
        'data' => $data,
    ]);
} finally {
    $this->localeSwitcher->reset();
}

See https://symfony.com/doc/current/translation.html#switch-locale-programmatically

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: dbu