Changes
Title
unchanged
Setting and maintaining the language in Application (i18n)
Category
unchanged
Tutorials
Yii version
unchanged
Tags
changed
i18n, translation
Content
changed
As seen in [this](http://www.yiiframework.com/forum/index.php/topic,1034.msg5968.html#msg5968) post, Yii doesn't enforce how language is set and maintained within the session.
According to that post, the preferred method is to create a base controller which implements code for maintaining the language state. That Controller is then used in your code instead of CControler
. (by defing your classes with "class ... extends *MyController*")
Here's my method of implementing this idea:[...]
```php
<?php
class LangBox extends CWidget
{
public function run()[...]
}
}
?>
```
**components/views/langBox.php**
```php
<?
=php echo CHtml::form()
; ?>
<div id="langdrop">
<?
=php echo CHtml::dropDownList('_lang', $currentLang, array(
'en_us' => 'English', 'is_is' => 'Icelandic'), array('submit' => ''))
; ?>
</div>
<
/form>
```
?php echo CHtml::endForm(); ?>
```
See also
------------------
- [Here](http://www.yiiframework.com/wiki/208/how-to-use-an-application-behavior-to-maintain-runtime-configuration/ "How to use an application behavior to maintain runtime configuration") is another approach using behaviors.
Links
-----
- [Chinese version](http://www.itkuaixun.com/bbs/thread-203-1-1.html "Chinese version")