refactor(format): localize relative time with Intl.RelativeTimeFormat
The tier table kept a divisor and a translation key as two independently maintained halves, and a mispairing there rendered minutes as "Ns ago" for 59 releases. The table now pairs a divisor with the Intl unit it produces and the platform supplies the words, so the wrong half is at least self-evident on sight — "minute" next to 3600 reads wrong in a way "time.minutesAgo" never did. It also removes 12 hand-written strings and hands plural rules to CLDR for any language added later. Hungarian output is byte-identical to the strings it replaces. English gets shorter: "59 min ago" to "59m ago", "1 wk ago" to "1w ago", "1 mo ago" to "1mo ago", "1 yr ago" to "1y ago"; "2h ago" and "1d ago" are unchanged. style narrow matches the app's compact timestamps and numeric always keeps it counting, rather than "yesterday"/"last week". time.justNow stays because Intl has no wording for the sub-minute case. Formatters are memoized per language, since this runs once per rendered timestamp across a virtualized feed.
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
{
|
||||
"justNow": "just now",
|
||||
"minutesAgo": "{{count}} min ago",
|
||||
"hoursAgo": "{{count}}h ago",
|
||||
"daysAgo": "{{count}}d ago",
|
||||
"weeksAgo": "{{count}} wk ago",
|
||||
"monthsAgo": "{{count}} mo ago",
|
||||
"yearsAgo": "{{count}} yr ago",
|
||||
"eta": {
|
||||
"now": "now",
|
||||
"done": "done",
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
{
|
||||
"justNow": "épp most",
|
||||
"minutesAgo": "{{count}} perce",
|
||||
"hoursAgo": "{{count}} órája",
|
||||
"daysAgo": "{{count}} napja",
|
||||
"weeksAgo": "{{count}} hete",
|
||||
"monthsAgo": "{{count}} hónapja",
|
||||
"yearsAgo": "{{count}} éve",
|
||||
"eta": {
|
||||
"now": "most",
|
||||
"done": "kész",
|
||||
|
||||
Reference in New Issue
Block a user