Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 616 to 648

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 17th November 2024 15:35 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.