Reputation: 4582
I'm experimenting on Symfony 2 Translation Component. My default locale is el_GR and my alternate locale is en_US. I 've set up my config.yml, I've created 2 translation files: messages.el_GR.yml and messages.en_US.yml and then cleared app/cache. I have translated the word Symfony in both locales. So when I use the command php app/console translation:debug en_US abcNikBundle I get:
State | Id | Message Preview (en_US) | Fallback Message Preview (el_GR)
| Symfony | Symfony_US | Symfony_GR
So in a twig template I write
{{ 'Symfony'|trans({},'messages') }}
It works fine when I use the en_US locale, (it prints Symfony_US) but When I use my default locale (el_GR), it prints Symfony instead of Symfony_GR. Can it be done somehow?
Upvotes: 2
Views: 1598
Reputation: 8276
Make sure your cache is completely deleted. You probably reset the cache after adding the English translation but not your fallback. See the Symfony documentation for more info:
Each time you create a new translation resource (or install a bundle that includes a translation resource), be sure to clear your cache so that Symfony can discover the new translation resources:
Sometimes just running the cache:clear
command fails for me in which case I just manually delete the contents of the app/cache
directory.
Also, if a translation cannot be found it is logged in debug mode in the translation channel (dev.translation.log) - check your logs to see if it couldn't find the translation. Also, you don't have to specify 'messages' since that's the default, you can just do {{ 'Symfony'|trans }}
Upvotes: 3