Static Public Member Functions

Locale Class Reference

List of all members.

Static Public Member Functions

static set ($locale=null)
static get ()
static set_system_locale ()
static load_pluggable_domain ($domain, $base_dir)
static list_all ()
static __run_plural_test ($header)
static __run_loadfile_test ($filename)
static _e ()
static _t ($text, $args=array(), $domain= 'habari')
static get_messages ($domain= 'habari')
static _u ($text, $domain= 'habari')
static _ne ($singular, $plural, $count, $domain= 'habari')
static _n ($singular, $plural, $count, $domain= 'habari')
static translate_xml (\SimpleXMLElement $parent,\SimpleXMLElement $child, $ns= 'http://www.w3.org/XML/1998/namespace', $locale=null)

Detailed Description

Habari Locale Class

Provides translation services.

Definition at line 17 of file locale.php.


Member Function Documentation

static Locale::__run_loadfile_test ( filename  )  [static]

DO NOT USE THIS FUNCTION. This function is only to be used by the test case for the Locale class!

Definition at line 289 of file locale.php.

static Locale::__run_plural_test ( header  )  [static]

DO NOT USE THIS FUNCTION. This function is only to be used by the test case for the Locale class!

Definition at line 274 of file locale.php.

static Locale::_e (  )  [static]

Echo a version of the string translated into the current locale

Parameters:
string $text The text to echo translated
string $domain (optional) The domain to search for the message

Definition at line 299 of file locale.php.

static Locale::_n ( singular,
plural,
count,
domain = 'habari' 
) [static]

Return a singular or plural string translated into the current locale based on the count provided

Parameters:
string $singular The singular form
string $plural The plural form
string $count The count
string $domain (optional) The domain to search for the message
Returns:
string The appropriately translated string

Definition at line 407 of file locale.php.

Referenced by _ne().

static Locale::_ne ( singular,
plural,
count,
domain = 'habari' 
) [static]

Echo singular or plural version of the string, translated into the current locale, based on the count provided

Parameters:
string $singular The singular form
string $plural The plural form
string $count The count
string $domain (optional) The domain to search for the message

Definition at line 393 of file locale.php.

static Locale::_t ( text,
args = array(),
domain = 'habari' 
) [static]

Return a version of the string translated into the current locale

Parameters:
string $text The text to echo translated
array $args
string $domain (optional) The domain to search for the message
Returns:
string The translated string

Definition at line 313 of file locale.php.

static Locale::_u ( text,
domain = 'habari' 
) [static]

Given a string translated into the current locale, return the untranslated string.

Parameters:
string $text The translated string
string $domain (optional) The domain to search for the message
Returns:
string The untranslated string

Definition at line 373 of file locale.php.

static Locale::get (  )  [static]

Return the current locale

Returns:
string The current locale.

Definition at line 44 of file locale.php.

Referenced by InstallHandler::act_begin_install(), and AdminHandler::get_sysinfo().

static Locale::get_messages ( domain = 'habari'  )  [static]

Return the entire message catalog for a domain as an array

Parameters:
string $domain (optional) The domain to return
Returns:
array The array of locale messages

Definition at line 361 of file locale.php.

Referenced by AjaxHandler::locale_js().

static Locale::list_all (  )  [static]

function list_all Retrieves an array of the Habari locales that are installed

Returns:
array. An array of Habari locales in the installation

Definition at line 121 of file locale.php.

Referenced by InstallHandler::act_begin_install().

static Locale::load_pluggable_domain ( domain,
base_dir 
) [static]

Load translations for a given domain and base directory for a pluggable object. Translations are stored in gettext-style .mo files. The internal workings of the file format are not entirely meant to be understood.

GNU Gettext Manual: Description of the MO file format string $domain the domain to load string $base_dir the base directory in which to find the translation files boolean true if data was successfully loaded, false otherwise

Definition at line 80 of file locale.php.

Referenced by Pluggable::load_text_domain().

static Locale::set ( locale = null  )  [static]

Sets the locale for Habari.

Parameters:
string $locale A language code like 'en' or 'en-us' or 'x-klingon', will be lowercased

Definition at line 29 of file locale.php.

Referenced by InstallHandler::act_begin_install().

static Locale::set_system_locale (  )  [static]

Set system locale.

The problem is that every platform has its own way to designate a locale, so for German you could have 'de', 'de_DE', 'de_DE.UTF-8', 'de_DE.UTF-8' (Linux) or 'DEU' (Windows), etc.

Todo:
: This setting should probably be stored in the language files.
Parameters:
string $locale The locale(s) to set. They will be tried in order.
Returns:
string the locale that was picked, or false if an error occurred

Definition at line 61 of file locale.php.

static Locale::translate_xml ( \SimpleXMLElement $  parent,
\SimpleXMLElement $  child,
ns = 'http://www.w3.org/XML/1998/namespace',
locale = null 
) [static]

Return a translated value of a SimpleXml object value based on the locale and namespace

Parameters:
\SimpleXMLElement $parent The parent node of the node we are translating
\SimpleXMLElement $child The child node we're trying to translate
string $ns The namespace to use for the lang attribute of the node to be translated
null|string $locale The locale we want to translate into

Definition at line 429 of file locale.php.

Referenced by Plugins::load_info().


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