From d242511e86c3a6d8a7013100845d2cdc8eb5252c Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 3 Apr 2022 17:46:48 +0800 Subject: 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. --- modules/web/middleware/locale.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules/web/middleware') diff --git a/modules/web/middleware/locale.go b/modules/web/middleware/locale.go index 3daf5f32d4..de8e497965 100644 --- a/modules/web/middleware/locale.go +++ b/modules/web/middleware/locale.go @@ -9,8 +9,8 @@ import ( "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/translation" + "code.gitea.io/gitea/modules/translation/i18n" - "github.com/unknwon/i18n" "golang.org/x/text/language" ) @@ -28,8 +28,8 @@ func Locale(resp http.ResponseWriter, req *http.Request) translation.Locale { } } - // Check again in case someone modify by purpose. - if lang != "" && !i18n.IsExist(lang) { + // Check again in case someone changes the supported language list. + if lang != "" && !i18n.DefaultLocales.HasLang(lang) { lang = "" changeLang = false } -- cgit v1.2.3