HTTP Language headers.
In php the way to get the language information sent by browser is with server reserved variables.

Which output (in my browsers):

  • ca,en-us;q=0.7,en;q=0.3 in Mozilla Firefox 13.0.1
  • es-ES in Internet Explorer 9 64b
  • ca-ES,ca;q=0.8 in Google Chrome 20.0

The "q-value" (when it's shown in a value range between 0-1) indicates the percent that the browser prefer this language. If it's not provided, we asume is 1 (maximum).

How to get the preferred language?
Here's a simple function I've coded to get the preferred language according q-value in ISO 639-1 format:

			$hi_code = substr($codelang,0,2);
			$hi_quof = $quoficient;
	return $hi_code;

echo "Your browser preferred language is: ".GetLanguageCodeISO6391();