locale_accept_from_http is the base shell of the ICU API uloc_acceptLanguageFromHTTP , but the PHP / PECL implementation seems fundamentally wrong that it uses systems of the whole set of locales instead of taking the list as a parameter?
For example, the user has HTTP_ACCEPT_LANGUAGE = zh-HK;q=0.2, fr , that is, the user reads traditional Chinese or French, preferring the latter. You have, for example, a news site that offers articles in traditional Chinese and simplified Chinese. Using the Locale::acceptFromHttp will only return fr .
<?php var_dump (Locale::acceptFromHttp ("zh-HK;q=0.2,fr")); ?>
Outputs:
string(2) "fr"
Steve-o
source share