PHP Class SimpleSAML\Locale\Language

Show file Open project: simplesamlphp/simplesamlphp Class Usage Examples

Public Methods

Method Description
__construct ( SimpleSAML_Configuration $configuration ) Constructor
getDefaultLanguage ( ) : string Return the default language according to configuration.
getLanguage ( ) : string This method will return the language selected by the user, or the default language. It looks first for a cached language code, then checks for a language cookie, then it tries to calculate the preferred language from HTTP headers.
getLanguageCodeAlias ( $langcode ) : string Return an alias for a langcode, if any
getLanguageCookie ( ) : string | null Retrieve the user-selected language from a cookie.
getLanguageList ( ) : array Return an indexed list of all languages available.
getLanguageLocalizedName ( string $code ) : string Get the localized name of a language, by ISO 639-2 code.
getLanguageParameterName ( ) : string Get the language parameter name.
getPosixLanguage ( $language ) * Rename to non-idiosyncratic language code
isLanguageRTL ( ) : boolean Check whether a language is written from the right to the left or not.
setLanguage ( string $language, boolean $setLanguageCookie = true ) This method will set a cookie for the user's browser to remember what language was selected.
setLanguageCookie ( string $language ) This method will attempt to set the user-selected language in a cookie. It will do nothing if the language specified is not in the list of available languages, or the headers have already been sent to the browser.

Private Methods

Method Description
getHTTPLanguage ( ) : string This method returns the preferred language for the user based on the Accept-Language HTTP header.
getInstalledLanguages ( ) : array Wash configured (available) languages against installed languages

Method Details

__construct() public method

Constructor
public __construct ( SimpleSAML_Configuration $configuration )
$configuration SimpleSAML_Configuration Configuration object

getDefaultLanguage() public method

Return the default language according to configuration.
public getDefaultLanguage ( ) : string
return string The default language that has been configured. Defaults to english if not configured.

getLanguage() public method

This method will return the language selected by the user, or the default language. It looks first for a cached language code, then checks for a language cookie, then it tries to calculate the preferred language from HTTP headers.
public getLanguage ( ) : string
return string The language selected by the user according to the processing rules specified, or the default language in any other case.

getLanguageCodeAlias() public method

Return an alias for a langcode, if any
public getLanguageCodeAlias ( $langcode ) : string
return string The alias, or null if alias not found

getLanguageCookie() public static method

Retrieve the user-selected language from a cookie.
public static getLanguageCookie ( ) : string | null
return string | null The selected language or null if unset.

getLanguageList() public method

Return an indexed list of all languages available.
public getLanguageList ( ) : array
return array An array holding all the languages available as the keys of the array. The value for each key is true in case that the language specified by that key is currently active, or false otherwise.

getLanguageLocalizedName() public method

Get the localized name of a language, by ISO 639-2 code.
public getLanguageLocalizedName ( string $code ) : string
$code string The ISO 639-2 code of the language.
return string The localized name of the language.

getLanguageParameterName() public method

Get the language parameter name.
public getLanguageParameterName ( ) : string
return string The language parameter name.

getPosixLanguage() public method

* Rename to non-idiosyncratic language code
public getPosixLanguage ( $language )
$language Language code for the language to rename, if neccesary.

isLanguageRTL() public method

Check whether a language is written from the right to the left or not.
public isLanguageRTL ( ) : boolean
return boolean True if the language is right-to-left, false otherwise.

setLanguage() public method

This method will set a cookie for the user's browser to remember what language was selected.
public setLanguage ( string $language, boolean $setLanguageCookie = true )
$language string Language code for the language to set.
$setLanguageCookie boolean Whether to set the language cookie or not. Defaults to true.

setLanguageCookie() public static method

This method will attempt to set the user-selected language in a cookie. It will do nothing if the language specified is not in the list of available languages, or the headers have already been sent to the browser.
public static setLanguageCookie ( string $language )
$language string The language set by the user.