Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

setLanguage()

Description

Set the user's current language based on get/post/cookie values as appropriate.

Parameters

This function accepts no parameters.

Return

string The language string set

Location

include/language_functions.php lines 575 to 615

Definition

 
function setLanguage()
    {
    global 
$browser_language,$disable_languages,$defaultlanguage,$languages,$global_cookies,$baseurl_short;
    
$language="";
    if (isset(
$_GET["language_set"]))
        {
        
$language=$_GET["language_set"];
        if(
array_key_exists($language,$languages)) 
            {
            
# Cannot use the general.php: rs_setcookie() here since general may not have been included.
            
if ($global_cookies)
                {
                
# Remove previously set cookies to avoid clashes
                
setcookie("language"""time() - 3600$baseurl_short "pages/"''falsetrue);
                
setcookie("language"""time() - 3600$baseurl_short''falsetrue);
                
# Set new cookie
                
setcookie("language"$languagetime() + (3600*24*1000), "/"''falsetrue);
                }
            else
                {
                
# Set new cookie
                
setcookie("language"$languagetime() + (3600*24*1000));
                
setcookie("language"$languagetime() + (3600*24*1000), $baseurl_short "pages/"''falsetrue);
                }
            return 
$language;
            }
            else{
$language="";}
        }
    if (isset(
$_GET["language"]) && array_key_exists($_GET["language"],$languages)) {return $_GET["language"];}    
    if (isset(
$_POST["language"]) && array_key_exists($_POST["language"],$languages)) {return $_POST["language"];}
    if (isset(
$_COOKIE["language"]) && array_key_exists($_COOKIE["language"],$languages)) {return $_COOKIE["language"];}

    if(!
$disable_languages && $browser_language && isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
        {
        
$language http_get_preferred_language();
        if(!empty(
$language) && array_key_exists($language,$languages)){return $language;}
        } 
    if((
$disable_languages || $language ==="") && isset($defaultlanguage)) {return $defaultlanguage;}
    
# Final case.
    
return 'en';
    }

This article was last updated 11th July 2020 01:35 Europe/London time based on the source file dated 7th July 2020 14:31 Europe/London time.