forked from forgejo/forgejo
Remove legacy unmaintained packages, refactor to support change default locale (#19308)
Remove two unmaintained vendor packages `i18n` and `paginater`. Changes: * Rewrite `i18n` package with a more clear fallback mechanism. Fix an unstable `Tr` behavior, add more tests. * Refactor the legacy `Paginater` to `Paginator`, test cases are kept unchanged. Trivial enhancement (no breaking for end users): * Use the first locale in LANGS setting option as the default, add a log to prevent from surprising users.
This commit is contained in:
parent
27c34dd011
commit
d242511e86
26 changed files with 758 additions and 42 deletions
|
@ -10,19 +10,19 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/unknwon/paginater"
|
||||
"code.gitea.io/gitea/modules/paginator"
|
||||
)
|
||||
|
||||
// Pagination provides a pagination via Paginater and additional configurations for the link params used in rendering
|
||||
// Pagination provides a pagination via paginator.Paginator and additional configurations for the link params used in rendering
|
||||
type Pagination struct {
|
||||
Paginater *paginater.Paginater
|
||||
Paginater *paginator.Paginator
|
||||
urlParams []string
|
||||
}
|
||||
|
||||
// NewPagination creates a new instance of the Pagination struct
|
||||
func NewPagination(total, page, issueNum, numPages int) *Pagination {
|
||||
p := &Pagination{}
|
||||
p.Paginater = paginater.New(total, page, issueNum, numPages)
|
||||
p.Paginater = paginator.New(total, page, issueNum, numPages)
|
||||
return p
|
||||
}
|
||||
|
||||
|
@ -53,5 +53,6 @@ func (p *Pagination) SetDefaultParams(ctx *Context) {
|
|||
p.AddParam(ctx, "sort", "SortType")
|
||||
p.AddParam(ctx, "q", "Keyword")
|
||||
p.AddParam(ctx, "tab", "TabName")
|
||||
// do not add any more uncommon params here!
|
||||
p.AddParam(ctx, "t", "queryType")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue