diff --git a/appendices/migration85/new-classes.xml b/appendices/migration85/new-classes.xml index d47bed152f20..86fa4e0360c5 100644 --- a/appendices/migration85/new-classes.xml +++ b/appendices/migration85/new-classes.xml @@ -29,6 +29,13 @@ + + Intl + + IntlListFormatter + + + URI diff --git a/reference/intl/book.xml b/reference/intl/book.xml index 611d0b91cf5f..664685fe385b 100644 --- a/reference/intl/book.xml +++ b/reference/intl/book.xml @@ -9,26 +9,26 @@ &reftitle.intro; - + Internationalization extension (further is referred as Intl) is a wrapper for ICU library, enabling PHP programmers to perform various locale-aware operations including but not limited to formatting, transliteration, encoding conversion, calendar operations, UCA-conformant collation, locating text boundaries and working with locale identifiers, timezones and graphemes. - + - + It tends to closely follow ICU APIs, so that people having experience working with ICU in either C/C++ or Java could easily use the PHP API. Also, this way ICU documentation would be useful to understand various ICU functions. - + - + Intl consists of several modules, each of them exposes the corresponding ICU API: - + @@ -98,13 +98,13 @@ Links - Miscellaneous ICU docs + Miscellaneous ICU docs - ICU User Guide + ICU User Guide - Unicode Collation Algorithm + Unicode Collation Algorithm @@ -133,6 +133,7 @@ &reference.intl.intlrulebasedbreakiterator; &reference.intl.intlcodepointbreakiterator; &reference.intl.intldatepatterngenerator; + &reference.intl.intllistformatter; &reference.intl.intlpartsiterator; &reference.intl.uconverter; diff --git a/reference/intl/intllistformatter.xml b/reference/intl/intllistformatter.xml new file mode 100644 index 000000000000..fc5884527796 --- /dev/null +++ b/reference/intl/intllistformatter.xml @@ -0,0 +1,178 @@ + + + + The IntlListFormatter class + IntlListFormatter + + + + +
+ &reftitle.intro; + + Formats, orders, and punctuates a list of items according to locale-specific rules. + Requires ICU 67 or later. + +
+ + +
+ &reftitle.classsynopsis; + + + + + IntlListFormatter + + + &Constants; + + public + const + int + IntlListFormatter::TYPE_AND + + + public + const + int + IntlListFormatter::TYPE_OR + + + public + const + int + IntlListFormatter::TYPE_UNITS + + + public + const + int + IntlListFormatter::WIDTH_WIDE + + + public + const + int + IntlListFormatter::WIDTH_SHORT + + + public + const + int + IntlListFormatter::WIDTH_NARROW + + + &Methods; + + + + + + + + + +
+ +
+ &reftitle.constants; + + + IntlListFormatter::TYPE_AND + + + Formats a list using conjunction (e.g. "A, B, and C"). + + + + + IntlListFormatter::TYPE_OR + + + Formats a list using disjunction (e.g. "A, B, or C"). + + + + + IntlListFormatter::TYPE_UNITS + + + Formats a list of units (e.g. "3 ft, 7 in"). + + + + + IntlListFormatter::WIDTH_WIDE + + + Uses the widest (most verbose) list format, typically with conjunctions spelled out in full. + + + + + IntlListFormatter::WIDTH_SHORT + + + Uses a short list format, typically using abbreviations. + + + + + IntlListFormatter::WIDTH_NARROW + + + Uses the narrowest list format, with minimal punctuation. + + + + +
+ +
+ &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 8.5.0 + + The class was added. + + + + + +
+ +
+ + &reference.intl.entities.intllistformatter; + +
+ diff --git a/reference/intl/intllistformatter/construct.xml b/reference/intl/intllistformatter/construct.xml new file mode 100644 index 000000000000..e80d7d8d28b1 --- /dev/null +++ b/reference/intl/intllistformatter/construct.xml @@ -0,0 +1,115 @@ + + + + + IntlListFormatter::__construct + Creates a new IntlListFormatter instance + + + + &reftitle.description; + + public IntlListFormatter::__construct + stringlocale + inttypeIntlListFormatter::TYPE_AND + intwidthIntlListFormatter::WIDTH_WIDE + + + Creates a new IntlListFormatter instance for the given locale. + + + + + &reftitle.parameters; + + + locale + + + The locale to use for formatting. + + + + + type + + + The list type. One of the IntlListFormatter::TYPE_* constants: + IntlListFormatter::TYPE_AND, + IntlListFormatter::TYPE_OR, or + IntlListFormatter::TYPE_UNITS. + + + + + width + + + The list width. One of the IntlListFormatter::WIDTH_* constants: + IntlListFormatter::WIDTH_WIDE, + IntlListFormatter::WIDTH_SHORT, or + IntlListFormatter::WIDTH_NARROW. + + + + + + + + &reftitle.errors; + + Throws an IntlException if the formatter cannot be created + (e.g. invalid locale or ICU version is below 67). + + + + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 8.5.0 + + The class was added. + + + + + + + + + &reftitle.seealso; + + IntlListFormatter::format + + + + + diff --git a/reference/intl/intllistformatter/format.xml b/reference/intl/intllistformatter/format.xml new file mode 100644 index 000000000000..a26abe885a96 --- /dev/null +++ b/reference/intl/intllistformatter/format.xml @@ -0,0 +1,88 @@ + + + + + IntlListFormatter::format + Format a list of items + + + + &reftitle.description; + + public stringfalseIntlListFormatter::format + arraylist + + + Formats a list of items as a locale-appropriate string. + + + + + &reftitle.parameters; + + + list + + + An array of strings to format as a list. + + + + + + + + &reftitle.returnvalues; + + The formatted list as a string, or &false; on failure. + + + + + &reftitle.examples; + + <methodname>IntlListFormatter::format</methodname> example + +format(['one', 'two', 'three']); +// one, two, and three + +$fmt = new IntlListFormatter('en_US', IntlListFormatter::TYPE_OR, IntlListFormatter::WIDTH_WIDE); +echo $fmt->format(['one', 'two', 'three']); +// one, two, or three +?> +]]> + + + + + + &reftitle.seealso; + + IntlListFormatter::__construct + + + + +