[DateTimePicker] Set calendar variables for date picker using Intl.getCalendarInfo

RESOLVED FIXED in Firefox 54

Status

()

Toolkit
XUL Widgets
RESOLVED FIXED
9 months ago
9 months ago

People

(Reporter: scottwu, Assigned: scottwu)

Tracking

(Blocks: 1 bug)

unspecified
mozilla54
Points:
---

Firefox Tracking Flags

(firefox54 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Assignee)

Description

9 months ago
Bug 1287503 has made locale dependent calendar information such as first-day-of-week and weekends available. The date picker should make use of the Intl.getCalendarInfo API to improve l10n support.
(Assignee)

Updated

9 months ago
Duplicate of this bug: 1332266
Comment hidden (mozreview-request)
(Assignee)

Updated

9 months ago
Attachment #8829339 - Flags: review?(mconley)
Attachment #8829339 - Flags: review?(gandalf)
(Assignee)

Comment 3

9 months ago
mozreview-review
Comment on attachment 8829339 [details]
Bug 1329589 - Set calendar variables for date picker using Intl.getCalendarInfo

https://reviewboard.mozilla.org/r/106456/#review107418

::: toolkit/content/widgets/datetimepopup.xml:197
(Diff revision 1)
> +      <method name="getCalendarInfo">
> +        <parameter name="locale"/>
> +        <body><![CDATA[
> +          const l10n = {};
> +          const mozIntl = Components.classes["@mozilla.org/mozintl;1"].getService(Components.interfaces.mozIMozIntl);
> +          mozIntl.addGetCalendarInfo(l10n);

gandalf: I saw that you've used mozIntl.addGetCalendarInfo(Intl) to add the method to `Intl`, but I wonder if it's okay to mutate `Intl`?
Comment on attachment 8829339 [details]
Bug 1329589 - Set calendar variables for date picker using Intl.getCalendarInfo

https://reviewboard.mozilla.org/r/106458/#review107670

Seems okay, but see my suggestion below.

::: toolkit/content/widgets/datetimepopup.xml:192
(Diff revision 1)
> +      <method name="getCalendarInfo">
> +        <parameter name="locale"/>
> +        <body><![CDATA[
> +          const l10n = {};
> +          const mozIntl = Components.classes["@mozilla.org/mozintl;1"].getService(Components.interfaces.mozIMozIntl);
> +          mozIntl.addGetCalendarInfo(l10n);
> +          return l10n.getCalendarInfo(locale);
> +        ]]></body>
> +      </method>
> +      <method name="parseCalendarInfo">
> +        <parameter name="calendarInfo"/>

Out of curiosity, why is this split into two steps? Do we expect to call getCalendarInfo and not pass immediately to parseCalendarInfo somewhere?

If not, I'm fine with having a helper function for getting the calendar info, but perhaps we can just have callers call `getCalendarInfo(locale)` and get back what you're returning from `parseCalendarInfo`?
Attachment #8829339 - Flags: review?(mconley) → review+
Comment hidden (mozreview-request)
(Assignee)

Comment 6

9 months ago
mozreview-review-reply
Comment on attachment 8829339 [details]
Bug 1329589 - Set calendar variables for date picker using Intl.getCalendarInfo

https://reviewboard.mozilla.org/r/106458/#review107670

> Out of curiosity, why is this split into two steps? Do we expect to call getCalendarInfo and not pass immediately to parseCalendarInfo somewhere?
> 
> If not, I'm fine with having a helper function for getting the calendar info, but perhaps we can just have callers call `getCalendarInfo(locale)` and get back what you're returning from `parseCalendarInfo`?

My initial thought was to make them two functions before they do different things, but I can see that combining them makes sense because I don't expect getCalendarInfo to be used anywhere else.

Comment 7

9 months ago
mozreview-review
Comment on attachment 8829339 [details]
Bug 1329589 - Set calendar variables for date picker using Intl.getCalendarInfo

https://reviewboard.mozilla.org/r/106458/#review107926

lgtm!
Attachment #8829339 - Flags: review?(gandalf) → review+
(Assignee)

Comment 8

9 months ago
Thanks! Checking it in.

:gandalf, I do have a question about testing. I'm working on adding browser chrome tests in Bug 1328219, and I wonder what would be a good way test for different UI locales?
Flags: needinfo?(gandalf)
Keywords: checkin-needed

Comment 9

9 months ago
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/e4754459cae8
Set calendar variables for date picker using Intl.getCalendarInfo r=gandalf,mconley
Keywords: checkin-needed
You can't do too much. As a rule of thumb, try to write tests that do not rely on any particular values returned from intl functions.

Where you do need some bits, test for 2 locales that have different values, maybe 'de' and 'ar'?
This would cover you for bidi and l10n.
Flags: needinfo?(gandalf)

Comment 11

9 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/e4754459cae8
Status: NEW → RESOLVED
Last Resolved: 9 months ago
status-firefox54: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla54
You need to log in before you can comment on or make changes to this bug.