Created
July 7, 2011 15:27
-
-
Save aabril/1069760 to your computer and use it in GitHub Desktop.
CodeIgniter method that extends Language.php for get the language by browser.
This file contains hidden or 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
| public function get_langname_byBrowser() | |
| { | |
| $this->CI = & get_instance(); | |
| // inicializamos, por si no detecta ninguna el navegador | |
| $name = ""; | |
| //prepare user language array | |
| $languages = array(); | |
| $languages[0] = ''; | |
| //check to see if language is set | |
| if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) ) | |
| { | |
| //explode languages into array | |
| $languages = strtolower( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ); | |
| $languages = explode( ",", $languages ); | |
| } | |
| $pos = strpos(strtolower($languages[0]),'es'); | |
| if ( $pos !== false ) | |
| $name = "spanish"; | |
| else | |
| $name = "english"; | |
| return $name; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment