Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function idioma() {
- $http_accept = getenv('HTTP_ACCEPT_LANGUAGE');
- if (isset($http_accept) && strlen($http_accept) > 1) {
- $x = explode(",", $http_accept);
- foreach ($x as $val) {
- if (preg_match("/(.*);q=([0-1]{0,1}.d{0,4})/i", $val, $matches))
- $lang[$matches[1]] = (float) $matches[2];
- else
- $lang[$val] = 1.0;
- }
- $qval = 0.0;
- foreach ($lang as $key => $value) {
- if ($value > $qval) {
- $qval = (float) $value;
- return $key;
- }
- }
- }
- return self::$tag_default;
- }
- switch (idioma()) {
- case "pt-BR":
- case "pt": header('Location: http://pt.dominio.com');
- break;
- case 'en-us': header('Location: index.php');
- break;
- case 'es': header('Location: http://es.dominio.com');
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment