]> source.dussan.org Git - gitea.git/commitdiff
Fix language switch for install page (#16043)
authora1012112796 <1012112796@qq.com>
Tue, 1 Jun 2021 19:12:50 +0000 (03:12 +0800)
committerGitHub <noreply@github.com>
Tue, 1 Jun 2021 19:12:50 +0000 (21:12 +0200)
Signed-off-by: a1012112796 <1012112796@qq.com>
routers/install.go
routers/routes/install.go

index 30340e99cd6362a3c4be589cc2ab1128aa223695..6c460a887d81cc546d861485d39c2b893c2a5f00 100644 (file)
@@ -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)
        })
index 2a2c8f1d2b5ae61aec1ec86faba33e877db5412f..0918da1a4b8ab280f80aae3f5282d2cf30d54aad 100644 (file)
@@ -103,7 +103,7 @@ func InstallRoutes() *web.Route {
        r.Get("/", routers.Install)
        r.Post("/", web.Bind(forms.InstallForm{}), routers.InstallPost)
        r.NotFound(func(w http.ResponseWriter, req *http.Request) {
-               http.Redirect(w, req, setting.AppURL, 302)
+               http.Redirect(w, req, setting.AppURL, http.StatusFound)
        })
        return r
 }