-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Prettify number of issues #17760
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
Prettify number of issues #17760
Changes from 18 commits
325de8b
ac90d3a
6507761
f6624c7
be2f7e5
734f77c
472a12e
c968fee
faaad8b
22fb8cb
c071eff
aef87e0
8a18fd7
e8a762c
c0a9be4
8d59655
3dce936
2a2712c
2d553d1
0d18f79
5116fcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 "mr-3"}} | ||
{{.i18n.Tr "repo.milestones.open_tab" .OpenCount}} | ||
{{JsPrettyNumber .OpenCount}} {{.i18n.Tr "repo.issues.open_title"}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and below, I worry about i18n here, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some languages like Arabic do |
||
</a> | ||
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.RepoLink}}/milestones?state=closed&q={{$.Keyword}}"> | ||
{{svg "octicon-milestone" 16 "mr-3"}} | ||
{{.i18n.Tr "repo.milestones.close_tab" .ClosedCount}} | ||
{{svg "octicon-check" 16 "mr-3"}} | ||
{{JsPrettyNumber .ClosedCount}} {{.i18n.Tr "repo.issues.closed_title"}} | ||
</a> | ||
</div> | ||
</div> | ||
|
@@ -83,8 +83,10 @@ | |
{{end}} | ||
{{end}} | ||
<span class="issue-stats"> | ||
{{svg "octicon-issue-opened"}} {{$.i18n.Tr "repo.issues.open_tab" .NumOpenIssues}} | ||
{{svg "octicon-issue-closed"}} {{$.i18n.Tr "repo.issues.close_tab" .NumClosedIssues}} | ||
{{svg "octicon-issue-opened" 16 "mr-3"}} | ||
{{JsPrettyNumber .NumOpenIssues}} {{$.i18n.Tr "repo.issues.open_title"}} | ||
{{svg "octicon-check" 16 "mr-3"}} | ||
{{JsPrettyNumber .NumClosedIssues}} {{$.i18n.Tr "repo.issues.closed_title"}} | ||
{{if .TotalTrackedTime}}{{svg "octicon-clock"}} {{.TotalTrackedTime|Sec2Time}}{{end}} | ||
{{if .UpdatedUnix}}{{svg "octicon-clock"}} {{$.i18n.Tr "repo.milestones.update_ago" (.TimeSinceUpdate|Sec2Time)}}{{end}} | ||
</span> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
<div class="ui compact tiny menu"> | ||
<a class="{{if not .IsShowClosed}}active{{end}} item" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&sort={{$.SortType}}&state=open&labels={{.SelectLabels}}&milestone={{.MilestoneID}}&assignee={{.AssigneeID}}"> | ||
{{svg "octicon-issue-opened" 16 "mr-3"}} | ||
{{.i18n.Tr "repo.issues.open_tab" .IssueStats.OpenCount}} | ||
{{if .PageIsPullList}} | ||
{{svg "octicon-git-pull-request" 16 "mr-3"}} | ||
{{else}} | ||
{{svg "octicon-issue-opened" 16 "mr-3"}} | ||
{{end}} | ||
{{JsPrettyNumber .IssueStats.OpenCount}} {{.i18n.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}}&assignee={{.AssigneeID}}"> | ||
{{svg "octicon-issue-closed" 16 "mr-3"}} | ||
{{.i18n.Tr "repo.issues.close_tab" .IssueStats.ClosedCount}} | ||
{{svg "octicon-check" 16 "mr-3"}} | ||
{{JsPrettyNumber .IssueStats.ClosedCount}} {{.i18n.Tr "repo.issues.closed_title"}} | ||
</a> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {prettyNumber} from '../utils.js'; | ||
|
||
const {lang} = document.documentElement; | ||
Gusted marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export function initFormattingReplacements() { | ||
// replace english formatted numbers with locale-specific separators | ||
for (const el of document.getElementsByClassName('js-pretty-number')) { | ||
const num = Number(el.getAttribute('data-value')); | ||
const formatted = prettyNumber(num, lang); | ||
if (formatted && formatted !== el.textContent) { | ||
el.textContent = formatted; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,3 +90,10 @@ export function strSubMatch(full, sub) { | |
} | ||
return res; | ||
} | ||
|
||
// pretty-print a number using locale-specific separators, e.g. 1200 -> 1,200 | ||
export function prettyNumber(num, locale = 'en-US') { | ||
if (typeof num !== 'number') return ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const {format} = new Intl.NumberFormat(locale); | ||
return format(num); | ||
} |
Uh oh!
There was an error while loading. Please reload this page.