Modules and message translation

Hi, am a newbie to Yii and I have an issue regarding message translation!

I have created a module name Site and in SiteModule class init() function I set the user language

if (true===isset($_GET['lang']) && true === Language::Exists($_GET['lang'])) {


			Yii::app()->setLanguage($_GET['lang']);	


		}

My localized message file is located in

WebRoot/protected/messages/el/site.php

I also set the application language and the application source language in

WebRoot/protected/config/main.php



language'=>'el',


'sourceLanguage'=>'en',

Although the CPhpMessageSource object seams to load the correct translated messages, the Yii::t() command doesn’t translate the message!

Any suggestions anyone?

Thanks in advance

I kept the default source language (us_en) and use Yii::t() to get "translated" strings (and views) from en and sv subdirs. (IIRC from testing, if a translated view isn't available the default will be used.)

/Tommy

Still, it doesn' t translate the messages! Thanks anyway…

Quote

Hi, am a newbie to Yii and I have an issue regarding message translation!

I have created a module name Site and in SiteModule class init() function I set the user language

if (true===isset($_GET['lang']) && true === Language::Exists($_GET['lang'])) {


			Yii::app()->setLanguage($_GET['lang']);	


		}

I'm a newbie too and this code (put in SiteController->init()) raise an error

Quote

Class 'Language' not found

are you sure?

this is my code and it works



class SiteController extends Controller


{


        public function init() {


                $language = Yii::app()->getLanguage();





                // Changed the language right now?


                if(isset($_GET['lang']) && $_GET['lang'] != '') {


                        $language = trim($_GET['lang']);


                        # Save in cookie


                        $cookie = new CHttpCookie('lang', $_GET['lang']);


                        $cookie->expire = time()+60*60*24*180;


                        Yii::app()->request->cookies['lang'] = $cookie;


                // Do we have a cookie for the language?


                } elseif(Yii::app()->request->cookies['lang']->value!='') {


                        $language = Yii::app()->request->cookies['lang']->value;


                }


                // TODO: check if the language exists 


                // Set the language


                Yii::app()->setLanguage($language);


        }


...


Where did you define the Language class?