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

Provides locale related features. More...

Public Member Functions

 __construct (protected 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

array $locale
 

Detailed Description

Provides locale related features.

Definition at line 13 of file LocaleService.php.

Constructor & Destructor Documentation

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

Create new service.

Parameters
Config$configElgg config

Definition at line 22 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 31 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 65 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 54 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 80 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 43 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 96 of file LocaleService.php.

Member Data Documentation

array Elgg\I18n\LocaleService::$locale
protected

Definition at line 15 of file LocaleService.php.


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