Hello,
I want to have translations of my website but I can’t figure out how to tell Yii to use the database as the message source.
I have read the documentation as best I can:
http://www.yiiframework.com/doc/guide/topics.i18n
http://www.yiiframework.com/doc/api/CDbMessageSource
I have created the tables in the database. I have a sample string in the category ‘UI’ and a translation to language ‘es’. I have edited config/main.php with:
<?php
'sourceLanguage' => 'en',
'language' => 'es',
I have a view with a sample string to translate: <?= Yii::t(‘UI’, ‘foo’) ?>
But I can’t figure out how to tell Yii to use the database (CDbMessageSource) instead of the default CPhpMessageSource.
Can anyone help me?
Any help would be really appreciated.
Y11
(Y!!)
April 14, 2010, 12:30pm
2
'components' => array(
'messages' => array(
'class' => 'CDbMessageSource',
// config for db message source here, see http://www.yiiframework.com/doc/api/CDbMessageSource
),
),
gliderfree
(Gliderfree)
October 22, 2013, 2:56pm
4
hi,
it works for Daniel
but not for me…
I just try to use ‘class’ => ‘CDbMessageSource’, and it does not work…
When i changed to
‘class’ => ‘CPhpMessageSource’, and
‘class’ => ‘CMessageSource’,
its working fine.
I follow every instructions steps before, (http://www.yiiframework.com/doc/api/CDbMessageSource )
including the creation of table data base.
it seems that i have missed something!
every page show fine, but are not translated.
if i change to one of the two classes using files, there’s no problem.
maybe Someone ca help!
Thanks!!