Best Dev Tutorials
Best Dev Tutorials

Reputation: 482

HTTP_ACCEPT_LANGUAGE always showing english

I'm trying to get the current user's language settings using:

$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);

When I VPN into another country, or even use geopeeker.com, I still get "en" when I echo out $lang.

Is this method not the best way of going about this? Or is my method of testing flawed?

Upvotes: 0

Views: 2350

Answers (2)

Ian Hunter
Ian Hunter

Reputation: 9774

This is based on your browser settings and is sent up in the request headers. See How to add custom Accept-Languages to Chrome for pseudolocalization testing? for changing your browser settings, or consider using something like curl to manually specify them.

Upvotes: 0

deceze
deceze

Reputation: 522442

The Accept-Language header is not set by the country you're visiting from, it's set by your browser. If you, with the same browser, VPN to another country, your browser will still send the same header. It's either a setting in your browser's preferences, or the browser takes it from the system's locale preferences.

Upvotes: 1

Related Questions