Closed Bug 1324133 Opened 7 years ago Closed 7 years ago

Don't hardcode formatting of numbers, dates, etc. (ICU, CLDR)

Categories

(Toolkit :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1329904

People

(Reporter: aryx, Unassigned)

References

Details

Bug 1301655 replaced usage of nsIScriptableDateFormat with formats from ICU, e.g.

>+  var dateFormatter = new Intl.DateTimeFormat(locale, { year: '2-digit',
>+                                                        month: 'numeric',
>+                                                        day: 'numeric' });

Hardcoding the output format of numbers etc. will be an issue, e.g. a Germany industry standard (DIN) switched to always use 4 digits for years. (Also month numbers as two digits - especially in lists and tables).

Using only the full, long, medium and short date & time formats should be considered once they are available ( https://github.com/tc39/ecma402/issues/108 ). According to #l10n, it might even depend on the locale which formatter should be used.

There might still be issues, e.g. for German, one can only get the year with 4 digits if one also accepts the seconds from these pre-defined formatters.
My first reaction is that we could solve this by introducing a thin-wrapper on top of Intl.DateTimeFormat that will give us short/long/full/medium.

We could start by hardcoding them, and then add two layers:

1) let localizers define the options for each style of the datetime format
2) retrieve the user preferences from the platform.

This would let us have the ultimate solution for the platform and Firefox until we can decide on something within ECMA402/ICU.

I'm wondering how would localizers define those preferences? Using l10n resources for that seems like a workaround. Wondering if there's a designated preferences file that localizers can use to configure such settings.

CC'ing Pike to get his opinion on the idea and suggestions for where it should go.

The data might look like this:

date-long = {
  year: 'numeric',
  month: 'long',
  day: 'numeric'
};

It would be great if it was optional (so that most localizers don't have to write it and we'll have some sane defaults).
Flags: needinfo?(l10n)
I'm tempted to use CLDR defaults with a file that has hard-coded overwrites. I'd not expose that option to localizers per-se, but just have the ability in our code to tweak what's in CLDR to our liking.
Flags: needinfo?(l10n)
This has been fixed in bug 1329904. We now use mozIntl.DateTimeFormat with dateStyle and timeStyle where possible.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.