Selecting best language based on Browser language and available languages.

Comparing #1 with #2

Content

[...]
At the time of writing, the code is not very much tested in production, but some small tests indicate it is ok.

You can call this code in an 'onBeginRequest' [as is suggested in this forum entry](http://www.yiiframework.com/forum/index.php/topic/48501-detecting-browser-language-onbeginrequest/ "Forum entry") or in another location that may be more appropriate for you.

 
```php 
class Utils {

 
Generally you'ld call 'Utils::setLanguageFromBrowser()'.  Change the class name to your likings, or include in your Utility class.
 
 
 
```php 
class Utils {
 
    /**
 
     * Set the best language based on browser request.
 
     */
 
    public static function setLanguageFromBrowser() {
 
        Yii::app()->setLanguage(self::getBestLanguageFromBrowser());
 
    }
 

/**
* Determine the best language base on browser preferences.
*
* @return string
*/
[...]