diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-04 00:58:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-03 12:58:09 -0400 |
commit | 19de52e0f4cbd2d62f9d41589fe8815c2c3ceef2 (patch) | |
tree | f5e2f0a5431f315946aed6d72e40e5e9893dabc0 /templates/repo | |
parent | 01d9466bfdbb2e043a03368ca7872944db211f49 (diff) | |
download | gitea-19de52e0f4cbd2d62f9d41589fe8815c2c3ceef2.tar.gz gitea-19de52e0f4cbd2d62f9d41589fe8815c2c3ceef2.zip |
Introduce GiteaLocaleNumber custom element to handle number localization on pages. (#23861)
Follow #21429 & #22861
Use `<gitea-locale-number>` instead of backend `PrettyNumber`. All old
`PrettyNumber` related functions are removed. A lot of code could be
simplified.
And some functions haven't been used for long time (dead code), so they
are also removed by the way (eg: `SplitStringAtRuneN`, `Dedent`)
This PR only tries to improve the `PrettyNumber` rendering problem, it
doesn't touch the "plural" problem.
Screenshot:
![image](https://user-images.githubusercontent.com/2114189/229290804-1f63db65-1e34-4a54-84ba-e00b44331b17.png)
![image](https://user-images.githubusercontent.com/2114189/229290911-c88dea00-b11d-48dd-accb-9f52edd73ce4.png)
Diffstat (limited to 'templates/repo')
-rw-r--r-- | templates/repo/issue/milestones.tmpl | 8 | ||||
-rw-r--r-- | templates/repo/issue/openclose.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/projects/list.tmpl | 8 | ||||
-rw-r--r-- | templates/repo/release/list.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/release/new.tmpl | 4 | ||||
-rw-r--r-- | templates/repo/sub_menu.tmpl | 2 |
6 files changed, 15 insertions, 15 deletions
diff --git a/templates/repo/issue/milestones.tmpl b/templates/repo/issue/milestones.tmpl index 0a113e2484..0336d35c17 100644 --- a/templates/repo/issue/milestones.tmpl +++ b/templates/repo/issue/milestones.tmpl @@ -18,11 +18,11 @@ <div class="ui compact tiny menu"> <a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/milestones?state=open&q={{$.Keyword}}"> {{svg "octicon-milestone" 16 "gt-mr-3"}} - {{JsPrettyNumber .OpenCount}} {{.locale.Tr "repo.issues.open_title"}} + {{LocaleNumber .OpenCount}} {{.locale.Tr "repo.issues.open_title"}} </a> <a class="item{{if .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/milestones?state=closed&q={{$.Keyword}}"> {{svg "octicon-check" 16 "gt-mr-3"}} - {{JsPrettyNumber .ClosedCount}} {{.locale.Tr "repo.issues.closed_title"}} + {{LocaleNumber .ClosedCount}} {{.locale.Tr "repo.issues.closed_title"}} </a> </div> </div> @@ -84,9 +84,9 @@ {{end}} <span class="issue-stats"> {{svg "octicon-issue-opened" 16 "gt-mr-3"}} - {{JsPrettyNumber .NumOpenIssues}} {{$.locale.Tr "repo.issues.open_title"}} + {{LocaleNumber .NumOpenIssues}} {{$.locale.Tr "repo.issues.open_title"}} {{svg "octicon-check" 16 "gt-mr-3"}} - {{JsPrettyNumber .NumClosedIssues}} {{$.locale.Tr "repo.issues.closed_title"}} + {{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}} </span> diff --git a/templates/repo/issue/openclose.tmpl b/templates/repo/issue/openclose.tmpl index e2c13fea18..6eb26b36c5 100644 --- a/templates/repo/issue/openclose.tmpl +++ b/templates/repo/issue/openclose.tmpl @@ -5,10 +5,10 @@ {{else}} {{svg "octicon-issue-opened" 16 "gt-mr-3"}} {{end}} - {{JsPrettyNumber .IssueStats.OpenCount}} {{.locale.Tr "repo.issues.open_title"}} + {{LocaleNumber .IssueStats.OpenCount}} {{.locale.Tr "repo.issues.open_title"}} </a> <a class="{{if .IsShowClosed}}active {{end}}item" href="{{$.Link}}?q={{$.Keyword}}&type={{.ViewType}}&sort={{$.SortType}}&state=closed&labels={{.SelectLabels}}&milestone={{.MilestoneID}}&project={{.ProjectID}}&assignee={{.AssigneeID}}&poster={{.PosterID}}"> {{svg "octicon-check" 16 "gt-mr-3"}} - {{JsPrettyNumber .IssueStats.ClosedCount}} {{.locale.Tr "repo.issues.closed_title"}} + {{LocaleNumber .IssueStats.ClosedCount}} {{.locale.Tr "repo.issues.closed_title"}} </a> </div> diff --git a/templates/repo/projects/list.tmpl b/templates/repo/projects/list.tmpl index 2350a3af54..227a272705 100644 --- a/templates/repo/projects/list.tmpl +++ b/templates/repo/projects/list.tmpl @@ -15,11 +15,11 @@ <div class="ui compact tiny menu"> <a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/projects?state=open"> {{svg "octicon-project" 16 "gt-mr-3"}} - {{JsPrettyNumber .OpenCount}} {{.locale.Tr "repo.issues.open_title"}} + {{LocaleNumber .OpenCount}} {{.locale.Tr "repo.issues.open_title"}} </a> <a class="item{{if .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/projects?state=closed"> {{svg "octicon-check" 16 "gt-mr-3"}} - {{JsPrettyNumber .ClosedCount}} {{.locale.Tr "repo.issues.closed_title"}} + {{LocaleNumber .ClosedCount}} {{.locale.Tr "repo.issues.closed_title"}} </a> </div> @@ -48,9 +48,9 @@ {{end}} <span class="issue-stats"> {{svg "octicon-issue-opened" 16 "gt-mr-3"}} - {{JsPrettyNumber .NumOpenIssues}} {{$.locale.Tr "repo.issues.open_title"}} + {{LocaleNumber .NumOpenIssues}} {{$.locale.Tr "repo.issues.open_title"}} {{svg "octicon-check" 16 "gt-mr-3"}} - {{JsPrettyNumber .NumClosedIssues}} {{$.locale.Tr "repo.issues.closed_title"}} + {{LocaleNumber .NumClosedIssues}} {{$.locale.Tr "repo.issues.closed_title"}} </span> </div> {{if and $.CanWriteProjects (not $.Repository.IsArchived)}} diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl index 3dc3deb395..9bc87fa80b 100644 --- a/templates/repo/release/list.tmpl +++ b/templates/repo/release/list.tmpl @@ -161,9 +161,9 @@ <li> <span class="ui text middle aligned right"> <span class="ui text grey">{{.Size | FileSize}}</span> - <span data-tooltip-content="{{$.locale.Tr "repo.release.download_count" (.DownloadCount | PrettyNumber)}}"> + <gitea-locale-number data-number-in-tooltip="{{dict "message" ($.locale.Tr "repo.release.download_count") "number" .DownloadCount | Json}}"> {{svg "octicon-info"}} - </span> + </gitea-locale-number> </span> <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}"> <strong>{{svg "octicon-package" 16 "gt-mr-2"}}{{.Name}}</strong> diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl index 589fe12cea..ea5c70e742 100644 --- a/templates/repo/release/new.tmpl +++ b/templates/repo/release/new.tmpl @@ -72,9 +72,9 @@ <input name="attachment-edit-{{.UUID}}" class="gt-mr-3 attachment_edit" required value="{{.Name}}"> <input name="attachment-del-{{.UUID}}" type="hidden" value="false"> <span class="ui text grey gt-mr-3">{{.Size | FileSize}}</span> - <span data-tooltip-content="{{$.locale.Tr "repo.release.download_count" (.DownloadCount | PrettyNumber)}}"> + <gitea-locale-number data-number-in-tooltip="{{dict "message" ($.locale.Tr "repo.release.download_count") "number" .DownloadCount | Json}}"> {{svg "octicon-info"}} - </span> + </gitea-locale-number> </div> </div> {{end}} diff --git a/templates/repo/sub_menu.tmpl b/templates/repo/sub_menu.tmpl index 61d23915c3..fe4148d744 100644 --- a/templates/repo/sub_menu.tmpl +++ b/templates/repo/sub_menu.tmpl @@ -4,7 +4,7 @@ <div class="ui two horizontal center link list"> {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsEmptyRepo)}} <div class="item{{if .PageIsCommits}} active{{end}}"> - <a href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}">{{svg "octicon-history"}} <b>{{JsPrettyNumber .CommitsCount}}</b> {{.locale.TrN .CommitsCount "repo.commit" "repo.commits"}}</a> + <a href="{{.RepoLink}}/commits/{{.BranchNameSubURL}}">{{svg "octicon-history"}} <b>{{LocaleNumber .CommitsCount}}</b> {{.locale.TrN .CommitsCount "repo.commit" "repo.commits"}}</a> </div> <div class="item{{if .PageIsBranches}} active{{end}}"> <a href="{{.RepoLink}}/branches">{{svg "octicon-git-branch"}} <b>{{.BranchesCount}}</b> {{.locale.TrN .BranchesCount "repo.branch" "repo.branches"}}</a> |