Yii Framework Forum: Using the t() function with databases? - Yii Framework Forum

Jump to content

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

Using the t() function with databases? Rate Topic: -----

#1 User is offline   DieJay 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 13-August 12

Posted 20 August 2012 - 01:24 PM

The database for my Yii application has two tables for translating words and short messages. One, called "labels" contains the keyword's id and name, while the other, "labelsLang", contains the translated keywords. The structure looks like this;

CREATE TABLE IF NOT EXISTS `labels` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `tag` varchar(200),
  PRIMARY KEY (`id`)
)

INSERT INTO `labels` (`id`, `tag`) VALUES
(1, 'Welcome'),
(2, 'Goodbye'),
(3, 'Thank you'),...

CREATE TABLE IF NOT EXISTS `labelsLang` (
  `l_id` int(10) NOT NULL AUTO_INCREMENT,
  `label_id` int(10) NOT NULL,
  `lang_id` varchar(6),
  `l_tag` varchar(200),
  PRIMARY KEY (`l_id`),
  KEY `lang_id` (`lang_id`),
  KEY `traduction_id` (`label_id`)
)

INSERT INTO `smcms_traductionslang` (`l_id`, `label_id`, `lang_id`, `l_tag`, `l_val`) VALUES
(1, 1, 'fr', 'Bienvenue'),
(2, 1, 'en', 'Welcome'),
(3, 1, 'es', 'Hola'),
(4, 1, 'it', 'Buongiorno'),
(5, 2, 'fr', 'Au revoir'),...


I'd like to be able to use the t() function to translate these keywords throughout the site, as I heard it's incredibly useful and everything, but I haven't found any examples on how to do this. Could anyone help me out with this, please?
0

#2 User is offline   Roman Solomatin 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 176
  • Joined: 21-October 10
  • Location:Tallinn, Estonia

Posted 22 August 2012 - 06:17 PM

Have you tried using the CDbMessageSource class?
http://www.yiiframew...bMessageSource/
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