yiisoft/yii — pull request #1673 by Rupert-RR (2012-11-08 13:38:43+00:00)
Title: CHttpRequest: Correct preference given to language in Accept-Language header, according to order in header. Store resulting sorted array of preferred languages for public access - useful for content negotiation.

By convention, when multiple languages are given with the same preference value in the Accept-Language header then the order of preference should correspond to the order in which they are given.
Currently CHttpRequest does not define any preference according to order when sorting languages after having parsed them.
This update creates a new variable to allow access to the sorted list of preferred languages (useful for content negotiation), and adds a very small decremental value to each language when parsing, so that earlier languages are given priority over later ones in the sort rather than relying on PHP's arsort to arbitrarily sort equal values.
Test with an Accept-Language header of "ru, en, en-GB, zh-Hans, ja, zh-Hant, fr, de, nl, it, es" (ru should be the preferred language rather than de).