bug #32014 Do not log or call the proxy function when the locale is the same (gmponos)

This PR was squashed before being merged into the 4.3 branch (closes #32014).

Discussion
----------

Do not log or call the proxy function when the locale is the same

| Q             | A
| ------------- | ---
| Branch?       | 4.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| License       | MIT

I was the one creating the PR for logging the change of the locale but ATM I am filled with logs of translator about switching the locale from "en" to "en".. Not sure why.

Commits
-------

31bdfb372c Do not log or call the proxy function when the locale is the same
This commit is contained in:
Fabien Potencier 2019-06-13 11:55:06 +02:00
commit dab7a554ae

View File

@ -84,6 +84,10 @@ class LoggingTranslator implements TranslatorInterface, LegacyTranslatorInterfac
{
$prev = $this->translator->getLocale();
$this->translator->setLocale($locale);
if ($prev === $locale) {
return;
}
$this->logger->debug(sprintf('The locale of the translator has changed from "%s" to "%s".', $prev, $locale));
}