Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\IntlInterface Interface Reference

Interface to provide internationalization. More...

+ Inheritance diagram for Erebot\IntlInterface:

Public Member Functions

 _ ($message)
 
 getLocale ($category)
 
 gettext ($message)
 
 setLocale ($category, $candidates)
 

Static Public Member Functions

static categoryToName ($category)
 
static nameToCategory ($name)
 

Public Attributes

const LC_ADDRESS = 9
 Address formats and location information.
 
const LC_ALL = 6
 Overrides the value for all the other LC_* constants.
 
const LC_COLLATE = 3
 Collation order.
 
const LC_CTYPE = 0
 Character classification and case conversion.
 
const LC_IDENTIFICATION = 12
 Metadata about the locale information.
 
const LC_MEASUREMENT = 11
 Measurement units (Metric or Other).
 
const LC_MESSAGES = 5
 
const LC_MONETARY = 4
 Monetary formats.
 
const LC_NAME = 8
 Name formats.
 
const LC_NUMERIC = 1
 Non-monetary numeric formats.
 
const LC_PAPER = 7
 Paper size.
 
const LC_TELEPHONE = 10
 Telephone number formats.
 
const LC_TIME = 2
 Date and time formats.
 

Detailed Description

Interface to provide internationalization.

This interface provides the necessary methods to provide internationalization of the messages the bot emits through logging or exceptions.

Definition at line 31 of file IntlInterface.php.

Member Function Documentation

Erebot\IntlInterface::_ (   $message)

Translates the given message using the translations for the current component.

Parameters
string$messageThe original message to translate, in US English.
Return values
stringThe message, translated into the selected locale.
Note
This method is an alias for Erebot::IntlInterface::gettext

Implemented in Erebot\Intl.

static Erebot\IntlInterface::categoryToName (   $category)
static

Returns the name associated with a given category.

Parameters
opaque$categoryOne of the constants defined in Erebot::IntlInterface, eg. Erebot::IntlInterface::LC_MESSAGES.
Return values
stringThe name of that category (eg. "LC_MESSAGES").

Implemented in Erebot\Intl.

Erebot\IntlInterface::getLocale (   $category)

Returns the target locale of this translator in canonical form for a given catergory.

Parameters
opaque$categoryOne of the constants defined in Erebot::IntlInterface indicating the category we're interested in querying. For the most basic usage, you should pass Erebot::IntlInterface::LC_MESSAGES as the category.
Return values
stringThe canonical form of the target locale for this translator.

Implemented in Erebot\Intl.

Erebot\IntlInterface::gettext (   $message)

Translates the given message using the translations for the current component.

Parameters
string$messageThe original message to translate, in US English.
Return values
stringThe message, translated into the selected locale.

Implemented in Erebot\Intl.

static Erebot\IntlInterface::nameToCategory (   $name)
static

Returns the value of the category matching the given name.

Parameters
string$nameA category name, such as "LC_MESSAGES".
Return values
opaqueThe corresponding category, returned as one of the constants in Erebot::IntlInterface, eg. Erebot::IntlInterface::LC_MESSAGES.

Implemented in Erebot\Intl.

Erebot\IntlInterface::setLocale (   $category,
  $candidates 
)

Sets the target locale of this translator for a given catergory.

Parameters
opaque$categoryOne 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$candidatesArray 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
stringThe 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.

Implemented in Erebot\Intl.

Member Data Documentation

const Erebot\IntlInterface::LC_MESSAGES = 5

Formats of informative and diagnostic messages and interfactive responses.

Definition at line 52 of file IntlInterface.php.

Referenced by Erebot\Config\Proxy\getTranslator(), Erebot\Config\Main\getTranslator(), and Erebot\Styling\Variables\DurationVariable\render().


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