Skip to content

Localize milestone related time strings #24051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions models/issues/milestone.go
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't do this.

It breaks the i18n translation, because different languages have different date/time syntax.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so just Updated %s for English is better just like closed. Because other languages may be %s xxx.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid making the i18n system more complex, a quick path could be:

milestones.updated = "Updated: "

The colon helps to separate the sentence, it works in all languages.

milestones.no_due_date = No due date
milestones.open = Open
milestones.close = Close
2 changes: 1 addition & 1 deletion templates/repo/issue/milestone_issues.tmpl
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
{{else}}
{{svg "octicon-calendar"}}
{{if .Milestone.DeadlineString}}
<span {{if .IsOverdue}}class="overdue"{{end}}>{{.Milestone.DeadlineString}}</span>
<span {{if .IsOverdue}}class="overdue"{{end}}>{{template "shared/datetime/short" (dict "Datetime" .Milestone.DeadlineString "Fallback" .Milestone.DeadlineString)}}</span>
{{else}}
{{$.locale.Tr "repo.milestones.no_due_date"}}
{{end}}
4 changes: 2 additions & 2 deletions templates/repo/issue/milestones.tmpl
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@
{{else}}
{{svg "octicon-calendar"}}
{{if .DeadlineString}}
<span {{if .IsOverdue}}class="overdue"{{end}}>{{.DeadlineString}}</span>
<span {{if .IsOverdue}}class="overdue"{{end}}>{{template "shared/datetime/short" (dict "Datetime" .DeadlineString "Fallback" .DeadlineString)}}</span>
{{else}}
{{$.locale.Tr "repo.milestones.no_due_date"}}
{{end}}
@@ -88,7 +88,7 @@
{{svg "octicon-check" 16 "gt-mr-3"}}
{{LocaleNumber .NumClosedIssues}}&nbsp;{{$.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}}
</span>
</div>
{{if and (or $.CanWriteIssues $.CanWritePulls) (not $.Repository.IsArchived)}}
2 changes: 1 addition & 1 deletion templates/user/dashboard/milestones.tmpl
Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@
{{else}}
{{svg "octicon-calendar"}}
{{if .DeadlineString}}
<span {{if .IsOverdue}}class="overdue"{{end}}>{{.DeadlineString}}</span>
<span {{if .IsOverdue}}class="overdue"{{end}}>{{template "shared/datetime/short" (dict "Datetime" .DeadlineString "Fallback" .DeadlineString)}}</span>
{{else}}
{{$.locale.Tr "repo.milestones.no_due_date"}}
{{end}}