Declaration:
<? class I18NLocale ?>
Description:
This is the central class in the i18n package. It provides access to locale-specific
information and methods for a given combination of country and dialect information.
You access instances of this class via a call to static I18N::getLocale()
factory method. Then you call various formatting methods of this object to have your
data formatted in a locale-specific way.
Locales support translation of messages via the I18NMessageDictionary
classes. Together with html you can create localizable templates
for multilingual sites.
Every locale object can have its own message dictionary and time zone. All date/time
formattings will be performed on UNIX timestamps converted to the locale's time zone
(see I18NLocale::setTimeZone() method), while all messages will
be translated into the locale's dialect.
The concrete implementations of the I18N API will likely use I18NCountry
and I18NDialect classes to combine them into the locale object; all
calls to the I18NLocale will be rerouted to the corresponding
methods of the underlying objects (this is how the free18n package
works)
See also:
- free18n package docs for tips on creating and using your own locale, country and dialect classes
Authors:
Methods:
-
__construct()
Each locale object is constructed with the country code, language code and dialect
code. Subclasses will always have to call the inherited constructor.
-
formatCurrency()
This function formats a monetary value according to the dialect's format and
country's currency codes and symbols
-
formatDate()
This function formats date of the given UNIX timestamp using either short, long or full
format
-
formatDateTime()
This method takes the UNIX timestamp $dt and returns the localized formatted
date and time string in the current time zone of this locale. The format specifiers are
the same, except for %z that is used to show the time zone name (like EEST),
and %Z that is used to show the time zone offset (like +0300)
-
formatNumber()
This method formats a number according to the dialect's format
-
formatTime()
This function formats time of the given UNIX timestamp using either short, long or full
format
-
getCountry()
Return the I18NCountry class used by this locale object
-
getCurrencyCode()
Return the currency code of the country. You may regard this method as a shortcut to
the I18NCountry::getCurrencyCode, that will return the underlying
country's intl currency code
-
getCurrencyDecimals()
This method returns the number of decimals in the monetary values used in the country
-
getCurrencySymbol()
This method returns the currency symbol. Subclasses may want to override this
to return translated symbols for a particular mix of a dialect and a country
(for example, in the CA_uk_Official locale this will return 'дол.' instead of '$')
-
getDialCode()
Get the dial code of the country
-
getDialect()
Return the I18NDialect class used by this locale object
-
getTimeZone()
Return the time zone object that is used by this locale object
-
setMessageDictionary()
Set the message dictionary object for this locale object
-
setTimeZone()
Set the time zone for use by this locale object
-
translateMessage()
Translate the message identified by $id into this locale's dialect
|
|