Skip to content

Commit 004fe74

Browse files
committed
Improved the Intl component docs
1 parent ec97c69 commit 004fe74

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
@@ -226,19 +226,20 @@ The ``Languages`` class provides access to the name of all languages::
226226
\Locale::setDefault('en');
227227

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

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

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

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

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

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

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

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

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

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

270281
.. versionadded:: 4.3
271282

272-
The ``Scrcipts`` class was introduced in Symfony 4.3.
283+
The ``Scripts`` class was introduced in Symfony 4.3.
273284

274285
.. _country-names:
275286

@@ -285,7 +296,8 @@ instead of a ``Countries`` class::
285296
\Locale::setDefault('en');
286297

287298
$countries = Regions::getNames();
288-
// => ['AF' => 'Afghanistan', ...]
299+
// ('regionCode' => 'regionName')
300+
// => ['AF' => 'Afghanistan', 'AX' => 'Åland Islands', ...]
289301

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

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

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

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

319334
$locales = Locales::getNames();
320-
// => ['af' => 'Afrikaans', ...]
335+
// ('localeCode' => 'localeName')
336+
// => ['af' => 'Afrikaans', 'af_NA' => 'Afrikaans (Namibia)', ...]
321337

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

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

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

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

349368
$currencies = Currencies::getNames();
350-
// => ['AFN' => 'Afghan Afghani', ...]
369+
// ('currencyCode' => 'currencyName')
370+
// => ['AFN' => 'Afghan Afghani', 'ALL' => 'Albanian Lek', ...]
351371

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

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

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

0 commit comments

Comments
 (0)