Skip to content

Commit 7081046

Browse files
authored
Fix language switch for install page (#16043)
Signed-off-by: a1012112796 <[email protected]>
1 parent 072df3f commit 7081046

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

routers/install.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/log"
2222
"code.gitea.io/gitea/modules/setting"
2323
"code.gitea.io/gitea/modules/templates"
24+
"code.gitea.io/gitea/modules/translation"
2425
"code.gitea.io/gitea/modules/user"
2526
"code.gitea.io/gitea/modules/util"
2627
"code.gitea.io/gitea/modules/web"
@@ -61,6 +62,8 @@ func InstallInit(next http.Handler) http.Handler {
6162
"DbOptions": setting.SupportedDatabases,
6263
"i18n": locale,
6364
"Language": locale.Language(),
65+
"Lang": locale.Language(),
66+
"AllLangs": translation.AllLangs(),
6467
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
6568
"PageStartTime": startTime,
6669
"TmplLoadTimes": func() string {
@@ -69,6 +72,12 @@ func InstallInit(next http.Handler) http.Handler {
6972
"PasswordHashAlgorithms": models.AvailableHashAlgorithms,
7073
},
7174
}
75+
for _, lang := range translation.AllLangs() {
76+
if lang.Lang == locale.Language() {
77+
ctx.Data["LangName"] = lang.Name
78+
break
79+
}
80+
}
7281
ctx.Req = context.WithContext(req, &ctx)
7382
next.ServeHTTP(resp, ctx.Req)
7483
})

routers/routes/install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func InstallRoutes() *web.Route {
103103
r.Get("/", routers.Install)
104104
r.Post("/", web.Bind(forms.InstallForm{}), routers.InstallPost)
105105
r.NotFound(func(w http.ResponseWriter, req *http.Request) {
106-
http.Redirect(w, req, setting.AppURL, 302)
106+
http.Redirect(w, req, setting.AppURL, http.StatusFound)
107107
})
108108
return r
109109
}

0 commit comments

Comments
 (0)