@@ -209,125 +209,152 @@ locale will be merged. In order to suppress this behavior, the last parameter
209209Accessing ICU Data
210210------------------
211211
212- The ICU data is located in several "resource bundles". You can access a PHP
213- wrapper of these bundles through the static
214- :class: `Symfony\\ Component\\ Intl\\ Intl ` class. At the moment, the following
215- data is supported:
212+ This component provides the following ICU data:
216213
217214* `Language and Script Names `_
218- * `Country Names `_
215+ * `Country and Region Names `_
219216* `Locales `_
220217* `Currencies `_
221218
222219Language and Script Names
223220~~~~~~~~~~~~~~~~~~~~~~~~~
224221
225- The translations of language and script names can be found in the language
226- bundle::
222+ The ``Languages `` class provides access to the name of all languages::
227223
228- use Symfony\Component\Intl\Intl ;
224+ use Symfony\Component\Intl\Languages ;
229225
230226 \Locale::setDefault('en');
231227
232- $languages = Intl::getLanguageBundle()->getLanguageNames ();
228+ $languages = Languages::getNames ();
233229 // => ['ab' => 'Abkhazian', ...]
234230
235- $language = Intl::getLanguageBundle()->getLanguageName ('de');
231+ $language = Languages::getName ('de');
236232 // => 'German'
237233
238- $language = Intl::getLanguageBundle()->getLanguageName ('de', 'AT');
234+ $language = Languages::getName ('de', 'AT');
239235 // => 'Austrian German'
240236
241- $scripts = Intl::getLanguageBundle()->getScriptNames();
237+ All methods accept the translation locale as the last, optional parameter,
238+ which defaults to the current default locale::
239+
240+ $languages = Languages::getNames('de');
241+ // => ['ab' => 'Abchasisch', ...]
242+
243+ .. versionadded :: 4.3
244+
245+ The ``Languages `` class was introduced in Symfony 4.3.
246+
247+ The ``Scripts `` class provides access to the optional four-letter script code
248+ that can follow the language code according to the `Unicode ISO 15924 Registry `_
249+ (e.g. ``HANS `` in ``zh_HANS `` for simplified Chinese and ``HANT `` in ``zh_HANT ``
250+ for traditional Chinese)::
251+
252+ use Symfony\Component\Intl\Scripts;
253+
254+ \Locale::setDefault('en');
255+
256+ $scripts = Scripts::getNames();
242257 // => ['Arab' => 'Arabic', ...]
243258
244- $script = Intl::getLanguageBundle()->getScriptName ('Hans');
259+ $script = Scripts::getName ('Hans');
245260 // => 'Simplified'
246261
247- All methods accept the translation locale as the last, optional parameter,
248- which defaults to the current default locale::
262+ .. versionadded :: 4.3
249263
250- $languages = Intl::getLanguageBundle()->getLanguageNames('de');
251- // => ['ab' => 'Abchasisch', ...]
264+ The ``Scrcipts `` class was introduced in Symfony 4.3.
265+
266+ .. _country-names :
252267
253- Country Names
254- ~~~~~~~~~~~~~
268+ Country and Region Names
269+ ~~~~~~~~~~~~~~~~~~~~~~~~
255270
256- The translations of country names can be found in the region bundle::
271+ In the world there are some territorial disputes that make it hard to define
272+ what a country is. That's why the Intl component provides a ``Regions `` class
273+ instead of a ``Countries `` class::
257274
258- use Symfony\Component\Intl\Intl ;
275+ use Symfony\Component\Intl\Regions ;
259276
260277 \Locale::setDefault('en');
261278
262- $countries = Intl::getRegionBundle()->getCountryNames ();
279+ $countries = Regions::getNames ();
263280 // => ['AF' => 'Afghanistan', ...]
264281
265- $country = Intl::getRegionBundle()->getCountryName ('GB');
282+ $country = Regions::getName ('GB');
266283 // => 'United Kingdom'
267284
268285All methods accept the translation locale as the last, optional parameter,
269286which defaults to the current default locale::
270287
271- $countries = Intl::getRegionBundle()->getCountryNames ('de');
288+ $countries = Regions::getNames ('de');
272289 // => ['AF' => 'Afghanistan', ...]
273290
291+ .. versionadded :: 4.3
292+
293+ The ``Regions `` class was introduced in Symfony 4.3.
294+
274295Locales
275296~~~~~~~
276297
277- The translations of locale names can be found in the locale bundle::
298+ A locale is the combination of a language and a region. For example, "Chinese"
299+ is the language and ``zh_Hans_MO `` is the locale for "Chinese" (language) +
300+ "Simplified" (script) + "Macau SAR China" (region). The ``Locales `` class
301+ provides access to the name of all locales::
278302
279- use Symfony\Component\Intl\Intl ;
303+ use Symfony\Component\Intl\Locales ;
280304
281305 \Locale::setDefault('en');
282306
283- $locales = Intl::getLocaleBundle()->getLocaleNames ();
307+ $locales = Locales::getNames ();
284308 // => ['af' => 'Afrikaans', ...]
285309
286- $locale = Intl::getLocaleBundle()->getLocaleName ('zh_Hans_MO');
310+ $locale = Locales::getName ('zh_Hans_MO');
287311 // => 'Chinese (Simplified, Macau SAR China)'
288312
289313All methods accept the translation locale as the last, optional parameter,
290314which defaults to the current default locale::
291315
292- $locales = Intl::getLocaleBundle()->getLocaleNames ('de');
316+ $locales = Locales::getNames ('de');
293317 // => ['af' => 'Afrikaans', ...]
294318
319+ .. versionadded :: 4.3
320+
321+ The ``Locales `` class was introduced in Symfony 4.3.
322+
295323Currencies
296324~~~~~~~~~~
297325
298- The translations of currency names and other currency-related information can
299- be found in the currency bundle ::
326+ The `` Currencies `` class provides access to the name of all currencies as well
327+ as some of their information (symbol, fraction digits, etc.) ::
300328
301- use Symfony\Component\Intl\Intl ;
329+ use Symfony\Component\Intl\Currencies ;
302330
303331 \Locale::setDefault('en');
304332
305- $currencies = Intl::getCurrencyBundle()->getCurrencyNames ();
333+ $currencies = Currencies::getNames ();
306334 // => ['AFN' => 'Afghan Afghani', ...]
307335
308- $currency = Intl::getCurrencyBundle()->getCurrencyName ('INR');
336+ $currency = Currencies::getName ('INR');
309337 // => 'Indian Rupee'
310338
311- $symbol = Intl::getCurrencyBundle()->getCurrencySymbol ('INR');
339+ $symbol = Currencies::getSymbol ('INR');
312340 // => '₹'
313341
314- $fractionDigits = Intl::getCurrencyBundle()-> getFractionDigits('INR');
342+ $fractionDigits = Currencies:: getFractionDigits('INR');
315343 // => 2
316344
317- $roundingIncrement = Intl::getCurrencyBundle()-> getRoundingIncrement('INR');
345+ $roundingIncrement = Currencies:: getRoundingIncrement('INR');
318346 // => 0
319347
320- All methods (except for
321- :method: `Symfony\\ Component\\ Intl\\ ResourceBundle\\ CurrencyBundleInterface::getFractionDigits `
322- and
323- :method: `Symfony\\ Component\\ Intl\\ ResourceBundle\\ CurrencyBundleInterface::getRoundingIncrement `)
324- accept the translation locale as the last, optional parameter, which defaults
325- to the current default locale::
348+ All methods (except for ``getFractionDigits() `` and ``getRoundingIncrement() ``)
349+ accept the translation locale as the last, optional parameter, which defaults to
350+ the current default locale::
326351
327- $currencies = Intl::getCurrencyBundle()->getCurrencyNames ('de');
352+ $currencies = Currencies::getNames ('de');
328353 // => ['AFN' => 'Afghanische Afghani', ...]
329354
330- That's all you need to know for now. Have fun coding!
355+ .. versionadded :: 4.3
356+
357+ The ``Currencies `` class was introduced in Symfony 4.3.
331358
332359Learn more
333360----------
@@ -346,3 +373,4 @@ Learn more
346373.. _intl extension : https://php.net/manual/en/book.intl.php
347374.. _install the intl extension : https://php.net/manual/en/intl.setup.php
348375.. _ICU library : http://site.icu-project.org/
376+ .. _`Unicode ISO 15924 Registry` : https://www.unicode.org/iso15924/iso15924-codes.html
0 commit comments