Class: I2CE Locales (Development): Difference between revisions

From IHRIS Wiki
(Created page with '{{otherversions|Class: I2CE_Locales}} This article describes the class ''I2CE_Locales'' . *Location: Part of the module I2CE in the packag…')
 
No edit summary
 
Line 1: Line 1:
{{otherversions|Class: I2CE_Locales}}
{{otherversions|Class: I2CE_Locales}}
This article describes the class ''I2CE_Locales'' .
This article describes the class ''I2CE_Locales'' .
*Location: Part of the module [[I2CE Module List (Development)#I2CE|I2CE]] in the package [https://launchpad.net/i2ce I2CE] 4.0-dev
*Location: Part of the module [[I2CE Module List (Development)#I2CE|I2CE]] in the package [https://launchpad.net/i2ce I2CE] 4.1-dev
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L37 lib/I2CE_Locales.php] on line 37
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L37 lib/I2CE_Locales.php] on line 37
I2CE_Locales  @todo Better Documentation
I2CE_Locales  @todo Better Documentation
==Constants==
==Constants==
Line 11: Line 11:
==Variables==
==Variables==
===$request_locale===
===$request_locale===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L110 i2ce/lib/I2CE_Locales.php] on line 110
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L110 i2ce/lib/I2CE_Locales.php] on line 110
*Type: static protected $request_locale
*Type: static protected $request_locale


===$preferred_locale===
===$preferred_locale===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L201 i2ce/lib/I2CE_Locales.php] on line 201
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L201 i2ce/lib/I2CE_Locales.php] on line 201
*Type: static protected $preferred_locale
*Type: static protected $preferred_locale


