diff --git a/options/locale_next/locale_en-US.json b/options/locale_next/locale_en-US.json index 7dee8fa37e..2778c44bae 100644 --- a/options/locale_next/locale_en-US.json +++ b/options/locale_next/locale_en-US.json @@ -49,13 +49,9 @@ "other": "%d years ago" }, "relativetime.1day": "yesterday", - "relativetime.2days": "two days ago", "relativetime.1week": "last week", - "relativetime.2weeks": "two weeks ago", "relativetime.1month": "last month", - "relativetime.2months": "two months ago", "relativetime.1year": "last year", - "relativetime.2years": "two years ago", "repo.issues.filter_poster.hint": "Filter by the author", "repo.issues.filter_assignee.hint": "Filter by assigned user", "repo.issues.filter_reviewers.hint": "Filter by user who reviewed", diff --git a/services/context/context.go b/services/context/context.go index 6c83ca5d02..f0502b32fe 100644 --- a/services/context/context.go +++ b/services/context/context.go @@ -204,7 +204,7 @@ func Contexter() func(next http.Handler) http.Handler { "FUTURE": ctx.Locale.TrString("relativetime.future"), "NOW": ctx.Locale.TrString("relativetime.now"), } - for _, key := range []string{"relativetime.1day", "relativetime.1week", "relativetime.1month", "relativetime.1year", "relativetime.2days", "relativetime.2weeks", "relativetime.2months", "relativetime.2years"} { + for _, key := range []string{"relativetime.1day", "relativetime.1week", "relativetime.1month", "relativetime.1year"} { // These keys are used for special-casing some time words. We only add keys that are actually translated, so that we // can fall back to the generic pluralized time word in the correct language if the special case is untranslated. if ctx.Locale.HasKey(key) { diff --git a/web_src/js/webcomponents/relative-time.js b/web_src/js/webcomponents/relative-time.js index c070cd6795..02bf8feffb 100644 --- a/web_src/js/webcomponents/relative-time.js +++ b/web_src/js/webcomponents/relative-time.js @@ -123,9 +123,6 @@ export function DoUpdateRelativeTime(object, now) { if (years === 1 && pageData.DATETIMESTRINGS['relativetime.1year']) { // Datetime is one year ago. object.textContent = pageData.DATETIMESTRINGS['relativetime.1year']; - } else if (years === 2 && pageData.DATETIMESTRINGS['relativetime.2years']) { - // Datetime is two year ago. - object.textContent = pageData.DATETIMESTRINGS['relativetime.2years']; } else { // Datetime is more than a year ago. object.textContent = GetPluralizedStringOrFallback('relativetime.years', years, 'year'); @@ -139,9 +136,6 @@ export function DoUpdateRelativeTime(object, now) { if (months === 1 && pageData.DATETIMESTRINGS['relativetime.1month']) { // Datetime is one month ago. object.textContent = pageData.DATETIMESTRINGS['relativetime.1month']; - } else if (months === 2 && pageData.DATETIMESTRINGS['relativetime.2months']) { - // Datetime is two months ago. - object.textContent = pageData.DATETIMESTRINGS['relativetime.2months']; } else { // Datetime is several months ago (but less than a year). object.textContent = GetPluralizedStringOrFallback('relativetime.months', months, 'month'); @@ -155,9 +149,6 @@ export function DoUpdateRelativeTime(object, now) { if (weeks === 1 && pageData.DATETIMESTRINGS['relativetime.1week']) { // Datetime is one week ago. object.textContent = pageData.DATETIMESTRINGS['relativetime.1week']; - } else if (weeks === 2 && pageData.DATETIMESTRINGS['relativetime.2weeks']) { - // Datetime is two week ago. - object.textContent = pageData.DATETIMESTRINGS['relativetime.2weeks']; } else { // Datetime is several weeks ago (but less than a month). object.textContent = GetPluralizedStringOrFallback('relativetime.weeks', weeks, 'week'); @@ -170,9 +161,6 @@ export function DoUpdateRelativeTime(object, now) { if (days === 1 && pageData.DATETIMESTRINGS['relativetime.1day']) { // Datetime is one day ago. object.textContent = pageData.DATETIMESTRINGS['relativetime.1day']; - } else if (days === 2 && pageData.DATETIMESTRINGS['relativetime.2days']) { - // Datetime is two days ago. - object.textContent = pageData.DATETIMESTRINGS['relativetime.2days']; } else { // Datetime is several days but less than a week ago. object.textContent = GetPluralizedStringOrFallback('relativetime.days', days, 'day'); diff --git a/web_src/js/webcomponents/relative-time.test.js b/web_src/js/webcomponents/relative-time.test.js index 5a8e2950e0..e12fa3476b 100644 --- a/web_src/js/webcomponents/relative-time.test.js +++ b/web_src/js/webcomponents/relative-time.test.js @@ -9,10 +9,6 @@ test('CalculateRelativeTimes', () => { 'relativetime.1week': 'last week', 'relativetime.1month': 'last month', 'relativetime.1year': 'last year', - 'relativetime.2days': 'two days ago', - 'relativetime.2weeks': 'two weeks ago', - 'relativetime.2months': 'two months ago', - 'relativetime.2years': 'two years ago', }; window.config.pageData.PLURALSTRINGS_LANG = { 'relativetime.mins': ['%d minute ago', '%d minutes ago'], @@ -84,7 +80,7 @@ test('CalculateRelativeTimes', () => { mock.setAttribute('datetime', '2024-10-25T01:00:00+02:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY); - expect(mock.textContent).toEqual('two days ago'); + expect(mock.textContent).toEqual('2 days ago'); mock.setAttribute('datetime', '2024-10-21T01:00:00+02:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY); @@ -100,7 +96,7 @@ test('CalculateRelativeTimes', () => { mock.setAttribute('datetime', '2024-10-13T01:00:00+02:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY); - expect(mock.textContent).toEqual('two weeks ago'); + expect(mock.textContent).toEqual('2 weeks ago'); mock.setAttribute('datetime', '2024-10-06T01:00:00+02:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY); @@ -116,7 +112,7 @@ test('CalculateRelativeTimes', () => { mock.setAttribute('datetime', '2024-07-30T01:00:00+02:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY); - expect(mock.textContent).toEqual('two months ago'); + expect(mock.textContent).toEqual('2 months ago'); mock.setAttribute('datetime', '2024-05-30T01:00:00+02:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY); @@ -152,7 +148,7 @@ test('CalculateRelativeTimes', () => { mock.setAttribute('datetime', '2022-10-20T01:00:00+10:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY); - expect(mock.textContent).toEqual('two years ago'); + expect(mock.textContent).toEqual('2 years ago'); mock.setAttribute('datetime', '2021-10-20T01:00:00+02:00'); expect(DoUpdateRelativeTime(mock, now)).toEqual(ONE_DAY);