Setlocale from browser?!?

I can’t figure this out… If I set locale like this:

setlocale(LC_ALL, "da_DK");

…it works just fine, but when I try to do it like this:

$browsLocale = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
$browsLocale = substr($browsLocale, 0, 5);
setlocale(LC_ALL, $browsLocale);

…it doesn’t work even though the $browsLocale comes out like da_DK!!!

Can anybody tell me what I’m doing wrong…

Thanks in advance :slight_smile:

$browsLocale = substr($browsLocale, 0, 4);

Thought substr was pulling an extra character, silly me :lol:

Did you read the documentation?

Contents of the Accept-Language: header from the current request, if there is one. Example: ‘en’.

Don’t see what difference this makes other than it becomes da-D instead of da-DK?