I\'m trying to build multilangual site.
I use this piece of code to detect users language. If you havent chosen a language, it will include your language file based
I know there already many good solutions, but have found my own way to solve this problem.
float 1
'en' => float 0.8
'uk' => float 0.6
'ru' => float 0.4
*/
Code will convert HTTP_ACCEPT_LANGUAGE string to array with locales as keys and weight as values, sorted from high value to low. So you can just get one by one with array_shift to get the best match with your site locales.