Closed Bug 1154088 Opened 10 years ago Closed 10 years ago

Show last synced time in Synced Tabs panel using relative time string

Categories

(Firefox for iOS :: Home screen, defect)

All
iOS 8
defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fennec + ---

People

(Reporter: nalexander, Assigned: sachin.irukula, Mentored)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

We want to show nice relative time strings (just now, a day ago, three weeks ago) for last synced timestamps in the Synced Tabs home panel. We'll probably want something similar in the Reading List home panel as well. There are a couple of parts to this ticket: 1) land a helper function into for converting timestamps (milliseconds since the epoch) into relative time strings. Pay attention to localization! I think the code at [1] is a good place to start, if the license is aggreeable. 2) use the helper function when updating the table view in RemoteTabsPanel. 3) (bonus points) update the table view strings every minute, so the timestamps are fresh. 4) (bonus points) work with stefan to update the table view in the Reading List home panel. [1] https://github.com/melvitax/AFDateHelper/blob/master/AF%2BDate%2BHelper/AF%2BDate%2BExtension.swift#L410
Assignee: nobody → sachin.irukula
Depends on: 1155990
Attached file Pull Request
Status: NEW → ASSIGNED
Attachment #8595013 - Flags: review?(sarentz)
Attachment #8595013 - Flags: review?(nalexander)
Comment on attachment 8595013 [details] [review] Pull Request @sachin004: looks good. One change requested, then fold everything into one commit and I'll land it. Thanks!
Attachment #8595013 - Flags: review?(sarentz)
Attachment #8595013 - Flags: review?(nalexander)
Attachment #8595013 - Flags: review+
Attachment #8595013 - Flags: review+ → review?(nalexander)
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Comment on attachment 8595013 [details] [review] Pull Request Landed! sachin, I noticed that this shows, for example, "37 seconds ago". Can we make that less precise, like "less than a minute ago" or something?
Attachment #8595013 - Flags: review?(nalexander) → review+
I think we have a big problem. Locales with complex plural form will never be able to localize strings like %@ years ago because "years" changes based on the number. Does iOS support proper plural forms?
If year is 1 then the output is "1 year ago" and if it's more than 1 then it's "%@ years ago"
(In reply to Sachin Irukula from comment #6) > If year is 1 then the output is "1 year ago" and if it's more than 1 then > it's "%@ years ago" Are you aware of the complexity of plural forms required by some languages? That's not 1 vs more than 1. https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals#List_of_Plural_Rules IMO this should be backed out and a proper fix landed, unless iOS is unable to deal with plural forms (and it would be surprising).
"Handling Noun Plurals and Units of Measurement" https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPInternational/LocalizingYourApp/LocalizingYourApp.html No idea how that would look when exported in a XLIFF file.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
An alternative to this is to use concepts like "just now", "this morning", "yesterday", "last week", which avoids the need to handle plural forms altogether.
Ok, but how do we handle if its more than 1 day/week/month/year like 2 or 3.
(In reply to Sachin Irukula from comment #11) > Ok, but how do we handle if its more than 1 day/week/month/year like 2 or 3. Very carefully. For example, you might say: Just now This morning Yesterday This week Last week This month More than a month ago … and get l10n review before you commit! But if we do try to do real relative timestamps, you'll need plural forms. The link flod kindly posted explains how plural forms are supposed to work on iOS: a stringsdict file is used to 'dispatch' to a range of strings identified by CLDR identifier[1]. If everyday localization is "string X in locale Y", plural localization is "string X in locale Y for plural count Z". The reason I suggest the option of simpler non-numeric forms like "today" and "yesterday" (which still aren't necessarily universal!) is that I don't know if Pootle (which IIRC is what we use) and our import/export pipelines correctly handle the use of stringsdicts. If they don't, then in the short term we simply must avoid the use of plural forms everywhere. [1] http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html
(In reply to Richard Newman [:rnewman] from comment #12) > The reason I suggest the option of simpler non-numeric forms like "today" > and "yesterday" (which still aren't necessarily universal!) is that I don't > know if Pootle (which IIRC is what we use) and our import/export pipelines > correctly handle the use of stringsdicts. Same here. I think we're late in the cycle to introduce a change of this scope: we'd need to see how the XLIFF looks with plural forms with a test app, then check if Pootle supports the format (teams not using Pootle are mostly using text editors) and update the current dashboard to parse these strings correctly. I wonder if we need so much granularity though. For example: Just now Today Yesterday This week This month This year More than a year ago We could expose the real timestamp with the last ones, as long as we format it correctly with iOS internationalization settings.
Folks, I don't think this needs to be re-opened, because what we're discussing is strictly an improvement to the existing behaviour. Not coincidentally, the existing behaviour is exactly what we do on Android in similar situations. sachin and I carefully handled separately the cases 0 (which doesn't appear), 1 (day, week), and more than 1 (days, weeks). We can add or refine the cases for languages that translate more than one differently in a follow-up. This is just like on Android, where we make a decent effort to hit more than just the English cases, giving a nod to 0/1/2+, and generally haven't killed ourselves to handle the nuances of 2+.
(In reply to Nick Alexander :nalexander from comment #14) > This is just like on Android, where we make a decent effort to > hit more than just the English cases, giving a nod to 0/1/2+, and generally > haven't killed ourselves to handle the nuances of 2+. Android doesn't support plural forms (bug 753859), iOS does. And they're not "nuances". How good would you feel with English saying "10 tab open" instead of "10 tabs open"?
(In reply to Francesco Lodolo [:flod] (UTC+2) from comment #15) > (In reply to Nick Alexander :nalexander from comment #14) > > This is just like on Android, where we make a decent effort to > > hit more than just the English cases, giving a nod to 0/1/2+, and generally > > haven't killed ourselves to handle the nuances of 2+. > > Android doesn't support plural forms (bug 753859), iOS does. Sort of. iOS does, but not using the system we use, and we don't even know if the /upstream/ system (Pootle?) can handle this. > And they're not "nuances". How good would you feel with English saying "10 > tab open" instead of "10 tabs open"? I would say file a follow-up! This ticket makes the issue better: it's enough for en-US, which might be all we ship. I'm all for getting this right, but I'm not going to block v1 on "37 second ago" instead "37 seconds ago". Also, I'm not going to spend a large amount of my time and a contributor's time getting this right for v1. Follow-up, triage, move on.
After heated discussion, let's go with a base NSLocalizedDateString and some progressive improvements on top, like: "Just now", "Today", "Yesterday". I feel like this kinda-sorta hits the most important use case, which is "I just refreshed, is this actually fresh?" sachin, do you want to update? (I can understand if you're done with this ticket.)
Flags: needinfo?(sachin.irukula)
Yes, I will make the necessary changes. The following strings will be used for relative dates: Just Now, Today, Yesterday, This Week, Last Week, This Month, Last Month, This Year, Last Year, More than an year.
Flags: needinfo?(sachin.irukula)
Not sure what to use after Last year, let me know if you guys have any suggestions.
(In reply to Sachin Irukula from comment #19) > Not sure what to use after Last year, let me know if you guys have any > suggestions. Let's not worry about. It's just old: use NSLocalizedDateString and just show the date.
(In reply to Sachin Irukula from comment #18) > Yes, I will make the necessary changes. > The following strings will be used for relative dates: Let's use sentence case and simplify these a little: Just now Today at 12:34pm // Use the date formatter Yesterday This week More than a week ago More than a month ago // Any more than that and we don't care.
Attachment #8595013 - Flags: review+ → review?(nalexander)
Comment on attachment 8595013 [details] [review] Pull Request Comments on GH. Good start, and thanks for digging back in to this!
Attachment #8595013 - Flags: review?(nalexander) → feedback+
FWIW, "nice relative time strings" actually depends on language, too. Different languages have different amount of days and weeks back and forth, for which they have "nice strings". I wonder, is there something like ICU on iOS?
tracking-fennec: --- → +
Comment on attachment 8599021 [details] [review] Link to Github pull-request: https://github.com/mozilla/firefox-ios/pull/396 rnewman, you've been following this, and I'm not. Can you drive it across the line?
Attachment #8599021 - Flags: review?(nalexander) → review?(rnewman)
Blocks: 1171186
I merged this with some cleanup and rebased. 465c4e4. Notably, I changed to lowercase: "today at" not "Today at", because we're labeling this string, and Last synced: More than a week ago looks bad. Bug 1171186 covers doing better.
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → FIXED
Follow-up to update the test: 8ec5ebb
Attachment #8599021 - Flags: review?(rnewman) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: