-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
UI language setting problems #15612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
issue/confirmed
Issue has been reviewed and confirmed to be present or accepted to be implemented
topic/ui
Change the appearance of the Gitea UI
Milestone
Comments
Hi there, I can confirm this issue in the following clients in Gitea Version: 1.15.6
Steps to Reproduce
|
Oh yes, I also meet the similar problem. The UI language sometimes differs from the language setting. |
I think this: diff --git a/modules/context/api.go b/modules/context/api.go
index c978835af..e25318940 100644
--- a/modules/context/api.go
+++ b/modules/context/api.go
@@ -245,6 +245,9 @@ func APIAuth(authMethod auth.Method) func(*APIContext) {
// Get user from session if logged in.
ctx.User = authMethod.Verify(ctx.Req, ctx.Resp, ctx, ctx.Session)
if ctx.User != nil {
+ if ctx.Locale.Language() != ctx.User.Language {
+ ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req)
+ }
ctx.IsBasicAuth = ctx.Data["AuthedMethod"].(string) == new(auth.Basic).Name()
ctx.IsSigned = true
ctx.Data["IsSigned"] = ctx.IsSigned
diff --git a/modules/context/context.go b/modules/context/context.go
index 8adf1f306..a405f93d1 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -614,6 +614,9 @@ func Auth(authMethod auth.Method) func(*Context) {
return func(ctx *Context) {
ctx.User = authMethod.Verify(ctx.Req, ctx.Resp, ctx, ctx.Session)
if ctx.User != nil {
+ if ctx.Locale.Language() != ctx.User.Language {
+ ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req)
+ }
ctx.IsBasicAuth = ctx.Data["AuthedMethod"].(string) == new(auth.Basic).Name()
ctx.IsSigned = true
ctx.Data["IsSigned"] = ctx.IsSigned
diff --git a/routers/web/user/auth.go b/routers/web/user/auth.go
index ba37c8e3e..1b1c70c8f 100644
--- a/routers/web/user/auth.go
+++ b/routers/web/user/auth.go
@@ -572,6 +572,10 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
middleware.SetLocaleCookie(ctx.Resp, u.Language, 0)
+ if ctx.Locale.Language() != u.Language {
+ ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req)
+ }
+
// Clear whatever CSRF has right now, force to generate a new one
middleware.DeleteCSRFCookie(ctx.Resp)
would solve the issue. It would be useful if you could test this patch. |
I'll try to test it on top of 1.15.6 |
r10r
added a commit
to drachenfels-de/gitea
that referenced
this issue
Nov 18, 2021
Works! Thanks @zeripath! Tested with
Will this be added to the 1.15.7 ? |
zeripath
added a commit
to zeripath/gitea
that referenced
this issue
Nov 20, 2021
When logging in reset the user's locale to ensure that it matches their preferred locale. Fix go-gitea#15612 Signed-off-by: Andrew Thornton <[email protected]>
Merged
zeripath
added a commit
that referenced
this issue
Nov 20, 2021
When logging in reset the user's locale to ensure that it matches their preferred locale. Fix #15612 Signed-off-by: Andrew Thornton <[email protected]>
zeripath
added a commit
to zeripath/gitea
that referenced
this issue
Dec 25, 2021
Backport go-gitea#17734 When logging in reset the user's locale to ensure that it matches their preferred locale. Fix go-gitea#15612 Signed-off-by: Andrew Thornton <[email protected]>
lunny
pushed a commit
that referenced
this issue
Dec 25, 2021
Backport #17734 When logging in reset the user's locale to ensure that it matches their preferred locale. Fix #15612 Signed-off-by: Andrew Thornton <[email protected]>
Chianina
pushed a commit
to Chianina/gitea
that referenced
this issue
Mar 28, 2022
When logging in reset the user's locale to ensure that it matches their preferred locale. Fix go-gitea#15612 Signed-off-by: Andrew Thornton <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
issue/confirmed
Issue has been reviewed and confirmed to be present or accepted to be implemented
topic/ui
Change the appearance of the Gitea UI
[x]
):Description
I used the Microsoft Edge browser and set the UI language to English, but after logging in again, it changed to Chinese by default.
Screenshots
The text was updated successfully, but these errors were encountered: