Languge functions.
More...
Languge functions.
Class with methods to operate with user language.
- Version
- 1.0
- Author
- Digger mrdig.nosp@m.ger@.nosp@m.sad-s.nosp@m.yste.nosp@m.ms.ru
- Copyright
- (c) 2015, SAD-Systems
static getLanguage |
( |
|
$shortForm = null , |
|
|
|
$acceptableLanguages = null |
|
) |
| |
|
static |
Returns the code of current language (selected by user or default)
- Parameters
-
boolean | $shortForm | TRUE is 2-symbols form (en|ru|...). FALSE is 5-symbols form (en-US|ru-RU|...). |
array | $acceptableLanguages | List of acceptable languages. The first in list is the default. |
- Returns
- string The code of current language. Can be 2-symbols form (en|ru|...) or 5-symbols form (en-US|ru-RU|...) depending on the $shortForm value.
- See also
- $shortForm
static getLanguageCode |
( |
|
$lang | ) |
|
|
static |
Converts the input language code to the standard form (language-COUNTRY)
- Parameters
-
string | $lang | Input language code - two letters or languge pair ( en | en-us | en_US | ru | ru-RU | ... ) |
- Returns
- string Language output code: language-COUNTRY ( en-US | ru-RU | ... )
Returns current system locale.
- Returns
- string The current system locale
static getLocales |
( |
|
$filter = null | ) |
|
|
static |
Returns locales list of current server.
- Returns
- array Locales list of current server
static getUserAcceptLanguage |
( |
| ) |
|
|
static |
Returns user's most accepted language
- Returns
- string 2-symbols code of user's most accepted language
static getUserAcceptLanguages |
( |
| ) |
|
|
static |
Returns language list accepted by user
- Returns
- array language list accepted by user
static isLanguageAcceptable |
( |
|
$inputLang | ) |
|
|
static |
Checks is the input language present in the acceptable list (in array $languages).
- Parameters
-
string | $inputLang | Input language code - two letters or languge pair ( en | en-us | en_US | ru | ru-RU | ... ) |
- Returns
- boolean|string FALSE | "standard language code"
static setLanguage |
( |
|
$inputLang | ) |
|
|
static |
Set current language and locale
- Parameters
-
string | $inputLang | Value of HTML tag "lang" (en|ru|en-US|ru-RU|...) |
- Returns
- string Locale code on success
$cookieLanguageKey = 'language' |
|
static |
string Cookie language key (to determine user's selection)
Initial value:array List of acceptable languages. The first in list is the default.
boolean Short form of language code.
- See also
- getLanguage
TRUE is 2-symbols form (en|ru|...). FALSE is 5-symbols form (en-US|ru-RU|...).
The documentation for this class was generated from the following file: