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.)
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);
}
...