PHP returns Accept-Languages ($_SERVER[‘HTTP_ACCEPT_LANGUAGE’]) in a format like “en-US”, “en”, “de-AT”. How can I convert them into a more readable format?
"en-US" -> "English USA"
"de-AT" -> "Österreichisch"
Is there a common way/function or do I have to look for a database (Whats the name of this format – is it ISO 639-1 with an optional region?!)?
If you’re using PHP 5.3.0 or above and have internationalisation extension installed then you can use
Localeclass or the corresponding procedural function:will output
(Inlt extension: http://pecl.php.net/package/intl)