I’ve just downloaded copy of yii framework and would like to change application default language.
According to documentation I’ve added ‘language’=>‘pl’ in main configuration file, but it does not change anything, all messages are still in english. I’ve also tried to copy messages file from framework dir do my application dir but it does not help.
When I put a call to method to show current language in template it shows correctly: pl, but messages are not translated
All texts in your views, controllers and model attributes need to be changed using the Yii::t() function. These function uses a file you should create in your messages directory having all translated messages.
Creating .php files works, creating .po files from .php the works too, when I comment ‘messages’ the translation comes out of .php files and work well (i.e. dirs are correct), need to make .po files work too.
Seems it is a configuration issues (sorry, downloaded yii first time only yesterday…), googling does not help, any comments appreciated…
I read that the catalog is to specify the default name of the file (messages) as it said in CGettextMessageSource.php file
* @var string the message catalog name. This is the name of the message file (without extension)
* that stores the translated messages. Defaults to 'messages'.
So this will not do anything.
I just add this small code in the main.php to set the default value if there is no cookie stored.
//set default language
if (!isset(Yii::app()->request->cookies['language']))
{ $daysExpires = 100;
Yii::app()->setLanguage('es');
$cookie = new CHttpCookie('language', 'es');
$cookie->expire = time() + 60 * 60 * 24 * $daysExpires;
Yii::app()->request->cookies['language'] = $cookie;
}