I'm currently working on a auto-user-language-detection for providing the content in the user's language.
of course its possible to change the language manually, but if a user visits the page for the first time I want to provide the content in his language.
So I was googling and found the $_SERVER['HTTP_ACCEPT_LANGUAGE']-Var to get a result like that:
de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
whats the best way to filter this result to get a clear result like "EN" / "DE" / "IT"?
$rL = $_SERVER["HTTP_ACCEPT_LANGUAGE"]; // de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
$langCode = strtoupper($rl[0].$rl[1]);
the second issue on this Server-Var is that its only give me a result if the browser provide some information. Is setting a default page language the only possibility to handle that?
The second possibility I'm interested in is to get the language by IP. So if I get the Language I probably know the language of the user. But whats in multi-language-countries like Switzerland, Belgium? Whats with tld's like .com / .net / .org and so on.
So which method would you apply to detect the users language?
thanks for helping.