Skip to content

[symfony/translation] Error in readLocalTranslations() #44185

Closed
@tomasz-kusy

Description

@tomasz-kusy

Symfony version(s) affected

5.3

Description

Method readLocalTranslations has wrongly implemented filterCatalogue method;
In TranslationTrait
near line 35
we have:

                foreach ($domains as $domain) {
                    $catalogue = $this->filterCatalogue($catalogue, $domain);
                    $bag->addCatalogue($catalogue);
                }

The problem is:

                    $catalogue = $this->filterCatalogue($catalogue, $domain);

If there are more than one domain, after the first run of the loop we got filtered $catalogue. So we can't find second domain.

How to reproduce

try to to use readLocalTranslations() with more than one $domain

Possible Solution

                foreach ($domains as $domain) {
                    $catalogue = $this->filterCatalogue($catalogue, $domain);
                    $bag->addCatalogue($catalogue);
                }

change to:

                foreach ($domains as $domain) {
                    $newCatalogue = $this->filterCatalogue($catalogue, $domain);
                    $bag->addCatalogue($newCatalogue);
                }

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions