Skip to content

Translation fallback order error #42480

Closed
@mboeck001

Description

@mboeck001

Discussed in #42479

Originally posted by mboeck001 August 11, 2021
Hi!

There seems to be a bug in Symfony\Component\Translation computing the fallbacks in method computeFallbackLocales. Perhapes someone can confirm or correct me?

  • We use a valid ICU language selector e.g de_AT_VIENNA and we have a message file for de, de_AT and de_AT_VIENNA containing a valid translation
  • locale is de_AT_VIENNA
  • the lookup ID is missing in de_AT_VIENNA, so fallback is triggered
  • the fallback is computed in the order first de, then de_AT, what is imo wrong, it has to be de_AT followed by de corresponding to ICU usage

I would just change the array_unshift to a normal append operation

Did I miss something? This seams to be since a long time ...

changed line arround line 441 of Translator.php to:

        if (null !== $locale) {
            // m.boeck: wrong order in fallback - bug in symfony
            $locales[] = $locale;
        }

removing the array_unshift operation. For me it works.

Thats also in the 4.x branch.

Martin

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