You can detect browser language using PHP global variable $_SERVER, exactly $_SERVER
EXAMPLES:
1.
<?php
$BLang= Locale::acceptFromHttp($_SERVER);
echo $BLang; // Return: en
?>
2.
<?php
$BLang= locale_accept_from_http($_SERVER);
echo $BLang; // Return: en
?>
3. Using substr...