I have some pages of my site that I translate to other languages to make things easier for the end user and I have been doing it based on the country they are in. I found out recently that I can do it based on their browsers set language which would be better for me, so I was wondering how I can detect the browser language, and define content based on the the detected browser language. Here is what I'm currently using:
$eng = (isset($_GET['country']) && (
$_GET['country'] == 'AU' ||
$_GET['country'] == 'CA' ||
$_GET['country'] == 'UK' ||
$_GET['country'] == 'US'));
if ($eng)
{
$text1 = "Text 1 content goes here";
$text2 = "Text 2 content goes here";
$text3 = "Text 3 content goes here";
}
Instead of using countries, how do I use browser languages? For example in Canada they speak english in some places and french in another so I would like to display the correct language which I think is done with ISO Language codes but im not completely sure