Created
December 4, 2012 21:19
-
-
Save ptasker/4208792 to your computer and use it in GitHub Desktop.
Detect French browser lang
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
| <?php | |
| /** | |
| @uses CodeIgniter 2.1 | |
| Grab the user's language from the HTTP_ACCEPT_LANGUAGE string. | |
| */ | |
| if ( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) { | |
| $pieces = explode( ",", $_SERVER['HTTP_ACCEPT_LANGUAGE'] ); | |
| if ( isset( $pieces[0] ) && stristr($pieces[0], 'fr') ) { | |
| if ( !$this->input->get( 'lang' ) ) { | |
| redirect( "FRENCH URL" ); | |
| return; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment