refactor: use translations to support rtl

This commit is contained in:
Tim-Niclas Oelschläger 2024-02-09 20:13:10 +01:00 committed by Lunny Xiao
parent 2b39981064
commit ad4d893ad5
5 changed files with 29 additions and 20 deletions

View File

@ -165,6 +165,7 @@ func NewFuncMap() template.FuncMap {
"RenderMarkdownToHtml": RenderMarkdownToHtml,
"RenderLabel": RenderLabel,
"RenderLabels": RenderLabels,
"RenderDependencies": RenderDependencies,
// -----------------------------------------------------------------
// misc

View File

@ -224,3 +224,21 @@ func RenderLabels(ctx context.Context, labels []*issues_model.Label, repoLink st
htmlCode += "</span>"
return template.HTML(htmlCode)
}
func RenderDependencies(ctx context.Context, dependencies []*issues_model.DependencyInfo) template.HTML {
if dependencies == nil || len(dependencies) < 1 {
return ""
}
htmlCode := ""
for index, dependency := range dependencies {
if index != 0 {
htmlCode += `<span>,</span>`
}
htmlCode += fmt.Sprintf(`<a href="%s" data-tooltip-content="#%d %s" class="gt-ml-2">#%d</a>`,
dependency.Issue.Link(), dependency.Issue.Index, RenderEmoji(ctx, dependency.Issue.Title), dependency.Issue.Index)
}
return template.HTML(htmlCode)
}

View File

@ -1685,9 +1685,9 @@ issues.dependency.issue_close_blocked = You need to close all issues blocking th
issues.dependency.issue_batch_close_blocked = "Cannot batch close issues that you choose, because issue #%d still has open dependencies"
issues.dependency.pr_close_blocked = You need to close all issues blocking this pull request before you can merge it.
issues.dependency.blocks_short = Blocks
issues.dependency.blocks_following = Blocks:
issues.dependency.blocks_following = Blocks: %s
issues.dependency.blocked_by_short = Depends on
issues.dependency.blocked_by_following = Depends on:
issues.dependency.blocked_by_following = Depends on: %s
issues.dependency.remove_header = Remove Dependency
issues.dependency.issue_remove_text = This will remove the dependency from this issue. Continue?
issues.dependency.pr_remove_text = This will remove the dependency from this pull request. Continue?

View File

@ -1,13 +1,5 @@
{{if and .DependenciesMap (index .DependenciesMap .ID)}}
<div class="flex-text-inline gt-gap-0">
<strong class="gt-mr-2">{{.Title}}</strong>
{{$first := true}}
{{range (index .DependenciesMap .ID)}}
{{if not $first}}<span class="gt-mr-2">,</span>{{end}}
{{$first = false}}
<a href="{{.Issue.Link}}" data-tooltip-content="#{{.Issue.Index}} {{.Issue.Title | RenderEmoji $.Context}}">
#{{.Issue.Index}}
</a>
{{end}}
</div>
{{if .Dependencies}}
<div class="flex-text-inline gt-gap-0">
{{(ctx.Locale.Tr .TitleKey (RenderDependencies ctx .Dependencies)) | Safe}}
</div>
{{end}}

View File

@ -119,13 +119,11 @@
</span>
{{end}}
{{template "shared/issue_dependency" (dict
"ID" .ID
"DependenciesMap" $.BlockingDependenciesMap
"Title" (ctx.Locale.Tr "repo.issues.dependency.blocks_following"))}}
"Dependencies" (index $.BlockingDependenciesMap .ID)
"TitleKey" "repo.issues.dependency.blocks_following")}}
{{template "shared/issue_dependency" (dict
"ID" .ID
"DependenciesMap" $.BlockedByDependenciesMap
"Title" (ctx.Locale.Tr "repo.issues.dependency.blocked_by_following"))}}
"Dependencies" (index $.BlockedByDependenciesMap .ID)
"TitleKey" "repo.issues.dependency.blocked_by_following")}}
{{if .IsPull}}
{{$approveOfficial := call $approvalCounts .ID "approve"}}
{{$rejectOfficial := call $approvalCounts .ID "reject"}}