mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-31 20:13:49 +00:00
Generate a context for docgen, on accompanying period
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Templating;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use function array_key_exists;
|
||||
@@ -21,10 +22,13 @@ final class TranslatableStringHelper implements TranslatableStringHelperInterfac
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(RequestStack $requestStack, TranslatorInterface $translator)
|
||||
private string $defaultLocale;
|
||||
|
||||
public function __construct(RequestStack $requestStack, TranslatorInterface $translator, ParameterBagInterface $parameterBag)
|
||||
{
|
||||
$this->requestStack = $requestStack;
|
||||
$this->translator = $translator;
|
||||
$this->defaultLocale = $parameterBag->get('kernel.default_locale');
|
||||
}
|
||||
|
||||
public function localize(array $translatableStrings): ?string
|
||||
@@ -35,11 +39,7 @@ final class TranslatableStringHelper implements TranslatableStringHelperInterfac
|
||||
|
||||
$request = $this->requestStack->getCurrentRequest();
|
||||
|
||||
if (null === $request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$language = $request->getLocale();
|
||||
$language = null === $request ? $this->defaultLocale : $request->getLocale();
|
||||
|
||||
if (array_key_exists($language, $translatableStrings)) {
|
||||
return $translatableStrings[$language];
|
||||
|
Reference in New Issue
Block a user