Skip to content

[Intl] Document support for ISO 3166-1 numeric codes #18610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions components/intl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,33 @@ You may convert codes between two-letter alpha2 and three-letter alpha3 codes::

$alpha2Code = Countries::getAlpha2Code($alpha3Code);

Numeric Country Codes
~~~~~~~~~~~~~~~~~~~~~

The :class:`Symfony\\Component\\Intl\\Countries` class also provides access to the
numeric country codes according to the `ISO 3166-1 numeric`_ list::

use Symfony\Component\Intl\Countries;

\Locale::setDefault('en');

$numericCodes = Countries::getNumericCodes();
// ('alpha2Code' => 'numericCode')
// => ['AA' => '958', 'AD' => '020', ...]

$numericCode = Countries::getNumericCode('FR');
// => '250'

$alpha2 = Countries::getAlpha2FromNumeric('250');
// => 'FR'

$exists = Countries::numericCodeExists('250');
// => true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a new feature, we must add a note like the following:

.. versionadded:: 6.4

    The support for numeric country codes was introduced in Symfony 6.4.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.. versionadded:: 6.4

The support for numeric country codes was introduced in Symfony 6.4.

Locales
~~~~~~~

Expand Down Expand Up @@ -435,6 +462,7 @@ Learn more
.. _`Unicode ISO 15924 Registry`: https://www.unicode.org/iso15924/iso15924-codes.html
.. _`ISO 3166-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
.. _`ISO 3166-1 alpha-3`: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
.. _`ISO 3166-1 numeric`: https://en.wikipedia.org/wiki/ISO_3166-1_numeric
.. _`UTC/GMT time offsets`: https://en.wikipedia.org/wiki/List_of_UTC_time_offsets
.. _`daylight saving time (DST)`: https://en.wikipedia.org/wiki/Daylight_saving_time
.. _`ISO 639-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_639-1
Expand Down