Elgg  Version 3.0
Public Member Functions | Protected Attributes | List of all members
Elgg\I18n\LocaleService Class Reference

Provides locale related features. More...

Public Member Functions

 __construct (Config $config)
 Create new service. More...
 
 getLanguageCodes ()
 Returns a list of supported laguage codes. More...
 
 setLocaleForLanguage (string $language, array $locale=[])
 Set the locale settings for a language key. More...
 
 getLocaleForLanguage (string $language)
 Returns the configured locale settings for a given language key. More...
 
 getLocale (int $category)
 Get the current locale. More...
 
 setLocale (int $category, $locale)
 Set the system locale to a new value, return the locale before the change. More...
 
 setLocaleFromLanguageKey (int $category, string $language=null)
 Set the locale from a language key. More...
 

Protected Attributes

 $config
 
 $locale
 

Detailed Description

Provides locale related features.

Definition at line 13 of file LocaleService.php.

Constructor & Destructor Documentation

Elgg\I18n\LocaleService::__construct ( Config  $config)

Create new service.

Parameters
Config$configElgg config

Definition at line 30 of file LocaleService.php.

Member Function Documentation

Elgg\I18n\LocaleService::getLanguageCodes ( )

Returns a list of supported laguage codes.

Mostly based on ISO-639-1

Returns
array

Definition at line 41 of file LocaleService.php.

Elgg\I18n\LocaleService::getLocale ( int  $category)

Get the current locale.

Parameters
int$categorywhich locale setting should be returned
Returns
array

Definition at line 75 of file LocaleService.php.

Elgg\I18n\LocaleService::getLocaleForLanguage ( string  $language)

Returns the configured locale settings for a given language key.

Parameters
string$languagethe language key (eg. 'en')
Returns
array

Definition at line 64 of file LocaleService.php.

Elgg\I18n\LocaleService::setLocale ( int  $category,
  $locale 
)

Set the system locale to a new value, return the locale before the change.

Parameters
int$categorywhich locale setting should be affected
string | array$localethe new locale
See also
setlocale()
https://secure.php.net/manual/en/function.setlocale.php
Returns
string[]

Definition at line 90 of file LocaleService.php.

Elgg\I18n\LocaleService::setLocaleForLanguage ( string  $language,
array  $locale = [] 
)

Set the locale settings for a language key.

Parameters
string$languagethe language key (eg. 'en')
array$localethe locale settings (eg. ['en_US'])
Returns
void

Definition at line 53 of file LocaleService.php.

Elgg\I18n\LocaleService::setLocaleFromLanguageKey ( int  $category,
string  $language = null 
)

Set the locale from a language key.

The key will be mapped to the configured locale settings

Parameters
int$categorywhich locale settings should be affected
string$languagethe language te set the locale for (default: current language)
Returns
string[]

Definition at line 106 of file LocaleService.php.

Member Data Documentation

Elgg\I18n\LocaleService::$config
protected

Definition at line 18 of file LocaleService.php.

Elgg\I18n\LocaleService::$locale
protected

Definition at line 23 of file LocaleService.php.


The documentation for this class was generated from the following file: