Saturday, July 17, 2010

How to split dictionary files in Symfony

Mainly, there are two ways to split the translation files in symfony.

01)

You can split the translation file into several dictionary files, with a certain name. For example, you can split the messages.si.xml file into these two (or more) files in the application i18n/ directory:
  • main.si.xml
  • sub.si.xml
When a translation is not to be found in the default messages.si.xml file, you must declare which dictionary is to be used each time you call the __() helper, using its third argument. For example, to output a string that is translated in the sub.si.xml dictionary, write this:

02)

The other way of organizing translation dictionaries is to split them by module. Instead of writing a single messages.xx.xml file for the whole application, you can write one in each "modules/[module_name]/i18n/" directory.

Ex:

  • symfony/apps/frontend/modules/NewModule/i18n/messages.si.xml
  • symfony/apps/frontend/modules/NewModule/i18n/messages.en.xml
  • symfony/apps/frontend/modules/NewModule/i18n/messages.ta.xml
If you have the same translation element in both main messages file and module specific messages file, the priority will be given to the module specific file's element.

0 comments:

Post a Comment