From 97176754beb4de23fa0f68df715c4737919c93b0 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Wed, 12 Apr 2023 09:29:49 +0300 Subject: [PATCH] Localize milestone related time strings (#24051) - With #23988 in place, we can improve these timestamps --------- Co-authored-by: silverwind --- models/issues/milestone.go | 5 ----- options/locale/locale_en-US.ini | 2 +- templates/repo/issue/milestone_issues.tmpl | 2 +- templates/repo/issue/milestones.tmpl | 4 ++-- templates/user/dashboard/milestones.tmpl | 2 +- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/models/issues/milestone.go b/models/issues/milestone.go index 8255db38f9..ffe5c8eb50 100644 --- a/models/issues/milestone.go +++ b/models/issues/milestone.go @@ -7,7 +7,6 @@ import ( "context" "fmt" "strings" - "time" "code.gitea.io/gitea/models/db" repo_model "code.gitea.io/gitea/models/repo" @@ -65,7 +64,6 @@ type Milestone struct { DeadlineString string `xorm:"-"` TotalTrackedTime int64 `xorm:"-"` - TimeSinceUpdate int64 `xorm:"-"` } func init() { @@ -84,9 +82,6 @@ func (m *Milestone) BeforeUpdate() { // AfterLoad is invoked from XORM after setting the value of a field of // this object. func (m *Milestone) AfterLoad() { - if !m.UpdatedUnix.IsZero() { - m.TimeSinceUpdate = time.Now().Unix() - m.UpdatedUnix.AsTime().Unix() - } m.NumOpenIssues = m.NumIssues - m.NumClosedIssues if m.DeadlineUnix.Year() == 9999 { return diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 0a10b70d9d..cf3208b5bd 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1710,7 +1710,7 @@ pulls.delete.text = Do you really want to delete this pull request? (This will p milestones.new = New Milestone milestones.closed = Closed %s -milestones.update_ago = Updated %s ago +milestones.updated = Updated milestones.no_due_date = No due date milestones.open = Open milestones.close = Close diff --git a/templates/repo/issue/milestone_issues.tmpl b/templates/repo/issue/milestone_issues.tmpl index c3c25843e8..1d55eb39cd 100644 --- a/templates/repo/issue/milestone_issues.tmpl +++ b/templates/repo/issue/milestone_issues.tmpl @@ -35,7 +35,7 @@ {{else}} {{svg "octicon-calendar"}} {{if .Milestone.DeadlineString}} - {{.Milestone.DeadlineString}} + {{template "shared/datetime/short" (dict "Datetime" .Milestone.DeadlineString "Fallback" .Milestone.DeadlineString)}} {{else}} {{$.locale.Tr "repo.milestones.no_due_date"}} {{end}} diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl index 42a6c4f919..2864d38a08 100644 --- a/templates/repo/issue/milestones.tmpl +++ b/templates/repo/issue/milestones.tmpl @@ -77,7 +77,7 @@ {{else}} {{svg "octicon-calendar"}} {{if .DeadlineString}} - {{.DeadlineString}} + {{template "shared/datetime/short" (dict "Datetime" .DeadlineString "Fallback" .DeadlineString)}} {{else}} {{$.locale.Tr "repo.milestones.no_due_date"}} {{end}} @@ -88,7 +88,7 @@ {{svg "octicon-check" 16 "gt-mr-3"}} {{LocaleNumber .NumClosedIssues}} {{$.locale.Tr "repo.issues.closed_title"}} {{if .TotalTrackedTime}}{{svg "octicon-clock"}} {{.TotalTrackedTime|Sec2Time}}{{end}} - {{if .UpdatedUnix}}{{svg "octicon-clock"}} {{$.locale.Tr "repo.milestones.update_ago" (.TimeSinceUpdate|Sec2Time)}}{{end}} + {{if .UpdatedUnix}}{{svg "octicon-clock"}} {{$.locale.Tr "repo.milestones.updated"}} {{TimeSinceUnix .UpdatedUnix $.locale}}{{end}} {{if and (or $.CanWriteIssues $.CanWritePulls) (not $.Repository.IsArchived)}} diff --git a/templates/user/dashboard/milestones.tmpl b/templates/user/dashboard/milestones.tmpl index 6788aa09a2..9915159721 100644 --- a/templates/user/dashboard/milestones.tmpl +++ b/templates/user/dashboard/milestones.tmpl @@ -97,7 +97,7 @@ {{else}} {{svg "octicon-calendar"}} {{if .DeadlineString}} - {{.DeadlineString}} + {{template "shared/datetime/short" (dict "Datetime" .DeadlineString "Fallback" .DeadlineString)}} {{else}} {{$.locale.Tr "repo.milestones.no_due_date"}} {{end}}