==Methods==
==Methods==
===ensureSelectableLocale()===
===ensureSelectableLocale()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L84 i2ce/lib/I2CE_Locales.php] on line 84
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L84 i2ce/lib/I2CE_Locales.php] on line 84
*Signature: static public function ensureSelectableLocale($locale,$fallback_site_preferred)
*Signature: static public function ensureSelectableLocale($locale,$fallback_site_preferred)
*Parameters:
*Parameters:
Line 27: Line 27:
***Default Value: true
***Default Value: true
===ensureValidResolution()===
===ensureValidResolution()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L334 i2ce/lib/I2CE_Locales.php] on line 334
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L334 i2ce/lib/I2CE_Locales.php] on line 334
*Signature: static public function ensureValidResolution($locale,$resolution)
*Signature: static public function ensureValidResolution($locale,$resolution)
*Parameters:
*Parameters:
Line 34: Line 34:
===getAvailableLocales()===
===getAvailableLocales()===
Get all locales that are either selectable or referenced in the reosltuion of a selectable locale
Get all locales that are either selectable or referenced in the reosltuion of a selectable locale
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L51 i2ce/lib/I2CE_Locales.php] on line 51
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L51 i2ce/lib/I2CE_Locales.php] on line 51
*Signature: static public function getAvailableLocales()
*Signature: static public function getAvailableLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string, the locales
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string, the locales
===getBrowserPreferredLocale()===
===getBrowserPreferredLocale()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L220 i2ce/lib/I2CE_Locales.php] on line 220
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L220 i2ce/lib/I2CE_Locales.php] on line 220
*Signature: static public function getBrowserPreferredLocale()
*Signature: static public function getBrowserPreferredLocale()
===getBrowserPrefferedLocales()===
===getBrowserPrefferedLocales()===
Get the locales that were requested by the browser in order of decreasing preferrence. @param boolean $validate. Defaults to true
Get the locales that were requested by the browser in order of decreasing preferrence. @param boolean $validate. Defaults to true
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L261 i2ce/lib/I2CE_Locales.php] on line 261
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L261 i2ce/lib/I2CE_Locales.php] on line 261
*Signature: static public function getBrowserPrefferedLocales()
*Signature: static public function getBrowserPrefferedLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string
===getLocaleResolution()===
===getLocaleResolution()===
Gets the resolution of search paths for a locale
Gets the resolution of search paths for a locale
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L318 i2ce/lib/I2CE_Locales.php] on line 318
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L318 i2ce/lib/I2CE_Locales.php] on line 318
*Signature: static public function getLocaleResolution($locale,$ensure_selectable)
*Signature: static public function getLocaleResolution($locale,$ensure_selectable)
*Parameters:
*Parameters:
Line 56: Line 56:
===getPreferredLocale()===
===getPreferredLocale()===
Get the preferred locale.  Checks against the selectable locales
Get the preferred locale.  Checks against the selectable locales
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L131 i2ce/lib/I2CE_Locales.php] on line 131
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L131 i2ce/lib/I2CE_Locales.php] on line 131
*Signature: static public function getPreferredLocale()
*Signature: static public function getPreferredLocale()
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]<br/>$locale
*Returns: [http://www.php.net/manual/en/language.types.string.php string ]<br/>$locale
===getPreferredLocales()===
===getPreferredLocales()===
Get the preffered  locales in order of decreasing preference
Get the preffered  locales in order of decreasing preference
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L66 i2ce/lib/I2CE_Locales.php] on line 66
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L66 i2ce/lib/I2CE_Locales.php] on line 66
*Signature: static public function getPreferredLocales()
*Signature: static public function getPreferredLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string.  The prefferend locales e.g.  array('fr_FR','en_GB','en_US')
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string.  The prefferend locales e.g.  array('fr_FR','en_GB','en_US')
===getSelectableLocales()===
===getSelectableLocales()===
Get a list of the selectable locales for the site.. i.e. the locales that we know something about. This should not be a big list.
Get a list of the selectable locales for the site.. i.e. the locales that we know something about. This should not be a big list.
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L80 i2ce/lib/I2CE_Locales.php] on line 80
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L80 i2ce/lib/I2CE_Locales.php] on line 80
*Signature: static public function getSelectableLocales()
*Signature: static public function getSelectableLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string
===getSitePreferredLocale()===
===getSitePreferredLocale()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L203 i2ce/lib/I2CE_Locales.php] on line 203
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L203 i2ce/lib/I2CE_Locales.php] on line 203
*Signature: static public function getSitePreferredLocale()
*Signature: static public function getSitePreferredLocale()
===isSetPreferredLocale()===
===isSetPreferredLocale()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L101 i2ce/lib/I2CE_Locales.php] on line 101
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L101 i2ce/lib/I2CE_Locales.php] on line 101
*Signature: static public function isSetPreferredLocale($locale)
*Signature: static public function isSetPreferredLocale($locale)
*Parameters:
*Parameters:
Line 79: Line 79:
***Default Value: null
***Default Value: null
===isSetPreferredLocales()===
===isSetPreferredLocales()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L179 i2ce/lib/I2CE_Locales.php] on line 179
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L179 i2ce/lib/I2CE_Locales.php] on line 179
*Signature: static protected function isSetPreferredLocales()
*Signature: static protected function isSetPreferredLocales()
===mapLanguageToLocale()===
===mapLanguageToLocale()===
attempt to map a language to a locale based on the selectable locales
attempt to map a language to a locale based on the selectable locales
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L294 i2ce/lib/I2CE_Locales.php] on line 294
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L294 i2ce/lib/I2CE_Locales.php] on line 294
*Signature: static public function mapLanguageToLocale($locale)
*Signature: static public function mapLanguageToLocale($locale)
*Parameters:
*Parameters:
Line 90: Line 90:
===setPreferredLocale()===
===setPreferredLocale()===
Set the preferred locale.  Checks against the selectable locales
Set the preferred locale.  Checks against the selectable locales
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L116 i2ce/lib/I2CE_Locales.php] on line 116
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L116 i2ce/lib/I2CE_Locales.php] on line 116
*Signature: static public function setPreferredLocale($locale)
*Signature: static public function setPreferredLocale($locale)
*Parameters:
*Parameters:
Line 96: Line 96:
===setPreferredLocales()===
===setPreferredLocales()===
Validates and sets the preferred locales for the session in order of decreasing preference.  It makes sure that self::DEFAULT_LOCALE is in the list of preferred locales. @param mixed @locales. string or array of  string.  The preferred locale or an array of prefered locales.
Validates and sets the preferred locales for the session in order of decreasing preference.  It makes sure that self::DEFAULT_LOCALE is in the list of preferred locales. @param mixed @locales. string or array of  string.  The preferred locale or an array of prefered locales.
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L152 i2ce/lib/I2CE_Locales.php] on line 152
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L152 i2ce/lib/I2CE_Locales.php] on line 152
*Signature: static protected function setPreferredLocales($locales)
*Signature: static protected function setPreferredLocales($locales)
*Parameters:
*Parameters:
Line 102: Line 102:
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string, the locales that were set.
*Returns: [http://www.php.net/manual/en/language.types.array.php array ]<br/>of string, the locales that were set.
===setSitePreferredLocale()===
===setSitePreferredLocale()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L211 i2ce/lib/I2CE_Locales.php] on line 211
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L211 i2ce/lib/I2CE_Locales.php] on line 211
*Signature: static public function setSitePreferredLocale($locale)
*Signature: static public function setSitePreferredLocale($locale)
*Parameters:
*Parameters:
**$locale  
**$locale  
===validateLocales()===
===validateLocales()===
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.0-dev/annotate/head:/lib/I2CE_Locales.php#L187 i2ce/lib/I2CE_Locales.php] on line 187
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/i2ce/4.1-dev/annotate/head:/lib/I2CE_Locales.php#L187 i2ce/lib/I2CE_Locales.php] on line 187
*Signature: static public function validateLocales($locales)
*Signature: static public function validateLocales($locales)
*Parameters:
*Parameters:

