Yii Framework Forum: Internationalization - CDbMessageSource - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Internationalization - CDbMessageSource How do I tell Yii to use CDbMessageSource ? Rate Topic: ***** 1 Votes

#1 User is offline   DanielCarrera 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 11-January 09
  • Location:Earth

Posted 14 April 2010 - 07:25 AM

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.yiiframew...ide/topics.i18n
http://www.yiiframew...DbMessageSource

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.
0

#2 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 14 April 2010 - 07:30 AM

'components' => array(
   'messages' => array(
      'class' => 'CDbMessageSource',
      // config for db message source here, see http://www.yiiframework.com/doc/api/CDbMessageSource
   ),
),

1

#3 User is offline   DanielCarrera 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 83
  • Joined: 11-January 09
  • Location:Earth

Posted 14 April 2010 - 07:53 AM

Thanks!
0

#4 User is offline   gliderfree 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-October 13

Posted 22 October 2013 - 09:56 AM

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.yiiframew...DbMessageSource)
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!!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users