View Single Post
  #47  
Old 11th October 2011, 22:50
Optix's Avatar
Optix Optix is offline
Senior Member
 
Join Date: Sep 2011
France
Posts: 145
Default
Nice try ! I really appreciate ;)

In an action, don't test the user culture, it's a lot of work. You can directly use the I18N module :
PHP Code:
$this->getContext()->getI18N()->__("Here is the English sentence."); 
It allows you 2 things :
- Symfony fills the "messages.xml" for you in order to translate the string (you've to run a command to do that, but the reporting is automatic).
- When the translation isn't available in German (for exemple), it will display the English one. That's very cool : no error any more :D

In a template, you can directly call the function <?=__("Send")?> ;)
The Following User Says Thank You to Optix For This Useful Post:
BamBam0077 (1st June 2022)