Hi all!
I read many posts, forums, google but nothing help in this problem…
I would like to translate my app with .po and .mo files.
My setup with PhpMessageSource working fine, but its not editable easily.
When i change the settings to GettextMessageSource the text in my php file not translate anymore.
I have 3 questions.
-
Can i use PoEdit for read and translate this? <?= \Yii::t(‘app’, ‘try’); ?> And if can, how can i read the texts?
-
What is the wrong in my settings?
-
If i only use .po file without .mo i get an error message because of missing .mo file. Is this normal?
I have an advanced application.
Here is my common/config/main-locale.php
return [
'bootstrap' => ['localeUrls'],
'language'=> 'en',
'sourceLanguage' => 'en',
'components' => [
[...]
// URL handler
'localeUrls' => [
'class' => 'codemix\localeurls\LocaleUrls',
// List all supported languages here
'languages' => ['en_US','en','hu_HU','hu']
],
// Override the urlManager component
'urlManager' => [
'class' => 'codemix\localeurls\UrlManager',
'showScriptName' => false,
'enablePrettyUrl' => true,
],
// language files
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\GettextMessageSource',
'basePath' => '@common/messages',
'sourceLanguage' => 'en',
],
],
],
],
];
This is my messages.po in common/messages/hu/messages.po
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2015-02-15 19:16+0100\n"
"PO-Revision-Date: 2015-02-15 19:20+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: hu_HU\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.7.4\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: C:\\test\\advanced\\frontend\n"
msgctxt "app"
msgid "try"
msgstr "Próba"
And here is a sample txt in /fontend/views/site/index.php
<?= \Yii::t('app', 'try'); ?>
The "try" txt allways appears in english, but the system return hu language code.
So i don’t know what do i wrong.
Can anybody help me?
Thank you,