Stud.IP  5.4
language.inc.php File Reference

Namespaces

 studip_core
 

Functions

 get_accepted_languages (Psr\Http\Message\RequestInterface $request=null)
 
 init_i18n ($_language)
 
 getUserLanguage ($uid)
 
 getUserLanguagePath ($uid)
 
 setTempLanguage ($uid=FALSE, $temp_language="")
 
 restoreLanguage ()
 
 setLocaleEnv ($language, $language_domain='')
 

Function Documentation

◆ get_accepted_languages()

get_accepted_languages ( Psr\Http\Message\RequestInterface  $request = null)

This function tries to find the preferred language

This function tries to find the preferred language. It returns the first accepted language from browser settings, which is installed.

public

Returns
string preferred user language, given in "en_GB"-style

◆ getUserLanguage()

getUserLanguage (   $uid)

retrieves preferred language of user from database, falls back to default language

public

Parameters
stringthe user_id of the user in question
Returns
string the preferred language of the user or the default language

◆ getUserLanguagePath()

getUserLanguagePath (   $uid)

Retrieves the path for the preferred language of a user which is specified by his/her ID.

This method can be used for sending language specific mails to other users.

Parameters
stringthe user_id of the recipient (function will try to get preferred language from database)
Returns
string the path to the language files, given in "en"-style

◆ init_i18n()

init_i18n (   $_language)

This function starts output via i18n system in the given language

This function starts output via i18n system in the given language. It returns the path to the choosen language.

public

Parameters
stringthe language to use for output, given in "en_GB"-style
Returns
string the path to the language file, given in "en"-style

◆ restoreLanguage()

restoreLanguage ( )

switch i18n back to original language

This function switches i18n system back to the original language. Should be called after writing strings to other users via setTempLanguage().

public

◆ setLocaleEnv()

setLocaleEnv (   $language,
  $language_domain = '' 
)

set locale to a given language and select translation domain

This function tries to set the appropriate environment variables and locale settings for the given language and also (optionally) sets the translation domain.

public

◆ setTempLanguage()

setTempLanguage (   $uid = FALSE,
  $temp_language = "" 
)

switch i18n to different language

This function switches i18n system to a different language. Should be called before writing strings to other users into database. Use restoreLanguage() to switch back.

public

Parameters
stringthe user_id of the recipient (function will try to get preferred language from database)
stringexplicit temporary language (set $uid to FALSE to switch to this language)