Skip to content
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

Profile language lost when browser is closed #18020

Closed
fmunch opened this issue Dec 18, 2021 · 2 comments · Fixed by #18023 or #18025
Closed

Profile language lost when browser is closed #18020

fmunch opened this issue Dec 18, 2021 · 2 comments · Fixed by #18023 or #18025
Milestone

Comments

@fmunch
Copy link

fmunch commented Dec 18, 2021

Gitea Version

1.15.7

Git Version

2.30.2

Operating System

Debian 11.2

How are you running Gitea?

Using https://dl.gitea.io/gitea/1.15.7/gitea-1.15.7-linux-amd64 running from systemd.

Database

MySQL

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Description

Hello!

I am using Chrome 96 which is sending accept-language: fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7.

  1. I go to https://mygitea/
  2. Gitea is in French.
  3. Navigate to Configuration > Profile, set Language = English, save.
  4. Gitea is now in English when I navigate in it.
  5. Close and reopen browser.
  6. Gitea is in French once again.
  7. If I go back to Configuration > Profile, Language is still English but the page is in French. I just have to click Update Profile to have Gitea in English without touching anything else.

I created an account on try.gitea.io, same thing happens.

The screenshots show the configuration page from my Gitea and try.gitea.io displayed in French but with the language setting showing English.

Screenshots

https://imgur.com/a/EP0mAO2

@wxiaoguang
Copy link
Contributor

+1, I can reproduce this problem with a very recent dev version (1.16), eg: cc129d2

@zeripath
Copy link
Contributor

Ah it looks like there are a couple of other places that the below magic needs to be copied in:

   // Language setting of the user overwrites the one previously set
   // If the user does not have a locale set, we save the current one.
   if len(u.Language) == 0 {
   	u.Language = ctx.Locale.Language()
   	if err := user_model.UpdateUserCols(db.DefaultContext, u, "language"); err != nil {
   		log.Error(fmt.Sprintf("Error updating user language [user: %d, locale: %s]", u.ID, u.Language))
   		return setting.AppSubURL + "/"
   	}
   }

   middleware.SetLocaleCookie(ctx.Resp, u.Language, 0)

   if ctx.Locale.Language() != u.Language {
   	ctx.Locale = middleware.Locale(ctx.Resp, ctx.Req)
   }

zeripath added a commit to zeripath/gitea that referenced this issue Dec 18, 2021
Fix go-gitea#18020

Signed-off-by: Andrew Thornton <[email protected]>
zeripath added a commit that referenced this issue Dec 19, 2021
* Reset locale on login

Fix #18020

Signed-off-by: Andrew Thornton <[email protected]>

* Update routers/web/user/auth.go

Co-authored-by: Gusted <[email protected]>

Co-authored-by: Gusted <[email protected]>
zeripath added a commit to zeripath/gitea that referenced this issue Dec 19, 2021
Backport go-gitea#18023

Although we reset the locale in a number of places there were several ways of logging in that were missing the same code.

Fix go-gitea#18020

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: Gusted <[email protected]>
@zeripath zeripath added this to the 1.15.8 milestone Dec 19, 2021
@zeripath zeripath linked a pull request Dec 19, 2021 that will close this issue
zeripath added a commit that referenced this issue Dec 19, 2021
Backport #18023

Although we reset the locale in a number of places there were several ways of logging in that were missing the same code.

Fix #18020

Signed-off-by: Andrew Thornton <[email protected]>
Co-authored-by: Gusted <[email protected]>
Chianina pushed a commit to Chianina/gitea that referenced this issue Mar 28, 2022
* Reset locale on login

Fix go-gitea#18020

Signed-off-by: Andrew Thornton <[email protected]>

* Update routers/web/user/auth.go

Co-authored-by: Gusted <[email protected]>

Co-authored-by: Gusted <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants