I want to make my yii app multilanguage. To do this I want to use gettext (because its much simpler than yii messages).
To this I used this yii extension, I configured the PO files, I made the translations, etc.
The big problem: nothing happened. Nothing was translated.
To use gettext without any extension follow those steps. In
config/main.php
set yout target language like this:Set
messages
component to useCGettextMessageSource
:Create
messages.po
file inprotected/messages/ru
folder (note: folder name is same as language code). If poedit is usedmessages.po
file must have appropriate headers. Example:Note
t:1c,2
. This means, that first parameter from functionYii::app()
will be used as context (see msgctx) and second as actual string to translate. Without this your i18n will not work!Now just open
messages.po
in poedit →Update
→ do translations →Save
. Andmessages.mo
file will be created and used by Yii.For you language plurals string see gettext help.
I can advice you this awesome multilanguage extension!
http://www.yiiframework.com/extension/tstranslation/