Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 64da9d7

Browse files
committed
Improved Intl documentation based on the PR comments
1 parent cfea950 commit 64da9d7

File tree

1 file changed

+18
-223
lines changed

1 file changed

+18
-223
lines changed

components/intl.rst

Lines changed: 18 additions & 223 deletions
Original file line numberDiff line numberDiff line change
@@ -34,246 +34,41 @@ not loaded:
3434
* :phpfunction:`intl_get_error_code`
3535
* :phpfunction:`intl_get_error_message`
3636

37-
If you don't use Composer but the Symfony ClassLoader component, you need to
38-
load them manually by adding the following lines to your autoload code::
37+
When the intl extension is not available, the following classes are used to
38+
replace the intl classes:
39+
40+
* :class:`Symfony\\Component\\Intl\\Collator\\Collator`
41+
* :class:`Symfony\\Component\\Intl\\DateFormatter\\IntlDateFormatter`
42+
* :class:`Symfony\\Component\\Intl\\Locale\\Locale`
43+
* :class:`Symfony\\Component\\Intl\\NumberFormatter\\NumberFormatter`
44+
* :class:`Symfony\\Component\\Intl\\Globals\\IntlGlobals`
45+
46+
Composer automatically exposes these classes in the global namespace.
47+
48+
If you don't use Composer but the
49+
:doc:`Symfony ClassLoader component</components/class_loader>`, you need to
50+
expose them manually by adding the following lines to your autoload code::
3951

4052
if (!function_exists('intl_is_failure')) {
4153
require '/path/to/Icu/Resources/stubs/functions.php';
4254

4355
$loader->registerPrefixFallback('/path/to/Icu/Resources/stubs');
4456
}
4557

46-
The component provides replacements for the following functions and classes:
47-
4858
.. note::
4959

5060
The stub implementation only supports the locale ``en``.
5161

