Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | yes |
RFC? | no |
Symfony version | 3.1.7 |
3.1.7 seems to have introduced a change that is breaking certain aspects of Translation our project was relying on.
Esentially, where a fallback locale is not found for a translation with a locale in the form "en_GB" (as opposed to just "en"), a cache file with no language entries is wrongly created.
If you instantiate a new translate class like so
$lang = 'en_GB';
$translator = new \Symfony\Component\Translation\Translator($lang, null, $cacheDirectory);
$translator->addLoader('pofile', new \Symfony\Component\Translation\Loader\PoFileLoader());
$translator->addResource('pofile', '/path/to/en.po', $lang);
echo $translator->trans('my_translation');
It will create a cache file for the (nonexistant) fallback language, named "catalogue.en.[sha1].php" with no translation entries, as well as the correct cache file for en_GB.
This is a problem because subsequently running the same code with $lang = 'en' will now erroneously not return a translation.
I realise this is something of a corner case, but I think the code in the original bug report at #17786 would have fixed the issue without introducing this regression.