|
eZ Publish
[4.2]
|
Provides unified access to locale information and conversions. More...
Provides unified access to locale information and conversions.
The eZLocale class handles locale information and can format time, date, numbers and currency for correct display for a given locale. The locale conversion uses plain numerical values for dates, times, numbers and currency, if you want more elaborate conversions consider using the eZDate, eZTime, eZDateTime and eZCurrency classes.
The first time a locale object is created (ie. eZLocale::instance() ) you must be sure to set a language using setLanguage before using any textual conversions.
Example:
//include_once( 'lib/ezlocale/classes/ezlocale.php' ); // Fetch the default values supplied by site.ini $locale = eZLocale::instance(); // Make sure PHP is to the correct locale $locale->initPHP(); print( $locale->formatTime() . '<br>' ); // Display current time print( $locale->formatDate() . '<br>' ); // Display current day foreach ( $locale->weekDays() as $day ) // Print a week with 3 letter daynames { print( $locale->shortDayName( $day ) . '<br>' ); }
Countries are specified by the ISO 3166 Country Code http://www.iso.ch/iso/en/prods-services/iso3166ma/index.html User-assigned code elements http://www.iso.ch/iso/en/prods-services/iso3166ma/04background-on-iso-3166/reserved-and-user-assigned-codes.html#userassigned
Language is specified by the ISO 639 Language Code http://www.w3.org/WAI/ER/IG/ert/iso639.htm
Currency/funds are specified by the ISO 4217 http://www.bsi-global.com/Technical+Information/Publications/_Publications/tig90.xalter
Discussion on Norwegian locales https://lister.ping.uio.no/pipermail/lister.ping.uio.no/i18n-nn/2002-April.txt http://www.sprakrad.no/oss.htm
The date and time formats are quite similar to the builtin PHP date function, the main differences are those which returns textual representations of months and days. More info on the date function here: http://www.php.net/manual/en/function.date.php
The following characters are not recognized in the format string:
The following characters are recognized in the format string:
Definition at line 130 of file ezlocale.php.
| eZLocale::allowedCharsets | ( | ) |
Definition at line 626 of file ezlocale.php.
| eZLocale::attribute | ( | $ | attribute | ) |
Definition at line 556 of file ezlocale.php.
| eZLocale::attributeFunctionMap | ( | ) |
Definition at line 577 of file ezlocale.php.
Referenced by attribute(), attributes(), and hasAttribute().
| eZLocale::attributes | ( | ) |
Definition at line 542 of file ezlocale.php.
| eZLocale::charset | ( | ) |
Returns the charset for this locale.
Definition at line 618 of file ezlocale.php.
| eZLocale::countryCode | ( | ) |
Returns the code for the country. eg. 'NO'
Definition at line 650 of file ezlocale.php.
Referenced by countryFile(), and localeFile().
| eZLocale::countryComment | ( | ) |
Returns the comment for the country, if any.
Definition at line 642 of file ezlocale.php.
| & eZLocale::countryFile | ( | $ | withVariation = false | ) |
Returns the eZINI object for the country ini file.
Definition at line 1503 of file ezlocale.php.
Referenced by eZLocale().
| static eZLocale::countryList | ( | $ | withVariations = true | ) | [static] |
| $withVariations | If true it will include variations of locales (ends with ) |
Definition at line 1419 of file ezlocale.php.
| eZLocale::countryName | ( | ) |
Returns the name of the country in British English.
Definition at line 634 of file ezlocale.php.
| eZLocale::countryVariation | ( | ) |
Returns the variation for the country. eg. 'spraakraad'
Definition at line 658 of file ezlocale.php.
Referenced by countryFile(), eZLocale(), languageFile(), localeFile(), and localeFullCode().
| static eZLocale::create | ( | $ | localeString = false | ) | [static] |
Similar to instance() but will always create a new copy.
Definition at line 1598 of file ezlocale.php.
| eZLocale::currencyDecimalCount | ( | ) |
Definition at line 855 of file ezlocale.php.
| eZLocale::currencyDecimalSymbol | ( | ) |
Definition at line 839 of file ezlocale.php.
| eZLocale::currencyName | ( | ) |
Returns the name of the currency.
Definition at line 774 of file ezlocale.php.
| eZLocale::currencyNegativeSymbol | ( | ) |
Definition at line 863 of file ezlocale.php.
| eZLocale::currencyPositiveSymbol | ( | ) |
Definition at line 871 of file ezlocale.php.
| eZLocale::currencyShortName | ( | ) |
Returns the short name of the currency.
Definition at line 782 of file ezlocale.php.
| eZLocale::currencySymbol | ( | ) |
Returns the currency symbol for this locale.
Definition at line 766 of file ezlocale.php.
| eZLocale::currencyThousandsSeparator | ( | ) |
Definition at line 847 of file ezlocale.php.
| static eZLocale::currentLocaleCode | ( | ) | [static] |
Returns the current locale code for this language which is the language and the country with a dash (-) between them, for instance nor-NO or eng-GB.
Definition at line 741 of file ezlocale.php.
| eZLocale::decimalCount | ( | ) |
Definition at line 815 of file ezlocale.php.
| eZLocale::decimalSymbol | ( | ) |
Definition at line 799 of file ezlocale.php.
| eZLocale::eZLocale | ( | $ | localeString | ) |
Initializes the locale with the locale string $localeString. All locale data is read from locale/$localeString.ini
Definition at line 138 of file ezlocale.php.
Referenced by create(), and instance().
| static eZLocale::fetchByHttpLocaleCode | ( | $ | httpLocaleCode | ) | [static] |
Returns eZLocale object by HTTP locale code $httpLocaleCode
Definition at line 948 of file ezlocale.php.
| eZLocale::formatCleanCurrency | ( | $ | number | ) |
Formats the same as formatCurrency, but drops the currency sign
| currency | input |
Definition at line 1215 of file ezlocale.php.
| eZLocale::formatCurrency | ( | $ | number, |
| $ | as_html = true |
||
| ) |
Definition at line 1205 of file ezlocale.php.
| eZLocale::formatCurrencyWithSymbol | ( | $ | number, |
| $ | symbol | ||
| ) |
Definition at line 1221 of file ezlocale.php.
Referenced by formatCleanCurrency(), and formatCurrency().
| eZLocale::formatDate | ( | $ | date = false | ) |
Formats the date $date according to locale information and returns it. If $date is not specified the current date is used.
Definition at line 1018 of file ezlocale.php.
| eZLocale::formatDateTime | ( | $ | date = false | ) |
Formats the date and time $date according to locale information and returns it. If $date is not specified the current date is used.
Definition at line 1036 of file ezlocale.php.
| eZLocale::formatDateTimeType | ( | $ | fmt, |
| $ | datetime = false |
||
| ) |
Formats the date and time $datetime according to the format $fmt. You shouldn't call this directly unless you want to deviate from the locale settings.
Definition at line 1080 of file ezlocale.php.
Referenced by formatDateTime(), and formatShortDateTime().
| eZLocale::formatDateType | ( | $ | fmt, |
| $ | date = false |
||
| ) |
Formats the date $date according to the format $fmt. You shouldn't call this directly unless you want to deviate from the locale settings.
Definition at line 1055 of file ezlocale.php.
Referenced by formatDate(), and formatShortDate().
| eZLocale::formatNumber | ( | $ | number | ) |
Formats the number $number according to locale information and returns it.
Definition at line 1175 of file ezlocale.php.
| eZLocale::formatShortDate | ( | $ | date = false | ) |
Formats the date $date according to locale information for short dates and returns it. If $date is not specified the current date is used.
Definition at line 1027 of file ezlocale.php.
| eZLocale::formatShortDateTime | ( | $ | date = false | ) |
Formats the date and time $date according to locale information for short dates and returns it. If $date is not specified the current date is used.
Definition at line 1045 of file ezlocale.php.
| eZLocale::formatShortTime | ( | $ | time = false | ) |
Formats the time $time according to locale information for short times and returns it. If $time is not specified the current time is used.
Definition at line 973 of file ezlocale.php.
| eZLocale::formatTime | ( | $ | time = false | ) |
Formats the time $time according to locale information and returns it. If $time is not specified the current time is used.
Definition at line 964 of file ezlocale.php.
| eZLocale::formatTimeType | ( | $ | fmt, |
| $ | time = false |
||
| ) |
Formats the time $time according to the format $fmt. You shouldn't call this directly unless you want to deviate from the locale settings.
Definition at line 983 of file ezlocale.php.
Referenced by formatShortTime(), and formatTime().
| eZLocale::getFormattingFunction | ( | $ | qualifier | ) |
Returns the method name belonging to a qualifier
Definition at line 933 of file ezlocale.php.
| eZLocale::hasAttribute | ( | $ | attribute | ) |
Definition at line 547 of file ezlocale.php.
| eZLocale::httpLocaleCode | ( | ) |
Definition at line 719 of file ezlocale.php.
| eZLocale::initCountry | ( | &$ | countryINI | ) | [private] |
Definition at line 342 of file ezlocale.php.
Referenced by eZLocale().
| eZLocale::initLanguage | ( | &$ | languageINI | ) | [private] |
Definition at line 381 of file ezlocale.php.
Referenced by eZLocale().
| eZLocale::initPHP | ( | $ | charset = false | ) |
Sets locale information in PHP. This means that some of the string/sort functions in PHP will work with non-latin1 characters. Make sure setLanguage is called before this.
Definition at line 535 of file ezlocale.php.
| static eZLocale::instance | ( | $ | localeString = false | ) | [static] |
Returns a shared instance of the eZLocale class pr locale string.
If $localeString is not specified the default local string in site.ini is used. Use this instead of newing eZLocale to benefit from speed and unified access. note: Use create() if you need to get a new unique copy you can alter.
| $localeString | string|false |
Definition at line 1564 of file ezlocale.php.
Referenced by eZContentLanguage\addLanguage(), eZGeneralDigestHandler\attribute(), eZTemplateCompiler\compilationFilename(), countryFile(), create(), currencyForLocale(), currentLocaleCode(), eZCurrency\eZCurrency(), ezcurrentLanguage(), eZDate\eZDate(), eZDateTime\eZDateTime(), eZTime\eZTime(), eZFloatType\fetchClassAttributeHTTPInput(), eZOrder\fetchLocaleCurrencyCode(), eZFloatType\fetchObjectAttributeHTTPInput(), eZPriceType\fetchObjectAttributeHTTPInput(), eZRSSExport\fetchRSS2_0(), eZCountryType\fetchTranslatedNames(), eZFloatType\fixupClassAttributeHTTPInput(), eZSubTreeHandler\handlePublishEvent(), httpLocaleCode(), eZTemplateLocaleOperator\l10nTransformation(), languageFile(), eZContentObjectTranslation\locale(), localeFile(), localeList(), eZContentLanguage\localeObject(), eZDateOperatorCollection\modify(), eZTemplateLocaleOperator\modify(), eZTemplateUnitOperator\modify(), eZTemplateUnitOperator\operatorTransform(), eZDiscountSubRule\setAttribute(), eZDateType\title(), eZTimeType\title(), eZDateTimeType\title(), eZContentObjectVersion\unserialize(), eZContentObject\unserialize(), eZFloatType\validateClassAttributeHTTPInput(), eZPriceType\validateObjectAttributeHTTPInput(), and eZFloatType\validateObjectAttributeHTTPInput().
| eZLocale::internalCurrency | ( | $ | number | ) |
Formats the currency according locale to the representation used internally in PHP
Definition at line 1242 of file ezlocale.php.
| eZLocale::internalNumber | ( | $ | number | ) |
Formats the number according locale to the representation used internally in PHP
Definition at line 1186 of file ezlocale.php.
| eZLocale::internationalLanguageName | ( | ) |
Returns the name of the language in English (eng).
Definition at line 758 of file ezlocale.php.
| static eZLocale::isDebugEnabled | ( | ) | [static] |
Definition at line 1614 of file ezlocale.php.
Referenced by countryFile(), languageFile(), and localeFile().
| eZLocale::isMondayFirst | ( | ) |
Returns true if the week starts with monday, false if sunday.
Definition at line 791 of file ezlocale.php.
| eZLocale::isValid | ( | ) |
Definition at line 334 of file ezlocale.php.
| eZLocale::languageCode | ( | ) |
Returns the language code for this language, for instance nor for norwegian or eng for english.
Definition at line 666 of file ezlocale.php.
Referenced by languageFile(), and localeFile().
| eZLocale::languageComment | ( | ) |
Returns the comment for the language, if any.
Definition at line 674 of file ezlocale.php.
| & eZLocale::languageFile | ( | $ | withVariation = false | ) |
Returns the eZINI object for the language ini file.
Definition at line 1531 of file ezlocale.php.
Referenced by eZLocale().
| static eZLocale::languageList | ( | $ | withVariations = true | ) | [static] |
| $withVariations | If true it will include variations of locales (ends with ) |
Definition at line 1446 of file ezlocale.php.
| eZLocale::languageName | ( | ) |
Returns the name of the language in its own tounge.
Definition at line 750 of file ezlocale.php.
| eZLocale::localeCode | ( | ) |
Returns the locale code for this language which is the language and the country with a dash (-) between them, for instance nor-NO or eng-GB.
Definition at line 696 of file ezlocale.php.
Referenced by httpLocaleCode().
| & eZLocale::localeFile | ( | $ | withVariation = false | ) |
Returns the eZINI object for the locale ini file.
Definition at line 1472 of file ezlocale.php.
Referenced by eZLocale().
| eZLocale::localeFullCode | ( | ) |
Same as localeCode() but appends the country variation if it is set.
Definition at line 704 of file ezlocale.php.
| eZLocale::localeInformation | ( | $ | localeString | ) |
Decodes a locale string into language, country and charset and returns an array with the information. Country and charset is optional, country is specified with a - or _ followed by the country code (NO, GB), charset is specified with a . followed by the charset name. Examples of locale strings are: nor-NO, en_GB.utf8, nn_NO
Definition at line 491 of file ezlocale.php.
Referenced by eZLocale().
| static eZLocale::localeList | ( | $ | asObject = false, |
| $ | withVariations = true |
||
| ) | [static] |
| $asObject | If true it returns each element as an eZLocale object |
| $withVariations | If true it will include variations of locales (ends with ) |
Definition at line 1380 of file ezlocale.php.
Referenced by fetchByHttpLocaleCode().
| static eZLocale::localeRegexp | ( | $ | withVariations = true, |
| $ | withCharset = true |
||
| ) | [static] |
true. The groups 6 and 7 will only be used if $withVariations is true. | $withVariations | If true it will include variations of locales (ends with ) |
Definition at line 480 of file ezlocale.php.
Referenced by countryList(), languageList(), and localeList().
| eZLocale::longDayName | ( | $ | num | ) |
Returns the long name of the day number $num. The different numbers for the days are: Sunday = 0 Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4 Friday = 5 Saturday = 6 This functions is usually used together with weekDays().
Definition at line 1296 of file ezlocale.php.
Referenced by formatDateTimeType(), and formatDateType().
| eZLocale::longMonthName | ( | $ | num | ) |
Returns the long name of the month number $num. The different numbers for the months are: Januray = 1 February = 2 March = 3 April = 4 May = 5 June = 6 July = 7 August = 8 September = 9 October = 10 November = 11 December = 12 This functions is usually used together with months().
Definition at line 1360 of file ezlocale.php.
Referenced by formatDateTimeType(), and formatDateType().
| eZLocale::meridiemName | ( | $ | time = false, |
| $ | upcase = false |
||
| ) |
Returns the name for the meridiem ie am (ante meridiem) or pm (post meridiem). If $time is not supplied or false the current time is used. If $upcase is false the name is in lowercase otherwise uppercase. The time is defined to be am if the hour is less than 12 and pm otherwise. Normally the hours 00 and 12 does not have am/pm attached and are instead called Midnight and Noon, but for simplicity the am/pm is always attached (if the locale allows it).
Definition at line 1003 of file ezlocale.php.
Referenced by formatDateTimeType(), and formatTimeType().
| eZLocale::months | ( | ) |
Returns the months of the year as an array. This only supplied for completeness.
Definition at line 890 of file ezlocale.php.
| eZLocale::monthsNames | ( | ) |
Returns the names of months as an array.
Definition at line 899 of file ezlocale.php.
| eZLocale::negativeSymbol | ( | ) |
Definition at line 823 of file ezlocale.php.
| eZLocale::positiveSymbol | ( | ) |
Definition at line 831 of file ezlocale.php.
| eZLocale::reset | ( | ) | [private] |
Definition at line 268 of file ezlocale.php.
Referenced by eZLocale().
| static eZLocale::resetGlobals | ( | $ | localeString = false | ) | [static] |
Definition at line 1633 of file ezlocale.php.
| static eZLocale::setIsDebugEnabled | ( | $ | debug | ) | [static] |
Sets whether internal debugging is enabled or not.
Definition at line 1625 of file ezlocale.php.
| eZLocale::shortDayName | ( | $ | num | ) |
Returns the short name of the day number $num. The different numbers for the days are: Sunday = 0 Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4 Friday = 5 Saturday = 6 This functions is usually used together with weekDays().
Definition at line 1269 of file ezlocale.php.
Referenced by formatDateTimeType(), and formatDateType().
| eZLocale::shortMonthName | ( | $ | num | ) |
Returns the short name of the month number $num. The different numbers for the months are: Januray = 1 February = 2 March = 3 April = 4 May = 5 June = 6 July = 7 August = 8 September = 9 October = 10 November = 11 December = 12 This functions is usually used together with months().
Definition at line 1328 of file ezlocale.php.
Referenced by formatDateTimeType(), and formatDateType().
| eZLocale::thousandsSeparator | ( | ) |
Definition at line 807 of file ezlocale.php.
| static eZLocale::transformToPHPFormat | ( | $ | fmt, |
| $ | allowed | ||
| ) | [static, private] |
Transforms the date/time string $fmt into a string that can be passed to the PHP function 'date'.
| $fmt | An eZ Publish locale format, x means a 'formatting character' from PHPs 'date' function. |
| $allowed | An array with characters that are considered allowed 'formatting characters' Any character not found in this array will be kept intact by escaping it. |
Definition at line 1115 of file ezlocale.php.
Referenced by formatDateTimeType(), formatDateType(), and formatTimeType().
| eZLocale::translatedCountryNames | ( | ) |
Definition at line 1234 of file ezlocale.php.
| eZLocale::translationCode | ( | ) |
Returns the locale code which is used for translation files. Normally this is the same as localeCode() but for some locales translation from other languages can be used
e.g. por-MZ (Mozambique) uses por-PT for translation.
Definition at line 687 of file ezlocale.php.
| eZLocale::weekDayNames | ( | $ | short = false | ) |
Returns the same array as in weekDays() but with all days translated to text.
Definition at line 907 of file ezlocale.php.
Referenced by weekDayShortNames().
| eZLocale::weekDays | ( | ) |
Returns an array with the days of the week according to locale information. Each entry in the array can be supplied to the shortDayName() and longDayName() functions.
Definition at line 881 of file ezlocale.php.
| eZLocale::weekDayShortNames | ( | ) |
Returns the same array as in weekDayNames() but with short version of days.
Definition at line 925 of file ezlocale.php.
| eZLocale::$AM |
AM and PM names.
Definition at line 1664 of file ezlocale.php.
| eZLocale::$Country |
Objects.
Definition at line 1705 of file ezlocale.php.
| eZLocale::$CountryCode |
Definition at line 1706 of file ezlocale.php.
| eZLocale::$CountryComment |
Definition at line 1708 of file ezlocale.php.
| eZLocale::$CountryINI |
Definition at line 1711 of file ezlocale.php.
| eZLocale::$CountryNames |
Definition at line 1719 of file ezlocale.php.
| eZLocale::$CountryVariation |
Definition at line 1707 of file ezlocale.php.
| eZLocale::$CurrencyDecimalSymbol |
Currency.
Definition at line 1678 of file ezlocale.php.
| eZLocale::$CurrencyFractDigits |
Definition at line 1680 of file ezlocale.php.
| eZLocale::$CurrencyNegativeFormat |
Definition at line 1685 of file ezlocale.php.
| eZLocale::$CurrencyNegativeSymbol |
Definition at line 1681 of file ezlocale.php.
| eZLocale::$CurrencyPositiveFormat |
Definition at line 1684 of file ezlocale.php.
| eZLocale::$CurrencyPositiveSymbol |
Definition at line 1682 of file ezlocale.php.
| eZLocale::$CurrencySymbol |
Definition at line 1683 of file ezlocale.php.
| eZLocale::$CurrencyThousandsSeparator |
Definition at line 1679 of file ezlocale.php.
| eZLocale::$DateArray |
Definition at line 1698 of file ezlocale.php.
| eZLocale::$DateFormat |
Format of dates.
Definition at line 1654 of file ezlocale.php.
| eZLocale::$DatePHPArray |
Definition at line 1700 of file ezlocale.php.
| eZLocale::$DayNames |
Help arrays.
Definition at line 1690 of file ezlocale.php.
| eZLocale::$DecimalSymbol |
Numbers.
Definition at line 1669 of file ezlocale.php.
| eZLocale::$FractDigits |
Definition at line 1671 of file ezlocale.php.
| eZLocale::$IntlLanguageName |
Internationalized name of the language.
Definition at line 1718 of file ezlocale.php.
| eZLocale::$IsValid |
Definition at line 1649 of file ezlocale.php.
| eZLocale::$LanguageCode |
The language code, for instance nor-NO, or eng-GB.
Definition at line 1714 of file ezlocale.php.
| eZLocale::$LanguageComment |
Definition at line 1709 of file ezlocale.php.
| eZLocale::$LanguageINI |
Definition at line 1712 of file ezlocale.php.
| eZLocale::$LanguageName |
Name of the language.
Definition at line 1716 of file ezlocale.php.
| eZLocale::$LocaleINI |
Definition at line 1710 of file ezlocale.php.
| eZLocale::$LongDayNames |
Definition at line 1691 of file ezlocale.php.
| eZLocale::$LongMonthNames |
Definition at line 1693 of file ezlocale.php.
| eZLocale::$LongWeekDayNames |
Definition at line 1695 of file ezlocale.php.
| eZLocale::$MondayFirst |
True if monday is the first day of the week.
Definition at line 1662 of file ezlocale.php.
| eZLocale::$MonthNames |
Definition at line 1692 of file ezlocale.php.
| eZLocale::$Months |
Definition at line 1694 of file ezlocale.php.
| eZLocale::$NegativeSymbol |
Definition at line 1672 of file ezlocale.php.
| eZLocale::$PM |
Definition at line 1664 of file ezlocale.php.
| eZLocale::$PositiveSymbol |
Definition at line 1673 of file ezlocale.php.
| eZLocale::$ShortDateFormat |
Format of short dates.
Definition at line 1656 of file ezlocale.php.
| eZLocale::$ShortDayNames |
Definition at line 1691 of file ezlocale.php.
| eZLocale::$ShortMonthNames |
Definition at line 1693 of file ezlocale.php.
| eZLocale::$ShortTimeFormat |
Format of short times.
Definition at line 1660 of file ezlocale.php.
| eZLocale::$ShortWeekDayNames |
Definition at line 1695 of file ezlocale.php.
| eZLocale::$ThousandsSeparator |
Definition at line 1670 of file ezlocale.php.
| eZLocale::$TimeArray |
Definition at line 1697 of file ezlocale.php.
| eZLocale::$TimeFormat |
Format of times.
Definition at line 1658 of file ezlocale.php.
| eZLocale::$TimePHPArray |
Definition at line 1699 of file ezlocale.php.
| eZLocale::$WeekDays |
Definition at line 1694 of file ezlocale.php.
| const eZLocale::DEBUG_INTERNALS = false |
Definition at line 132 of file ezlocale.php.
Referenced by isDebugEnabled().