52-
Stubbed Classes
53-
---------------
54-
55-
The stubbed classes of the intl extension are limited to the locale "en" and
56-
will throw an exception if you try to use a different locale. For using other
57-
locales, `install the intl extension`_ instead.
58-
59-
Locale
60-
~~~~~~
61-
62-
The only method supported in the :phpclass:`Locale` class is
63-
:phpmethod:`Locale::getDefault`. This method will always return "en". All other
64-
methods will throw an exception when used.
65-
66-
NumberFormatter
67-
~~~~~~~~~~~~~~~
68-
69-
Numbers can be formatted with the :phpclass:`NumberFormatter` class.
70-
The following methods are supported. All other methods are not supported and
71-
will throw an exception when used.
72-
73-
.. _`NumberFormatter::__construct()`:
74-
75-
\__construct($locale = $style = null, $pattern = null)
76-
......................................................
77-
78-
The only supported locale is "en". The supported styles are
79-
``NumberFormatter::DECIMAL`` and ``NumberFormatter::CURRENCY``. The argument
80-
``$pattern`` may not be used.
81-
82-
::create($locale = $style = null, $pattern = null)
83-
..................................................
84-
85-
See `NumberFormatter::__construct()`_.
86-
87-
formatCurrency($value, $currency)
88-
.................................
89-
90-
Fully supported.
91-
92-
format($value, $type = NumberFormatter::TYPE_DEFAULT)
93-
.....................................................
94-
95-
Only type ``NumberFormatter::TYPE_DEFAULT`` is supported.
96-
97-
getAttribute($attr)
98-
...................
99-
100-
Fully supported.
101-
102-
getErrorCode()
103-
..............
104-
105-
Fully supported.
106-
107-
getErrorMessage()
108-
.................
109-
110-
Fully supported.
111-
112-
getLocale($type = Locale::ACTUAL_LOCALE)
113-
........................................
114-
115-
The parameter ``$type`` is ignored.
116-
117-
parse($value, $type = NumberFormatter::TYPE_DOUBLE, &$position = null)
118-
......................................................................
119-
120-
The supported types are ``NumberFormatter::TYPE_DOUBLE``,
121-
``NumberFormatter::TYPE_INT32`` and ``NumberFormatter::TYPE_INT64``. The
122-
parameter ``$position`` must always be ``null``.
123-
124-
setAttribute($attr, $value)
125-
...........................
126-
127-
The only supported attributes are ``NumberFormatter::FRACTION_DIGITS``,
128-
``NumberFormatter::GROUPING_USED`` and ``NumberFormatter::ROUNDING_MODE``.
129-
130-
The only supported rounding modes are ``NumberFormatter::ROUND_HALFEVEN``,
131-
``NumberFormatter::ROUND_HALFDOWN`` and ``NumberFormatter::ROUND_HALFUP``.
132-
133-
IntlDateFormatter
134-
~~~~~~~~~~~~~~~~~
135-
136-
Dates can be formatted with the :phpclass:`IntlDateFormatter` class. The
137-
following methods are supported. All other methods are not supported and will
138-
throw an exception when used.
139-
140-
.. _`IntlDateFormatter::__construct()`:
141-
142-
\__construct($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
143-
........................................................................................................................
144-
145-
The only supported locale is "en". The parameter ``$calendar`` can only be
146-
``IntlDateFormatter::GREGORIAN``.
147-
148-
::create($locale, $datetype, $timetype, $timezone = null, $calendar = IntlDateFormatter::GREGORIAN, $pattern = null)
149-
....................................................................................................................
150-
151-
See `IntlDateFormatter::__construct()`_.
152-
153-
format($timestamp)
154-
..................
155-
156-
Fully supported.
157-
158-
getCalendar()
159-
.............
160-
161-
Fully supported.
162-
163-
getDateType()
164-
.............
165-
166-
Fully supported.
167-
168-
getErrorCode()
169-
..............
170-
171-
Fully supported.
172-
173-
getErrorMessage()
174-
.................
175-
176-
Fully supported.
177-
178-
getLocale($type = Locale::ACTUAL_LOCALE)
179-
........................................
180-
181-
The parameter ``$type`` is ignored.
182-
183-
getPattern()
184-
............
185-
186-
Fully supported.
187-
188-
getTimeType()
189-
.............
190-
191-
Fully supported.
192-
193-
getTimeZoneId()
194-
...............
195-
196-
Fully supported.
197-
198-
isLenient()
199-
...........
200-
201-
Always returns ``false``.
202-
203-
parse($value, &$position = null)
204-
................................
205-
206-
The parameter ``$position`` must always be ``null``.
207-
208-
setLenient($lenient)
209-
....................
210-
211-
Only accepts ``false``.
212-
213-
setPattern($pattern)
214-
....................
215-
216-
Fully supported.
217-
218-
setTimeZoneId($timeZoneId)
219-
..........................
220-
221-
Fully supported.
222-
223-
setTimeZone($timeZone)
224-
......................
225-
226-
Fully supported.
227-
228-
Collator
229-
~~~~~~~~
230-
231-
Localized strings can be sorted with the :phpclass:`\Collator` class. The
232-
following methods are supported. All other methods are not supported and will
233-
throw an exception when used.
234-
235-
.. _`Collator::__construct()`:
236-
237-
\__construct($locale)
238-
.....................
239-
240-
The only supported locale is "en".
241-
242-
create($locale)
243-
...............
244-
245-
See `Collator::__construct()`_.
246-
247-
asort(&$array, $sortFlag = Collator::SORT_REGULAR)
248-
..................................................
249-
250-
Fully supported.
251-
252-
getErrorCode()
253-
..............
254-
255-
Fully supported.
256-
257-
getErrorMessage()
258-
.................
259-
260-
Fully supported.
261-
262-
getLocale($type = Locale::ACTUAL_LOCALE)
263-
........................................
264-
265-
The parameter ``$type`` is ignored.
266-
267-
ResourceBundle
268-
~~~~~~~~~~~~~~
62+
Writing and Reading Resource Bundles
63+
------------------------------------
26964

27065
The :phpclass:`ResourceBundle` class is not and will not be supported. Instead,
27166
this component ships a set of readers and writers for reading and writing arrays
27267
(or array-like objects) from/to resource bundle files. The following classes
27368
are supported:
27469

27570
TextBundleWriter
276-
................
71+
~~~~~~~~~~~~~~~~
27772

27873
Writes an array or an array-like object to a plain text resource bundle. The
27974
resulting .txt file can be converted to a binary .res file with the
@@ -397,7 +192,7 @@ locale will be merged. In order to suppress this behavior, the last parameter
397192

398193
echo $reader->readEntry('/path/to/bundle', 'en', array('Data', 'entry1'), false);
399194

400-
Included Resource Bundles
195+
Provided Resource Bundles
401196
-------------------------
402197

403198
The ICU data is located in several "resource bundles". You can access a PHP

0 commit comments

Comments
 (0)