mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 20:07:03 +01:00
Fix language switch for install page (#16043)
Signed-off-by: a1012112796 <1012112796@qq.com>
This commit is contained in:
parent
072df3ff87
commit
7081046b5f
2 changed files with 10 additions and 1 deletions
|
@ -21,6 +21,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/templates"
|
"code.gitea.io/gitea/modules/templates"
|
||||||
|
"code.gitea.io/gitea/modules/translation"
|
||||||
"code.gitea.io/gitea/modules/user"
|
"code.gitea.io/gitea/modules/user"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
"code.gitea.io/gitea/modules/web"
|
"code.gitea.io/gitea/modules/web"
|
||||||
|
@ -61,6 +62,8 @@ func InstallInit(next http.Handler) http.Handler {
|
||||||
"DbOptions": setting.SupportedDatabases,
|
"DbOptions": setting.SupportedDatabases,
|
||||||
"i18n": locale,
|
"i18n": locale,
|
||||||
"Language": locale.Language(),
|
"Language": locale.Language(),
|
||||||
|
"Lang": locale.Language(),
|
||||||
|
"AllLangs": translation.AllLangs(),
|
||||||
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
|
"CurrentURL": setting.AppSubURL + req.URL.RequestURI(),
|
||||||
"PageStartTime": startTime,
|
"PageStartTime": startTime,
|
||||||
"TmplLoadTimes": func() string {
|
"TmplLoadTimes": func() string {
|
||||||
|
@ -69,6 +72,12 @@ func InstallInit(next http.Handler) http.Handler {
|
||||||
"PasswordHashAlgorithms": models.AvailableHashAlgorithms,
|
"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)
|
ctx.Req = context.WithContext(req, &ctx)
|
||||||
next.ServeHTTP(resp, ctx.Req)
|
next.ServeHTTP(resp, ctx.Req)
|
||||||
})
|
})
|
||||||
|
|
|
@ -103,7 +103,7 @@ func InstallRoutes() *web.Route {
|
||||||
r.Get("/", routers.Install)
|
r.Get("/", routers.Install)
|
||||||
r.Post("/", web.Bind(forms.InstallForm{}), routers.InstallPost)
|
r.Post("/", web.Bind(forms.InstallForm{}), routers.InstallPost)
|
||||||
r.NotFound(func(w http.ResponseWriter, req *http.Request) {
|
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
|
return r
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue