Skip to content

Commit

Permalink
ICU-22723 Integrate CLDR 46 release alpha0, part 3, source files
Browse files Browse the repository at this point in the history
  • Loading branch information
DraganBesevic committed Aug 15, 2024
1 parent b865f26 commit d041548
Show file tree
Hide file tree
Showing 24 changed files with 432 additions and 158 deletions.
28 changes: 28 additions & 0 deletions icu4c/source/i18n/number_longnames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#include "unicode/simpleformatter.h"
#include "unicode/ures.h"
#include "unicode/plurrule.h"
#include "unicode/strenum.h"
#include "ureslocs.h"
#include "charstr.h"
#include "uresimp.h"
Expand All @@ -18,6 +20,7 @@
#include <algorithm>
#include "cstring.h"
#include "util.h"
#include "sharedpluralrules.h"

using namespace icu;
using namespace icu::number;
Expand Down Expand Up @@ -519,10 +522,35 @@ void getCurrencyLongNameData(const Locale &locale, const CurrencyUnit &currency,
// In ICU4J, this method gets a CurrencyData from CurrencyData.provider.
// TODO(ICU4J): Implement this without going through CurrencyData, like in ICU4C?
PluralTableSink sink(outArray);
// Here all outArray entries are bogus.
LocalUResourceBundlePointer unitsBundle(ures_open(U_ICUDATA_CURR, locale.getName(), &status));
if (U_FAILURE(status)) { return; }
ures_getAllChildrenWithFallback(unitsBundle.getAlias(), "CurrencyUnitPatterns", sink, status);
if (U_FAILURE(status)) { return; }
// Here the outArray[] entries are filled in with any CurrencyUnitPatterns data for locale,
// or if there is no CurrencyUnitPatterns data for locale since the patterns all inherited
// from the "other" pattern in root (which is true for many locales in CLDR 46), then only
// the "other" entry has a currency pattern. So now what we do is: For all valid plural keywords
// for the locale, if the corresponding outArray[] entry is bogus, fill it in from the "other"
// entry. In the longer run, clients of this should instead consider using CurrencyPluralInfo
// (see i18n/unicode/currpinf.h).
UErrorCode localStatus = U_ZERO_ERROR;
const SharedPluralRules *pr = PluralRules::createSharedInstance(
locale, UPLURAL_TYPE_CARDINAL, localStatus);
if (U_SUCCESS(localStatus)) {
LocalPointer<StringEnumeration> keywords((*pr)->getKeywords(localStatus), localStatus);
if (U_SUCCESS(localStatus)) {
const char* keyword;
while (((keyword = keywords->next(nullptr, localStatus)) != nullptr) && U_SUCCESS(localStatus)) {
int32_t index = StandardPlural::indexOrOtherIndexFromString(keyword);
if (index != StandardPlural::Form::OTHER && outArray[index].isBogus()) {
outArray[index].setTo(outArray[StandardPlural::Form::OTHER]);
}
}
}
pr->removeRef();
}

for (int32_t i = 0; i < StandardPlural::Form::COUNT; i++) {
UnicodeString &pattern = outArray[i];
if (pattern.isBogus()) {
Expand Down
10 changes: 5 additions & 5 deletions icu4c/source/test/cintltst/ccaltst.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ static const UCalGetTypeTest ucalGetTypeTests[] = {
{ "th-TH-u-ca-gregory", UCAL_DEFAULT, "gregorian" },
{ "ja_JP@calendar=japanese", UCAL_GREGORIAN, "gregorian" },
{ "fr_CH", UCAL_DEFAULT, "gregorian" },
{ "fr_SA", UCAL_DEFAULT, "islamic-umalqura" },
{ "fr_CH@rg=sazzzz", UCAL_DEFAULT, "islamic-umalqura" },
{ "fr_CH@rg=sa14", UCAL_DEFAULT, "islamic-umalqura" },
{ "fr_SA", UCAL_DEFAULT, "gregorian" },
{ "fr_CH@rg=sazzzz", UCAL_DEFAULT, "gregorian" },
{ "fr_CH@rg=sa14", UCAL_DEFAULT, "gregorian" },
{ "fr_CH@calendar=japanese;rg=sazzzz", UCAL_DEFAULT, "japanese" },
{ "fr_CH@rg=twcyi", UCAL_DEFAULT, "gregorian" }, // test for ICU-22364
{ "fr_CH@rg=ugw", UCAL_DEFAULT, "gregorian" }, // test for ICU-22364
Expand Down Expand Up @@ -1634,7 +1634,7 @@ static void TestGetKeywordValuesForLocale(void) {
{ "en@calendar=islamic", "gregorian", NULL, NULL, NULL, NULL },
{ "zh_TW", "gregorian", "roc", "chinese", NULL, NULL },
{ "ar_IR", "persian", "gregorian", "islamic", "islamic-civil", "islamic-tbla" },
{ "th@rg=SAZZZZ", "islamic-umalqura", "gregorian", "islamic", "islamic-rgsa", NULL },
{ "th@rg=SAZZZZ", "gregorian", "islamic-umalqura", "islamic", "islamic-rgsa", NULL },

// tests for ICU-22364
{ "zh_CN@rg=TW", "gregorian", "chinese", NULL, NULL, NULL }, // invalid subdivision code
Expand Down Expand Up @@ -2860,7 +2860,7 @@ TestGetIanaTimeZoneID(void) {
{u"Europe/Zaporozhye", u"Europe/Kyiv"},
{u"Etc/GMT-1", u"Etc/GMT-1"},
{u"Etc/GMT+20", UNKNOWN},
{u"PST8PDT", u"PST8PDT"},
{u"PST8PDT", u"America/Los_Angeles"},
{u"GMT-08:00", UNKNOWN},
{0, 0}
};
Expand Down
14 changes: 7 additions & 7 deletions icu4c/source/test/cintltst/cdattst.c
Original file line number Diff line number Diff line change
Expand Up @@ -2089,24 +2089,24 @@ static void TestHourCycle(void) {
// test some locales for which we have data
u"en_US", u"Tuesday, March 16, 1943 at 3:45:32 PM",
u"en_CA", u"Tuesday, March 16, 1943 at 3:45:32 p.m.",
u"en_GB", u"Tuesday 16 March 1943 at 15:45:32",
u"en_AU", u"Tuesday 16 March 1943 at 3:45:32 pm",
u"en_GB", u"Tuesday, 16 March 1943 at 15:45:32",
u"en_AU", u"Tuesday, 16 March 1943 at 3:45:32 pm",
// test a couple locales for which we don't have specific locale files (we should still get the correct hour cycle)
u"en_CO", u"Tuesday, March 16, 1943 at 3:45:32 PM",
u"en_MX", u"Tuesday, March 16, 1943 at 3:45:32 PM",
// test that the rg subtag does the right thing
u"en_US@rg=GBzzzz", u"Tuesday, March 16, 1943 at 15:45:32",
u"en_US@rg=CAzzzz", u"Tuesday, March 16, 1943 at 3:45:32 PM",
u"en_CA@rg=USzzzz", u"Tuesday, March 16, 1943 at 3:45:32 p.m.",
u"en_GB@rg=USzzzz", u"Tuesday 16 March 1943 at 3:45:32 pm",
u"en_GB@rg=CAzzzz", u"Tuesday 16 March 1943 at 3:45:32 pm",
u"en_GB@rg=AUzzzz", u"Tuesday 16 March 1943 at 3:45:32 pm",
u"en_GB@rg=USzzzz", u"Tuesday, 16 March 1943 at 3:45:32 pm",
u"en_GB@rg=CAzzzz", u"Tuesday, 16 March 1943 at 3:45:32 pm",
u"en_GB@rg=AUzzzz", u"Tuesday, 16 March 1943 at 3:45:32 pm",
// test that the hc ("hours") subtag does the right thing
u"en_US@hours=h23", u"Tuesday, March 16, 1943 at 15:45:32",
u"en_GB@hours=h12", u"Tuesday 16 March 1943 at 3:45:32 pm",
u"en_GB@hours=h12", u"Tuesday, 16 March 1943 at 3:45:32 pm",
// test that the rg and hc subtags do the right thing when used together
u"en_US@rg=GBzzzz;hours=h12", u"Tuesday, March 16, 1943 at 3:45:32 PM",
u"en_GB@rg=USzzzz;hours=h23", u"Tuesday 16 March 1943 at 15:45:32",
u"en_GB@rg=USzzzz;hours=h23", u"Tuesday, 16 March 1943 at 15:45:32",
};

for (int32_t i = 0; i < UPRV_LENGTHOF(testCases); i += 2) {
Expand Down
8 changes: 8 additions & 0 deletions icu4c/source/test/cintltst/cldrtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,10 @@ static void VerifyTranslation(void) {
log_knownIssue("CLDR-17203", "Some day names in kxv(_Deva)? use chars not in exemplars")) {
end = 0;
}
if (uprv_strncmp(currLoc,"ak",2) == 0 &&
log_knownIssue("CLDR-17852", "Some month names in ax(_GH) use chars not in exemplars")) {
end = 0;
}

for (idx = 0; idx < end; idx++) {
const UChar *fromBundleStr = ures_getStringByIndex(resArray, idx, &langSize, &errorCode);
Expand Down Expand Up @@ -1057,6 +1061,10 @@ static void VerifyTranslation(void) {
log_knownIssue("CLDR-17203", "Some month names in kxv(_Deva)? use chars not in exemplars")) {
end = 0;
}
if (uprv_strncmp(currLoc,"ak",2) == 0 &&
log_knownIssue("CLDR-17852", "Some month names in ax(_GH) use chars not in exemplars")) {
end = 0;
}

for (idx = 0; idx < end; idx++) {
const UChar *fromBundleStr = ures_getStringByIndex(resArray, idx, &langSize, &errorCode);
Expand Down
44 changes: 22 additions & 22 deletions icu4c/source/test/cintltst/crelativedateformattest.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,31 +258,31 @@ static const FieldsDat fr_attrDef_long_midSent_day[kNumOffsets*2] = {

static const char* ak_decDef_long_stdAlon_sec[kNumOffsets*2] = { // falls back to root
/* text numeric */
"-5 s", "-5 s", /* -5 */
"-2.2 s", "-2.2 s", /* -2.2 */
"-2 s", "-2 s", /* -2 */
"-1 s", "-1 s", /* -1 */
"-0.7 s", "-0.7 s", /* -0.7 */
"now", "-0 s", /* -0 */
"now", "+0 s", /* 0 */
"+0.7 s", "+0.7 s", /* 0.7 */
"+1 s", "+1 s", /* 1 */
"+2 s", "+2 s", /* 2 */
"+5 s", "+5 s", /* 5 */
"nnibuo 5 a atwam", "nnibuo 5 a atwam", /* -5 */
"nnibuo 2.2 a atwam", "nnibuo 2.2 a atwam", /* -2.2 */
"nnibuo 2 a atwam", "nnibuo 2 a atwam", /* -2 */
"anibuo 1 a atwam", "anibuo 1 a atwam", /* -1 */
"nnibuo 0.7 a atwam", "nnibuo 0.7 a atwam", /* -0.7 */
"seesei", "anibuo 0 a atwam", /* -0 */
"seesei", "anibuo 0 mu", /* 0 */
"nnibuo 0.7 mu", "nnibuo 0.7 mu", /* 0.7 */
"anibuo 1 mu", "anibuo 1 mu", /* 1 */
"nnibuo 2 mu", "nnibuo 2 mu", /* 2 */
"nnibuo 5 mu", "nnibuo 5 mu", /* 5 */
};

static const FieldsDat ak_attrDef_long_stdAlon_sec[kNumOffsets*2] = {
{UDAT_REL_NUMERIC_FIELD, 1, 2}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{UDAT_REL_NUMERIC_FIELD, 1, 4}, {UDAT_REL_NUMERIC_FIELD, 1, 4},
{UDAT_REL_NUMERIC_FIELD, 1, 2}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{UDAT_REL_NUMERIC_FIELD, 1, 2}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{UDAT_REL_NUMERIC_FIELD, 1, 4}, {UDAT_REL_NUMERIC_FIELD, 1, 4},
{ -1, -1, -1}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{ -1, -1, -1}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{UDAT_REL_NUMERIC_FIELD, 1, 4}, {UDAT_REL_NUMERIC_FIELD, 1, 4},
{UDAT_REL_NUMERIC_FIELD, 1, 2}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{UDAT_REL_NUMERIC_FIELD, 1, 2}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{UDAT_REL_NUMERIC_FIELD, 1, 2}, {UDAT_REL_NUMERIC_FIELD, 1, 2},
{UDAT_REL_NUMERIC_FIELD, 7, 8}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
{UDAT_REL_NUMERIC_FIELD, 7, 10}, {UDAT_REL_NUMERIC_FIELD, 7, 10},
{UDAT_REL_NUMERIC_FIELD, 7, 8}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
{UDAT_REL_NUMERIC_FIELD, 7, 8}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
{UDAT_REL_NUMERIC_FIELD, 7, 10}, {UDAT_REL_NUMERIC_FIELD, 7, 10},
{ -1, -1, -1}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
{ -1, -1, -1}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
{UDAT_REL_NUMERIC_FIELD, 7, 10}, {UDAT_REL_NUMERIC_FIELD, 7, 10},
{UDAT_REL_NUMERIC_FIELD, 7, 8}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
{UDAT_REL_NUMERIC_FIELD, 7, 8}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
{UDAT_REL_NUMERIC_FIELD, 7, 8}, {UDAT_REL_NUMERIC_FIELD, 7, 8},
};

static const char* enIN_decDef_short_midSent_weds[kNumOffsets*2] = {
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/test/cintltst/creststn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,7 @@ static void TestFallback(void)
UResourceBundle* myResB = ures_open(NULL,"no_NO_NY",&err);
UResourceBundle* resLocID = ures_getByKey(myResB, "Version", NULL, &err);
const UChar* version = NULL;
static const UChar versionStr[] = u"45"; // 45 in nn_NO or in a parent bundle/root
static const UChar versionStr[] = u"46"; // 45 in nn_NO or in a parent bundle/root

if(U_FAILURE(err)) {
log_data_err("Expected success when trying to test no_NO_NY aliased to nn_NO for Version "
Expand Down
Loading

0 comments on commit d041548

Please sign in to comment.