Skip to content

Commit 2db896d

Browse files
committed
minor #11474 Improved the Intl component docs (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Improved the Intl component docs This adds more examples and more elements to the collections shown in each example result. Commits ------- 004fe74 Improved the Intl component docs
2 parents bfa8444 + 004fe74 commit 2db896d

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

components/intl.rst

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,20 @@ The ``Languages`` class provides access to the name of all languages::
227227
\Locale::setDefault('en');
228228

229229
$languages = Languages::getNames();
230-
// => ['ab' => 'Abkhazian', ...]
230+
// ('languageCode' => 'languageName')
231+
// => ['ab' => 'Abkhazian', 'ace' => 'Achinese', ...]
231232

232-
$language = Languages::getName('de');
233-
// => 'German'
234-
235-
$language = Languages::getName('de', 'AT');
236-
// => 'Austrian German'
233+
$language = Languages::getName('fr');
234+
// => 'French'
237235

238236
All methods accept the translation locale as the last, optional parameter,
239237
which defaults to the current default locale::
240238

241239
$languages = Languages::getNames('de');
242-
// => ['ab' => 'Abchasisch', ...]
240+
// => ['ab' => 'Abchasisch', 'ace' => 'Aceh', ...]
241+
242+
$language = Languages::getName('fr', 'de');
243+
// => 'Französisch'
243244

244245
You can also check if a given language code is valid::
245246

@@ -259,18 +260,28 @@ for traditional Chinese)::
259260
\Locale::setDefault('en');
260261

261262
$scripts = Scripts::getNames();
262-
// => ['Arab' => 'Arabic', ...]
263+
// ('scriptCode' => 'scriptName')
264+
// => ['Adlm' => 'Adlam', 'Afak' => 'Afaka', ...]
263265

264266
$script = Scripts::getName('Hans');
265267
// => 'Simplified'
266268

269+
All methods accept the translation locale as the last, optional parameter,
270+
which defaults to the current default locale::
271+
272+
$languages = Scripts::getNames('de');
273+
// => ['Adlm' => 'Adlam', 'Afak' => 'Afaka', ...]
274+
275+
$language = Scripts::getName('Hans', 'de');
276+
// => 'Vereinfacht'
277+
267278
You can also check if a given script code is valid::
268279

269280
$isValidScript = Scripts::exists($scriptCode);
270281

271282
.. versionadded:: 4.3
272283

273-
The ``Scrcipts`` class was introduced in Symfony 4.3.
284+
The ``Scripts`` class was introduced in Symfony 4.3.
274285

275286
.. _country-names:
276287

@@ -286,7 +297,8 @@ instead of a ``Countries`` class::
286297
\Locale::setDefault('en');
287298

288299
$countries = Regions::getNames();
289-
// => ['AF' => 'Afghanistan', ...]
300+
// ('regionCode' => 'regionName')
301+
// => ['AF' => 'Afghanistan', 'AX' => 'Åland Islands', ...]
290302

291303
$country = Regions::getName('GB');
292304
// => 'United Kingdom'
@@ -295,7 +307,10 @@ All methods accept the translation locale as the last, optional parameter,
295307
which defaults to the current default locale::
296308

297309
$countries = Regions::getNames('de');
298-
// => ['AF' => 'Afghanistan', ...]
310+
// => ['AF' => 'Afghanistan', 'EG' => 'Ägypten', ...]
311+
312+
$country = Regions::getName('GB', 'de');
313+
// => 'Vereinigtes Königreich'
299314

300315
You can also check if a given region code is valid::
301316

@@ -318,7 +333,8 @@ provides access to the name of all locales::
318333
\Locale::setDefault('en');
319334

320335
$locales = Locales::getNames();
321-
// => ['af' => 'Afrikaans', ...]
336+
// ('localeCode' => 'localeName')
337+
// => ['af' => 'Afrikaans', 'af_NA' => 'Afrikaans (Namibia)', ...]
322338

323339
$locale = Locales::getName('zh_Hans_MO');
324340
// => 'Chinese (Simplified, Macau SAR China)'
@@ -327,7 +343,10 @@ All methods accept the translation locale as the last, optional parameter,
327343
which defaults to the current default locale::
328344

329345
$locales = Locales::getNames('de');
330-
// => ['af' => 'Afrikaans', ...]
346+
// => ['af' => 'Afrikaans', 'af_NA' => 'Afrikaans (Namibia)', ...]
347+
348+
$locale = Locales::getName('zh_Hans_MO', 'de');
349+
// => 'Chinesisch (Vereinfacht, Sonderverwaltungsregion Macau)'
331350

332351
You can also check if a given locale code is valid::
333352

@@ -348,7 +367,8 @@ as some of their information (symbol, fraction digits, etc.)::
348367
\Locale::setDefault('en');
349368

350369
$currencies = Currencies::getNames();
351-
// => ['AFN' => 'Afghan Afghani', ...]
370+
// ('currencyCode' => 'currencyName')
371+
// => ['AFN' => 'Afghan Afghani', 'ALL' => 'Albanian Lek', ...]
352372

353373
$currency = Currencies::getName('INR');
354374
// => 'Indian Rupee'
@@ -367,7 +387,10 @@ accept the translation locale as the last, optional parameter, which defaults to
367387
the current default locale::
368388

369389
$currencies = Currencies::getNames('de');
370-
// => ['AFN' => 'Afghanische Afghani', ...]
390+
// => ['AFN' => 'Afghanischer Afghani', 'EGP' => 'Ägyptisches Pfund', ...]
391+
392+
$currency = Currencies::getName('INR', 'de');
393+
// => 'Indische Rupie'
371394

372395
You can also check if a given currency code is valid::
373396

0 commit comments

Comments
 (0)