Closed Bug 1383562 Opened 7 years ago Closed 7 years ago

Months in the downloads panel are in nominative instead of genitive

Categories

(Firefox :: Downloads Panel, defect, P3)

defect

Tracking

()

RESOLVED FIXED
Firefox 58
Tracking Status
firefox58 --- fixed

People

(Reporter: piotrdrag, Assigned: hrdktg, Mentored)

Details

(Whiteboard: [good first bug])

Attachments

(2 files, 5 obsolete files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0 Build ID: 20170628075643 Steps to reproduce: Opened the download panel using Polish localization. Actual results: "15 lipiec" is displayed ("Months - wide - Standalone" in CLDR.) Expected results: "15 lipca" should be displayed ("Months - wide - Formatting" in CLDR.)
Component: Untriaged → pl / Polish
Product: Firefox → Mozilla Localizations
Version: 54 Branch → unspecified
I can’t find anything in localization that could be responsible. It’s more likely to be a bug in tools or incorrect use of ICU data.
Component: pl / Polish → Downloads Panel
Product: Mozilla Localizations → Firefox
Status: UNCONFIRMED → NEW
Component: Downloads Panel → JavaScript: Internationalization API
Ever confirmed: true
Product: Firefox → Core
|new Date(2017, 7-1, 15).toLocaleString("pl", {month: "long", day: "numeric"})| returns "15 lipca" for me (current inbound, but also moz54). DownloadUtils.jsm computes the standalone month and then concatenates it with the current day [1,2]. Maybe it makes sense to either switch completely to Intl.DateTimeFormat or use Intl.DateTimeFormat.prototype.formatToParts to retrieve the correct month name in a non-standalone context. [1] http://searchfox.org/mozilla-central/rev/ad093e98f42338effe2e2513e26c3a311dd96422/toolkit/mozapps/downloads/DownloadUtils.jsm#367-369 [2] http://searchfox.org/mozilla-central/rev/ad093e98f42338effe2e2513e26c3a311dd96422/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties#107
Either way, it's not an issue for the "JavaScript: Internationalization API" component.
Component: JavaScript: Internationalization API → Downloads Panel
Product: Core → Firefox
new Date(2017, 7-1, 15).toLocaleString("pl", {month: "long"}) return: "lipiec"
Flags: needinfo?(andrebargull)
(In reply to YF (Yang) from comment #5) > new Date(2017, 7-1, 15).toLocaleString("pl", {month: "long"}) return: > "lipiec" Yes, that looks correct to me. "lipiec" in a stand-alone context, otherwise "lipca". From CLDR (common/main/pl.xml): <calendar type="gregorian"> <months> <monthContext type="format"> <!-- ... --> <monthWidth type="wide"> <month type="1">stycznia</month> <month type="2">lutego</month> <month type="3">marca</month> <month type="4">kwietnia</month> <month type="5">maja</month> <month type="6">czerwca</month> <month type="7">lipca</month> <month type="8">sierpnia</month> <month type="9">września</month> <month type="10">października</month> <month type="11">listopada</month> <month type="12">grudnia</month> </monthWidth> </monthContext> <monthContext type="stand-alone"> <!-- ... --> <monthWidth type="wide"> <month type="1">styczeń</month> <month type="2">luty</month> <month type="3">marzec</month> <month type="4">kwiecień</month> <month type="5">maj</month> <month type="6">czerwiec</month> <month type="7">lipiec</month> <month type="8">sierpień</month> <month type="9">wrzesień</month> <month type="10">październik</month> <month type="11">listopad</month> <month type="12">grudzień</month> </monthWidth> </monthContext> </months>
Flags: needinfo?(andrebargull)
Yeah, Andre is right, this should be switched to full Intl API: aDate.getLocaleString(undefined, { month: "long", day: "numeric" }); and remove the entity from .properties
Thanks gandalf, with the solution already outlined in comment 7 this looks like a good first bug for a new contributor, but anyone should feel free to fix it.
Priority: -- → P3
Whiteboard: [good first bug]
Hello. I'd be happy to help if there's still work to do on this. As far as I know, the fix has to be applied in downloadUtils.jsm, in line #367. I'll wait for feedback.
yes! I'll be happy to mentor you.
Mentor: gandalf
OK. so, it has to go from this: let month = aDate.toLocaleDateString(undefined, {month: "long" }); to: let dateTimeCompact = Intl.DateTimeFormat(undefined, {month: "long", day: "numeric"}).format(aDate); and then drop the next two lines. Will this fix the problem? I'm not sure how to check the validity of the code; nodejs in my computer shows a valid string, but I'm still not sure.
You can build Firefox using Artifact Build - https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Build_Instructions/Artifact_builds This will be quite fast and allow you to modify JS code, rebuild and see the result.
thank you. I'm on it now.
I got my build to run (had already built it, just forgot how to run it), and the solution is already in the works. Will have to wait until tomorrow to continue and hopefully finish before next weekend. I'll keep you updated. Attempted the change proposed before, but it'll take some more time.
Is this still being worked on?
Flags: needinfo?(luischa123)
Seems like this bug is for grabs. The instruction for anyone interested: 1) Replace the code in http://searchfox.org/mozilla-central/rev/ad093e98f42338effe2e2513e26c3a311dd96422/toolkit/mozapps/downloads/DownloadUtils.jsm#367-369 to use: aDate.toLocaleString(undefined, { month: "long", day: "numeric" }); 2) Remove this line: http://searchfox.org/mozilla-central/rev/ad093e98f42338effe2e2513e26c3a311dd96422/toolkit/locales/en-US/chrome/mozapps/downloads/downloads.properties#107
Flags: needinfo?(luischa123)
Attached patch Bugfix#1383562 (obsolete) — Splinter Review
Attachment #8920421 - Flags: review?(gandalf)
Comment on attachment 8920421 [details] [diff] [review] Bugfix#1383562 Review of attachment 8920421 [details] [diff] [review]: ----------------------------------------------------------------- Thank you for the patch! Looks good! One more nit and we'll be done I believe :) ::: toolkit/mozapps/downloads/DownloadUtils.jsm @@ +367,5 @@ > + let curMonthDate = aDate.toLocaleString(undefined, { > + month: "long", > + day: "numeric" > + }); > + dateTimeCompact = gBundle.formatStringFromName(gStr.monthDate, [curMonthDate], 1); No need for the string: `dateTimeCompact = aDate.toLoclaeString(...);` Also, you can then remove the `gStr.monthDate` in line 88.
Assignee: nobody → hrdktg
Status: NEW → ASSIGNED
There is a big problem, I did the above changes built the code and ran it. Saw in the downloads panel by changing the dates and it is just blank. On the original code the download panel shows the Month and date of download. Is there any proper way of checking the output of this javascript function.
Flags: needinfo?(gandalf)
Can you update your patch so I can test it? ``` var aDate = new Date();aDate.toLocaleString(undefined, {month: "long",day: "numeric"}); ``` in a browser console works for me.
Flags: needinfo?(gandalf)
Attached patch ttt.patch (obsolete) — Splinter Review
Problem was on my build. I was doing a silly mistake. Its working good now.
Attachment #8920421 - Attachment is obsolete: true
Attachment #8920421 - Flags: review?(gandalf)
Attachment #8920430 - Flags: review?(gandalf)
Attached patch fixed.patch (obsolete) — Splinter Review
Attachment #8920430 - Attachment is obsolete: true
Attachment #8920430 - Flags: review?(gandalf)
Attachment #8920431 - Flags: review?(gandalf)
That looks good! Sorry for not mentioning in the previous round - you need to update the bug title to something aligned with our bug naming guidelines. Instead of `Fixed Bug#1383562` it should be: `Bug 1383562 - Correctly decline date in DownloadUtils.jsm. r=gandalf`
Is "Bug 1383562 - Correctly get Month and date in DownloadUtils.jsm. r=gandalf" fine?
Flags: needinfo?(gandalf)
Attachment #8920431 - Attachment is obsolete: true
Attachment #8920431 - Flags: review?(gandalf)
Attachment #8920437 - Flags: review?(gandalf)
yes! :) But I think you accidentally removed the hunk that removes the line 88 from the file ;)
Flags: needinfo?(gandalf)
:) Sorry..
Attachment #8920437 - Attachment is obsolete: true
Attachment #8920437 - Flags: review?(gandalf)
Attachment #8920438 - Flags: review?(gandalf)
Looks good! Aaand, last request - can you remove the localization comment that is right above the line you removed from the .properties file? It's not needed once the string is gone :)
Attachment #8920438 - Attachment is obsolete: true
Attachment #8920438 - Flags: review?(gandalf)
Attachment #8920530 - Flags: review?(gandalf)
Comment on attachment 8920530 [details] [diff] [review] Bug 1383562 - Correctly get Month and date in DownloadUtils.jsm. r=gandalf Thank you! Looks great!
Attachment #8920530 - Flags: review?(gandalf) → review+
When you're ready to land this - add "checkin-needed" to keywords.
Keywords: checkin-needed
Pushed by ryanvm@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/d42c58ea0e83 Correctly get Month and date in DownloadUtils.jsm. r=gandalf
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 58
Thank you for your contribution hardik!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: