Skip to content

ICU-23656 Stop inheriting intervalFormatItem patterns from root for non-root locales - #4414

Draft
sffc wants to merge 1 commit into
unicode-org:mainfrom
sffc:ICU-23656
Draft

sffc wants to merge 1 commit into
unicode-org:mainfrom
sffc:ICU-23656

Conversation

@sffc

@sffc sffc commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

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 GenerateProductionData stripped explicitly vetted ↑↑↑ (INHERITANCE_MARKER) intervalFormatItem entries whose Bailey value matched root (e.g., de y/y, M/M, h/a; hi h/a, h/h; th d/d; nl H/H). Against ICU's current CLDR 49 .txt bundles, suppressing root inheritance 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):

  • ICU4C DateIntervalFormatTest/testFormat: de\y, de\M, de\h, th\d (4 failures)
  • ICU4C DateIntervalFormatTest/testHourMetacharacters: hi_IN\jj (2 failures)
  • ICU4J DateIntervalFormatTest.TestFormat: de\y, de\M (×2), de\h, th\d (5 failures)
  • ICU4J DateIntervalFormatTest.TestHourMetacharacters: hi_IN\jj (2 failures)

Existing test expectations for de, th, and hi_IN are 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 inherit intervalFormatItem from root (and no implementation has enforced UTS #35 Step 1 since ICU-12013 in 2016), CLDR-19944 also proposes Option 2: updating UTS #35 to reflect current universal root-inheritance behavior instead of changing code across CLDR and ICU (which would allow closing ICU-23656 and both Draft PRs).

Summary

Implements ICU-23656 to restore compliance with UTS #35 Part 4 Step 1 (intervalFormatItem entries must not inherit from root for non-root locales, while intervalFormatFallback, root's calendar aliases, and explicit root/und locales continue working as expected):

  1. Root intervalFormatItem suppression (ICU4C & ICU4J):

    • icu4c/source/i18n/dtitvinf.cpp & icu4j/main/core/src/main/java/com/ibm/icu/text/DateIntervalInfo.java: compute isRootLocale from the top-level locale resource bundle (rb / resource.isRoot(), not calBundle) and pass it to DateIntervalSink. In DateIntervalSink::put, skip URES_TABLE / ICUResourceBundle.TABLE when noFallback && !isRootLocale, while continuing to follow URES_ALIAS / ICUResourceBundle.ALIAS entries in root (buddhist → generic, dangi → chinese, islamic-* → islamic → generic, ethiopic-amete-alem → ethiopic → generic, etc.).
    • intervalFormats/fallback continues inheriting from root as before.
    • Explicit root/und locales (Locale::getRoot(), Locale("root"), und, und-u-ca-chinese, und-u-ca-buddhist) retain root's own intervalFormatItem entries.
  2. Empty-fIntervalPatterns fixes exposed once real locales legitimately have no intervalFormatItem entries:

    • ICU4J (DateIntervalInfo.java:getBestSkeleton): return BestMatchInfo("", -1) immediately when fIntervalPatterns.isEmpty() instead of falsely returning differenceInfo == 0 (which previously caused concatSingleDate2TimeInterval to append null and throw IllegalArgumentException: Illegal pattern character 'n' on skeletons like "yMdH" in fr-u-ca-chinese or agq). Also guard timeItvPtnInfo.getSecondPart() != null in DateIntervalFormat.concatSingleDate2TimeInterval.
    • ICU4C (dtitvfmt.cpp:setSeparateDateTimePtn): populate fDatePattern and fTimePattern before returning on bestSkeleton == nullptr || differenceInfo == -1 (and guard fDateTimeFormat in fallbackFormat) so same-day date+time fallback ("yMdHm") produces single date + time range matching ICU4J.
    • ICU4J (DateIntervalFormat.java:LOCAL_PATTERN_CACHE): cache fDatePattern, fTimePattern, and fDateTimeFormat alongside the pattern map in a CachedPatterns holder so subsequent getInstance(...) cache hits preserve same-day date+time fallback behavior.
  3. Tests:

    • Added symmetric testTicket23656 tests in dtifmtts.h / dtifmtts.cpp and DateIntervalFormatTest.java covering fr-u-ca-chinese (yMd, same-day yMdHm including 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 explicit root/und (Locale::getRoot(), "root", "und", "und-u-ca-chinese", "und-u-ca-buddhist").

Verification

  • ICU4C:
    • intltest format/DateIntervalFormatTest/testTicket23656 — passed.
    • cintltst /tsformat/cdateintervalformattest — passed.
    • Full intltest format — passed except the 6 expected pre-CLDR-19944 failures in DateIntervalFormatTest listed above.
  • ICU4J:
    • DateIntervalFormatTest#testTicket23656 — passed.
    • CoverageTest (90 tests) and CompatibilityTest (366 tests) serialization suites — all 456 passed.
    • Full com.ibm.icu.dev.test.format.*Test (465 tests) — passed except the 7 expected pre-CLDR-19944 failures in DateIntervalFormatTest listed above.

Checklist

  • Required: Issue filed: ICU-23656
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable
  • Approver: Feel free to merge on my behalf

🤖 This pull request was created by an AI agent working with @sffc.

…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>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant