diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/intl/doc | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/intl/doc')
-rw-r--r-- | ext/intl/doc/Tutorial.txt | 239 | ||||
-rw-r--r-- | ext/intl/doc/collator_api.php | 397 | ||||
-rw-r--r-- | ext/intl/doc/common_api.php | 56 | ||||
-rw-r--r-- | ext/intl/doc/datefmt_api.php | 436 | ||||
-rw-r--r-- | ext/intl/doc/formatter_api.php | 500 | ||||
-rw-r--r-- | ext/intl/doc/grapheme_api.php | 132 | ||||
-rw-r--r-- | ext/intl/doc/locale_api.php | 434 | ||||
-rw-r--r-- | ext/intl/doc/msgfmt_api.php | 209 | ||||
-rw-r--r-- | ext/intl/doc/normalizer_api.php | 92 |
9 files changed, 2495 insertions, 0 deletions
diff --git a/ext/intl/doc/Tutorial.txt b/ext/intl/doc/Tutorial.txt new file mode 100644 index 0000000..4a66dc1 --- /dev/null +++ b/ext/intl/doc/Tutorial.txt @@ -0,0 +1,239 @@ +1. Collator::getAvailableLocales(). +Return the locales available at the time of the call, including registered locales. +If a sever error occurs (such as out of memory condition) this will return null. +If there is no locale data, an empty enumeration will be returned. +Returned locales list is a strings in format of RFC4646 standart (see http://www.rfc-editor.org/rfc/rfc4646.txt). +Examle of locales format: 'en_US', 'ru_UA', 'ua_UA' (see http://demo.icu-project.org/icu-bin/locexp). + + +2. Collator::getDisplayName( $obj_locale, $disp_locale ). +Get name of the object for the desired Locale, in the desired langauge. Both arguments +must be from getAvailableLocales method. + + @param string $obj_locale Locale to get display name for. + @param string $disp_locale Specifies the desired locale for output + +Both parameters are case insensitive. +For locale format see RFC4647 standart in ftp://ftp.rfc-editor.org/in-notes/rfc4647.txt + +3. Collator::getLocaleByType( $type ). +Allow user to select whether she wants information on requested, valid or actual locale. +Returned locale tag is a string formatted to a RFC4646 standart and normalize to normal form - +value is a string from +For example, a collator for "en_US_CALIFORNIA" was requested. In the current state of ICU (2.0), +the requested locale is "en_US_CALIFORNIA", the valid locale is "en_US" (most specific locale +supported by ICU) and the actual locale is "root" (the collation data comes unmodified from the UCA) +The locale is considered supported by ICU if there is a core ICU bundle for that locale (although +it may be empty). + + +4. VariableTop +The Variable_Top attribute is only meaningful if the Alternate attribute is not set to NonIgnorable. +In such a case, it controls which characters count as ignorable. The string value specifies +the "highest" character (in UCA order) weight that is to be considered ignorable. +Thus, for example, if a user wanted whitespace to be ignorable, but not any visible characters, +then s/he would use the value Variable_Top="\u0020" (space). The string should only be a +single character. All characters of the same primary weight are equivalent, so +Variable_Top="\u3000" (ideographic space) has the same effect as Variable_Top="\u0020". +This setting (alone) has little impact on string comparison performance; setting it lower or higher +will make sort keys slightly shorter or longer respectively. + + +5. Strength +The ICU Collation Service supports many levels of comparison (named "Levels", but also +known as "Strengths"). Having these categories enables ICU to sort strings precisely +according to local conventions. However, by allowing the levels to be selectively +employed, searching for a string in text can be performed with various matching +conditions. +Performance optimizations have been made for ICU collation with the default level +settings. Performance specific impacts are discussed in the Performance section below. +Following is a list of the names for each level and an example usage: + +1. Primary Level: Typically, this is used to denote differences between base characters +(for example, "a" < "b"). It is the strongest difference. For example, dictionaries are +divided into different sections by base character. This is also called the level1 +strength. + +2. Secondary Level: Accents in the characters are considered secondary differences (for +example, "as" < "as" < "at"). Other differences between letters can also be considered +secondary differences, depending on the language. A secondary difference is ignored +when there is a primary difference anywhere in the strings. This is also called the +level2 strength. +Note: In some languages (such as Danish), certain accented letters are considered to +be separate base characters. In most languages, however, an accented letter only has a +secondary difference from the unaccented version of that letter. + +3. Tertiary Level: Upper and lower case differences in characters are distinguished at the +tertiary level (for example, "ao" < "Ao" < "ao"). In addition, a variant of a letter differs +from the base form on the tertiary level (such as "A" and " "). Another ? example is the +difference between large and small Kana. A tertiary difference is ignored when there is +a primary or secondary difference anywhere in the strings. This is also called the level3 +strength. + +4. Quaternary Level: When punctuation is ignored (see Ignoring Punctuations ) at level +13, an additional level can be used to distinguish words with and without punctuation +(for example, "ab" < "a-b" < "aB"). This difference is ignored when there is a primary, +secondary or tertiary difference. This is also known as the level4 strength. The +quaternary level should only be used if ignoring punctuation is required or when +processing Japanese text (see Hiragana processing). + +5. Identical Level: When all other levels are equal, the identical level is used as a +tiebreaker. The Unicode code point values of the NFD form of each string are +compared at this level, just in case there is no difference at levels 14 +. For example, Hebrew cantillation marks are only distinguished at this level. This level should be +used sparingly, as only code point values differences between two strings is an +extremely rare occurrence. Using this level substantially decreases the performance for +both incremental comparison and sort key generation (as well as increasing the sort +key length). It is also known as level 5 strength. + +For example, people may choose to ignore accents or ignore accents and case when searching +for text. Almost all characters are distinguished by the first three levels, and in most +locales the default value is thus Tertiary. However, if Alternate is set to be Shifted, +then the Quaternary strength can be used to break ties among whitespace, punctuation, and +symbols that would otherwise be ignored. If very fine distinctions among characters are required, +then the Identical strength can be used (for example, Identical Strength distinguishes +between the Mathematical Bold Small A and the Mathematical Italic Small A.). However, using +levels higher than Tertiary the Identical strength result in significantly longer sort +keys, and slower string comparison performance for equal strings. + + + +6. Collator::__construct( $locale ). +The Locale attribute is typically the most important attribute for correct sorting and matching, +according to the user expectations in different countries and regions. The default UCA +ordering will only sort a few languages such as Dutch and Portuguese correctly ("correctly" +meaning according to the normal expectations for users of the languages). +Otherwise, you need to supply the locale to UCA in order to properly collate text for a +given language. Thus a locale needs to be supplied so as to choose a collator that is correctly +tailored for that locale. The choice of a locale will automatically preset the values for +all of the attributes to something that is reasonable for that locale. Thus most of the time the +other attributes do not need to be explicitly set. In some cases, the choice of locale will make a +difference in string comparison performance and/or sort key length. +In short attribute names, <language>_<script>_<region>_<keyword>. +Not all the elements are required. Valid values for locale elements are general valid values +for RFC4646 locale naming, and RFC 4647 lookup algorithm. +Example: +Locale="sv" (Swedish) "Kypper" < "Kopfe" +Locale="de" (German) "Kopfe" < "Kypper" + + +7. Collator::get/setAttribute. +ICU uses UCA as a default starting point for ordering. Not all languages have sorting sequences +that correspond with the UCA because UCA cannot simultaneously encompass the specifics of all +the languages currently in use. Therefore, ICU provides a data-driven, flexible, and run-time +customizable mechanism called "tailoring". Tailoring overrides the default order of code points +and the values of the ICU Collation Service attributes. +Collator have followed attributes: + - FRENCH_COLLATION, possible values are: + ON + OFF (default) + DEFAULT + + - CASE_FIRST, possible values are: + OFF (default) + LOWER_FIRST + UPPER_FIRST + DEFAULT + + - CASE_LEVEL, possible values are: + OFF (default) + ON + DEFAULT + + - NORMALIZATION_MODE, possible values are: + OFF (default) + ON + DEFAULT + + - STRENGTH, possible values are: + PRIMARY + SECONDARY + TERTIARY (default) + QUATERNARY + IDENTICAL + DEFAULT + + - ALTERNATE_HANDLING, possible values are: + NON_IGNORABLE (default) + SHIFTED + DEFAULT + + - HIRAGANA_QUATERNARY_MODE, possible values are: + ON + OFF (default) + DEFAULT + + - NUMERIC_COLLATION, possible values are: + ON + OFF (default) + DEFAULT + +Description of all of this attributes: + +FRENCH_COLLATION - Sort strings with different accents from the back of the string. This attribute +is automatically set to On for the French locales and a few others. Users normally would +not need to explicitly set this attribute. There is a string comparison performance cost when +it is set On, but sort key length is unaffected. +Example: +F=X cote < cote < cote < cote +F=O cote < cote < cote < cote + +CASE_FIRST - The Case_First attribute is used to control whether uppercase letters come before +lowercase letters or vice versa, in the absence of other differences in the strings. The possible +values are Uppercase_First (U) and Lowercase_First (L), plus the standard Default and Off. +There is almost no difference between the Off and Lowercase_First options in terms of results, +so typically users will not use Lowercase_First: only Off or Uppercase_First. (People interested +in the detailed differences between X and L should consult the Collation Customization). +Specifying either L or U won't affect string comparison performance, but will affect the sort key +length. +Example: +C=X or C=L "china" < "China" < "denmark" < +"Denmark" +C=U "China" < "china" < "Denmark" < "denmark" + +CASE_LEVEL - The Case_Level attribute is used when ignoring accents but not case. In such a situation, +set Strength to be Primary, and Case_Level to be On. In most locales, this setting is Off by default. +There is a small string comparison performance and sort key impact if this attribute is set to be On. +Example: +S=1, E=X role = Role = role +S=1, E=O role = role < Role + +NORMALIZATION_MODE - The Normalization setting determines whether text is thoroughly normalized +or not in comparison. Even if the setting is off (which is the default for many locales), text as +represented in common usage will compare correctly (for details, see UTN #5). Only if the accent +marks are in noncanonical order will there be a problem. If the setting is On, then the best +results are guaranteed for all possible text input. There is a medium string comparison performance +cost if this attribute is On, depending on the frequency of sequences that require normalization. +There is no significant effect on sort key length. If the input text is known to be in NFD or NFKD +normalization forms, there is no need to enable this Normalization option. + +STRENGTH - see Collator::setStrength chapter. + +ALTERNATE_HANDLING - The Alternate attribute is used to control the handling of the socalled +variable characters in the UCA: whitespace, punctuation and symbols. If Alternate is set to +NonIgnorable (N), then differences among these characters are of the same importance as +differences among letters. If Alternate is set to Shifted (S), then these characters are of only +minor importance. The Shifted value is often used in combination with Strength set to Quaternary. +In such a case, whitespace, punctuation, and symbols are considered when comparing strings, +but only if all other aspects of the strings (base letters, accents, and case) are identical. +If Alternate is not set to Shifted, then there is no difference between a Strength of 3 and +a Strength of 4. For more information and examples, see +Variable_Weighting in the UCA (http://www.unicode.org/reports/tr10/#Variable_Weighting). +The reason the Alternate values are not simply On and Off is that additional Alternate values +may be added in the future. The UCA option Blanked is expressed with Strength set to 3, +and Alternate set to Shifted. The default for most locales is NonIgnorable. If Shifted is selected, +it may be slower if there are many strings that are the same except for punctuation; +sort key length will not be affected unless the strength level is also increased. +Example: +S=3, A=N di Silva < Di Silva < diSilva < U.S.A. < USA +S=3, A=S di Silva = diSilva < Di Silva < U.S.A. = USA +S=4, A=S di Silva < diSilva < Di Silva < U.S.A. < USA + +HIRAGANA_QUATERNARY_MODE - Compatibility with JIS x 4061 requires the introduction of an additional +level to distinguish Hiragana and Katakana characters. If compatibility with that standard is required, +then this attribute should be set On, and the strength set to Quaternary. This will affect sort key +length and string comparison string comparison performance. + +NUMERIC_COLLATION - When turned on, this attribute generates a collation key for the +numeric value of substrings of digits. This is a way to get '100' to sort AFTER '2'. + diff --git a/ext/intl/doc/collator_api.php b/ext/intl/doc/collator_api.php new file mode 100644 index 0000000..ef72502 --- /dev/null +++ b/ext/intl/doc/collator_api.php @@ -0,0 +1,397 @@ +<?php +############################################################################# +# Object-oriented API +############################################################################# + +/** + * Collator class. + * + * This is a wrapper around ICU Collator C API (declared in ucol.h). + * + * Example: + * <code> + * + * </code> + * + * @see http://www.icu-project.org/apiref/icu4c/ucol_8h.html + * @see http://www.icu-project.org/apiref/icu4c/classCollator.html + * + */ +class Collator { +############################################################################# +# Common constants. +############################################################################# + +/** + * Locale-related constants. + * + * These will be moved out of Collator when Locale class is created. + */ + const ULOC_ACTUAL_LOCALE = 0; + const ULOC_VALID_LOCALE = 1; + const ULOC_REQUESTED_LOCALE = 2; + + /* + * WARNING: + * The values described here are NOT the actual values in PHP code. + * They are references to the ICU C definitions, so the line + * const DEFAULT_STRENGTH = 'UCOL_DEFAULT_STRENGTH'; + * actually means that Collator::DEFAULT_STRENGTH is the same as + * UCOL_DEFAULT_STRENGTH constant in the ICU library. + */ + /** + * Valid attribute values. + * + * @see Collator::setAttribute() + * @see collator_set_attribute() + */ + const DEFAULT_VALUE = 'UCOL_DEFAULT'; + const PRIMARY = 'UCOL_PRIMARY'; + const SECONDARY = 'UCOL_SECONDARY'; + const TERTIARY = 'UCOL_TERTIARY'; + const DEFAULT_STRENGTH = 'UCOL_DEFAULT_STRENGTH'; + const QUATERNARY = 'UCOL_QUATERNARY'; + const IDENTICAL = 'UCOL_IDENTICAL'; + const OFF = 'UCOL_OFF'; + const ON = 'UCOL_ON'; + const SHIFTED = 'UCOL_SHIFTED'; + const NON_IGNORABLE = 'UCOL_NON_IGNORABLE'; + const LOWER_FIRST = 'UCOL_LOWER_FIRST'; + const UPPER_FIRST = 'UCOL_UPPER_FIRST'; + + /** + * Valid attribute names. + * + * @see Collator::setAttribute() + * @see collator_set_attribute() + */ + const FRENCH_COLLATION = 'UCOL_FRENCH_COLLATION'; + const ALTERNATE_HANDLING = 'UCOL_ALTERNATE_HANDLING'; + const CASE_FIRST = 'UCOL_CASE_FIRST'; + const CASE_LEVEL = 'UCOL_CASE_LEVEL'; + const NORMALIZATION_MODE = 'UCOL_NORMALIZATION_MODE'; + const STRENGTH = 'UCOL_STRENGTH'; + const HIRAGANA_QUATERNARY_MODE = 'UCOL_HIRAGANA_QUATERNARY_MODE'; + const NUMERIC_COLLATION = 'UCOL_NUMERIC_COLLATION'; + + /** + * Create a collator + * + * @param string $locale The locale whose collation rules + * should be used. Special values for + * locales can be passed in - if null is + * passed for the locale, the default + * locale collation rules will be used. If + * empty string ("") or "root" are passed, + * UCA rules will be used. + * + * @return Collator New instance of Collator object. + */ + public function __construct( $locale ) {} + + /** + * Create a collator + * + * Creates a new instance of Collator. + * + * This method is useful when you prefer just to get null on error, + * as if you called collator_create(). + * + * @return Collator Newly created Collator instance, + * or null on error. + * + * @see __construct() + * @see collator_create() + */ + public static function create( $locale ) {} + + /** + * Get collator's last error code. + * + * @return int Error code returned by the last + * Collator method call. + */ + public function getErrorCode() {} + + /** + * Return error text for the last ICU operation. + * + * @return string Description of an error occurred in the last + * Collator method call. + */ + public function getErrorMessage() {} + + /** + * Compare two strings using PHP strcmp() semantics. + * + * Wrapper around ICU ucol_strcoll(). + * + * @param string $str1 First string to compare. + * @param string $str2 Second string to compare. + * + * @return int 1 if $str1 is greater than $str2; + * 0 if $str1 is equal to $str2; + * -1 if $str1 is less than $str2. + * On error false is returned. + */ + public function compare( $str1, $str2 ) {} + + /** + * Equivalent to standard PHP sort() using Collator. + * + * @param array $arr Array of strings to sort + * @param int $sort_flags Optional sorting type, one of the following: + * - SORT_REGULAR - compare items normally (don't change types) + * - SORT_NUMERIC - compare items numerically + * - SORT_STRING - compare items as strings + * Default sorting type is SORT_REGULAR. + * + * @return bool true on success or false on failure. + */ + public function sort( $arr, $sort_flags ) {} + + /** + * Sort array maintaining index association. + * + * Equivalent to standard PHP asort() using Collator. + * + * @param array $arr Array of strings to sort + * @param int $sort_flags Optional sorting type + * + * @return bool true on success or false on failure. + * + * @see Collator::sort() + */ + public function asort( $arr, $sort_flags ) {} + + /** + * Equivalent to standard PHP sort() using Collator. + * + * Similar to Collator::sort(). + * Uses ICU ucol_getSortKey() to gain more speed on large arrays. + * + * @param array $arr Array of strings to sort + * + * @return bool true on success or false on failure. + */ + public function sortWithSortKeys( $arr ) {} + + /** + * @todo Do we want to support other standard PHP sort functions: ksort, rsort, asort? + */ + + /** + * Get collation attribute value. + * + * Wrapper around ICU ucol_getAttribute(). + * + * @param int $attr Attribute to get value for. + * + * @return int Attribute value, or false on error. + */ + public function getAttribute( $attr ) {} + + /** + * Set collation attribute. + * + * Wrapper around ICU ucol_setAttribute(). + * + * @param int $attr Attribute. + * @param int $val Attribute value. + * + * @return bool true on success, false otherwise. + */ + public function setAttribute( $attr, $val ) {} + + /** + * Get current collation strength. + * + * Wrapper around ICU ucol_getStrength(). + * + * @return int Current collation strength, or false on error. + */ + public function getStrength() {} + + /** + * Set collation strength. + * + * Wrapper around ICU ucol_setStrength(). + * + * @param int $strength Strength to set. + * + * @return bool true on success, false otherwise. + */ + public function setStrength( $strength ) {} + + /** + * Get the locale name of the collator. + * + * Wrapper around ICU ucol_getLocaleByType(). + * + * @param int $type You can choose between requested, valid + * and actual locale + * (ULOC_REQUESTED_LOCALE, + * ULOC_VALID_LOCALE, ULOC_ACTUAL_LOCALE, + * respectively). + * + * @return string Real locale name from which the + * collation data comes. If the collator + * was instantiated from rules or an error occurred, + * returns false. + */ + public function getLocale( $type ) {} +} + +############################################################################# +# Procedural API +############################################################################# + +/** + * Create collator. + * + * @param string $locale The locale containing the required + * collation rules. Special values for + * locales can be passed in - if null is + * passed for the locale, the default + * locale collation rules will be used. If + * empty string ("") or "root" are passed, + * UCA rules will be used. + * + * @return Collator New instance of Collator object, or null on error. + */ +function collator_create( $locale ) {} + +/** + * Compare two strings. + * + * The strings will be compared using the options already + * specified. + * + * @param Collator $coll Collator object. + * @param string $str1 The first string to compare. + * @param string $str2 The second string to compare. + * + * @return int 1 if $str1 is greater than $str2; + * 0 if $str1 is equal to $str2; + * -1 if $str1 is less than $str2. + * On error false is returned. + * + */ +function collator_compare( $coll, $str1, $str2 ) {} + +/** + * Sort array using specified collator. + * + * @param Collator $coll Collator object. + * @param array $arr Array of strings to sort. + * @param int $sort_flags Optional sorting type, one of the following: + * - SORT_REGULAR - compare items normally (don't change types) + * - SORT_NUMERIC - compare items numerically + * - SORT_STRING - compare items as strings + * Default sorting type is SORT_REGULAR. + * + * @return bool true on success or false on failure. + */ +function collator_sort( $coll, $arr, $sort_flags ) {} + +/** + * Sort array maintaining index association. + * + * @param Collator $coll Collator object. + * @param array $arr Array of strings to sort. + * @param int $sort_flags Optional sorting type. + * + * @return bool true on success or false on failure. + * + * @see collator_sort() + */ +function collator_asort( $coll, $arr, $sort_flags ) {} + +/** + * Sort array using specified collator. + * + * Similar to collator_sort(). + * Uses ICU ucol_getSortKey() to gain more speed on large arrays. + * + * @param Collator $coll Collator object. + * @param array $arr Array of strings to sort + * + * @return bool true on success or false on failure. + */ +function collator_sort_with_sort_keys( $coll, $arr ) {} + +/** + * Get the locale name of the collator. + * + * @param Collator $coll Collator object. + * @param int $type You can choose between valid and + * actual locale + * (ULOC_VALID_LOCALE, ULOC_ACTUAL_LOCALE + * respectively). + * + * @return string Real locale name from which the + * collation data comes. If the collator + * was instantiated from rules or an error occurred, + * returns false. + */ +function collator_get_locale( $coll, $type ) {} + +/** + * Get collation attribute value. + * + * @param Collator $coll Collator object. + * @param int $attr Attribute to get value for. + * + * @return int Attribute value, or false on error. + */ +function collator_get_attribute( $coll, $attr ) {} + +/** + * Get current collation strength. + * + * @param Collator $coll Collator object. + * + * @return int Current collation strength, or false on error. + */ +function collator_get_strength( $coll ) {} + +/** + * Set collation strength. + * + * @param Collator $coll Collator object. + * @param int $strength Strength to set. + * + * @return bool true on success, false otherwise. + */ +function collator_set_strength( $coll, $strength ) {} + +/** + * Set collation attribute. + * + * @param Collator $coll Collator object. + * @param int $attr Attribute. + * @param int $val Attribute value. + * + * @return bool true on success, false otherwise. + */ +function collator_set_attribute( $coll, $attr, $val ) {} + +/** + * Get collator's last error code. + * + * @param Collator $coll Collator object. + * + * @return int Error code returned by the last + * Collator API function call. + */ +function collator_get_error_code( $coll ) {} + +/** + * Get text for collator's last error code. + * + * @param Collator $coll Collator object. + * + * @return string Description of an error occurred in the last + * Collator API function call. + */ +function collator_get_error_message( $coll ) {} diff --git a/ext/intl/doc/common_api.php b/ext/intl/doc/common_api.php new file mode 100644 index 0000000..993dab1 --- /dev/null +++ b/ext/intl/doc/common_api.php @@ -0,0 +1,56 @@ +<?php + +/** + * Handling of errors occurred in static methods + * when there's no object to get error code/message from. + * + * Example #1: + * <code> + * $coll = collator_create( '<bad_param>' ); + * if( !$coll ) + * handle_error( intl_get_error_code() ); + * </code> + * + * Example #2: + * <code> + * if( Collator::getAvailableLocales() === false ) + * show_error( intl_get_error_message() ); + * </code> + */ + +/** + * Get the last error code. + * + * @return int Error code returned by the last + * API function call. + */ +function intl_get_error_code() {} + +/** + * Get description of the last error. + * + * @return string Description of an error occurred in the last + * API function call. + */ +function intl_get_error_message() {} + +/** + * Check whether the given error code indicates failure. + * + * @param int $code ICU error code. + * + * @return bool true if it the code indicates some failure, + * and false in case of success or a warning. + */ +function intl_is_failure($code) {} + +/** + * Get symbolic name for a given error code. + * + * The returned string will be the same as the name of the error code constant. + * + * @param int $code ICU error code. + * + * @return string Error code name. + */ +function intl_error_name($code) {} diff --git a/ext/intl/doc/datefmt_api.php b/ext/intl/doc/datefmt_api.php new file mode 100644 index 0000000..272abdb --- /dev/null +++ b/ext/intl/doc/datefmt_api.php @@ -0,0 +1,436 @@ +<?php + +/** + * Date Formatter class - locale-dependent formatting/parsing of dates using pattern strings and/or canned patterns. + * + * This class represents the ICU date formatting functionality. It allows users to + * display dates in a localized format or to parse strings + * into PHP date values using pattern strings and/or canned patterns. + * + * Example: + * <code> + * $datefmt = new DateFormatter("de-DE", LONG, SHORT, date_default_timezone_get()); + * echo $formatter->format(time()); + * </code> + * + * <code> + * $datefmt = new DateFormatter("de-DE", LONG, SHORT, date_default_timezone_get() , GREGORIAN , "yyyy-MM-dd HH:mm:ss z"); + * echo $formatter->format(time()); + * </code> + * + * @see http://www.icu-project.org/apiref/icu4c/udat_8h.html + * + */ +class DateFormatter { + +############################################################################# +# Common constants. +############################################################################# + + /** + * The following constants are used to specify different formats + * in the constructor. + */ + const NONE = -1; + const FULL = 0; + const LONG = 1; + const MEDIUM = 2; + const SHORT = 3; + + /** + * The following int constants are used to specify the calendar. + * These calendars are all based directly on the Gregorian calendar + * Non-Gregorian calendars need to be specified in locale. + * Examples might include locale="hi@calendar=BUDDHIST" + */ + const TRADITIONAL = 0; // non-Gregorian calendar that is locale-defined, required by ICU + const GREGORIAN = 1 ;// Gregorian calendar + +############################################################################# +# Object-oriented API +############################################################################# + /** + * Create a date formatter + * + * @param string $locale Locale to use when formatting or parsing + * @param integer $datetype Date type to use (none, short, medium, long, full) + * @param integer $timetype Time type to use (none, short, medium, long, full) + * @param [String] $timezone Time zone ID ; default is system default + * @param [integer] $calendar Calendar to use for formatting or parsing; default is + * GREGORIAN + * @param [string] $pattern Optional pattern to use when formatting or parsing + * @return DateFormatter + * @see __construct + * @see datefmt_create + */ + public function __construct($locale, $datetype, $timetype, $timezone = null, $calendar= null , $pattern= null) {} + + /** + * Create a date formatter + * + * @param string $locale Locale to use when formatting or parsing + * @param integer $datetype Date type to use (none, short, medium, long, full) + * @param integer $timetype Time type to use (none, short, medium, long, full) + * @param [string] $timezone Time zone ID ; default is system default + * @param [integer] $calendar Calendar to use for formatting or parsing; default is + * GREGORIAN + * @param [string] $pattern Optional pattern to use when formatting or parsing + * @return DateFormatter + * @see __construct + * @see datefmt_create + */ + public static function create($locale, $datetype, $timetype, $timezone = null, $calendar= null , $pattern= null) {} + + /** + * formats the time value as a string. + * @param mixed $value - value to format + * integer: a unix timestamp value (seconds since epoch, UTC) + * array: a localtime array - uses 24 hour clock in tm_hour field + * @return string a formatted string or, if an error occurred, 'null'. + */ + public function format($value) {} + + + /** + * converts string $value to an incremental time value, starting at + * $parse_pos and consuming as much of the input value as possible + * If no error occurs before $value is consumed, $parse_pos will contain -1 + * otherwise it will contain the position at which parsing ended (and the error + * occurred). + * @param string $value string to convert to a time + * @param integer $parse_pos position at which to start the parsing in $value (zero-based) + * This variable will contain the end position if the parse fails + * If $parse_pos > strlen($value), the parse fails immediately. + * @return integer timestamp parsed value + */ + public function parse($value, $parse_pos=0) {} + + + /** + * converts string $value to a field-based time value, starting at + * $parse_pos and consuming as much of the input value as possible + * If no error occurs before $value is consumed, $parse_pos will contain -1 + * otherwise it will contain the position at which parsing ended (and the error + * occurred). + * @param string $value string to convert to a time + * @param integer $parse_pos position at which to start the parsing in $value (zero-based) + * This variable will contain the end position if the parse fails + * If $parse_pos > strlen($value), the parse fails immediately. + * @return array localtime compatible array of integers - uses 24 hour clock in tm_hour field + */ + public function localtime($value, $parse_pos=0) {} + + + /** + * Gets the datetype in use + * @return integer the current 'datetype' value of the formatter + */ + public function getDateType() {} + + + /** + * Gets the timetype in use + * @return integer the current 'timetype' value of the formatter + */ + public function getTimeType() {} + + + /** + * Gets the leniency in use + * @return boolean 'true' if parser is lenient, 'false' if parser is strict + * default value for parser is 'false'. + */ + public function isLenient() {} + + + /** + * Sets the leniency to use + * @param boolean $lenient sets whether the parser is lenient or not, default is 'false' + * 'true' sets the parser to accept otherwise flawed date or + * time patterns, parsing as much as possible to obtain a value. + * 'false' sets the parser to strictly parse strings into dates. + * Extra space, unrecognized tokens, or invalid values + * ("Feburary 30th") are not accepted. + * + * @return boolean 'true' if successful; 'false' if an error occurred. + */ + public function setLenient($lenient) {} + + + /** + * Gets the locale in use + * @param [integer] which locale should be returned? + * values may include ULOC_ACTUAL_LOCALE, + * ULOC_VALID_LOCALE. By default the actual + * locale is returned. + * @return string the locale of this formatter or 'false' if error + */ + + public function getLocale($type = ULOC_ACTUAL_LOCALE) {} + + + /** + * @return string ID string for the time zone used by this formatter + */ + public function getTimeZoneId() {} + + + /** + * sets the time zone to use + * @param string $zone zone ID string of the time zone to use. + * if null or the empty string, the default time zone for + * the runtime is used. + * @return boolean 'true' on successful setting of the time zone, 'false' + * if an error occurred (such as the time zone wasn't recognized). + */ + public function setTimeZoneId($zone) {} + + + /** + * Sets the calendar used to the appropriate calendar, which must be + * one of the constants defined above. Some examples include: + * - Gregorian calendar + * - Traditional + * Default value is GREGORIAN + * @param integer $which the calendar (an enumerated constant) to use. + * @return boolean 'true' if successful, 'false' if an error occurred or if the calendar was not recognized + */ + public function setCalendar($which) {} + + + /** + * Gets the Calendar in use + * @return integer the calendar being used by the formatter + */ + public function getCalendar() {} + + + /** + * Gets the pattern in use + * @return string the pattern string being used to format/parse + */ + public function getPattern() {} + + + /** + * Sets the pattern to use + * @param string $pattern new pattern string to use + * @return boolean 'true' if successful, 'false' if an error occurred. Bad format + * strings are usually the cause of the latter. + */ + public function setPattern($pattern) {} + + + /** + * Get the error code from last operation + * + * Returns error code from the last number formatting operation. + * + * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. + */ + public function getErrorCode() {} + + + /** + * Get the error text from the last operation. + * + * @return string Description of the last error. + */ + public function getErrorMessage() {} + + +} + +############################################################################# +# Procedural API +############################################################################# + + + /** + * Create a date formatter + * + * @param string $locale Locale to use when formatting or parsing + * @param integer $datetype Date type to use (none, short, medium, long, full) + * @param integer $timetype Time type to use (none, short, medium, long, full) + * @param [string] $timezone Time zone ID ; default is system default + * @param [integer] $calendar Calendar to use for formatting or parsing; default is + * GREGORIAN + * @param [string] $pattern Optional pattern to use when formatting or parsing + * @return DateFormatter + * @see datefmt_create + */ + function datefmt_create($locale, $datetype, $timetype, $timezone = null, $calendar= null ,$pattern=null ) {} + + + /** + * formats the time value as a string. + * @param DateFormatter $fmt The date formatter resource + * @param mixed $value - value to format + * integer: a unix timestamp value (seconds since epoch, UTC) + * array: a localtime array - uses 24 hour clock in tm_hour field + * @return string a formatted string or, if an error occurred, 'null'. + */ + function datefmt_format($fmt , $value) {} + + + /** + * converts string $value to an incremental time value, starting at + * $parse_pos and consuming as much of the input value as possible + * If no error occurs before $value is consumed, $parse_pos will contain -1 + * otherwise it will contain the position at which parsing ended (and the error + * occurred). + * @param DateFormatter $fmt The date formatter resource + * @param string $value string to convert to a time + * @param integer $parse_pos position at which to start the parsing in $value (zero-based) + * This variable will contain the end position if the parse fails + * If $parse_pos > strlen($value), the parse fails immediately. + * @return integer timestamp parsed value + */ + function datefmt_parse($fmt , $value, $parse_pos=0) {} + + + /** + * converts string $value to a field-based time value, starting at + * $parse_pos and consuming as much of the input value as possible + * If no error occurs before $value is consumed, $parse_pos will contain -1 + * otherwise it will contain the position at which parsing ended (and the error + * occurred). + * @param DateFormatter $fmt The date formatter resource + * @param string $value string to convert to a time + * @param integer $parse_pos position at which to start the parsing in $value (zero-based) + * This variable will contain the end position if the parse fails + * If $parse_pos > strlen($value), the parse fails immediately. + * @return array localtime compatible array of integers - uses 24 hour clock in tm_hour field + */ + function datefmt_localtime($fmt , $value, $parse_pos=0) {} + + + /** + * Gets the Datetype in use + * @param DateFormatter $fmt The date formatter resource + * @return integer the current 'datetype' value of the formatter + */ + function datefmt_get_datetype($fmt ) {} + + + /** + * Gets the timetype in use + * @param DateFormatter $fmt The date formatter resource + * @return integer the current 'timetype' value of the formatter + */ + function datefmt_get_timetype($fmt) {} + + + /** + * Gets the leniency of the formatter + * @param DateFormatter $fmt The date formatter resource + * @return boolean 'true' if parser is lenient, 'false' if parser is strict + * default value for parser is 'false'. + */ + function datefmt_is_lenient($fmt) {} + + + /** + * Sets the leniency of the formatter + * @param DateFormatter $fmt The date formatter resource + * @param boolean $lenient sets whether the parser is lenient or not, default is 'false' + * 'true' sets the parser to accept otherwise flawed date or + * time patterns, parsing as much as possible to obtain a value. + * 'false' sets the parser to strictly parse strings into dates. + * Extra space, unrecognized tokens, or invalid values + * ("Feburary 30th") are not accepted. + * + * @return boolean 'true' if successful; 'false' if an error occurred. + */ + function datefmt_set_lenient($fmt , $lenient) {} + + + /** + * Gets the locale in use + * @param DateFormatter $fmt The date formatter resource + * @param [integer] which locale should be returned? + * values may include ULOC_ACTUAL_LOCALE, + * ULOC_VALID_LOCALE. By default the actual + * locale is returned. + * @return string the locale of this formatter or 'false' if error + */ + function datefmt_get_locale($fmt , $type = ULOC_ACTUAL_LOCALE) {} + + + /** + * Gets the time zone id in use + * @param DateFormatter $fmt The date formatter resource + * @return string ID string for the time zone used by this formatter + */ + function datefmt_get_timezone_id($fmt) {} + + + /** + * Sets the time zone to use + * @param DateFormatter $fmt The date formatter resource + * @param string $zone zone ID string of the time zone to use. + * if null or the empty string, the default time zone for + * the runtime is used. + * @return boolean 'true' on successful setting of the time zone, 'false' + * if an error occurred (such as the time zone wasn't recognized). + */ + function datefmt_set_timezone_id($fmt , $zone) {} + + + /** + * Sets the calendar used to the appropriate calendar, which must be + * one of the constants defined above. Some examples include: + * - Gregorian calendar + * - Traditional + * Default value is GREGORIAN + * @param DateFormatter $fmt The date formatter resource + * @param integer $which the calendar (an enumerated constant) to use. + * @return boolean 'true' if successful, 'false' if an error occurred or if the calendar was not recognized + */ + function datefmt_set_calendar($fmt , $which) {} + + + /** + * Gets the calendar in use + * @param DateFormatter $fmt The date formatter resource + * @return integer the calendar being used by the formatter + */ + function datefmt_get_calendar($fmt) {} + + + /** + * Gets the pattern in use + * @param DateFormatter $fmt The date formatter resource + * @return string the pattern string being used to format/parse + */ + function datefmt_get_pattern($fmt) {} + + + /** + * Sets the pattern to use + * @param DateFormatter $fmt The date formatter resource + * @param string $pattern new pattern string to use + * @return boolean 'true' if successful, 'false' if an error occurred. Bad format + * strings are usually the cause of the latter. + */ + function datefmt_set_pattern($fmt , $pattern) {} + + + /** + * Get the error code from last operation + * + * @param DateFormatter $fmt The date formatter resource + * Returns error code from the last number formatting operation. + * + * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. + */ + function datefmt_get_error_code($fmt) {} + + + /** + * Get the error text from the last operation. + * + * @param DateFormatter $fmt The date formatter resource + * @return string Description of the last error. + */ + function datefmt_get_error_message($fmt) {} diff --git a/ext/intl/doc/formatter_api.php b/ext/intl/doc/formatter_api.php new file mode 100644 index 0000000..14d98db --- /dev/null +++ b/ext/intl/doc/formatter_api.php @@ -0,0 +1,500 @@ +<?php + +/** + * Number formatter class - locale-dependent number formatting/parsing. + * + * This class represents the ICU number formatting functionality. It allows to display + * number according to the localized format or given pattern or set of rules, and to + * parse strings into numbers according to the above patterns. + * + * Example: + * <code> + * $value = 1234567; + * $formatter = new NumberFormatter("de_DE", NumberFormatter::DECIMAL); + * echo $formatter->format($value); + * </code> + * + * @see http://www.icu-project.org/apiref/icu4c/unum_8h.html + * @see http://www.icu-project.org/apiref/icu4c/classNumberFormat.html + * + * The class would also contain all the constants listed in the following enums: + * UNumberFormatStyle, UNumberFormatRoundingMode, UNumberFormatPadPosition, + * UNumberFormatAttribute, UNumberFormatTextAttribute, UNumberFormatSymbol. + */ +class NumberFormatter { +############################################################################# +# Common constants. +############################################################################# + + /* + * WARNING: + * The values described here are NOT the actual values in PHP code. + * They are references to the ICU C definitions, so the line + * const PATTERN_DECIMAL = 'UNUM_PATTERN_DECIMAL'; + * actually means that NumberFormatter::PATTERN_DECIMAL is the same as + * UNUM_PATTERN_DECIMAL constant in the ICU library. + */ + + /* + * These constants define formatter/parser argument type - integer, floating point or currency. + */ + const TYPE_DEFAULT = 'FORMAT_TYPE_DEFAULT'; + const TYPE_INT32 = 'FORMAT_TYPE_INT32'; + const TYPE_INT64 = 'FORMAT_TYPE_INT64'; + const TYPE_DOUBLE = 'FORMAT_TYPE_DOUBLE'; + const TYPE_CURRENCY = 'FORMAT_TYPE_CURRENCY'; + + /* + * UNumberFormatStyle constants + */ + const PATTERN_DECIMAL = 'UNUM_PATTERN_DECIMAL'; + const DECIMAL = 'UNUM_DECIMAL'; + const CURRENCY = 'UNUM_CURRENCY'; + const PERCENT = 'UNUM_PERCENT'; + const SCIENTIFIC = 'UNUM_SCIENTIFIC'; + const SPELLOUT = 'UNUM_SPELLOUT'; + const ORDINAL = 'UNUM_ORDINAL'; + const DURATION = 'UNUM_DURATION'; + const PATTERN_RULEBASED = 'UNUM_PATTERN_RULEBASED'; + const DEFAULT = 'UNUM_DEFAULT'; + const IGNORE = 'UNUM_IGNORE'; + + /* + * UNumberFormatRoundingMode + */ + const ROUND_CEILING = 'UNUM_ROUND_CEILING'; + const ROUND_FLOOR = 'UNUM_ROUND_FLOOR'; + const ROUND_DOWN = 'UNUM_ROUND_DOWN'; + const ROUND_UP = 'UNUM_ROUND_UP'; + const ROUND_HALFEVEN = 'UNUM_ROUND_HALFEVEN'; + const ROUND_HALFDOWN = 'UNUM_ROUND_HALFDOWN'; + const ROUND_HALFUP = 'UNUM_ROUND_HALFUP'; + + /* + * UNumberFormatPadPosition + */ + const PAD_BEFORE_PREFIX = 'UNUM_PAD_BEFORE_PREFIX'; + const PAD_AFTER_PREFIX = 'UNUM_PAD_AFTER_PREFIX'; + const PAD_BEFORE_SUFFIX = 'UNUM_PAD_BEFORE_SUFFIX'; + const PAD_AFTER_SUFFIX = 'UNUM_PAD_AFTER_SUFFIX'; + + /* + * UNumberFormatAttribute + */ + const PARSE_INT_ONLY = 'UNUM_PARSE_INT_ONLY'; + const GROUPING_USED = 'UNUM_GROUPING_USED'; + const DECIMAL_ALWAYS_SHOWN = 'UNUM_DECIMAL_ALWAYS_SHOWN'; + const MAX_INTEGER_DIGITS = 'UNUM_MAX_INTEGER_DIGITS'; + const MIN_INTEGER_DIGITS = 'UNUM_MIN_INTEGER_DIGITS'; + const INTEGER_DIGITS = 'UNUM_INTEGER_DIGITS'; + const MAX_FRACTION_DIGITS = 'UNUM_MAX_FRACTION_DIGITS'; + const MIN_FRACTION_DIGITS = 'UNUM_MIN_FRACTION_DIGITS'; + const FRACTION_DIGITS = 'UNUM_FRACTION_DIGITS'; + const MULTIPLIER = 'UNUM_MULTIPLIER'; + const GROUPING_SIZE = 'UNUM_GROUPING_SIZE'; + const ROUNDING_MODE = 'UNUM_ROUNDING_MODE'; + const ROUNDING_INCREMENT = 'UNUM_ROUNDING_INCREMENT'; + const FORMAT_WIDTH = 'UNUM_FORMAT_WIDTH'; + const PADDING_POSITION = 'UNUM_PADDING_POSITION'; + const SECONDARY_GROUPING_SIZE = 'UNUM_SECONDARY_GROUPING_SIZE'; + const SIGNIFICANT_DIGITS_USED = 'UNUM_SIGNIFICANT_DIGITS_USED'; + const MIN_SIGNIFICANT_DIGITS = 'UNUM_MIN_SIGNIFICANT_DIGITS'; + const MAX_SIGNIFICANT_DIGITS = 'UNUM_MAX_SIGNIFICANT_DIGITS'; + const LENIENT_PARSE = 'UNUM_LENIENT_PARSE'; + + /* + * UNumberFormatTextAttribute + */ + const POSITIVE_PREFIX = 'UNUM_POSITIVE_PREFIX'; + const POSITIVE_SUFFIX = 'UNUM_POSITIVE_SUFFIX'; + const NEGATIVE_PREFIX = 'UNUM_NEGATIVE_PREFIX'; + const NEGATIVE_SUFFIX = 'UNUM_NEGATIVE_SUFFIX'; + const PADDING_CHARACTER = 'UNUM_PADDING_CHARACTER'; + const CURRENCY_CODE = 'UNUM_CURRENCY_CODE'; + const DEFAULT_RULESET = 'UNUM_DEFAULT_RULESET'; + const PUBLIC_RULESETS = 'UNUM_PUBLIC_RULESETS'; + + /* + * UNumberFormatSymbol + */ + const DECIMAL_SEPARATOR_SYMBOL = 'UNUM_DECIMAL_SEPARATOR_SYMBOL'; + const GROUPING_SEPARATOR_SYMBOL = 'UNUM_GROUPING_SEPARATOR_SYMBOL'; + const PATTERN_SEPARATOR_SYMBOL = 'UNUM_PATTERN_SEPARATOR_SYMBOL'; + const PERCENT_SYMBOL = 'UNUM_PERCENT_SYMBOL'; + const ZERO_DIGIT_SYMBOL = 'UNUM_ZERO_DIGIT_SYMBOL'; + const DIGIT_SYMBOL = 'UNUM_DIGIT_SYMBOL'; + const MINUS_SIGN_SYMBOL = 'UNUM_MINUS_SIGN_SYMBOL'; + const PLUS_SIGN_SYMBOL = 'UNUM_PLUS_SIGN_SYMBOL'; + const CURRENCY_SYMBOL = 'UNUM_CURRENCY_SYMBOL'; + const INTL_CURRENCY_SYMBOL = 'UNUM_INTL_CURRENCY_SYMBOL'; + const MONETARY_SEPARATOR_SYMBOL = 'UNUM_MONETARY_SEPARATOR_SYMBOL'; + const EXPONENTIAL_SYMBOL = 'UNUM_EXPONENTIAL_SYMBOL'; + const PERMILL_SYMBOL = 'UNUM_PERMILL_SYMBOL'; + const PAD_ESCAPE_SYMBOL = 'UNUM_PAD_ESCAPE_SYMBOL'; + const INFINITY_SYMBOL = 'UNUM_INFINITY_SYMBOL'; + const NAN_SYMBOL = 'UNUM_NAN_SYMBOL'; + const SIGNIFICANT_DIGIT_SYMBOL = 'UNUM_SIGNIFICANT_DIGIT_SYMBOL'; + const MONETARY_GROUPING_SEPARATOR_SYMBOL = 'UNUM_MONETARY_GROUPING_SEPARATOR_SYMBOL'; + + /** + * Create a number formatter + * + * Creates a number formatter from locale and pattern. This formatter would be used to + * format or parse numbers. + * + * @param integer $style Style of the formatting, one of the UNumberFormatStyle constants + * @param string $locale Locale in which the number would be formatted + * @param [string] $pattern Pattern string in case chose style requires pattern + * @return NumberFormatter + */ + public function __construct($locale, $style, $pattern = null) {} + + /** + * Create a number formatter + * + * Creates a number formatter from locale and pattern. This formatter would be used to + * format or parse numbers. + * + * This method is useful when you prefer just to get null on error, + * as if you called numfmt_create(). + * + * @param integer $style Style of the formatting, one of the UNumberFormatStyle constants + * @param string $locale Locale in which the number would be formatted + * @param [string] $pattern Pattern string in case chose style requires pattern + * @return NumberFormatter + * @see __construct + * @see numfmt_create + */ + public static function create($locale, $style, $pattern = null) {} + + /** + * Format a number according to current formatting rules. + * + * If the type is not specified, the type is derived from the $number parameter. I.e., if it's + * integer then INT32 would be chosen on 32-bit, INT64 on 64-bit, if it's double, DOUBLE would be + * chosen. It is possible to format 64-bit number on 32-bit machine by passing it as double and using + * TYPE_INT64. + * When formatting currency, default formatter's currency code is used. + * + * @param integer|double $number Number to format + * @param [integer] $type Type of the formatting - one of TYPE constants. If not specified, default for the type. + * @return string formatted number + */ + public function format($number, $type = 0) {} + + /** + * Parse a number according to current formatting rules. + * + * @param string $string String to parse + * @param [integer] $type Type of the formatting - one of TYPE constants. + * TYPE_DOUBLE is used by default. + * @param [integer] $position On input, the position to start parsing, default is 0; + * on output, moved to after the last successfully parse character; + * on parse failure, does not change. + * @return integer|double|false Parsed number, false if parsing failed + */ + public function parse($string, $type, &$position) {} + + /** + * Format number as currency. + * + * Uses user-defined currency string. + * + * @param double $number Number to format + * @param string $currency 3-letter currency code (ISO 4217) to use in format + */ + public function formatCurrency($number, $currency) {} + + /** + * Parse currency string + * + * This parser would use parseCurrency API string to parse currency string. The format is defined by the + * formatter, returns both number and currency code. + * + * @param string $string String to parse + * @param string $currency Parameter to return parsed currency code + * @param [integer] $position On input, the position within text to match, default is 0; + * on output, the position after the last matched character; + * on parse failure, does not change. + * @return double currency number + */ + public function parseCurrency($string, &$currency, &$position) {} + + /** + * Set formatter attribute. + * + * This function is used to set any of the formatter attributes. Example: + * + * $formatter->setAttribute(NumberFormat::FORMAT_WIDTH, 10); + * + * @param integer $attr One of UNumberFormatAttribute constants + * @param integer|double $value Value of the attribute + * @return false if attribute is unknown or can not be set, true otherwise + */ + public function setAttribute($attr, $value) {} + /** + * Set formatter attribute. + * + * This function is used to set any of the formatter attributes. Example: + * + * $formatter->setTextAttribute(NumberFormat::POSITIVE_PREFIX, "+"); + * + * @param integer $attr One of UNumberFormatTextAttribute constants + * @param string $value Value of the attribute + * @return false if attribute is unknown or can not be set, true otherwise + */ + public function setTextAttribute($attr, $value) {} + /** + * Set formatting symbol. + * + * Example: + * + * $formatter->setSymbol(NumberFormat::EXPONENTIAL_SYMBOL, "E"); + * + * @param integer|array $attr One of UNumberFormatSymbol constants or array of symbols, indexed by + * these constants + * @param string $value Value of the symbol + */ + public function setSymbol($attr, $value) {} + /** + * Set pattern used by the formatter + * + * Valid only if the formatter is using pattern and is not rule-based. + * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html + * Localized patterns are not currently supported. + * + * @param string $pattern The pattern to be used. + * @return boolean false if formatter pattern could not be set, true otherwise + */ + public function setPattern($pattern) {} + /** + * Get value of the formatter attribute + * + * @param integer $attr One of UNumberFormatAttribute constants + * @return integer|double value of the attribute or false if the value can not be obtained + */ + public function getAttribute($attr) {} + /** + * Get value of the formatter attribute + * + * @param integer $attr One of UNumberFormatTextAttribute constants + * @return string value of the attribute or false if the value can not be obtained + */ + public function getTextAttribute($attr) {} + /** + * Get value of the formatter symbol + * + * @param integer $attr One of UNumberFormatSymbol constants specifying the symbol + * @return string|false The symbol value, or false if the value can not be obtained + */ + public function getSymbol($attr) {} + /** + * Get pattern used by the formatter. + * + * Gets current state of the formatter as a pattern. + * Localized patterns are not currently supported. + * + * Valid only if the formatter is UNUM_PATTERN_DECIMAL + * @return string|false The pattern used by the formatter or false if formatter is of a type + * that does not support patterns. + */ + public function getPattern() {} + /** + * Get the locale for which the formatter was created. + * + * @param [integer] $type One of ULocDataLocaleType values + * @return string locale name + */ + public function getLocale($type = 0) {} + /** + * Get the error code from last operation + * + * Returns error code from the last number formatting operation. + * + * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. + */ + public function getErrorCode() {} + /** + * Get the error text from the last operation. + * + * @return string Description of the last occurred error. + */ + public public function getErrorMessage() {} + +} + +/** Now the same as procedural API */ + +/** + * Create a number formatter + * + * Creates a number formatter from locale and pattern. This formatter would be used to + * format or parse numbers. + * + * @param string $locale Locale in which the number would be formatted + * @param integer $style Style of the formatting, one of the UNumberFormatStyle constants + * @param [string] $pattern Pattern string in case chose style requires pattern + * @return Numberformatter resource NumberFormatter + */ +function numfmt_create($locale, $style, $pattern = null) {} +/** + * Format a number according to current formatting rules. + * + * If the type is not specified, the type is derived from the $number parameter. I.e., if it's + * integer then INT32 would be chosen on 32-bit, INT64 on 64-bit, if it's double, DOUBLE would be + * chosen. It is possible to format 64-bit number on 32-bit machine by passing it as double and using + * TYPE_INT64. + * + * @param NumberFormatter $formatter The formatter resource + * @param integer|double $number Number to format + * @param [integer] $type Type of the formatting - one of TYPE constants. If not specified, default for the type. + * @return string formatted number + */ +function numfmt_format($formatter, $number, $type = null) {} +/** + * Parse a number according to current formatting rules. + * + * This parser uses DOUBLE type by default. When parsing currency, + * default currency definitions are used. + * + * @param NumberFormatter $formatter The formatter resource + * @param string $string String to parse + * @param [integer] $type Type of the formatting - one of TYPE constants. + * @param [integer] $position String position after the end of parsed data. + * @return integer|double|false Parsed number, false if parsing failed + */ +function numfmt_parse($formatter, $string, $type, &$position) {} +/** + * Format number as currency. + * + * Uses user-defined currency string. + * + * @param NumberFormatter $formatter The formatter resource + * @param double $number Number to format + * @param string $currency 3-letter currency code (ISO 4217) to use in format + */ +function numfmt_format_currency($formatter, $number, $currency) {} +/** + * Parse currency string + * + * This parser would use parseCurrency API string to parse currency string. The format is defined by the + * formatter, returns both number and currency code. + * + * @param NumberFormatter $formatter The formatter resource + * @param string $string String to parse + * @param string $currency Parameter to return parsed currency code + * @param [integer] $position String position after the end of parsed data. + * @return double currency number + */ +function numfmt_parse_currency($formatter, $string, &$currency, &$position) {} +/** + * Set formatter attribute. + * + * This function is used to set any of the formatter attributes. Example: + * + * numfmt_format_set_attribute($formatter, NumberFormat::FORMAT_WIDTH, 10); + * + * @param NumberFormatter $formatter The formatter resource + * @param integer $attr One of UNumberFormatAttribute constants + * @param integer|double $value Value of the attribute + * @return false if attribute is unknown or can not be set, true otherwise + */ +function numfmt_set_attribute($formatter, $attribute, $value) {} +/** + * Set formatter attribute. + * + * This function is used to set any of the formatter attributes. Example: + * + * numfmt_format_set_text_attribute($formatter, NumberFormat::POSITIVE_PREFIX, "+"); + * + * @param NumberFormatter $formatter The formatter resource + * @param integer $attr One of UNumberFormatTextAttribute constants + * @param string $value Value of the attribute + * @return false if attribute is unknown or can not be set, true otherwise + */ +function numfmt_set_text_attribute($formatter, $attribute, $value) {} +/** + * Set formatting symbol. + * + * Example: + * + * $formatter->setSymbol(NumberFormat::EXPONENTIAL_SYMBOL, "E"); + * + * @param NumberFormatter $formatter The formatter resource + * @param integer|array $attr One of UNumberFormatSymbol constants or array of symbols, + * indexed by these constants + * @param string $value Value of the symbol + */ +function numfmt_set_symbol($formatter, $attribute, $value) {} +/** + * Set pattern used by the formatter + * + * Valid only if the formatter is using pattern and is not rule-based. + * @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html + * Localized patterns are not currently supported. + * + * @param NumberFormatter $formatter The formatter resource + * @param string $pattern The pattern to be used. + * @return boolean false if formatter pattern could not be set, true otherwise + */ +function numfmt_set_pattern($formatter, $pattern) {} +/** + * Get value of the formatter attribute + * + * @param NumberFormatter $formatter The formatter resource + * @param integer $attribute One of UNumberFormatAttribute constants + * @return integer|double value of the attribute or false if the value can not be obtained + */ +function numfmt_get_attribute($formatter, $attribute) {} +/** + * Get value of the formatter attribute + * + * @param NumberFormatter $formatter The formatter resource + * @param integer $attribute One of UNumberFormatTextAttribute constants + * @return string value of the attribute or false if the value can not be obtained + */ +function numfmt_get_text_attribute($formatter, $attribute) {} +/** + * Get value of the formatter symbol + * + * @param NumberFormatter $formatter The formatter resource + * @param integer $attribute One of UNumberFormatSymbol constants specifying the symbol + * @return string|false The symbol value, or false if the value can not be obtained + */ +function numfmt_get_symbol($formatter, $attribute) {} +/** + * Get pattern used by the formatter. + * + * Gets current state of the formatter as a pattern. + * Localized patterns are not currently supported. + * + * Valid only if the formatter is UNUM_PATTERN_DECIMAL + * @param NumberFormatter $formatter The formatter resource + * @return string|false The pattern used by the formatter or false if formatter is of a type + * that does not support patterns. + */ +function numfmt_get_pattern($formatter) {} +/** + * Get the locale for which the formatter was created. + * + * @param NumberFormatter $formatter The formatter resource + * @param [integer] $type One of ULocDataLocaleType values + * @return string locale name + */ +function numfmt_get_locale($formatter, $type = 0) {} +/** + * Get the error code from last operation + * + * Returns error code from the last number formatting operation. + * + * @param NumberFormatter $formatter The formatter resource + * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. + */ +function numfmt_get_error_code($formatter) {} +/** + * Get the error text from the last operation. + * + * @param NumberFormatter $formatter The formatter resource + * @return string Description of the last occurred error. + */ +function numfmt_get_error_message($formatter) {} diff --git a/ext/intl/doc/grapheme_api.php b/ext/intl/doc/grapheme_api.php new file mode 100644 index 0000000..465453f --- /dev/null +++ b/ext/intl/doc/grapheme_api.php @@ -0,0 +1,132 @@ +<?php +############################################################################# +# Grapheme constants. +############################################################################# + + /** + * grapheme_extract extract_type + * + */ + /** Extract the given number of whole grapheme clusters from the string: */ + define('GRAPHEME_EXTR_COUNT', 0); + /** Extract as many whole grapheme clusters as will fit into the given number of bytes: */ + define('GRAPHEME_EXTR_MAXBYTES', 1); + /** Extract whole grapheme clusters up to a maximum number of UTF-8 characters: */ + define('GRAPHEME_EXTR_MAXCHARS', 2); + + +############################################################################# +# Grapheme API +############################################################################# + + /** + * Get string length in grapheme units + * @param string $input The string being measured for length. + * @return int The length of the string on success, and 0 if the string is empty. + */ + function grapheme_strlen($input) {} + + /** + * Find position (in grapheme units) of first occurrence of a string + * @param string $haystack The string to look in + * @param string $needle The string to look for + * @param [int] $offset The optional offset parameter allows you to specify + which character in haystack to start searching. The position + returned is still relative to the beginning of haystack. + * @return int Returns the position as an integer. If needle is not found, strpos() will return boolean FALSE. + */ + function grapheme_strpos($haystack, $needle, $offset = 0) {} + + + /** + * Find position (in grapheme units) of first occurrence of a case-insensitive string + * @param string $haystack The string to look in + * @param string $needle The string to look for + * @param [int] $offset The optional offset parameter allows you to specify + which character in haystack to start searching. The position + returned is still relative to the beginning of haystack. + * @return int Returns the position as an integer. If needle is not found, grapheme_stripos() will return boolean FALSE. + */ + function grapheme_stripos($haystack, $needle, $offset = 0) {} + + + /** + * Find position (in grapheme units) of last occurrence of a string + * @param string $haystack The string to look in + * @param string $needle The string to look for + * @param [int] $offset The optional offset parameter allows you to specify + which character in haystack to start searching. The position + returned is still relative to the beginning of haystack. + * @return int Returns the position as an integer. If needle is not found, grapheme_strrpos() will return boolean FALSE. + */ + function grapheme_strrpos($haystack, $needle, $offset = 0) {} + + + /** + * Find position (in grapheme units) of last occurrence of a case-insensitive string + * @param string $haystack The string to look in + * @param string $needle The string to look for + * @param [int] $offset The optional offset parameter allows you to specify + which character in haystack to start searching. The position + returned is still relative to the beginning of haystack. + * @return int Returns the position as an integer. If needle is not found, grapheme_strripos() will return boolean FALSE. + */ + function grapheme_strripos($haystack, $needle, $offset = 0) {} + + + /** + * Return part of a string + * @param string $string The input string. + * @param int $start If start is non-negative, the returned string will start at the + start'th position in string, counting from zero. If start is negative, + the returned string will start at the start'th character from the + end of string. + * @param [int] $length If length is given and is positive, the string returned will contain + at most length characters beginning from start (depending on the + length of string). If string is less than or equal to start characters + long, FALSE will be returned. If length is given and is negative, then + that many characters will be omitted from the end of string (after the + start position has been calculated when a start is negative). If start + denotes a position beyond this truncation, an empty string will be returned. + * @return int Returns the extracted part of string. + */ + function grapheme_substr($string, $start, $length = -1) {} + + + /** + * Returns part of haystack string from the first occurrence of needle to the end of haystack. + * @param string $haystack The input string. + * @param string $needle The string to look for. + * @param [boolean] $before_needle If TRUE (the default is FALSE), grapheme_strstr() returns the part of the + haystack before the first occurence of the needle. + * @return string Returns the portion of string, or FALSE if needle is not found. + */ + function grapheme_strstr($haystack, $needle, $before_needle = FALSE) {} + + + /** + * Returns part of haystack string from the first occurrence of case-insensitive needle to the end of haystack. + * @param string $haystack The input string. + * @param string $needle The string to look for. + * @param [boolean] $before_needle If TRUE (the default is FALSE), grapheme_strstr() returns the part of the + haystack before the first occurence of the needle. + * @return string Returns the portion of string, or FALSE if needle is not found. + */ + function grapheme_stristr($haystack, $needle, $before_needle = FALSE) {} + + + /** + * Function to extract a sequence of default grapheme clusters from a text buffer, which must be encoded in UTF-8. + * @param string $haystack string to search + * @param int $size maximum number of units - based on the $extract_type - to return + * @param [int] $extract_type one of GRAPHEME_EXTR_COUNT (default), GRAPHEME_EXTR_MAXBYTES, or GRAPHEME_EXTR_MAXCHARS + * @param [int] $start starting position in $haystack in bytes + * @param [&int] $next set to next starting position in bytes + * @return string A string starting at offset $start containing no more than $size grapheme clusters + and ending on a default grapheme cluster boundary. + */ + function grapheme_extract($haystack, $size, $extract_type = GRAPHEME_EXTR_COUNT, $start = 0, &$next) {} + +?> + + diff --git a/ext/intl/doc/locale_api.php b/ext/intl/doc/locale_api.php new file mode 100644 index 0000000..c6c41ed --- /dev/null +++ b/ext/intl/doc/locale_api.php @@ -0,0 +1,434 @@ +<?php + +/** + * A "Locale" is an identifier used to get language, culture, or regionally-specific + * behavior from an API. PHP locales are organized and identified the same + * way that the CLDR locales used by ICU (and many vendors of Unix-like operating + * systems, the Mac, Java, and so forth) use. Locales are identified using + * RFC 4646 language tags (which use hyphen, not underscore) in addition to the + * more traditional underscore-using identifiers. Unless otherwise noted + * the functions in this class are tolerant of both formats. + * + * Examples of identifiers include: + * + * * en-US (English, United States) + * * zh-Hant-TW (Chinese, Traditional Script, Taiwan) + * * fr-CA, fr-FR (French for Canada and France respectively) + * + * The Locale class (and related procedural functions) are used to interact + * with locale identifiers--to verify that an ID is well-formed, valid, + * etc. The extensions used by CLDR in UAX #35 (and inherited by ICU) are + * valid and used wherever they would be in ICU normally. + * + * Locales cannot be instantiated as objects. All of the functions/methods + * provided are static. + * + * * The null or empty string obtains the "root" locale. + * The "root" locale is equivalent to "en_US_POSIX" in CLDR. + * * Language tags (and thus locale identifiers) are case insensitive. There + * exists a canonicalization function to make case match the specification. + * + * @see http://www.icu-project.org/apiref/icu4c/uloc_8h.html + * @see http://www.unicode.org/reports/tr35/ + * + */ +class Locale { + +############################################################################# +# Common constants. +############################################################################# + + /** + * The following static members are used with the getLocale methods of + * the various locale affected classes, such as numfmt. + */ + const DEFAULT_LOCALE = null; + + /** + * identifiers for the actual locale, valid locale + * WARNING: + * The values described here are NOT the actual values in PHP code. + * They are references to the ICU C definitions, so the line + * const ACTUAL_LOCALE = 'ULOC_ACTUAL_LOCALE'; + * actually means that Locale::ACTUAL_LOCALE is the same as + * ULOC_ACTUAL_LOCALE constant in the ICU library. + */ + const ACTUAL_LOCALE = 'ULOC_ACTUAL_LOCALE'; + const VALID_LOCALE = 'ULOC_VALID_LOCALE'; + + /** + * Valid locale tag and subtag values + */ + const LANG_TAG = "language"; + const EXTLANG_TAG = "extlang"; + const SCRIPT_TAG = "script"; + const REGION_TAG = "region"; + const VARIANT_TAG = "variant"; + const GRANDFATHERED_LANG_TAG = "grandfathered"; + const PRIVATE_TAG = "private"; + + +############################################################################# +# Object-oriented API +############################################################################# + + /** + * Gets the default locale value from the INTL global 'default_locale' + * At the PHP initilaization (MINIT) this value is set to + * 'intl.default_locale' value from php.ini if that value exists + * or from ICU's function uloc_getDefault() + * Then onwards picks up changes from setDefault() calls also + * + * @return string the current runtime locale + */ + public static function getDefault() {} + + /** + * sets the default runtime locale to $locale + * This changes the value of INTL global 'default_locale' + * + * @param string $locale is a BCP 47 compliant language tag containing the + * locale identifier. UAX #35 extensions are accepted. + * @return boolean 'true' if okay, 'false' if an error + */ + public static function setDefault($locale) {} + + + /** + * Gets the primary language for the input locale + * + * @param string $locale the locale to extract the primary language code from + * @return string the language code associated with the language + * or null in case of error. + */ + public static function getPrimaryLanguage($locale) {} + + + /** + * Gets the script for the input locale + * + * @param string $locale the locale to extract the script code from + * @return string the script subtag for the locale or null if not present + */ + public static function getScript($locale) {} + + + /** + * Gets the region for the input locale + * + * @param string $locale the locale to extract the region code from + * @return string the region subtag for the locale or null if not present + */ + public static function getRegion($locale) {} + + + /** + * Gets the variants for the input locale + * + * @param string $locale the locale to extract the variants from + * @return array the array containing the list of all variants + * subtag for the locale or null if not present + */ + public static function getAllVariants($locale) {} + + + /** + * Gets the keywords for the input locale + * + * @param string $locale the locale to extract the keywords from + * @return array associative array containing the keyword-value pairs for this locale + */ + public static function getKeywords($locale) {} + + + /** + * Returns an appropriately localized display name for the input locale + * + * @param string $locale the locale to return a displayname for + * @param [string] $in_locale optional format locale + * If is 'null' then the default locale is used. + * @return string display name of the locale in the format + * appropriate for $in_locale. + */ + public static function getDisplayName($locale, $in_locale = null) {} + + + /** + * Returns an appropriately localized display name for language of the input locale + * + * @param string $locale the locale to return a display language for + * @param [string] $in_locale optional format locale to use to display the language name + * If is 'null' then the default locale is used. + * @return string display name of the language for the $locale in the format + * appropriate for $in_locale. + */ + public static function getDisplayLanguage($lang, $in_locale = null) {} + + /** + * Returns an appropriately localized display name for script of the input locale + * + * @param string $locale the locale to return a display script for + * @param [string] $in_locale optional format locale to use to display the script name + * If is 'null' then the default locale is used. + * @return string display name of the script for the $locale in the format + * appropriate for $in_locale. + */ + public static function getDisplayScript($script, $in_locale = null) {} + + + /** + * Returns an appropriately localized display name for region of the input locale + * + * @param string $locale the locale to return a display region for + * @param [string] $in_locale optional format locale to use to display the region name + * If is 'null' then the default locale is used. + * @return string display name of the region for the $locale in the format + * appropriate for $in_locale. + */ + public static function getDisplayRegion($region, $in_locale = null) {} + + + /** + * Returns an appropriately localized display name for variants of the input locale + * + * @param string $locale the locale to return a display variant for + * @param [string] $in_locale optional format locale to use to display the variant name + * If is 'null' then the default locale is used. + * @return string display name of the variant for the $locale in the format + * appropriate for $in_locale. + */ + public static function getDisplayVariant($variant, $in_locale = null) {} + + + /** + * Checks if a $langtag filter matches with $locale according to + * RFC 4647's basic filtering algorithm + * + * @param string $langtag the language tag to check + * @param string $locale the language range to check against + * @param bool $canonicalize Canonicalize parameters? + * @return boolean 'true' if $locale matches $langtag 'false' otherwise + */ + public static function filterMatches($langtag, $locale, $canonicalize) {} + + /** + * Searchs the items in $langtag for the best match to the language + * range specified in $locale according to RFC 4647's lookup algorithm. + * + * @param array $langtag an array containing a list of language tags to compare + * to $locale + * @param string $locale the locale to use as the language range when matching + * @param string $default the locale to use if no match is found + * @return string closest matching language tag, $default, + * or empty string + */ + public static function lookup(array $langtag, $locale, $default = null) {} + + + /** + * Returns a correctly ordered and delimited locale ID + * + * @param array $subtags an array containing a list of key-value pairs, where + * the keys identify the particular locale ID subtags, + * and the values are the associated subtag values. + * + * @return string the corresponding locale identifier. + */ + public static function composeLocale(array $subtags) {} + + + /** + * Returns a key-value array of locale ID subtag elements. + * + * @param string $locale the locale to extract the subtag array from + * + * @return array $subtags an array containing a list of key-value pairs, where + * the keys identify the particular locale ID subtags, + * and the values are the associated subtag values. + */ + public static function parseLocale($locale) {} + +} + +############################################################################# +# Procedural API +############################################################################# + + + /** + * Gets the default locale value from the INTL global 'default_locale' + * At the PHP initilaization (MINIT) this value is set to + * 'intl.default_locale' value from php.ini if that value exists + * or from ICU's function uloc_getDefault() + * Then onwards picks up changes from setDefault() calls also + * + * @return string the current runtime locale + */ + function locale_get_default() {} + + /** + * sets the default runtime locale to $locale + * This changes the value of INTL global 'default_locale' + * + * @param string $locale is a BCP 47 compliant language tag containing the + * locale identifier. UAX #35 extensions are accepted. + * @return boolean 'true' if okay, 'false' if an error + */ + function locale_set_default($locale) {} + + + /** + * Gets the primary language for the input locale + * + * @param string $locale the locale to extract the primary language code from + * @return string the language code associated with the language + * or null in case of error. + */ + function locale_get_primary_language($locale) {} + + + /** + * Gets the script for the input locale + * + * @param string $locale the locale to extract the script code from + * @return string the script subtag for the locale or null if not present + */ + function locale_get_script($locale) {} + + + /** + * Gets the region for the input locale + * + * @param string $locale the locale to extract the region code from + * @return string the region subtag for the locale or null if not present + */ + function locale_get_region($locale) {} + + + /** + * Gets the variants for the input locale + * + * @param string $locale the locale to extract the variants from + * @return array the array containing the list of all variants + * subtag for the locale or null if not present + */ + function locale_get_all_variants($locale) {} + + + /** + * Gets the keywords for the input locale + * + * @param string $locale the locale to extract the keywords from + * @return array associative array containing the keyword-value pairs for this locale + */ + function locale_get_keywords($locale) {} + + + /** + * Returns an appropriately localized display name for the input locale + * + * @param string $locale the locale to return a displayname for + * @param [string] $in_locale optional format locale + * If is 'null' then the default locale is used. + * @return string display name of the locale in the format + * appropriate for $in_locale. + */ + function locale_get_display_name($locale, $in_locale = null) {} + + + /** + * Returns an appropriately localized display name for language of the input locale + * + * @param string $locale the locale to return a display language for + * @param [string] $in_locale optional format locale to use to display the language name + * If is 'null' then the default locale is used. + * @return string display name of the language for the $locale in the format + * appropriate for $in_locale. + */ + function locale_get_display_language($lang, $in_locale = null) {} + + /** + * Returns an appropriately localized display name for script of the input locale + * + * @param string $locale the locale to return a display script for + * @param [string] $in_locale optional format locale to use to display the script name + * If is 'null' then the default locale is used. + * @return string display name of the script for the $locale in the format + * appropriate for $in_locale. + */ + function locale_get_display_script($script, $in_locale = null) {} + + + /** + * Returns an appropriately localized display name for region of the input locale + * + * @param string $locale the locale to return a display region for + * @param [string] $in_locale optional format locale to use to display the region name + * If is 'null' then the default locale is used. + * @return string display name of the region for the $locale in the format + * appropriate for $in_locale. + */ + function locale_get_display_region($region, $in_locale = null) {} + + + /** + * Returns an appropriately localized display name for variants of the input locale + * + * @param string $locale the locale to return a display variant for + * @param [string] $in_locale optional format locale to use to display the variant name + * If is 'null' then the default locale is used. + * @return string display name of the variant for the $locale in the format + * appropriate for $in_locale. + */ + function locale_get_display_variant($variant, $in_locale = null) {} + + + /** + * Checks if a $langtag filter matches with $locale according to + * RFC 4647's basic filtering algorithm + * + * @param string $langtag the language tag to check + * @param string $locale the language range to check against + * @param bool $canonicalize Canonicalize parameters? + * @return boolean 'true' if $locale matches $langtag 'false' otherwise + */ + function locale_filter_matches($langtag, $locale, $canonicalize) {} + + /** + * Searchs the items in $langtag for the best match to the language + * range specified in $locale according to RFC 4647's lookup algorithm. + * + * @param array $langtag an array containing a list of language tags to compare + * to $locale + * @param string $locale the locale to use as the language range when matching + * @param string $default the locale to use if no match is found + * @return string closest matching language tag, $default, + * or empty string + */ + function locale_lookup(array $langtag, $locale, $default = null) {} + + + /** + * Returns a correctly ordered and delimited locale ID + * + * @param array $subtags an array containing a list of key-value pairs, where + * the keys identify the particular locale ID subtags, + * and the values are the associated subtag values. + * + * @return string the corresponding locale identifier. + */ + function locale_compose_locale(array $subtags) {} + + + /** + * Returns a key-value array of locale ID subtag elements. + * + * @param string $locale the locale to extract the subtag array from + * + * @return array $subtags an array containing a list of key-value pairs, where + * the keys identify the particular locale ID subtags, + * and the values are the associated subtag values. + */ + function locale_parse_locale($locale) {} + +?> diff --git a/ext/intl/doc/msgfmt_api.php b/ext/intl/doc/msgfmt_api.php new file mode 100644 index 0000000..e4d047b --- /dev/null +++ b/ext/intl/doc/msgfmt_api.php @@ -0,0 +1,209 @@ +<?php + +/** + * Message formatter class. + * + * Message Format provides for runtime formatting of messages in a manner + * somewhat similar to sprintf. The pattern string has its component parts + * replaced in a locale-sensitive manner using items in the arguments array. + * + * @see http://www.icu-project.org/apiref/icu4c/umsg_8h.html + * + */ +class MessageFormatter { + + /** + * Constructs a new Message Formatter + * + * @param string $locale the locale to use when formatting arguments + * @param string $pattern the pattern string to stick arguments into + */ + public function __construct($locale, $pattern) {} + + /** + * Constructs a new Message Formatter + * + * @param string $locale the locale to use when formatting arguments + * @param string $pattern the pattern string to stick arguments into + */ + public static function create($locale, $pattern) {} + + /** + * Format the message + * @param array $args arguments to insert into the pattern string + * @return string the formatted string, or false if an error ocurred + */ + public function format($args) {} + + /** + * Parse input string and returns any extracted items as an array + * + * $error will contain any error code. If an error occurs, $parse_pos contains + * the position of the error. + * + * @param string $value string to parse for items + * @return array array containing items extracted + * + */ + public function parse($value) {} + + /** + * Inserts the items in $args into $pattern, formatting them + * according to $locale. This is the static implementation. + * + * @param string $locale the locale to use when formatting numbers and dates and suchlike + * @param string $pattern the pattern string to insert things into + * @param array $args the array of values to insert into $pattern + * @return string the formatted pattern string or false if an error occurred + */ + public static function formatMessage($locale, $pattern, $args) {} + + /** + * parses input string and returns any extracted items as an array + * + * $error will contain any error code. If an error occurs, $parse_pos contains + * the position of the error. + * + * @param string $locale the locale to use when formatting numbers and dates and suchlike + * @param string $value string to parse for items + * @return array array containing items extracted + * + */ + public static function parseMessage($locale, $value) {} + + /** + * Get the pattern used by the formatter + * + * @return string the pattern string for this message formatter + */ + public function getPattern() {} + + /** + * Set the pattern used by the formatter + * + * @param string $pattern the pattern string to use in this message formatter + * @return boolean 'true' if successful, 'false' if an error + */ + public function setPattern($pattern) {} + + /** + * Get the error code from last operation + * + * Returns error code from the last number formatting operation. + * + * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. + */ + public function getErrorCode() {} + /** + * Get the error text from the last operation. + * + * @return string Description of the last error. + */ + public function getErrorMessage() {} + /** + * Get the locale for which the formatter was created. + * + * @return string locale name + */ + public function getLocale() {} +} + + /** Now the same as procedural API */ + + + /** + * Constructs a new Message Formatter + * + * @param string $locale the locale to use when formatting arguments + * @param string $pattern the pattern string to stick arguments into + * @return MessageFormatter formatter object + */ + function msgfmt_create($locale, $pattern) {} + + /** + * Format the message + * @param MessageFormatter $fmt The message formatter + * @param array $args arguments to insert into the pattern string + * @return string the formatted string, or false if an error ocurred + */ + function msgfmt_format($fmt, $args) {} + + /** + * parses input string and returns any extracted items as an array + * + * $error will contain any error code. If an error occurs, $parse_pos contains + * the position of the error. + * + * @param MessageFormatter $fmt The message formatter + * @param string $value string to parse for items + * @return array array containing items extracted + * + */ + function msgfmt_parse($fmt, $value) {} + + /** + * Inserts the items in $args into $pattern, formatting them + * according to $locale. This is the static implementation. + * + * @param string $locale the locale to use when formatting numbers and dates and suchlike + * @param string $pattern the pattern string to insert things into + * @param array $args the array of values to insert into $pattern + * @return string the formatted pattern string or false if an error occurred + */ + function msgfmt_format_message($locale, $pattern, $args) {} + + /** + * parses input string and returns any extracted items as an array + * + * $error will contain any error code. If an error occurs, $parse_pos contains + * the position of the error. + * + * @param string $locale the locale to use when formatting numbers and dates and suchlike + * @param string $value string to parse for items + * @return array array containing items extracted + * + */ + function msgfmt_parse_message($locale, $value) {} + + /** + * Get the pattern used by the formatter + * + * @param MessageFormatter $fmt The message formatter + * @return string the pattern string for this message formatter + */ + function msgfmt_get_pattern($fmt) {} + + /** + * Set the pattern used by the formatter + * + * @param MessageFormatter $fmt The message formatter + * @param string $pattern the pattern string to use in this message formatter + * @return boolean 'true' if successful, 'false' if an error + */ + function msgfmt_set_pattern($fmt, $pattern) {} + + /** + * Get the error code from last operation + * + * Returns error code from the last number formatting operation. + * + * @param MessageFormatter $fmt The message formatter + * @return integer the error code, one of UErrorCode values. Initial value is U_ZERO_ERROR. + */ + function msgfmt_get_error_code($fmt) {} + /** + * Get the error text from the last operation. + * + * @param MessageFormatter $fmt The message formatter + * @return string Description of the last error. + */ + function msgfmt_get_error_message($fmt) {} + + /** + * Get the locale for which the formatter was created. + * + * @param NumberFormatter $formatter The formatter resource + * @return string locale name + */ + function msgfmt_get_locale($formatter) {} +?> diff --git a/ext/intl/doc/normalizer_api.php b/ext/intl/doc/normalizer_api.php new file mode 100644 index 0000000..a9bb566 --- /dev/null +++ b/ext/intl/doc/normalizer_api.php @@ -0,0 +1,92 @@ +<?php + +############################################################################# +# Object-oriented API +############################################################################# + +/** + * Normalizer class. + * + * Normalizer provides access to Unicode normalization of strings. This class consists + * only of static methods. The iterator interface to normalizer is rarely used, so is + * not provided here. + * + * Example: + * <code> + * + * </code> + * + * @see http://www.icu-project.org/apiref/icu4c/unorm_8h.html + * @see http://www.icu-project.org/apiref/icu4c/classNormalizer.html + * + */ +class Normalizer { +############################################################################# +# Common constants. +############################################################################# + + /** + * Valid normalization form values. + * + * @see Normalizer::normalize() + * @see Normalizer::isNormalize() + * @see normalizer_normalize() + * @see normalizer_is_normalized() + */ + const NONE = 1; + /** Canonical decomposition. */ + const NFD = 2; + const FORM_D = NFD; + /** Compatibility decomposition. */ + const NFKD = 3; + const FORM_KD = NFKD; + /** Canonical decomposition followed by canonical composition. */ + const NFC = 4; + const FORM_C = NFC; + /** Compatibility decomposition followed by canonical composition. */ + const NFKC =5; + const FORM_KC = NFKC; + + + /** + * Normalizes the input provided and returns the normalized string + * @param string $input The input string to normalize + * @param [int] $form One of the normalization forms + * @return string The normalized string or null if an error occurred. + */ + public static function normalize($input, $form = Normalizer::FORM_C) {} + + /** + * Checks if the provided string is already in the specified normalization form. + * @param string $input The input string to normalize + * @param [int] $form One of the normalization forms + * @return boolean True if normalized, false otherwise or if there is an error + */ + public static function isNormalized($input, $form = Normalizer::FORM_C) {} + +} + +############################################################################# +# Procedural API +############################################################################# + + /** + * Normalizes the input provided and returns the normalized string + * @param string $input The input string to normalize + * @param [int] $form One of the normalization forms + * @return string The normalized string or null if an error occurred. + */ + function normalizer_normalize($input, $form = Normalizer::FORM_C) {} + + /** + * Checks if the provided string is already in the specified normalization form. + * @param string $input The input string to normalize + * @param [int] $form One of the normalization forms + * @return boolean True if normalized, false otherwise or if there an error + */ + function normalizer_is_normalized($input, $form = Normalizer::FORM_C) {} + + +?> + + |