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 32620ba commit 74e134f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 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')])
->setFactory(KdybyTranslator::class, [$this->prefix('@userLocaleResolver'), $config['default']])
->addSetup('?->setTranslator(?)', [$this->prefix('@userLocaleResolver.param'), '@self'])
->addSetup('setDefaultLocale', [$config['default']])
->addSetup('setLocaleWhitelist', [$config['whitelist']]);
Expand Down
5 changes: 3 additions & 2 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ 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 @@ -84,6 +85,7 @@ class Translator extends \Symfony\Component\Translation\Translator implements \K
*/
public function __construct(
IUserLocaleResolver $localeResolver,
string $locale,
MessageFormatterInterface $formatter,
CatalogueCompiler $catalogueCompiler,
FallbackResolver $fallbackResolver,
Expand All @@ -96,8 +98,7 @@ public function __construct(
$this->fallbackResolver = $fallbackResolver;
$this->translationsLoader = $loader;

parent::__construct('', $formatter);
$this->setLocale(NULL);
parent::__construct($locale, $formatter);
}

/**
Expand Down

0 comments on commit 74e134f

Please sign in to comment.