Created
May 18, 2016 08:52
-
-
Save dagostoni/20b40eec9f5d3793195b7e1f8e9b7c9c to your computer and use it in GitHub Desktop.
lang detection PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$detected_lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); | |
switch ($detected_lang){ | |
case "fr": | |
$_REQUEST['lang'] = 'fr'; | |
break; | |
case "de": | |
$_REQUEST['lang'] = 'de'; | |
break; | |
case "es": | |
$_REQUEST['lang'] = 'es'; | |
break; | |
case "en": | |
$_REQUEST['lang'] = 'en'; | |
break; | |
default: | |
$_REQUEST['lang'] = 'it'; | |
break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment