Repository navigation
Conversation
…on-root locales Per UTS #35 Part 4 Step 1, intervalFormatItem entries do not inherit from root for non-root locales, whereas intervalFormatFallback and root's calendar-level intervalFormats aliases (buddhist -> generic, dangi -> chinese, islamic-* -> islamic -> generic, etc.) continue to resolve normally. Explicit root/und locales retain root's own intervalFormatItem entries. Changes: - ICU4C (dtitvinf.cpp) & ICU4J (DateIntervalInfo.java): pass isRootLocale (checked on the top-level locale bundle) into DateIntervalSink and skip URES_TABLE / ICUResourceBundle.TABLE when noFallback && !isRootLocale while continuing to follow URES_ALIAS / ICUResourceBundle.ALIAS entries in root. - Fix empty-fIntervalPatterns bugs exposed once real CLDR locales legitimately have no intervalFormatItem entries: - ICU4J DateIntervalInfo.getBestSkeleton(): return BestMatchInfo("", -1) when fIntervalPatterns is empty (avoiding false exact-match -> null-concat crash in concatSingleDate2TimeInterval), plus guard secondPart != null. - ICU4C DateIntervalFormat::setSeparateDateTimePtn(): populate fDatePattern and fTimePattern before returning on bestSkeleton == nullptr so same-day date+time fallback formatting matches ICU4J. - ICU4J DateIntervalFormat LOCAL_PATTERN_CACHE: cache fDatePattern, fTimePattern, and fDateTimeFormat alongside the pattern map so cache hits preserve same-day date+time fallback behavior. - Add symmetric unit tests (testTicket23656) in ICU4C and ICU4J. Co-authored-by: Gemini <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 task done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Important
Draft PR — Blocked on CLDR-19944 + ICU CLDR Data Refresh
This PR must not be merged until CLDR-19944 (unicode-org/cldr#6305) lands and ICU's CLDR data is regenerated via
cldr-to-icu.Why: Pre-CLDR-19944
GenerateProductionDatastripped explicitly vetted↑↑↑(INHERITANCE_MARKER)intervalFormatItementries whose Bailey value matchedroot(e.g.,dey/y,M/M,h/a;hih/a,h/h;thd/d;nlH/H). Against ICU's current CLDR 49.txtbundles, suppressingrootinheritance fixes unvetted locales/calendars (e.g.,fr-u-ca-chinese,agq) across 252 top-level locales, but would simultaneously regress explicitly vetted↑↑↑entries across 163 top-level locales (154 Gregorian, 138 Generic, 15 Chinese; 525/457/64 across all 908 non-alias ICU locales).Expected CI test failures against current CLDR 49 data (all resolved once CLDR-19944 data is imported into ICU):
DateIntervalFormatTest/testFormat:de\y,de\M,de\h,th\d(4 failures)DateIntervalFormatTest/testHourMetacharacters:hi_IN\jj(2 failures)DateIntervalFormatTest.TestFormat:de\y,de\M(×2),de\h,th\d(5 failures)DateIntervalFormatTest.TestHourMetacharacters:hi_IN\jj(2 failures)Existing test expectations for
de,th, andhi_INare intentionally kept unchanged because those expectations reflect what vetters approved in CLDR and will pass once CLDR-19944 data is imported.Alternative TC Option (see CLDR-19944): Because Survey Tool,
GenerateProductionData,cldr-json, ICU4C, ICU4J, and ICU4X all currently inheritintervalFormatItemfromroot(and no implementation has enforced UTS #35 Step 1 sinceICU-12013in 2016),CLDR-19944also proposes Option 2: updating UTS #35 to reflect current universal root-inheritance behavior instead of changing code across CLDR and ICU (which would allow closingICU-23656and both Draft PRs).Summary
Implements ICU-23656 to restore compliance with UTS #35 Part 4 Step 1 (
intervalFormatItementries must not inherit fromrootfor non-root locales, whileintervalFormatFallback,root's calendar aliases, and explicitroot/undlocales continue working as expected):Root
intervalFormatItemsuppression (ICU4C & ICU4J):icu4c/source/i18n/dtitvinf.cpp&icu4j/main/core/src/main/java/com/ibm/icu/text/DateIntervalInfo.java: computeisRootLocalefrom the top-level locale resource bundle (rb/resource.isRoot(), notcalBundle) and pass it toDateIntervalSink. InDateIntervalSink::put, skipURES_TABLE/ICUResourceBundle.TABLEwhennoFallback && !isRootLocale, while continuing to followURES_ALIAS/ICUResourceBundle.ALIASentries inroot(buddhist→generic,dangi→chinese,islamic-*→islamic→generic,ethiopic-amete-alem→ethiopic→generic, etc.).intervalFormats/fallbackcontinues inheriting fromrootas before.root/undlocales (Locale::getRoot(),Locale("root"),und,und-u-ca-chinese,und-u-ca-buddhist) retainroot's ownintervalFormatItementries.Empty-
fIntervalPatternsfixes exposed once real locales legitimately have nointervalFormatItementries:DateIntervalInfo.java:getBestSkeleton): returnBestMatchInfo("", -1)immediately whenfIntervalPatterns.isEmpty()instead of falsely returningdifferenceInfo == 0(which previously causedconcatSingleDate2TimeIntervalto appendnulland throwIllegalArgumentException: Illegal pattern character 'n'on skeletons like"yMdH"infr-u-ca-chineseoragq). Also guardtimeItvPtnInfo.getSecondPart() != nullinDateIntervalFormat.concatSingleDate2TimeInterval.dtitvfmt.cpp:setSeparateDateTimePtn): populatefDatePatternandfTimePatternbefore returning onbestSkeleton == nullptr || differenceInfo == -1(and guardfDateTimeFormatinfallbackFormat) so same-day date+time fallback ("yMdHm") produces single date + time range matching ICU4J.DateIntervalFormat.java:LOCAL_PATTERN_CACHE): cachefDatePattern,fTimePattern, andfDateTimeFormatalongside the pattern map in aCachedPatternsholder so subsequentgetInstance(...)cache hits preserve same-day date+time fallback behavior.Tests:
testTicket23656tests indtifmtts.h/dtifmtts.cppandDateIntervalFormatTest.javacoveringfr-u-ca-chinese(yMd, same-dayyMdHmincluding cache hit,yMdH),fr-u-ca-dangi,agq,agq-CM,agq-u-ca-chinese,uz-Cyrl(%%Parent{"root"}), 1-hop & 2-hop root calendar aliases (fr-u-ca-buddhist,fr-u-ca-islamic-civil,zh-u-ca-dangi,zh-u-ca-buddhist), non-root parent fallback (en-GB), and explicitroot/und(Locale::getRoot(),"root","und","und-u-ca-chinese","und-u-ca-buddhist").Verification
intltest format/DateIntervalFormatTest/testTicket23656— passed.cintltst /tsformat/cdateintervalformattest— passed.intltest format— passed except the 6 expected pre-CLDR-19944 failures inDateIntervalFormatTestlisted above.DateIntervalFormatTest#testTicket23656— passed.CoverageTest(90 tests) andCompatibilityTest(366 tests) serialization suites — all 456 passed.com.ibm.icu.dev.test.format.*Test(465 tests) — passed except the 7 expected pre-CLDR-19944 failures inDateIntervalFormatTestlisted above.Checklist
🤖 This pull request was created by an AI agent working with @sffc.