Yii Framework Forum: Multiple message source for I18n - Yii Framework Forum

Jump to content

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

Multiple message source for I18n Rate Topic: -----

#1 User is offline   Francois Allard 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 26-February 10
  • Location:Montreal, Canada

Posted 02 March 2010 - 08:39 AM

I was wondering if its possible to have multiple message source for the translation. I want to have my menu translate using CDbMessageSource, and the rest using CGettextMessageSource.

From what I read, we can only specify one source in the configuration.

Thank you!
0

#2 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 02 March 2010 - 09:17 AM

You need to specify 4-param for Yii::t() function (check the signature), and then configurate provider for you messages:

Yii::t('menu',"My first Menu Item",array(),"menuMessages");


in config:
 'menuMessages' => array(
   'class' => 'CDbMessageSource',
   ...
 ),

-Posted Image-
Thanks, you make me stronger!
0

#3 User is offline   Francois Allard 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 26-February 10
  • Location:Montreal, Canada

Posted 02 March 2010 - 09:35 AM

View Postvamp, on 02 March 2010 - 09:17 AM, said:

You need to specify 4-param for Yii::t() function (check the signature), and then configurate provider for you messages:

Yii::t('menu',"My first Menu Item",array(),"menuMessages");


in config:
 'menuMessages' => array(
   'class' => 'CDbMessageSource',
   ...
 ),


Thank you, it works perfectly. I think I tried it and I got a bug, so I thought it couldn't work like that. I should have investigate more :)
0

#4 User is offline   vamp 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 181
  • Joined: 30-January 09

Posted 02 March 2010 - 09:43 AM

View PostFrancois Allard, on 02 March 2010 - 09:35 AM, said:

Thank you, it works perfectly. I think I tried it and I got a bug, so I thought it couldn't work like that. I should have investigate more :)


You didn't create following tables:
SourceMessage
  id
  category
  message

Message
  id
  language
  translation

-Posted Image-
Thanks, you make me stronger!
0

#5 User is offline   Francois Allard 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 26-February 10
  • Location:Montreal, Canada

Posted 02 March 2010 - 10:00 AM

View Postvamp, on 02 March 2010 - 09:43 AM, said:

You didn't create following tables:
SourceMessage
  id
  category
  message

Message
  id
  language
  translation



No, that wasn't the problem. The translation from the database was working. I was getting an error when entering the source parameter in Yii::t(), but now it works :)

Edit: Oh, I remember what I did. When I put the source parameter in t(), I forgot to put the array parameter just before it.
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