Since Yii can not create PO files without a special extension, I just created a .po file with Poedit. I want use CGettextMessageSource
and configured everything in main.php
.
But Yii is just ignoring my settings in main.php
and my .po file itself.
main.php
'language' => 'de_DE',
[...]
'components' => array(
'messages' => array(
'class' => 'CGettextMessageSource',
'useMoFile' => false,
'catalog' => 'messages',
'basePath' => 'protected/messages'
),
),
my po file
protected => messages => de_DE => messages.mo, messages.po
content of my .po file
msgid ""
msgstr ""
"Project-Id-Version: myTest\n"
"POT-Creation-Date: 2014-04-28 17:18+0100\n"
"PO-Revision-Date: 2014-04-29 09:16+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.4\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-KeywordsList: t\n"
"X-Poedit-SearchPath-0: /..."
"trunk/fe/htdocs/protected\n"
#: /htdocs/protected/views/site/index.php:9
msgid "_TEST_"
msgstr "Congratulations! You have successfully created your Yii application."
Since I can not extend the t
-function because of strict standards I wrote a wrapper in yii.php
which I copied to protected
and include it in main.php
.
class Yii extends YiiBase
{
public static function _($message, $category, $params = array())
{
return parent::t($category, $message, $params);
}
}
And this is my index.php where I have a string that should be converted:
<?php echo Yii::_('_TEST_', 'messages');?>