Closed mime29 closed 2 years ago
I should maybe add one thing: The function doc says it's iso 639 codes. And clearly it's not.
You can get the localized country name for the region code from Locale
:
func localizedCountryName(for regionCode: String) -> String? {
let regionCode = regionCode.lowercased()
return Locale.current.localizedString(forRegionCode: regionCode)
}
thank you, that's nice.
It's not clear in Apple doc if they are using 3166 for regionCode
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html
but I would assume so. They say Region Designators
are using it.
so that can work.
Still need to update the inline documentation for PhoneNumberKit to indicate that the codes are 3166-1 and not 639.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This needs a fix with maybe the addition of a helper to return the country lists as well. https://www.wikiwand.com/fr/ISO_3166-1
I wanted to build a UI showing the country name and the prefix.
I used this function to retrieve all codes and prefixes:
but then I wanted to match the code with localized countries name but iso639 codes were not matching any codes (or only a few). Then I implemented the ISO 3166-1
alpha-2
codes to return the country names et voila!