Skip to content

Localize the issue due date events #24055

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1505,9 +1505,10 @@ issues.due_date_form_edit = "Edit"
issues.due_date_form_remove = "Remove"
issues.due_date_not_writer = "You need repository write access to update an issue's due date."
issues.due_date_not_set = "No due date set."
issues.due_date_added = "added the due date %s %s"
issues.due_date_modified = "modified the due date from %[2]s to %[1]s %[3]s"
issues.due_date_remove = "removed the due date %s %s"
issues.due_date_added = "added the due date"
issues.due_date_modified_from = "modified the due date from"
issues.due_date_modified_to = "to"
issues.due_date_remove = "removed the due date"
Comment on lines +1508 to +1511
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better not to do so. At least, wait for a proper i18n system (with correct datetime support)

issues.due_date_overdue = "Overdue"
issues.due_date_invalid = "The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'."
issues.dependency.title = Dependencies
Expand Down
14 changes: 11 additions & 3 deletions templates/repo/issue/view_content/comments.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.due_date_added" .Content $createdStr | Safe}}
{{$.locale.Tr "repo.issues.due_date_added"}}
{{template "shared/datetime/short" (dict "Datetime" .Content "Fallback" .Content)}}
{{$createdStr}}
Comment on lines +298 to +300
Copy link
Member

Choose a reason for hiding this comment

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

I can only see one suitable solution that will take some refactoring:
Add a method Comment.AsTimeStamp() that only works on comments with the correct comment types where the content of the comment is a timestamp in string form.
Then, you can call .AsTimeStamp().TimeSinceUnix().
You may even decide to panic in this new method instead of throwing an error as it can only happen when someone calls this method in the wrong place.

Copy link
Contributor

@wxiaoguang wxiaoguang Apr 11, 2023

Choose a reason for hiding this comment

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

It could be like this:

{{$s := printf "<relative-time ...>" ....}}

Then pass the $s to Tr

</span>
</div>
{{else if eq .Type 17}}
Expand All @@ -305,7 +307,11 @@
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$parsedDeadline := .Content | ParseDeadline}}
{{$.locale.Tr "repo.issues.due_date_modified" (index $parsedDeadline 0) (index $parsedDeadline 1) $createdStr | Safe}}
{{$.locale.Tr "repo.issues.due_date_modified_from"}}
{{template "shared/datetime/short" (dict "Datetime" (index $parsedDeadline 1) "Fallback" (index $parsedDeadline 1))}}
{{$.locale.Tr "repo.issues.due_date_modified_to"}}
{{template "shared/datetime/short" (dict "Datetime" (index $parsedDeadline 0) "Fallback" (index $parsedDeadline 0))}}
{{$createdStr}}
</span>
</div>
{{else if eq .Type 18}}
Expand All @@ -314,7 +320,9 @@
{{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}}
<span class="text grey muted-links">
{{template "shared/user/authorlink" .Poster}}
{{$.locale.Tr "repo.issues.due_date_remove" .Content $createdStr | Safe}}
{{$.locale.Tr "repo.issues.due_date_remove"}}
{{template "shared/datetime/short" (dict "Datetime" .Content "Fallback" .Content)}}
{{$createdStr}}
</span>
</div>
{{else if eq .Type 19}}
Expand Down