Skip to content

Commit

Permalink
*fix - User Deprecated - Passing "null" as the $locale argument to Sy…
Browse files Browse the repository at this point in the history
…mfony\Component\Translation\Translator::setLocale() is deprecated since Symfony 4.4

*issue - Kdyby#173
  • Loading branch information
xsuchy09 committed Dec 19, 2019
1 parent 74e134f commit 3c99189
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/DI/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function loadConfiguration()
$config['cache'] = new Statement($config['cache'], [dirname(Helpers::expand('%tempDir%/cache', $builder->parameters))]);

$translator = $builder->addDefinition($this->prefix('default'))
->setFactory(KdybyTranslator::class, [$this->prefix('@userLocaleResolver'), $config['default']])
->setFactory(KdybyTranslator::class, [$this->prefix('@userLocaleResolver')])
->addSetup('?->setTranslator(?)', [$this->prefix('@userLocaleResolver.param'), '@self'])
->addSetup('setDefaultLocale', [$config['default']])
->addSetup('setLocaleWhitelist', [$config['whitelist']]);
Expand Down
6 changes: 2 additions & 4 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class Translator extends \Symfony\Component\Translation\Translator implements \K

/**
* @param \Kdyby\Translation\IUserLocaleResolver $localeResolver
* @param string $locale
* @param \Symfony\Component\Translation\Formatter\MessageFormatterInterface $formatter
* @param \Kdyby\Translation\CatalogueCompiler $catalogueCompiler
* @param \Kdyby\Translation\FallbackResolver $fallbackResolver
Expand All @@ -85,7 +84,6 @@ class Translator extends \Symfony\Component\Translation\Translator implements \K
*/
public function __construct(
IUserLocaleResolver $localeResolver,
string $locale,
MessageFormatterInterface $formatter,
CatalogueCompiler $catalogueCompiler,
FallbackResolver $fallbackResolver,
Expand All @@ -98,7 +96,7 @@ public function __construct(
$this->fallbackResolver = $fallbackResolver;
$this->translationsLoader = $loader;

parent::__construct($locale, $formatter);
parent::__construct('', $formatter);
}

/**
Expand Down Expand Up @@ -351,7 +349,7 @@ public function setLocale($locale)
*/
public function getLocale()
{
if (parent::getLocale() === NULL) {
if (parent::getLocale() === '') {
$this->setLocale($this->localeResolver->resolve($this));
}

Expand Down

0 comments on commit 3c99189

Please sign in to comment.