PHP Class SimpleSAML\Locale\Language

Afficher le fichier Open project: simplesamlphp/simplesamlphp Class Usage Examples

Méthodes publiques

Méthode 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

Méthode 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 méthode

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

getDefaultLanguage() public méthode

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

getLanguage() public méthode

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
Résultat string The language selected by the user according to the processing rules specified, or the default language in any other case.

getLanguageCodeAlias() public méthode

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

getLanguageCookie() public static méthode

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

getLanguageList() public méthode

Return an indexed list of all languages available.
public getLanguageList ( ) : array
Résultat 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 méthode

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.
Résultat string The localized name of the language.

getLanguageParameterName() public méthode

Get the language parameter name.
public getLanguageParameterName ( ) : string
Résultat string The language parameter name.

getPosixLanguage() public méthode

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

isLanguageRTL() public méthode

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

setLanguage() public méthode

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 méthode

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.