Latest revision as of 08:15, 6 May 2015


This article describes the class I2CE_Locales .

I2CE_Locales @todo Better Documentation

Constants

I2CE_Locales::DEFAULT_LOCALE

The 'defualt' locale for I2CE. You should not need to change this unless you are doing something crazy.

@var string DEFAULT_LOCALE

Defined as: 'en_US'

Variables

$request_locale

$preferred_locale

Methods

ensureSelectableLocale()

  • Defined in i2ce/lib/I2CE_Locales.php on line 84
  • Signature: static public function ensureSelectableLocale($locale,$fallback_site_preferred)
  • Parameters:
    • $locale
    • $fallback_site_preferred
      • Default Value: true

ensureValidResolution()

  • Defined in i2ce/lib/I2CE_Locales.php on line 334
  • Signature: static public function ensureValidResolution($locale,$resolution)
  • Parameters:
    • $locale
    • $resolution

getAvailableLocales()

Get all locales that are either selectable or referenced in the reosltuion of a selectable locale

getBrowserPreferredLocale()

getBrowserPrefferedLocales()

Get the locales that were requested by the browser in order of decreasing preferrence. @param boolean $validate. Defaults to true

getLocaleResolution()

Gets the resolution of search paths for a locale

  • Defined in i2ce/lib/I2CE_Locales.php on line 318
  • Signature: static public function getLocaleResolution($locale,$ensure_selectable)
  • Parameters:
    • string $locale
    • $ensure_selectable
      • Default Value: false
  • Returns: array
    of string;

getPreferredLocale()

Get the preferred locale. Checks against the selectable locales

getPreferredLocales()

Get the preffered locales in order of decreasing preference

  • Defined in i2ce/lib/I2CE_Locales.php on line 66
  • Signature: static public function getPreferredLocales()
  • Returns: array
    of string. The prefferend locales e.g. array('fr_FR','en_GB','en_US')

getSelectableLocales()

Get a list of the selectable locales for the site.. i.e. the locales that we know something about. This should not be a big list.

getSitePreferredLocale()

isSetPreferredLocale()

  • Defined in i2ce/lib/I2CE_Locales.php on line 101
  • Signature: static public function isSetPreferredLocale($locale)
  • Parameters:
    • $locale
      • Default Value: null

isSetPreferredLocales()

mapLanguageToLocale()

attempt to map a language to a locale based on the selectable locales

  • Defined in i2ce/lib/I2CE_Locales.php on line 294
  • Signature: static public function mapLanguageToLocale($locale)
  • Parameters:
    • $locale
  • Returns: mixed.
    false on failure. string on success

setPreferredLocale()

Set the preferred locale. Checks against the selectable locales

setPreferredLocales()

Validates and sets the preferred locales for the session in order of decreasing preference. It makes sure that self::DEFAULT_LOCALE is in the list of preferred locales. @param mixed @locales. string or array of string. The preferred locale or an array of prefered locales.

  • Defined in i2ce/lib/I2CE_Locales.php on line 152
  • Signature: static protected function setPreferredLocales($locales)
  • Parameters:
    • $locales
  • Returns: array
    of string, the locales that were set.

setSitePreferredLocale()

  • Defined in i2ce/lib/I2CE_Locales.php on line 211
  • Signature: static public function setSitePreferredLocale($locale)
  • Parameters:
    • $locale

validateLocales()

  • Defined in i2ce/lib/I2CE_Locales.php on line 187
  • Signature: static public function validateLocales($locales)
  • Parameters:
    • $locales