Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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 609 to 641

Definition

 
function setLanguage()
    {
    global 
$browser_language,$disable_languages,$defaultlanguage,$languages,$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.
            # 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((string)$_GET["language"],$languages)) {return $_GET["language"];} 
    if (isset(
$_POST["language"]) && array_key_exists((string)$_POST["language"],$languages)) {return $_POST["language"];}
    if (isset(
$_COOKIE["language"]) && array_key_exists((string)$_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 22nd July 2024 21:35 Europe/London time based on the source file dated 3rd May 2024 14:45 Europe/London time.