symfony/symfony — Issue #2437: Translation fallback seems to stop working once translations are cached
Author: ricardclau
Created: 2011-10-20 08:52:20+00:00
State: open

Hi

I am having problems with translation fallbacks:

My translation setup is:

(config.yml)
translator: { fallback: en }
session:
default_locale: es_ES

Then in MyBundle/Resources/config/translations I have got

(messages.en.yml)

bundle:
exceptions:
invalidtoken: Invalid token

(messages.es_ES.yml)

bundle:
exceptions:
invalidtokena: Token inválido

(Note that the key is different, to try if fallback translations work)

I setup a controller action like this:

/**
* @Route("/translate.{_format}", requirements={"_format"="json"})
* @Template("MyBundle:Base:translate.json.twig")
*/
public function testTranslationsAction()
{
return array('message' => 'bundle.exceptions.invalidtoken');
}

And my MyBundle:Base:translate.json.twig is just

{{ message | trans }}

I know it is not pure json or whatever, but this should be the fastest setup and be enough to reproduce the issue I am having, I guess

So, if my session has locale es_ES (which actually is), in this conditions it should just render the fallback english translation unless I miss some further configuration.

And at first request, when app/cache/[ENV]/translations folder is empty, it just works as desired.
But on that request, a translation folder is created with all translations cached.

And beyond that step, fallback translation stops working, it will just print the translation key bundle.exceptions.invalidtoken and not any translation

If I delete this cache folder, it gets back to work, so there seems to be a problem in the cache folder.

And this only happens with fallback translation, if my messages.es_ES.yml is

(messages.es_ES.yml)

bundle:
exceptions:
invalidtoken: Token inválido

it will always render the spanish translation properly

Is this a known issue (or even an issue and not some bad configuration)?

Any comments will be appreciated, if you cannot reproduce the issue or need further info, please let me know.
I am using Symfony2.0.4 standard edition.