locale_accept_from_http
is a basic wrapper around ICU's API uloc_acceptLanguageFromHTTP
but the PHP/PECL implementation seems fundamentally flawed that it uses the systems entire set of locales instead of taking a list as a parameter?
For example say a user has HTTP_ACCEPT_LANGUAGE = zh-HK;q=0.2, fr
, i.e. the user reads Traditional Chinese or French, preferring the latter. You have, for example, a news site that offers articles in say Traditional Chinese and Simplified Chinese. Using the API
Locale::acceptFromHttp
will only return fr
.
<?php
var_dump (Locale::acceptFromHttp ("zh-HK;q=0.2,fr"));
?>
Outputs:
string(2) "fr"