aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authora10121127962021-06-10 21:19:40 +0800
committerGitHub2021-06-10 21:19:40 +0800
commitc1887bfc9b8a093632eed23f07e8738f998a02a4 (patch)
treea91c7e614e1cd8284b86c353788802673c61384f
parent41a4047e79b593b32a6a3e4fc55ca4788190e71e (diff)
Fix language switch for install page (#16043) (#16128)
Signed-off-by: a1012112796 <1012112796@qq.com>
-rw-r--r--routers/install.go9
-rw-r--r--routers/routes/install.go2
2 files changed, 10 insertions, 1 deletions
diff --git a/routers/install.go b/routers/install.go
index 7f01738ef..060463e84 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -22,6 +22,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)
})
diff --git a/routers/routes/install.go b/routers/routes/install.go
index 22c9d5feb..eae803fdc 100644
--- a/routers/routes/install.go
+++ b/routers/routes/install.go
@@ -111,7 +111,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
}