Skip to content

Commit e9db551

Browse files
committed
feature #31242 Update LoggingTranslator to log the change of a locale (gmponos)
This PR was squashed before being merged into the 4.3-dev branch (closes #31242). Discussion ---------- Update LoggingTranslator to log the change of a locale | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT I would like to see inside my logs that the translator changed the locale. I've had a case that I spent significant amount of time trying to debug it. Commits ------- 20380f9 Update LoggingTranslator to log the change of a locale
2 parents 09e5cc1 + 20380f9 commit e9db551

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Symfony/Component/Translation/LoggingTranslator.php

+2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ public function transChoice($id, $number, array $parameters = [], $domain = null
8282
*/
8383
public function setLocale($locale)
8484
{
85+
$prev = $this->translator->getLocale();
8586
$this->translator->setLocale($locale);
87+
$this->logger->debug(sprintf('The locale of the translator has changed from "%s" to "%s".', $prev, $locale));
8688
}
8789

8890
/**

0 commit comments

Comments
 (0)