I'm a beginner in YII framework (PHP) When creating a new site with YII, it will displayed with english page.
I want to change the default language to French, so pages will be displayed in French.
To change the language, set CApplication::language
appropriately. This can be done at runtime as in
Yii::app()->language = 'fr';
but usually it's done in your application configuration:
array(
// ...settings...
'language' => 'fr',
// ...more settings...
)
and so you can set the default languages in the config/main.php as
return array(
...
'sourceLanguage' => 'fr',
'language'=>'en',
...
'params' => array(
...
'languages'=>array('en_us'=>'English', 'fr'=>'French', 'fa_ir'=>'فارسی'),
....
),
);
and change your language everywhere you like:
Yii::app()->language = Yii::app()->params->languages['fa_ir'];
or more:
Yii::app()->language = Yii::app()->params->languages[$_GET['lang']];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With