Cradle  0.3.3
Simple library for creating Web-based applications
Language Class Reference

Languge functions. More...

Static Public Member Functions

static getLanguageCode ($lang)
 
static isLanguageAcceptable ($inputLang)
 
static setLanguage ($inputLang)
 
static getUserAcceptLanguages ()
 
static getUserAcceptLanguage ()
 
static getLanguage ($shortForm=null, $acceptableLanguages=null)
 
static getLocale ()
 
static getLocales ($filter=null)
 

Static Public Attributes

static $cookieLanguageKey = 'language'
 
static $languages
 
static $shortForm = false
 
static $delimiter = '-'
 

Detailed Description

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

Member Function Documentation

static getLanguage (   $shortForm = null,
  $acceptableLanguages = null 
)
static

Returns the code of current language (selected by user or default)

Parameters
boolean$shortFormTRUE is 2-symbols form (en|ru|...). FALSE is 5-symbols form (en-US|ru-RU|...).
array$acceptableLanguagesList 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$langInput 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 | ... )
static getLocale ( )
static

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$inputLangInput 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$inputLangValue of HTML tag "lang" (en|ru|en-US|ru-RU|...)
Returns
string Locale code on success

Field Documentation

$cookieLanguageKey = 'language'
static

string Cookie language key (to determine user's selection)

$delimiter = '-'
static

string Language code delimiter

$languages
static
Initial value:
= [
"en",
"ru",
]

array List of acceptable languages. The first in list is the default.

$shortForm = false
static

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: