mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
[v14.0/forgejo] fix(ui): hardcode sort options in search syntax hint, improve look (#11413)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/11381 Followup to https://codeberg.org/forgejo/forgejo/pulls/9109 Fix issue reported by @mahlzahn that the string was confusing translators and they translated the part that wasn't meant to be translated Part of this fix was to replace custom IterWithTr with simple dict iteration to allow for placeholders in strings. Co-authored-by: 0ko <0ko@noreply.codeberg.org> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/11413 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Reviewed-by: Beowulf <beowulf@beocode.eu> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
parent
a72cffddfa
commit
d52756b879
4 changed files with 13 additions and 30 deletions
|
|
@ -73,12 +73,6 @@ func (handler Handler) handleTemplateNode(fset *token.FileSet, node tmplParser.N
|
|||
funcname = nodeVar.Ident[2]
|
||||
}
|
||||
|
||||
if funcname == "IterWithTr" {
|
||||
for i := 2; i < len(nodeCommand.Args); i += 2 {
|
||||
handler.handleTemplateMsgid(fset, nodeCommand.Args[i])
|
||||
}
|
||||
}
|
||||
|
||||
var gotUnexpectedInvoke *int
|
||||
ltf, ok := handler.LocaleTrFunctions[funcname]
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package translation
|
|||
import (
|
||||
"context"
|
||||
"html/template"
|
||||
"iter"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
|
|
@ -328,16 +327,6 @@ func (l *locale) PrettyNumber(v any) string {
|
|||
return l.msgPrinter.Sprintf("%v", number.Decimal(v))
|
||||
}
|
||||
|
||||
func (l *locale) IterWithTr(kvs ...string) iter.Seq2[string, template.HTML] {
|
||||
return func(yield func(string, template.HTML) bool) {
|
||||
for i := 0; i < len(kvs); i += 2 {
|
||||
if !yield(kvs[i], l.TrHTML(kvs[i+1])) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func GetPluralRule(l Locale) int {
|
||||
return GetPluralRuleImpl(l.Language())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@
|
|||
"repo.issues.filter_reviewers.hint": "Filter by user who reviewed",
|
||||
"repo.issues.filter_mention.hint": "Filter by mentioned user",
|
||||
"repo.issues.filter_modified.hint": "Filter by last modified date",
|
||||
"repo.issues.filter_sort.hint": "Sort by: created/comments/updated/deadline",
|
||||
"repo.issues.filter_sort.hint_with_placeholder": "Sort by: %s",
|
||||
"issues.updated": "updated %s",
|
||||
"repo.pulls.poster_manage_approval": "Manage approval",
|
||||
"repo.pulls.poster_requires_approval": "Some workflows are <a href=\"%[1]s\">waiting to be reviewed.</a>",
|
||||
|
|
|
|||
|
|
@ -6,26 +6,26 @@
|
|||
<table class="tw-table-auto">
|
||||
<tbody>
|
||||
{{range $filter, $tr :=
|
||||
ctx.Locale.IterWithTr
|
||||
"is:open" "repo.issues.open_title"
|
||||
"is:closed" "repo.issues.closed_title"
|
||||
"is:all" "repo.issues.all_title"
|
||||
"author:<username>" "repo.issues.filter_poster.hint"
|
||||
"assignee:<username>" "repo.issues.filter_assignee.hint"
|
||||
"review:<username>" "repo.issues.filter_reviewers.hint"
|
||||
"mentions:<username>" "repo.issues.filter_mention.hint"
|
||||
"sort:<by>:[asc|desc]" "repo.issues.filter_sort.hint"
|
||||
"modified:[>|<]<date>" "repo.issues.filter_modified.hint"}}
|
||||
dict
|
||||
"is:open" (ctx.Locale.TrString "repo.issues.open_title")
|
||||
"is:closed" (ctx.Locale.TrString "repo.issues.closed_title")
|
||||
"is:all" (ctx.Locale.TrString "repo.issues.all_title")
|
||||
"author:<username>" (ctx.Locale.TrString "repo.issues.filter_poster.hint")
|
||||
"assignee:<username>" (ctx.Locale.TrString "repo.issues.filter_assignee.hint")
|
||||
"review:<username>" (ctx.Locale.TrString "repo.issues.filter_reviewers.hint")
|
||||
"mentions:<username>" (ctx.Locale.TrString "repo.issues.filter_mention.hint")
|
||||
"sort:<by>:[asc|desc]" (ctx.Locale.Tr "repo.issues.filter_sort.hint_with_placeholder" (HTMLFormat "<code>created|comments|updated|deadline</code>"))
|
||||
"modified:[>|<]<date>" (ctx.Locale.TrString "repo.issues.filter_modified.hint")}}
|
||||
<tr>
|
||||
<th class="tw-p-2"><code>{{$filter}}</code></th>
|
||||
<td class="tw-p-2">{{$tr | SafeHTML}}</td>
|
||||
<td class="tw-p-2">{{$tr}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<footer class="actions">
|
||||
<button class="ui button icon cancel">{{ctx.Locale.Tr "settings.cancel"}}</button>
|
||||
<button class="secondary button cancel">{{ctx.Locale.Tr "settings.cancel"}}</button>
|
||||
</footer>
|
||||
</article>
|
||||
</dialog>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue