unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.37k stars 176 forks source link

Add datetime API for loading length patterns, sitting on top of semantic skeleta #5162

Open sffc opened 4 months ago

sffc commented 4 months ago

CLDR issue: https://unicode-org.atlassian.net/browse/CLDR-17775

Semantic skeleta allow a lot of flexibility for locales to select the fields most relevant for their formatting.

However, they produce different output than date length patterns since the backing CLDR data is different.

For 2.0, I suggest moving forward with something like this:

use icu::datetime::{YearMonthDay, CldrDateStyle, Length};

// Semantic Skeleta data
icu::datetime::Formatter::<YearMonthDay>::try_new(locale.into(), Length::Short)

// CLDR Length Pattern data
icu::datetime::Formatter::<CldrDateStyle>::try_new(locale.into(), Length::Short)

This way, in 2.0, we nudge users toward semantic skeleta, but we give an escape hatch for using the CLDR date length data, which is well signaled.

Thoughts? @eggrobin @zbraniecki

sffc commented 3 months ago

What I want to do for 2.0:

sffc commented 1 month ago

The LDML spec doesn't include CldrStyle so I would like to remove it.

@zbraniecki to post more info / screenshots.

zbraniecki commented 1 month ago

This is what's in Windows 10:

This is MacOS:

(based on https://github.com/tc39/ecma402/issues/109 )

I think the trend is to simplify it, as I don't have access to latest Windows, but on latest MacOS I can't find the same UI in my Settings.

sffc commented 1 month ago

OK, got it, this is just about the OS override stuff?

I think the right design is to implement this in a thin wrapper that sits on top of icu::datetime::Formatter. I'd be fine having that be in the crate as a first-class supported abstraction.

I'm going to repurpose this issue and remove it from the 2.0 milestone.

sffc commented 1 month ago

Discussed with @zbraniecki. It is solvable via either the higher-level type in ICU4X or in userland, so this doesn't need to block 2.0.