Skip to content

Commit

Permalink
fix locale resolution doesn't happen with new versions of symphony tr…
Browse files Browse the repository at this point in the history
…anslator
  • Loading branch information
matlad committed Jun 9, 2023
1 parent 2bc453b commit 44ce278
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ class Translator extends \Symfony\Component\Translation\Translator implements \K
*/
private $formatter;

/**
* @var bool
*/
private $localeResolved = false;

/**
* @param \Kdyby\Translation\IUserLocaleResolver $localeResolver
* @param \Symfony\Component\Translation\Formatter\MessageFormatterInterface $formatter
Expand Down Expand Up @@ -348,8 +353,9 @@ public function setLocale($locale)
*/
public function getLocale()
{
if (empty(parent::getLocale())) {
if (!$this->localeResolved) {
$this->setLocale($this->localeResolver->resolve($this));
$this->localeResolved = true;
}

return parent::getLocale();
Expand Down

0 comments on commit 44ce278

Please sign in to comment.