In this previous questions, someone told me how to make WPLANG clickleable, so that the user can choose his preferred language (usually you can only define WPLANG by modifying the wp-config). But I'm sure how to make the link. Are the following functions giving me the possibility of using example/?lang=
Or example/en
?
*wp-lang.php
session_start();
if ( isset( $_GET['lang'] ) ) {
$_SESSION['WPLANG'] = $_GET['lang'];
define ('WPLANG', $_SESSION[WPLANG]);
} else {
if(isset($_SESSION['WPLANG'])) {
define ('WPLANG', $_SESSION['WPLANG']);
$_GET['lang'] = $_SESSION['WPLANG'];
} else {
if ( isset( $_SERVER["HTTP_ACCEPT_LANGUAGE"] ) ) {
$languages = strtolower( $_SERVER["HTTP_ACCEPT_LANGUAGE"] );
$languages = explode( ",", $languages );
$_SESSION['WPLANG'] = $languages[0];
$_SESSION['WPLANG'] = str_replace("-", "_", $_SESSION['WPLANG']);
$_GET['lang'] = substr($_SESSION['WPLANG'],0,2);
define ('WPLANG', $_SESSION[WPLANG]);
} else {
define ('WPLANG', '');
}
}
}
*wp-config.php - Find the section where the constant WPLANG is defined. Add in the following line just before the WPLANG declaration.
require_once(dirname(__FILE__).'/wp-lang.php');
define ('WPLANG', '');