Closed HankBrown closed 7 years ago
The app
and yii
message category is configured default by the Yii 2 to use the files shipped with the framework. Try to use another message category for your messages, or overwrite the i18n config for these categories like this:
'i18n' => [
'translations' => [
'*' => [
'db' => 'dbFOX',
'class' => 'yii\i18n\DbMessageSource',
'sourceLanguage' => 'en-US', // Developer language
'sourceMessageTable' => '{{%language_source}}',
'messageTable' => '{{%language_translate}}',
'cachingDuration' => 86400,
'enableCaching' => false, // Hmmm guessing while dev/implement
//'forceTranslation' => true, // NOPE
],
'app' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'dbFOX',
'sourceLanguage' => 'en-US', // Developer language
'sourceMessageTable' => '{{%language_source}}',
'messageTable' => '{{%language_translate}}',
'cachingDuration' => 86400,
'enableCaching' => false,
],
'yii' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'dbFOX',
'sourceLanguage' => 'en-US', // Developer language
'sourceMessageTable' => '{{%language_source}}',
'messageTable' => '{{%language_translate}}',
'cachingDuration' => 86400,
'enableCaching' => false,
],
],
],
Thank you so much moltam. You beat me to the punch by a minute ;) I saw this as a previous issue but it did not register with me.
No problem :-)
Help please. I am not seeing any translations.
In the database I have:
category='app', message='Apple' in language_source table.
language='fr-FR', translation='Pomme de terre' in language_translate table.
To test, I have SiteController init:
The view has:
By inserting some debug I can see the translations were not loaded (I think):
In the app log I find this sql:
(SELECT
t1
.message
ASmessage
,t2
.translation
AStranslation
FROMlanguage_source
t1
,language_translate
t2
WHERE (t1
.id
=t2
.id
) AND (t1
.category
='language') AND (t2
.language
='fr-FR')) UNION ALL ( SELECTt1
.message
ASmessage
,t2
.translation
AStranslation
FROMlanguage_source
t1
,language_translate
t2
WHERE ((t1
.id
=t2
.id
) AND (t1
.category
='language') AND (t2
.language
='fr')) AND (t2
.id
NOT IN (SELECTid
FROMlanguage_translate
WHERElanguage
='fr-FR')) )I notice the occurrence of 'fr' instead of 'fr-FR' in the query. Nowhere do I use 'fr' instead of 'fr-FR'. This returns the expected result in phpMyAdmin when I manually change
a) 'language' to 'app', and b) 'fr' to 'fr-FR;
2017-01-11 10:30:57 [192.168.56.1][1][-][error][yii\i18n\PhpMessageSource::loadFallbackMessages] The message file for category 'app' does not exist: /home/me/sites/www/frontend/messages/fr-FR/app.php Fallback file does not exist as well: /home/me/sites/www/frontend/messages/fr/app.php in /home/me/sites/www/vendor/lajax/yii2-translate-manager/helpers/Language.php:55
This confuses me, I have only DbMessageSource configured.
I am sure this is a simple/stupid error but I am lost.
Config is
Any suggestions much appreciated. Thank you.
Later: change config (remove asterisk, replace with category names) and I see translations:
So I know what I am chasing maybe. Why would '*' fail?