From e3e6569c5fd8c69aa65384e6d1636cc14b23a32b Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Sat, 2 Mar 2024 22:55:02 +0100 Subject: [PATCH] Add option to set language in admin user view (#28449) ![image](https://github.com/go-gitea/gitea/assets/24977596/be7e3f92-af3f-4628-b4ed-abf6439687f3) `/admin/users//edit` ![image](https://github.com/go-gitea/gitea/assets/24977596/906af0dd-cceb-4ed9-9cd9-32c71ae1bf71) `/admin/users/` --- *Sponsored by Kithara Software GmbH* --- routers/web/admin/users.go | 1 + services/forms/admin.go | 1 + templates/admin/user/edit.tmpl | 15 +++++++++++++++ templates/admin/user/view_details.tmpl | 8 ++++++++ 4 files changed, 25 insertions(+) diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index ca47175401..a34e0d0f0d 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -439,6 +439,7 @@ func EditUserPost(ctx *context.Context) { AllowCreateOrganization: optional.Some(form.AllowCreateOrganization), IsRestricted: optional.Some(form.Restricted), Visibility: optional.Some(form.Visibility), + Language: optional.Some(form.Language), } if err := user_service.UpdateUser(ctx, u, opts); err != nil { diff --git a/services/forms/admin.go b/services/forms/admin.go index f112013060..81276f8f46 100644 --- a/services/forms/admin.go +++ b/services/forms/admin.go @@ -41,6 +41,7 @@ type AdminEditUserForm struct { Password string `binding:"MaxSize(255)"` Website string `binding:"ValidUrl;MaxSize(255)"` Location string `binding:"MaxSize(50)"` + Language string `binding:"MaxSize(5)"` MaxRepoCreation int Active bool Admin bool diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index fcb8ce0827..159c821099 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -70,6 +70,21 @@

{{ctx.Locale.Tr "admin.users.password_helper"}}

+ +
+ + +
+
diff --git a/templates/admin/user/view_details.tmpl b/templates/admin/user/view_details.tmpl index 21425eecb4..be2f32b5ec 100644 --- a/templates/admin/user/view_details.tmpl +++ b/templates/admin/user/view_details.tmpl @@ -48,6 +48,14 @@ {{svg "octicon-x"}} {{end}}
+ {{if .User.Language}} +
+ + {{ctx.Locale.Tr "settings.language"}}: + {{range .AllLangs}}{{if eq $.User.Language .Lang}}{{.Name}}{{end}}{{end}} + +
+ {{end}} {{if .User.Location}}
{{svg "octicon-location"}}{{.User.Location}}