diff options
author | kolaente <konrad@kola-entertainments.de> | 2018-05-05 02:28:30 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-05-05 08:28:30 +0800 |
commit | 1fdf5606785e4a45da7b301b40229a4335a0473c (patch) | |
tree | f018a866607c1e84c8ea0f0d62af905ca8cee9a7 /routers/user/setting.go | |
parent | 795dcc8ecf635aedeec848336c293189d3996605 (diff) | |
download | gitea-1fdf5606785e4a45da7b301b40229a4335a0473c.tar.gz gitea-1fdf5606785e4a45da7b301b40229a4335a0473c.zip |
Added user language setting (#3875)
* Added user language setting
* Added translation string for setting
* Fixed import order + typo
* improved checking if the user has a language saved in the db
* The current saved language is now set a default inside the dropdown
* fmt
* When a user signs in and doesn't have a language saved, the current browser language is saved
* updated gitea-sdk
* Merge branch 'master' of https://github.com/go-gitea/gitea into save-user-language
# Conflicts:
# models/migrations/migrations.go
# models/migrations/v62.go
* Made tests work again
* trigger CI
* trigger CI
* fmt
* re-trigger that FUCKING CI SO IT REALLY PICKS UP THE LATEST COMMIT ISTEAD OF PREDENDING TO DO SO
* re-trigger that FUCKING CI SO IT REALLY PICKS UP THE LATEST COMMIT ISTEAD OF PREDENDING TO DO SO
* When loggin in, only the language col gets updated instead of everything
Diffstat (limited to 'routers/user/setting.go')
-rw-r--r-- | routers/user/setting.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go index 2d8b53ff63..f4326bf0f5 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/Unknwon/com" + "github.com/Unknwon/i18n" "github.com/pquerna/otp" "github.com/pquerna/otp/totp" @@ -105,6 +106,7 @@ func SettingsPost(ctx *context.Context, form auth.UpdateProfileForm) { ctx.User.KeepEmailPrivate = form.KeepEmailPrivate ctx.User.Website = form.Website ctx.User.Location = form.Location + ctx.User.Language = form.Language if err := models.UpdateUserSetting(ctx.User); err != nil { if _, ok := err.(models.ErrEmailAlreadyUsed); ok { ctx.Flash.Error(ctx.Tr("form.email_been_used")) @@ -115,8 +117,11 @@ func SettingsPost(ctx *context.Context, form auth.UpdateProfileForm) { return } + // Update the language to the one we just set + ctx.SetCookie("lang", ctx.User.Language, nil, setting.AppSubURL) + log.Trace("User settings updated: %s", ctx.User.Name) - ctx.Flash.Success(ctx.Tr("settings.update_profile_success")) + ctx.Flash.Success(i18n.Tr(ctx.User.Language, "settings.update_profile_success")) ctx.Redirect(setting.AppSubURL + "/user/settings") } |