Hello!
A client wants to add a third language in her site, does anybody know how do I do that in localizer_init.php?
Thanks in advance!
Here’s the code:
indent preformatted text by 4 spaces
<?php
// Checking for locale and storing in session
session_start();
$locale = "";
// 1. url parameter
// if set, will overwrite stored locale in session
parse_str(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY));
if ($locale && strlen($locale) > 1) {
$locale = substr($locale, 0, 2);
}
// 2. session storage
// if no url parameter is given, check if there is already a stored locale in session
if (strlen($locale) == 0){
if ($_SESSION["locale"] && strlen($_SESSION["locale"]) == 2){
$locale = substr($_SESSION["locale"], 0, 2);
}
}
// 3. browser
// if no locale was given in url parameter or session, take browser locale
if (strlen($locale) == 0){
if ($_SERVER['HTTP_ACCEPT_LANGUAGE']) {
$locale = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
}
// 4. fallback
// if no language was given by the browser, set language to en
if (strlen($locale) == 0) {
$locale = "en";
}
$_SESSION["locale"] = $locale;
?>