-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add documentation about alpha3 methods #12105
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
Conversation
…braten-certua) This PR was merged into the 4.4 branch. Discussion ---------- [Intl] Support ISO 3166-1 Alpha-3 country codes | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20313 | Doc PR | symfony/symfony-docs#12105 | License | MIT This is a pre-requiste for fixing #20313 and only handles the changes to the INTL component. Commits ------- 848f60e905 Support ISO 3166-1 Alpha-3 country codes
…braten-certua) This PR was merged into the 4.4 branch. Discussion ---------- [Intl] Support ISO 3166-1 Alpha-3 country codes | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20313 | Doc PR | symfony/symfony-docs#12105 | License | MIT This is a pre-requiste for fixing #20313 and only handles the changes to the INTL component. Commits ------- 848f60e Support ISO 3166-1 Alpha-3 country codes
@ro0NL would you do me a favor and review this PR? Thank you 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😁
@@ -79,6 +79,20 @@ The ``Languages`` class provides access to the name of all languages:: | |||
$language = Languages::getName('fr'); | |||
// => 'French' | |||
|
|||
If you want to you can also use the ISO 639-2 three-letter language codes instead of | |||
the ISO 639-1 two-letter codes. (They are here called alpha3 codes.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use the ISO 639-2 three-letter language codes instead of
the ISO 639-1 two-letter codes, respectively called alpha3 and alpha2 codes.
|
||
use Symfony\Component\Intl\Countries; | ||
|
||
\Locale::setDefault('en'); | ||
|
||
// Indexed with alpha-2 | ||
$countries = Countries::getNames(); | ||
// ('countryCode' => 'countryName') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps mention "alpha2" here to reduce comments, e.g. // ('alpha2Code' => 'countryName')
$countries = Countries::getNames(); | ||
// ('countryCode' => 'countryName') | ||
// => ['AF' => 'Afghanistan', 'AX' => 'Åland Islands', ...] | ||
|
||
// Indexed with alhpa-3 | ||
$countries = Countries::getAlpha3Names(); | ||
// ('countryCode' => 'countryName') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same // ('alpha3Code' => 'countryName')
$country = Countries::getName('GB', 'de'); | ||
// => 'Vereinigtes Königreich' | ||
|
||
$country = Countries::getName('GBR', 'de'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAlpha3Name
$isValidCountry = Countries::exists($countryCode); | ||
$isValidCountry = Countries::exists($alpha2Code); | ||
|
||
$isValidCountry = Countries::alpha3CodeExists($alpha2Code); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would add a paragraph in between like languages does
Or if you have a alpha3 country code you want to check:
$isValidCountry = Countries::alpha3CodeExists($alpha3Code);
@@ -94,6 +108,16 @@ to catching the exception, you can also check if a given language code is valid: | |||
|
|||
$isValidLanguage = Languages::exists($languageCode); | |||
|
|||
Or if you have a three-letter language code you want to check: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
::
i believe (not a format expert here :D)
It took time, but here we go, this is in now. Thank you very much Terje. I made the requested changes while merging (b3d776d) 👍 |
* 4.4: Tweaks. refs #12105 Add documentation about alpha3 methods
This PR was merged into the 4.4 branch. Discussion ---------- Update intl.rst tiny follow up of #12105 cc @OskarStark Commits ------- d757a2d Update intl.rst
This PR was squashed before being merged into the 4.3 branch (closes #12173). Discussion ---------- Mention ISO 639 for languages we've added this in 4.4 (#12105), but languages in 4.3 already had (partial) alpha3 support. let me know if this is merged in 4.4 :) it needs some cleanup after. cc @OskarStark Commits ------- 8ee8df7 Mention ISO 639 for languages
Replaces #12104