bug #40529 [Translation] Missing translations from traits (insekticid)

This PR was submitted for the 5.4 branch but it was merged into the 4.4 branch instead.

Discussion
----------

[Translation] Missing translations from traits

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #40528 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

If you use ->trans() in traits, your translations will be cleaned with translation:update --clean command

Affected all Symfony versions

Please write some tests for me, I took me long time to debug and repair this :(

![image](https://user-images.githubusercontent.com/177340/111880657-159eac80-89ad-11eb-803b-7c63c67b27b9.png)

Commits
-------

0d8737ff16 Missing translations from traits
This commit is contained in:
Fabien Potencier 2021-07-04 11:22:50 +02:00
commit a224fa73b9
1 changed files with 3 additions and 0 deletions

View File

@ -60,6 +60,9 @@ class TranslatorPathsPass extends AbstractRecursivePass
foreach ($this->paths as $class => $_) {
if (($r = $container->getReflectionClass($class)) && !$r->isInterface()) {
$paths[] = $r->getFileName();
foreach ($r->getTraits() as $trait) {
$paths[] = $trait->getFileName();
}
}
}
if ($paths) {