Closed
Bug 814355
Opened 13 years ago
Closed 13 years ago
l10n_date.js / pretty dates: support compact formats
Categories
(Firefox OS Graveyard :: Gaia, defect, P1)
Tracking
(blocking-basecamp:+)
People
(Reporter: kaze, Assigned: kaze)
References
Details
Attachments
(2 files, 3 obsolete files)
On small screens, there are a few situations where we prefer displaying "24m ago" rather than "24 minutes ago", assuming that this kind of truncation is doable with all languages.
The `shared/js/date_l10n.js` library, along with the `shared/locales/date.ini` locales, could be modified to support that.
| Assignee | ||
Updated•13 years ago
|
Updated•13 years ago
|
Assignee: nobody → kaze
blocking-basecamp: ? → +
Priority: -- → P1
Comment 1•13 years ago
|
||
Kaze I guess this should be a C2 since it blocks an other C2!
Target Milestone: --- → B2G C2 (20nov-10dec)
| Assignee | ||
Comment 2•13 years ago
|
||
Right.
| Assignee | ||
Comment 3•13 years ago
|
||
Here’s a simple patch that adds an optional `useCompactFormat' boolean argument to the `.fromNow()' method.
Re-reading the related code, I realize it implies two completely arbitrary parameters:
• a 10-day limit, above which an absolute time is returned;
• the `%x' format is used when an absolute time is returned.
I can see two ways to remove these arbitrary parameters:
• either we always return a relative time and add l10n resources for months and years — this would be my preferred option but it could break the compatibility;
• or we could pass an array of { limit: format } as a third parameter, to explicitly decide which format to use — and the default could be [{ "10d": "%x" }] to preserve the compatibility.
As `fromNow' is only used twice in Gaia [1], I’d go for the first option. Étienne, what’s your opinion on this?
[1] email and calendar apps:
apps/email/js/mail-common.js:1078
apps/calendar/js/controllers/alarm.js:42
Attachment #687500 -
Flags: review?(etienne)
Attachment #687500 -
Flags: feedback?(stas)
Comment 4•13 years ago
|
||
Comment on attachment 687500 [details] [diff] [review]
patch proposal
Review of attachment 687500 [details] [diff] [review]:
-----------------------------------------------------------------
::: shared/js/l10n.js
@@ +86,4 @@
> var evtObject = document.createEvent('Event');
> evtObject.initEvent('localized', false, false);
> evtObject.language = lang;
> + document.dispatchEvent(evtObject);
It seems like this change is out of scope of this bug? Won't it break all apps that listen to window's 'localized' event? E.g. https://github.com/mozilla-b2g/gaia/blob/master/apps/settings/js/settings.js#L702
::: shared/js/l10n_date.js
@@ +17,5 @@
> * - a `toLocaleFormat()' that really works (i.e. fully translated);
> * - a `fromNow()' method to handle relative dates ("pretty dates").
> + *
> + * WARNING: this library relies on the non-standard `toLocaleFormat()' method,
> + * which is specific to Firefox -- no other browser is not supported.
Nit: I'm guessing you meant s/not/now/ ?
@@ +96,4 @@
> if (secDiff >= 0) { // past
> var dayDiff = Math.floor(secDiff / 86400);
> if (secDiff < 3600) {
> + return _('minutesAgo' + f, { m: round(secDiff / 60) });
I would recommend using `Math.floor` instead of `round` here. The "just now" case seems to me important enough to support it even in short formatting.
For this to work properly, `minutesAgo-short` should be pluralized.
::: shared/locales/date/date.en-US.properties
@@ +97,5 @@
> +# Relative time ("pretty dates"), short variant
> +
> +minutesAgo-short = {{m}}’ ago
> +hoursAgo-short = {{h}}h ago
> +daysAgo-short = {{d}}d ago
Can we put a LOCALIZATION NOTE here that gives rough guidelines on how long (or short) these strings should be? How many Latin characters (approximately) do we allow?
Attachment #687500 -
Flags: feedback?(stas) → feedback+
| Assignee | ||
Comment 5•13 years ago
|
||
(In reply to Staś Małolepszy :stas (traveling until Dec 4) from comment #4)
> @@ +96,4 @@
> > if (secDiff >= 0) { // past
> > var dayDiff = Math.floor(secDiff / 86400);
> > if (secDiff < 3600) {
> > + return _('minutesAgo' + f, { m: round(secDiff / 60) });
>
> I would recommend using `Math.floor` instead of `round` here. The "just
> now" case seems to me important enough to support it even in short
> formatting.
>
That would be a UX question, but I’d say that “1’ ago” or “just now” should be equivalent in a context where we’re mostly looking for most compact form.
> For this to work properly, `minutesAgo-short` should be pluralized.
>
Ugh, really? Pluralization for an abbreviated unit? Just out of curiosity, which languages would be concerned?
> ::: shared/locales/date/date.en-US.properties
> @@ +97,5 @@
> > +# Relative time ("pretty dates"), short variant
> > +
> > +minutesAgo-short = {{m}}’ ago
> > +hoursAgo-short = {{h}}h ago
> > +daysAgo-short = {{d}}d ago
>
> Can we put a LOCALIZATION NOTE here that gives rough guidelines on how long
> (or short) these strings should be? How many Latin characters
> (approximately) do we allow?
Doable.
| Assignee | ||
Comment 6•13 years ago
|
||
I’ve addressed Staś’ first comments (thanks for the good catch!). The l10n part might still change if it turns out we really need pluralization support for the time units but the API won’t change… unless Étienne asks me to.
Attachment #687500 -
Attachment is obsolete: true
Attachment #687500 -
Flags: review?(etienne)
Attachment #687724 -
Flags: review?(etienne)
Attachment #687724 -
Flags: feedback?(stas)
| Assignee | ||
Comment 7•13 years ago
|
||
w/ localization note
Attachment #687724 -
Attachment is obsolete: true
Attachment #687724 -
Flags: review?(etienne)
Attachment #687724 -
Flags: feedback?(stas)
Attachment #687727 -
Flags: review?(etienne)
Attachment #687727 -
Flags: feedback?(stas)
Comment 8•13 years ago
|
||
(In reply to Fabien Cazenave [:kaze] from comment #6)
> Created attachment 687724 [details] [diff] [review]
> patch proposal
>
> I’ve addressed Staś’ first comments (thanks for the good catch!). The l10n
> part might still change if it turns out we really need pluralization support
> for the time units but the API won’t change… unless Étienne asks me to.
Do we need pluralization on abbrevation for the shipping countries? If not let's not block on that an open a followup.
Comment 9•13 years ago
|
||
(In reply to Fabien Cazenave [:kaze] from comment #5)
> That would be a UX question, but I’d say that “1’ ago” or “just now” should
> be equivalent in a context where we’re mostly looking for most compact form.
I agree that this is not blocking, but let's get UX input on this. Josh, what do you think? Are we OK to use "1' ago" in the short format, or would you prefer "just now"?
> > For this to work properly, `minutesAgo-short` should be pluralized.
> >
>
> Ugh, really? Pluralization for an abbreviated unit? Just out of curiosity,
> which languages would be concerned?
I only meant this for the "just now" case, were we to implement it.
minutesAgo-short = {[ plural(m) ]}
minutesAgo-short[zero] = Just now
minutesAgo-short[other] = {{m}}' ago
I think 'zero' and 'other' are enough in this case.
Flags: needinfo?(jcarpenter)
Comment 10•13 years ago
|
||
(In reply to Staś Małolepszy :stas (traveling until Dec 4) from comment #9)
> (In reply to Fabien Cazenave [:kaze] from comment #5)
>
> > That would be a UX question, but I’d say that “1’ ago” or “just now” should
> > be equivalent in a context where we’re mostly looking for most compact form.
>
> I agree that this is not blocking, but let's get UX input on this. Josh,
> what do you think? Are we OK to use "1' ago" in the short format, or would
> you prefer "just now"?
>
Not blocking. Let's land a followup if needed. (just now sounds better for me fwiw)
> > > For this to work properly, `minutesAgo-short` should be pluralized.
> > >
> >
> > Ugh, really? Pluralization for an abbreviated unit? Just out of curiosity,
> > which languages would be concerned?
>
> I only meant this for the "just now" case, were we to implement it.
>
> minutesAgo-short = {[ plural(m) ]}
> minutesAgo-short[zero] = Just now
> minutesAgo-short[other] = {{m}}' ago
>
> I think 'zero' and 'other' are enough in this case.
| Assignee | ||
Comment 11•13 years ago
|
||
(In reply to Staś Małolepszy :stas (traveling until Dec 4) from comment #9)
> (In reply to Fabien Cazenave [:kaze] from comment #5)
> > Ugh, really? Pluralization for an abbreviated unit? Just out of curiosity,
> > which languages would be concerned?
> I only meant this for the "just now" case, were we to implement it.
>
Oh, I see. Agreed, it’d make sense.
| Assignee | ||
Comment 12•13 years ago
|
||
I think this patch should address all the comments Staś made.
Étienne, please let me know what you think concerning the API (see comment #3).
Attachment #687727 -
Attachment is obsolete: true
Attachment #687727 -
Flags: review?(etienne)
Attachment #687727 -
Flags: feedback?(stas)
Attachment #687823 -
Flags: review?(etienne)
Attachment #687823 -
Flags: feedback?(stas)
Comment 13•13 years ago
|
||
(In reply to Fabien Cazenave [:kaze] from comment #3)
> Created attachment 687500 [details] [diff] [review]
> patch proposal
>
> Here’s a simple patch that adds an optional `useCompactFormat' boolean
> argument to the `.fromNow()' method.
>
> Re-reading the related code, I realize it implies two completely arbitrary
> parameters:
> • a 10-day limit, above which an absolute time is returned;
> • the `%x' format is used when an absolute time is returned.
>
> I can see two ways to remove these arbitrary parameters:
> • either we always return a relative time and add l10n resources for months
> and years — this would be my preferred option but it could break the
> compatibility;
> • or we could pass an array of { limit: format } as a third parameter, to
> explicitly decide which format to use — and the default could be [{ "10d":
> "%x" }] to preserve the compatibility.
>
> As `fromNow' is only used twice in Gaia [1], I’d go for the first option.
> Étienne, what’s your opinion on this?
Mmmhhh... not even sure the calendar really uses this.
I see no problem in having those arbitrary parameters for v1 :)
Which probably makes me unqualified to express my opinion between option 1 or 2.
I vote for option 3, we keep it as is and open a follow up to discuss the API. Since we pass 0 parameters to the fromNow() call right now it will be easy to keep whatever we decide backward compatible.
Comment 14•13 years ago
|
||
Comment on attachment 687823 [details] [diff] [review]
patch proposal
Review of attachment 687823 [details] [diff] [review]:
-----------------------------------------------------------------
smooth
Attachment #687823 -
Flags: review?(etienne) → review+
Comment 15•13 years ago
|
||
Comment on attachment 687823 [details] [diff] [review]
patch proposal
Review of attachment 687823 [details] [diff] [review]:
-----------------------------------------------------------------
::: shared/locales/date/date.en-US.properties
@@ +102,5 @@
> +minutesAgo-short[zero] = just now
> +minutesAgo-short[other] = {{m}}’ ago
> +
> +hoursAgo-short={[ plural(h) ]}
> +hoursAgo-short[zero] = just now
I don't think we need the zero case here, do we? If the time difference is under 1 hour, we'll use minutesAgo anyways. So, for Math.floor(secDiff / 3600), secDiff is greater than 3600, and the floor funcitons returns at minimum. The same holds for days.
Attachment #687823 -
Flags: feedback?(stas) → feedback+
| Assignee | ||
Comment 16•13 years ago
|
||
We don’t: it’s just to be consistent with the long formats. We don’t need these [zero] values at the moment but they’re here in case we add something to the code to that would limit the precision to hours or days…
If you want me to remove them, let me know. Otherwise I’ll merge the current patch as is.
| Assignee | ||
Comment 17•13 years ago
|
||
Comment 18•13 years ago
|
||
(In reply to Staś Małolepszy :stas (traveling until Dec 4) from comment #9)
> (In reply to Fabien Cazenave [:kaze] from comment #5)
>
> > That would be a UX question, but I’d say that “1’ ago” or “just now” should
> > be equivalent in a context where we’re mostly looking for most compact form.
You guys moved fast on this one :) I'd prefer "just now". I don't think many people will understand "1' ago".
Flags: needinfo?(jcarpenter)
| Assignee | ||
Comment 19•13 years ago
|
||
"just now" has been merged already, and the localization note suggests to keep the translation to a ~10 latin character length.
| Assignee | ||
Comment 20•13 years ago
|
||
note that for any time greater than 60 seconds you’ll get strings like:
1’ ago a minute ago
35’ ago 35 minutes ago
1h ago an hour ago
12h ago 12 hours ago
1d ago yesterday
6d ago 6 days ago
The first column is the (new) compact form, the second one is the standard form. So yes, the latter is more explicit, but the point was to be able to fit relative times in small strings.
| Assignee | ||
Updated•13 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Comment 21•13 years ago
|
||
(In reply to Fabien Cazenave [:kaze] from comment #20)
> note that for any time greater than 60 seconds you’ll get strings like:
>
> 1’ ago a minute ago
> 35’ ago 35 minutes ago
> 1h ago an hour ago
> 12h ago 12 hours ago
> 1d ago yesterday
> 6d ago 6 days ago
>
> The first column is the (new) compact form, the second one is the standard
> form. So yes, the latter is more explicit, but the point was to be able to
> fit relative times in small strings.
1 foot ago?
35 feet ago?
Prime is not commonly associated with "minutes" in the english speaking world. We need to use "m" for "minute". I hope that is not a difficult change. In the future please give me more than 5 hours to respond to a needsinfo before merging UX-heavy modifications like this. Besides being respectful, it will also help us avoid unnecessary rework.
Updated•13 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
| Assignee | ||
Comment 22•13 years ago
|
||
(In reply to Josh Carpenter [:jcarpenter] from comment #21)
> In the future please give me more than 5 hours to respond to a
> needsinfo before merging UX-heavy modifications like this. Besides being
> respectful, it will also help us avoid unnecessary rework.
Sorry Josh, I’ve been asked to merge this one quickly because it was blocking another C2 bug. Note that as I merged it it had no UX implication at all, since this new format requires a specific parameter to be activated. If you had raised any objection 3 days ago when you replied, a follow-up would have been proposed immediately.
I’m sending a patch to s/’/m/ right now. Out of curiosity, what should we use for “months” in case we address comment #3?
Comment 23•13 years ago
|
||
Thanks man. Sorry if I sound prickly. Too many very late nights and too many bugs. Thanks for pushing this through. Getting dates in the Notification Center was one of my top must-fix bugs.
(In reply to Fabien Cazenave [:kaze] from comment #22)
> I’m sending a patch to s/’/m/ right now. Out of curiosity, what should we
> use for “months” in case we address comment #3?
In the original bug I believe we specified that after X period, the date display switched to "Dec 7", "Aug 24", etc. Would that work?
| Assignee | ||
Comment 24•13 years ago
|
||
(In reply to Josh Carpenter [:jcarpenter] from comment #23)
> Thanks man. Sorry if I sound prickly.
You’re welcome, no offense as far as I’m concerned — and I’ve probably been too harsh lately as well anyway. ;-)
Feel free to open follow-ups for any l10n fix. It’s easier for us and for Staś to have pure l10n fixes rather than re-opening existing bugs.
> (In reply to Fabien Cazenave [:kaze] from comment #22)
> > I’m sending a patch to s/’/m/ right now. Out of curiosity, what should we
> > use for “months” in case we address comment #3?
>
> In the original bug I believe we specified that after X period, the date
> display switched to "Dec 7", "Aug 24", etc. Would that work?
Yes, with [X = 10 days] currently, but as I’d like to remove this “X” limit from this library (see long explanation in comment #3) we’ll need an abbreviation for “months” and “years”.
No emergency anyway, this will stay like this for v1 — that’s mostly out of curiosity. FWIW, I used the prime instead of “m” because I thought we’d use “m” for months, precisely…
Attachment #689686 -
Flags: review?(jcarpenter)
| Assignee | ||
Comment 25•13 years ago
|
||
Marking as fixed since Josh has just validated the PR directly on github:
https://github.com/mozilla-b2g/gaia/commit/8036ba14843198e98dd3f90017d5df1e60115f53
Status: REOPENED → RESOLVED
Closed: 13 years ago → 13 years ago
Resolution: --- → FIXED
Comment 26•13 years ago
|
||
We had the ' patch on gaia-l10n/en-US already, we should have bumped the keys here, I guess. Waiting with the transplant of this for feedback.
Comment 27•13 years ago
|
||
(In reply to Fabien Cazenave [:kaze] from comment #24)
> No emergency anyway, this will stay like this for v1 — that’s mostly out of
> curiosity. FWIW, I used the prime instead of “m” because I thought we’d use
> “m” for months, precisely…
If the comment #3 change happens at some point, I'd suggest "mo" for months (and "yr" for years, rather than just "y") - IMO, the extra character gives significantly better readability/recognizability, and the result should still be acceptably short.
| Assignee | ||
Comment 28•13 years ago
|
||
(In reply to Axel Hecht [:Pike] from comment #26)
> We had the ' patch on gaia-l10n/en-US already, we should have bumped the
> keys here, I guess. Waiting with the transplant of this for feedback.
I assumed the s/’/m/ change only relates to en-US and that other locales would use the prime (’). Is that acceptable?
(In reply to Jonathan Kew (:jfkthame) from comment #27)
> If the comment #3 change happens at some point, I'd suggest "mo" for months
> (and "yr" for years, rather than just "y") - IMO, the extra character gives
> significantly better readability/recognizability, and the result should
> still be acceptably short.
Noted, thanks.
Comment 29•13 years ago
|
||
Not really bound to just one locale, according to my grep:
grep 'minutesAgo-short\[other' */shared/date/date.properties
de/shared/date/date.properties:minutesAgo-short[other] = vor {{m}} min
en-US/shared/date/date.properties:minutesAgo-short[other] = {{m}}’ ago
es/shared/date/date.properties:minutesAgo-short[other] = hace {{m}}’
fr/shared/date/date.properties:minutesAgo-short[other] = il y a {{m}}m
fy-NL/shared/date/date.properties:minutesAgo-short[other] = {{m}}’ lyn
hu/shared/date/date.properties:# minutesAgo-short[other] = {{m}}’ ago
it/shared/date/date.properties:minutesAgo-short[other] = {{m}}’ fa
nl/shared/date/date.properties:minutesAgo-short[other] = {{m}}’ geleden
ru/shared/date/date.properties:minutesAgo-short[other] = {{m}}’ назад
zh-CN/shared/date/date.properties:minutesAgo-short[other] = {{m}}’ 以前
zh-TW/shared/date/date.properties:minutesAgo-short[other] = {{m}} 分
Also, the strings here don't have the international plural forms, and just the english ones.
| Assignee | ||
Comment 30•13 years ago
|
||
(In reply to Axel Hecht [:Pike] from comment #29)
> Not really bound to just one locale, according to my grep
I mean, using “m” instead of the prime probably only makes sense with en-US.
> Also, the strings here don't have the international plural forms, and just
> the english ones.
I don’t understand, please rephrase.
I assumed that abbreviated units like “m” or prime don’t require any pluralization and Staś confirmed it in an earlier comment, so I guess you’re referring to something else?
| Assignee | ||
Comment 31•13 years ago
|
||
Axel, in case that’s what you were referring to:
(In reply to Staś Małolepszy :stas (offline Dec 7-Dec 16) from comment #9)
> minutesAgo-short = {[ plural(m) ]}
> minutesAgo-short[zero] = Just now
> minutesAgo-short[other] = {{m}}' ago
>
> I think 'zero' and 'other' are enough in this case.
| Assignee | ||
Comment 32•13 years ago
|
||
(In reply to Josh Carpenter [:jcarpenter] from comment #21)
> (In reply to Fabien Cazenave [:kaze] from comment #20)
> > note that for any time greater than 60 seconds you’ll get strings like:
> >
> > 1’ ago a minute ago
> > 35’ ago 35 minutes ago
> > […]
> 1 foot ago?
> 35 feet ago?
For the record, “m” it the official unit for “meter”: “1m” and “35m” mean “1 meter” and “35 meters” in all countries using the metric system (= pretty much everywhere except English-speaking countries).
A more i18n-compatible approach would be to use the standard units: "h" for hours and "min" for minutes, it would work for every country but of course, that’s a bit longer.
Comment 33•13 years ago
|
||
I don't think the prime is associated with minutes anymore outside of the English speaking world than within. Looking at the existing localizations, some just took the liberty to not agree with the original UX using the prime and used 'm' or 'min', while some followed the en-US guidance. That got changed, and thus I think we should fix they key.
Regarding the amount of plural forms, I disagree with stas on that one. As soon as you show a number, make it the full plural. The opposite holds, too, fwiw. If one does not show the number, one must not use the plural form. (Returns '1' forms inappropriately)
| Assignee | ||
Comment 34•13 years ago
|
||
As this bug has already been r+’ed and marked resolved/fixed, please open a new one and I’ll submit a patch.
(In reply to Axel Hecht [:Pike] from comment #33)
> Regarding the amount of plural forms, I disagree with stas on that one. As
> soon as you show a number, make it the full plural. The opposite holds, too,
> fwiw. If one does not show the number, one must not use the plural form.
> (Returns '1' forms inappropriately)
Sorry, I don’t understand the. Would you rephrase please? Which strings would be concerned?
Out of curiosity, what language would require pluralized forms when using numbers with abbreviated physical units?
| Assignee | ||
Comment 35•13 years ago
|
||
s/ the//
Comment 36•13 years ago
|
||
Filed bug 820027.
Re the full plural, "2m ago" is short for "this happened 2 minutes ago", and for some languages that doesn't work out like that. Got a private email from our Fulah localizer at least. Thus, it's more about the "ago" than the "2m". Also, sometimes, languages just need a modifier for a particular concept. Like nouns ending in -isi in Zulu. Anyway, when such a language and a complex plural come together, you need both.
| Assignee | ||
Comment 37•13 years ago
|
||
Nice. Thanks for satisfying my curiosity. :-)
| Assignee | ||
Comment 38•13 years ago
|
||
Comment on attachment 689686 [details]
l10n fix
Clearing the r? for Josh, since he validated the PR directly on github two weeks ago.
Attachment #689686 -
Flags: review?(jcarpenter)
Comment 39•13 years ago
|
||
Confirmed in Unagi version 20130102070202. Notations are appearing as "#m ago".
Comment 40•13 years ago
|
||
Confirmed in Unagi version 20130102070202. Notations are appearing as "#m ago".
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•