I created a simple component in my Yii project and there is a text on it that needs to be translated using i18n feature of Yii
class MySimpleComponent{
public static function WelcomeCurrentUser(){
$wuser = Yii::t("lstrings","Welcome back ");
$wuser .= Yii::app()->session['curuser'];
return $wuser;
}
}
I invoke that small component function in one of my views.
echo MySimpleComponent::WelcomeCurrentUser();
but as i change the language in one of my controllers using the following code
Yii::app()->language = 'ja' //change language to japanese
the translation doesn’t work… I double check my i18n strings to ensure that messages are exact to each other and still doesn’t work.
this is my lstrings.php file
return array("Hello"=>"こんにちは",
"Welcome back "=>"お帰りなさい",
);
Any ideas why the translation does not work? any solutions? thanks