Class: I2CE Locales: Difference between revisions

From IHRIS Wiki
No edit summary
No edit summary
Line 1: Line 1:
This article desrcibes the class '''I2CE_Locales'''
This article desrcibes the class '''I2CE_Locales'''.
It is contained in the module [[iHRIS Module List#I2CE|I2CE]] in the package [https://launchpad.net/i2ce I2CE]
It is contained in the module [[iHRIS Module List#I2CE|I2CE]] in the package [https://launchpad.net/i2ce I2CE]


Line 34: Line 34:
of a selectable locale
of a selectable locale
*Signature: static public function getAvailableLocales()
*Signature: static public function getAvailableLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array] of string, the locales
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] of string, the locales
===getBrowserPreferredLocale()===
===getBrowserPreferredLocale()===
*Signature: static public function getBrowserPreferredLocale()
*Signature: static public function getBrowserPreferredLocale()
Line 41: Line 41:
@param boolean $validate. Defaults to true
@param boolean $validate. Defaults to true
*Signature: static public function getBrowserPrefferedLocales()
*Signature: static public function getBrowserPrefferedLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array] of string
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] of string
===getLocaleResolution()===
===getLocaleResolution()===
Gets the resolution of search paths for a locale
Gets the resolution of search paths for a locale
*Signature: static public function getLocaleResolution($locale,$ensure_selectable)
*Signature: static public function getLocaleResolution($locale,$ensure_selectable)
*Returns: [http://www.php.net/manual/en/language.types.array.php array] of string;
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] of string;
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $locale
* [http://www.php.net/manual/en/language.types.string.php string ] $locale
*$ensure_selectable  
*$ensure_selectable  
**Default Value: false
**Default Value: false
Line 53: Line 53:
Get the preferred locale.  Checks against the selectable locales
Get the preferred locale.  Checks against the selectable locales
*Signature: static public function getPreferredLocale()
*Signature: static public function getPreferredLocale()
*Returns: [http://www.php.net/manual/en/language.types.string.php string] $locale
*Returns: [http://www.php.net/manual/en/language.types.string.php string ] $locale
===getPreferredLocales()===
===getPreferredLocales()===
Get the preffered  locales in order of decreasing preference
Get the preffered  locales in order of decreasing preference
*Signature: static public function getPreferredLocales()
*Signature: static public function getPreferredLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array] 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 ] 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.
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.
This should not be a big list.
*Signature: static public function getSelectableLocales()
*Signature: static public function getSelectableLocales()
*Returns: [http://www.php.net/manual/en/language.types.array.php array] of string
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] of string
===getSitePreferredLocale()===
===getSitePreferredLocale()===
*Signature: static public function getSitePreferredLocale()
*Signature: static public function getSitePreferredLocale()
Line 82: Line 82:
*Signature: static public function setPreferredLocale($locale)
*Signature: static public function setPreferredLocale($locale)
Parameters:
Parameters:
* [http://www.php.net/manual/en/language.types.string.php string] $locale
* [http://www.php.net/manual/en/language.types.string.php string ] $locale
===setPreferredLocales()===
===setPreferredLocales()===
Validates and sets the preferred locales for the session
Validates and sets the preferred locales for the session
Line 89: Line 89:
@param mixed @locales. string or array of  string.  The preferred locale or an array of prefered locales.
@param mixed @locales. string or array of  string.  The preferred locale or an array of prefered locales.
*Signature: static protected function setPreferredLocales($locales)
*Signature: static protected function setPreferredLocales($locales)
*Returns: [http://www.php.net/manual/en/language.types.array.php array] of string, the locales that were set.
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] of string, the locales that were set.
Parameters:
Parameters:
*$locales  
*$locales  

Revision as of 22:25, 16 October 2009

This article desrcibes the class I2CE_Locales. It is contained in the module I2CE in the package I2CE

The class is defined in the file: lib/I2CE_Locales.php

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

  • Type: static protected $request_locale

$preferred_locale

  • Type: static protected $preferred_locale

Methods

ensureSelectableLocale()

  • Signature: static public function ensureSelectableLocale($locale,$fallback_site_preferred)

Parameters:

  • $locale
  • $fallback_site_preferred
    • Default Value: true

ensureValidResolution()

  • 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

  • Signature: static public function getAvailableLocales()
  • Returns: array of string, the locales

getBrowserPreferredLocale()

  • Signature: static public function getBrowserPreferredLocale()

getBrowserPrefferedLocales()

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

  • Signature: static public function getBrowserPrefferedLocales()
  • Returns: array of string

getLocaleResolution()

Gets the resolution of search paths for a locale

  • Signature: static public function getLocaleResolution($locale,$ensure_selectable)
  • Returns: array of string;

Parameters:

  • string $locale
  • $ensure_selectable
    • Default Value: false

getPreferredLocale()

Get the preferred locale. Checks against the selectable locales

  • Signature: static public function getPreferredLocale()
  • Returns: string $locale

getPreferredLocales()

Get the preffered locales in order of decreasing preference

  • 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.

  • Signature: static public function getSelectableLocales()
  • Returns: array of string

getSitePreferredLocale()

  • Signature: static public function getSitePreferredLocale()

isSetPreferredLocale()

  • Signature: static public function isSetPreferredLocale($locale)

Parameters:

  • $locale
    • Default Value: null

isSetPreferredLocales()

  • Signature: static protected function isSetPreferredLocales()

mapLanguageToLocale()

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

  • Signature: static public function mapLanguageToLocale($locale)
  • Returns: mixed. false on failure. string on success

Parameters:

  • $locale

setPreferredLocale()

Set the preferred locale. Checks against the selectable locales

  • Signature: static public function setPreferredLocale($locale)

Parameters:

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.

  • Signature: static protected function setPreferredLocales($locales)
  • Returns: array of string, the locales that were set.

Parameters:

  • $locales

setSitePreferredLocale()

  • Signature: static public function setSitePreferredLocale($locale)

Parameters:

  • $locale

validateLocales()

  • Signature: static public function validateLocales($locales)

Parameters:

  • $locales