message-format-wg icon indicating copy to clipboard operation
message-format-wg copied to clipboard

Resolve hour12 and hourCycle

Open sffc opened this issue 4 months ago • 4 comments

First raised in https://github.com/unicode-org/message-format-wg/pull/1083#issuecomment-3047632326

I would like to stop propagating the two options hour12 and hourCycle, which are distinctly different but also so close that most people don't know the difference or how to use them.

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

sffc avatar Aug 13 '25 20:08 sffc

Note that hourCycle is not an option recognised by Unicode MessageFormat. It might be set by a -u-hc subtag on a locale, but not as an option on e.g. :datetime. There, hour12 is the only supported option.

eemeli avatar Aug 13 '25 21:08 eemeli

We discussed this a while ago. The hour12 option is a user-facing option that allows the message author to potentially override the locale and specifically select 12 vs. 24 hour time. This is useful for applications that maintain a separate user preference or for the rare message that wants to show both ({$time :time hour12=true} is {$time :time hour12=false}). The hour cycle associated with each of the 12 and 24 hour time representations is controlled by the locale and is not exposed to message authors (you'd need to override the locale to change it).

I agree that hourCycle is hard for users to grok and use effectively. That option exposes something that locales are good at hiding/abstracting. An ideal message is one in which the translators do not need to adjust the options to match locale expectations. hourCycle more-or-less would require such adjustment, while hour12, by contrast, leans on locale magic to get the right presentation, but allows presentational control.

aphillips avatar Aug 14 '25 13:08 aphillips

I understand the difference.

ECMAScript has both hourCycle and hour12 in the same API (Intl.DateTimeFormat), and I understand why, but it's still not a great situation to be in.

I also strongly prefer enumerated options over booleans. In fact, hour12 is already a 3-way enum: unset, true, or false. Better would be if it were a named enumeration.

sffc avatar Aug 15 '25 01:08 sffc

I also strongly prefer enumerated options over booleans. In fact, hour12 is already a 3-way enum: unset, true, or false. Better would be if it were a named enumeration.

I somewhat agree, and do note that we have a pending action from the 2025-07-21 meeting on this:

@mihnita and @sffc to consider proposing an alternative to the hour12=true|false option.

eemeli avatar Aug 15 '25 07:08 eemeli