diff options
author | a1012112796 <1012112796@qq.com> | 2021-06-02 03:12:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-01 21:12:50 +0200 |
commit | 7081046b5f3665860b65eb0c0c12eb77a3994727 (patch) | |
tree | e030915e5c268f622ae4a86be6e7bc12dfaf2ed3 /routers/install.go | |
parent | 072df3ff87c399bccfddfc0901e63ebacfaec73d (diff) | |
download | gitea-7081046b5f3665860b65eb0c0c12eb77a3994727.tar.gz gitea-7081046b5f3665860b65eb0c0c12eb77a3994727.zip |
Fix language switch for install page (#16043)
Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'routers/install.go')
-rw-r--r-- | routers/install.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/routers/install.go b/routers/install.go index 30340e99cd..6c460a887d 100644 --- a/routers/install.go +++ b/routers/install.go @@ -21,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/templates" + "code.gitea.io/gitea/modules/translation" "code.gitea.io/gitea/modules/user" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" @@ -61,6 +62,8 @@ func InstallInit(next http.Handler) http.Handler { "DbOptions": setting.SupportedDatabases, "i18n": locale, "Language": locale.Language(), + "Lang": locale.Language(), + "AllLangs": translation.AllLangs(), "CurrentURL": setting.AppSubURL + req.URL.RequestURI(), "PageStartTime": startTime, "TmplLoadTimes": func() string { @@ -69,6 +72,12 @@ func InstallInit(next http.Handler) http.Handler { "PasswordHashAlgorithms": models.AvailableHashAlgorithms, }, } + for _, lang := range translation.AllLangs() { + if lang.Lang == locale.Language() { + ctx.Data["LangName"] = lang.Name + break + } + } ctx.Req = context.WithContext(req, &ctx) next.ServeHTTP(resp, ctx.Req) }) |