Last active
September 18, 2018 15:44
-
-
Save cubehrends/364f2044cd31729662eb2555149fda0f to your computer and use it in GitHub Desktop.
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 | |
if ( $_GET ) { | |
$lang = set_lang( key($_GET) ); | |
} else if ( isset($_COOKIE['lang']) ) { | |
$lang = $_COOKIE['lang']; | |
} else { | |
$lang = set_lang( substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) ); | |
} | |
function set_lang( $l ) { | |
switch ( $l ) { | |
case 'de': | |
break; | |
case 'fr': | |
break; | |
default: | |
$l = 'en'; | |
} | |
setcookie('lang', $l, time()+3600, '/'); | |
return $l; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple language selection for On-Pager to use with e.g. Bootstrap.