From b8777539d75d53086ea1b09cd8e8ca823941a8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Hansl=C3=ADk?= Date: Thu, 8 Oct 2020 15:53:59 +0200 Subject: [PATCH] Fixed localization of relative time (#7256) --- src/common/datetime/relative_time.ts | 10 ++++------ src/translations/en.json | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/common/datetime/relative_time.ts b/src/common/datetime/relative_time.ts index c2a761394b..ef3b8b50c7 100644 --- a/src/common/datetime/relative_time.ts +++ b/src/common/datetime/relative_time.ts @@ -38,13 +38,11 @@ export default function relativeTime( roundedDelta = Math.round(delta); } - const timeDesc = localize( - `ui.components.relative_time.duration.${unit}`, + return localize( + options.includeTense === false + ? `ui.components.relative_time.duration.${unit}` + : `ui.components.relative_time.${tense}_duration.${unit}`, "count", roundedDelta ); - - return options.includeTense === false - ? timeDesc - : localize(`ui.components.relative_time.${tense}`, "time", timeDesc); } diff --git a/src/translations/en.json b/src/translations/en.json index ad917f2bae..c69b86bb32 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -355,8 +355,6 @@ "select": "Select" }, "relative_time": { - "past": "{time} ago", - "future": "In {time}", "never": "Never", "just_now": "Just now", "duration": { @@ -365,6 +363,20 @@ "hour": "{count} {count, plural,\n one {hour}\n other {hours}\n}", "day": "{count} {count, plural,\n one {day}\n other {days}\n}", "week": "{count} {count, plural,\n one {week}\n other {weeks}\n}" + }, + "past_duration": { + "second": "{count} {count, plural,\n one {second}\n other {seconds}\n} ago", + "minute": "{count} {count, plural,\n one {minute}\n other {minutes}\n} ago", + "hour": "{count} {count, plural,\n one {hour}\n other {hours}\n} ago", + "day": "{count} {count, plural,\n one {day}\n other {days}\n} ago", + "week": "{count} {count, plural,\n one {week}\n other {weeks}\n} ago" + }, + "future_duration": { + "second": "In {count} {count, plural,\n one {second}\n other {seconds}\n}", + "minute": "In {count} {count, plural,\n one {minute}\n other {minutes}\n}", + "hour": "In {count} {count, plural,\n one {hour}\n other {hours}\n}", + "day": "In {count} {count, plural,\n one {day}\n other {days}\n}", + "week": "In {count} {count, plural,\n one {week}\n other {weeks}\n}" } }, "history_charts": {