Skip to content

Commit e3e6569

Browse files
authored
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/<UserID>/edit` ![image](https://github.com/go-gitea/gitea/assets/24977596/906af0dd-cceb-4ed9-9cd9-32c71ae1bf71) `/admin/users/<UserID>` --- *Sponsored by Kithara Software GmbH*
1 parent 937e8b5 commit e3e6569

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

routers/web/admin/users.go

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ func EditUserPost(ctx *context.Context) {
439439
AllowCreateOrganization: optional.Some(form.AllowCreateOrganization),
440440
IsRestricted: optional.Some(form.Restricted),
441441
Visibility: optional.Some(form.Visibility),
442+
Language: optional.Some(form.Language),
442443
}
443444

444445
if err := user_service.UpdateUser(ctx, u, opts); err != nil {

services/forms/admin.go

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type AdminEditUserForm struct {
4141
Password string `binding:"MaxSize(255)"`
4242
Website string `binding:"ValidUrl;MaxSize(255)"`
4343
Location string `binding:"MaxSize(50)"`
44+
Language string `binding:"MaxSize(5)"`
4445
MaxRepoCreation int
4546
Active bool
4647
Admin bool

templates/admin/user/edit.tmpl

+15
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@
7070
<input id="password" name="password" type="password" autocomplete="new-password">
7171
<p class="help">{{ctx.Locale.Tr "admin.users.password_helper"}}</p>
7272
</div>
73+
74+
<div class="field {{if .Err_Language}}error{{end}}">
75+
<label for="language">{{ctx.Locale.Tr "settings.language"}}</label>
76+
<div class="ui selection dropdown">
77+
<input name="language" type="hidden" value="{{.User.Language}}">
78+
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
79+
<div class="text">{{range .AllLangs}}{{if eq $.User.Language .Lang}}{{.Name}}{{end}}{{end}}</div>
80+
<div class="menu">
81+
{{range .AllLangs}}
82+
<div class="item{{if eq $.User.Language .Lang}} active selected{{end}}" data-value="{{.Lang}}">{{.Name}}</div>
83+
{{end}}
84+
</div>
85+
</div>
86+
</div>
87+
7388
<div class="field {{if .Err_Website}}error{{end}}">
7489
<label for="website">{{ctx.Locale.Tr "settings.website"}}</label>
7590
<input id="website" name="website" type="url" value="{{.User.Website}}" placeholder="http://mydomain.com or https://mydomain.com" maxlength="255">

templates/admin/user/view_details.tmpl

+8
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
{{svg "octicon-x"}}
4949
{{end}}
5050
</div>
51+
{{if .User.Language}}
52+
<div class="flex-item-body">
53+
<span class="flex-text-inline">
54+
<b>{{ctx.Locale.Tr "settings.language"}}:</b>
55+
{{range .AllLangs}}{{if eq $.User.Language .Lang}}{{.Name}}{{end}}{{end}}
56+
</span>
57+
</div>
58+
{{end}}
5159
{{if .User.Location}}
5260
<div class="flex-item-body">
5361
<span class="flex-text-inline">{{svg "octicon-location"}}{{.User.Location}}</span>

0 commit comments

Comments
 (0)