A class which provides translations for messages used by the core and modules.
More...
|
|
| $component |
| | The component to get translations from (a module name or "Erebot").
|
| |
|
| $locales |
| | The actual locales used for i18n.
|
| |
|
|
static | $cache = array() |
| | A cache for translation catalogs, with some additional metadata.
|
| |
A class which provides translations for messages used by the core and modules.
Definition at line 28 of file Intl.php.
| Erebot\Intl::__construct |
( |
|
$component | ) |
|
Creates a new translator for messages.
- Parameters
-
| string | $component | The name of the component to use for translations. This should be set to the name of the module or "Erebot" for the core. |
Definition at line 50 of file Intl.php.
| Erebot\Intl::_ |
( |
|
$message | ) |
|
Translates the given message using the translations for the current component.
- Parameters
-
| string | $message | The original message to translate, in US English. |
- Return values
-
| string | The message, translated into the selected locale. |
- Note
- This method is an alias for Erebot::IntlInterface::gettext
Implements Erebot\IntlInterface.
Definition at line 349 of file Intl.php.
| static Erebot\Intl::categoryToName |
( |
|
$category | ) |
|
|
static |
Returns the name associated with a given category.
- Parameters
-
- Return values
-
| string | The name of that category (eg. "LC_MESSAGES"). |
Implements Erebot\IntlInterface.
Definition at line 97 of file Intl.php.
| static Erebot\Intl::clearCache |
( |
| ) |
|
|
static |
Clears the cache used for translation catalogs.
- Return values
-
| This | method does not return any value. |
Definition at line 360 of file Intl.php.
| Erebot\Intl::getLocale |
( |
|
$category | ) |
|
Returns the target locale of this translator in canonical form for a given catergory.
- Parameters
-
- Return values
-
| string | The canonical form of the target locale for this translator. |
Implements Erebot\IntlInterface.
Definition at line 119 of file Intl.php.
| Erebot\Intl::gettext |
( |
|
$message | ) |
|
Translates the given message using the translations for the current component.
- Parameters
-
| string | $message | The original message to translate, in US English. |
- Return values
-
| string | The message, translated into the selected locale. |
Implements Erebot\IntlInterface.
Definition at line 344 of file Intl.php.
| Erebot\Intl::getTranslation |
( |
|
$component, |
|
|
|
$message |
|
) |
| |
|
protected |
Returns the translation for the given message, as contained in some translation catalog (MO file).
- Parameters
-
| string | $file | Path to the translation catalog to use. |
| string | $message | The message to translate. |
| string | $mode | Either "MO" or "PO", indicating whether the given file refers to a MO or PO catalog. |
- Return values
-
| string | The translation matching the given message. |
| null | The message could not be found in the translation catalog. |
- Note
- This method implements a caching strategy so that the translation catalog is not read again every time this method is called but only when the catalog actually changed.
Definition at line 241 of file Intl.php.
| static Erebot\Intl::nameToCategory |
( |
|
$name | ) |
|
|
static |
Returns the value of the category matching the given name.
- Parameters
-
| string | $name | A category name, such as "LC_MESSAGES". |
- Return values
-
Implements Erebot\IntlInterface.
Definition at line 73 of file Intl.php.
| Erebot\Intl::reallyGetText |
( |
|
$message, |
|
|
|
$component |
|
) |
| |
|
protected |
Low-level translation method.
- Parameters
-
| string | $message | The message to translate. |
| string | $component | The name of the component this translation belongs to, such as "Erebot" for core messages or "Erebot_Module_ABC" for messages belonging to the module named "Erebot_Module_ABC". |
- Return values
-
| string | Either the translation for the given message is returned, or the original message if none could be found. |
Definition at line 335 of file Intl.php.
| Erebot\Intl::setLocale |
( |
|
$category, |
|
|
|
$candidates |
|
) |
| |
Sets the target locale of this translator for a given catergory.
- Parameters
-
| opaque | $category | One of the constants defined in Erebot::IntlInterface indicating the category we're interested in setting. For the most basic usage, you should pass Erebot::IntlInterface::LC_MESSAGES as the category. |
| array | $candidates | Array of locales that can be used. The candidate locales will be reviewed in order and the first one to match a locale available to the bot will be used as the effective locale. |
- Return values
-
| string | The locale effectively in use after this method has been called, in its canonical form. |
- Note
- The bot assumes the "en_US" locale is always available. If none of the given candidates matches a locale available to the bot, "en_US" will automatically be selected as the locale to use.
Implements Erebot\IntlInterface.
Definition at line 140 of file Intl.php.
The documentation for this class was generated from the following file: