-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Intl][Form] Support ISO 3166-1 Alpha-3 country codes #20313
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
Comments
In our app, we have reset the list of nationalities to handle it: $nationalities = array_flip(Intl::getRegionBundle()->getCountryNames());
$nationalities = array_map([$this, 'getISO3Code'], $nationalities);
$builder
->add(
'nationality',
CountryType::class,
[
'required' => $required,
'label' => 'nationality',
'attr' => [
'data-field' => 'nationality',
],
'choices' => $nationalities,
'preferred_choices' => array('FRA'),
]
) And it works fine in 3.1.x. |
@ro0NL Would we be able to provide access to the three-letter codes through the Intl API? |
Have a look at #8492 (comment) |
Seems ICU has the same dataset available (from #8492 (comment)) So we could investigate this :) Moreover, for languages we maintain the mapping ourselves:
But AFAIK it's also available in ICU, e.g. https://github.com/unicode-org/icu/blob/13889bece13f51b0e9b3eef16cd34490c96da291/icu4c/source/data/misc/metadata.txt#L14-L17 To be able to extract the "alpha3" lists we first need to understand the format. I think we need all codes only with reason=overlong. |
Okay, so once the API from the Intl component allows us to access these data we should be able to extend the |
Be aware of the difference between language codes and region codes. They are not the same. Region is about geographic country names. Language codes is about codes for the different spoken languages. The tables @ro0NL linked to seemed to all be about language codes and not region codes. |
The icu metadata holds both languaes and regions/territories ;) |
Please have a look at symfony/intl#10 I hope that can bring this issue closer to an implementation. |
Make that PR #32663 instead. |
Make that PR #32676 instead. |
…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
The necessarry support in the Intl library has now been merged in #32988 |
Next step |
Yes, but I might not have time for it until next week, or even later. Sorry. But it should be a simple task now for anyone to pick up. If someone feels like it, feel free to submit a PR. |
…ry codes (creiner) This PR was squashed before being merged into the 4.4 branch (closes #33791). Discussion ---------- [Form] Added CountryType option for using alpha3 country codes | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fixes #20313 | License | MIT | Doc PR | - In the linked issue #20313 was a proposal to add an alpha3 option to the country type. Here it is.. Hopefully I've made no mistake, so when the code is fine, I will create a documentation PR.. :-) Commits ------- d07f5a3 [Form] Added CountryType option for using alpha3 country codes
Could we please extend the form type
CountryType
via an option to make it support ISO_3166-1 Alpha-3 country codes?Sources for the country codes:
I'm currently working on a project where I need country codes as 3 characters instead of just 2.
Would it be possible to include a new alpha3 option or something to support 3 characters country codes?
(This was first raised in #8492 but that issue was closed without being resolved properly)
The text was updated successfully, but these errors were encountered: