Skip to content
New issue

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

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

Already on GitHub? # to your account

Implement functions to return 3 letter ISO language and country codes #372

Merged
merged 4 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
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
Binary file modified eng/prebuilts/mobile/icudt_hybrid.dat
Binary file not shown.
31 changes: 2 additions & 29 deletions icu-filters/icudt_hg_mobile.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,37 +231,10 @@
"brkitr_rules": {
"whitelist": ["char"]
},
"coll_tree": "exclude"
"coll_tree": "exclude",
"locales_tree": "exclude"
},
"resourceFilters": [
{
"categories": ["locales_tree"],
"rules": [
"-/characterLabel",
"-/measurementSystemNames",
"-/listPattern",
"-/fields",
"-/delimiters",
"-/Ellipsis",
"-/NumberElements/latn/miscPatterns",
"-/NumberElements/latn/patternsLong",
"-/NumberElements/latn/patternsShort",
"-/NumberElements/*/patternsLong",
"-/NumberElements/*/patternsShort",
"-/NumberElements/minimalPairs",
"-/NumberElements/*/symbols",
"-/calendar/Gregorian/AmPmMarkers",
"-/calendar/Gregorian/AmPmMarkersAbbr",
"-/calendar/Gregorian/AmPmMarkersNarrow",
"-/parse",
"-/AuxExemplarCharacters",
"-/ExemplarCharacters",
"-/ExemplarCharactersIndex",
"-/ExemplarCharactersNumbers",
"-/ExemplarCharactersPunctuation",
"-/MoreInformation"
]
},
{
"categories": ["misc"],
"files": {
Expand Down
19 changes: 19 additions & 0 deletions icu/icu4c/source/common/uloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,15 @@ uloc_getISO3Language(const char* localeID)
return LANGUAGES_3[offset];
}

U_CAPI const char* U_EXPORT2
uloc_getISO3LanguageByLangCode(const char* langCode)
{
int16_t offset = _findIndex(LANGUAGES, langCode);
if (offset < 0)
return "";
return LANGUAGES_3[offset];
}

U_CAPI const char* U_EXPORT2
uloc_getISO3Country(const char* localeID)
{
Expand All @@ -1982,6 +1991,16 @@ uloc_getISO3Country(const char* localeID)
return COUNTRIES_3[offset];
}

U_CAPI const char* U_EXPORT2
uloc_getISO3CountryByCountryCode(const char* countryCode)
{
int16_t offset = _findIndex(COUNTRIES, countryCode);
if (offset < 0)
return "";

return COUNTRIES_3[offset];
}

U_CAPI uint32_t U_EXPORT2
uloc_getLCID(const char* localeID)
{
Expand Down
19 changes: 19 additions & 0 deletions icu/icu4c/source/common/unicode/uloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,15 @@ uloc_canonicalize(const char* localeID,
U_CAPI const char* U_EXPORT2
uloc_getISO3Language(const char* localeID);

/**
* Gets the 3 letter ISO language code for the specified 2 letter language code.
*
* @param langCode Iso639LanguageTwoLetterName
* @return language the ISO language code for langCode
* DOTNET CUSTOM API
*/
U_CAPI const char* U_EXPORT2
uloc_getISO3LanguageByLangCode(const char* langCode);

/**
* Gets the ISO country code for the specified locale.
Expand All @@ -535,6 +544,16 @@ uloc_getISO3Language(const char* localeID);
U_CAPI const char* U_EXPORT2
uloc_getISO3Country(const char* localeID);

/**
* Gets the 3 letter ISO country code for the specified 2 letter country code.
*
* @param countryCode Iso3166CountryName
* @return country the ISO country code for countryCode
* DOTNET CUSTOM API
*/
U_CAPI const char* U_EXPORT2
uloc_getISO3CountryByCountryCode(const char* countryCode);

/**
* Gets the Win32 LCID value for the specified locale.
* If the ICU locale is not recognized by Windows, 0 will be returned.
Expand Down
2 changes: 2 additions & 0 deletions icu/icu4c/source/common/unicode/urename.h
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,9 @@
#define uloc_getDisplayScript U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayScript)
#define uloc_getDisplayVariant U_ICU_ENTRY_POINT_RENAME(uloc_getDisplayVariant)
#define uloc_getISO3Country U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Country)
#define uloc_getISO3CountryByCountryCode U_ICU_ENTRY_POINT_RENAME(uloc_getISO3CountryByCountryCode)
#define uloc_getISO3Language U_ICU_ENTRY_POINT_RENAME(uloc_getISO3Language)
#define uloc_getISO3LanguageByLangCode U_ICU_ENTRY_POINT_RENAME(uloc_getISO3LanguageByLangCode)
#define uloc_getISOCountries U_ICU_ENTRY_POINT_RENAME(uloc_getISOCountries)
#define uloc_getISOLanguages U_ICU_ENTRY_POINT_RENAME(uloc_getISOLanguages)
#define uloc_getKeywordValue U_ICU_ENTRY_POINT_RENAME(uloc_getKeywordValue)
Expand Down