PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Translation Source Structures

Your next step is to create the translation sources for the languages you want to translate. Every adapter is created its own way as described here, but there are common features applicable for all adapters.

You have to decide where to store your translation source files. Using Zend_Translate you are not restricted in any way. The following structures are preferable:

  • Single structured source

    /application/
    /languages/
    /languages/lang.en
    /languages/lang.de
    /library/
    

    Positive: all source files for every languages are stored in one directory. No splitting of related files.

  • Language structured source

    /application/
    /languages/
    /languages/en/
    /languages/en/first.en
    /languages/en/second.en
    /languages/de/
    /languages/de/first.de
    /languages/de/second.de
    /library
    

    Positive: Every language is stored in their own directories. Easy translation, as every language team has to translate only one directory. Also the usage of multiple files is transparent.

  • Application structured source

    /application/
    /application/languages/
    /application/languages/first.en
    /application/languages/first.de
    /application/languages/second.en
    /application/languages/second.de
    /library/
    

    Positive: all source files for every language are stored in one directory. No splitting of related files.

    Negative: having multiple files for the same language can be problematic.

  • Gettext structured source

    /application/
    /languages/
    /languages/de/
    /languages/de/LC_MESSAGES/
    /languages/de/LC_MESSAGES/first.mo
    /languages/de/LC_MESSAGES/second.mo
    /languages/en/
    /languages/en/LC_MESSAGES/
    /languages/en/LC_MESSAGES/first.mo
    /languages/en/LC_MESSAGES/second.mo
    /library/
    

    Positive: existing gettext sources can be used without changing structure.

    Negative: having sub-sub directories may be confusing for people who have not used gettext before.

  • File structured source

    /application/
    /application/models/
    /application/models/MyModel.php
    /application/models/MyModel.de
    /application/models/MyModel.en
    /application/controllers/
    /application/controllers/MyController.php
    /application/controllers/MyController.de
    /application/controllers/MyController.en
    /library/
    

    Positive: translation files are localted near their source.

    Negative: too many and also small translation files result in being tedious to translate. Also every file has to be added as translation source.

Single structured and language structured source files are most usable for Zend_Translate.

So now, that we know which structure we want to have, we should create our translation source files.

Zend Framework