Skip to content

Commit

Permalink
Use correct translation key for errors (#18342)
Browse files Browse the repository at this point in the history
- Noted by:
#17876 (comment)
  • Loading branch information
Gusted authored Jan 20, 2022
1 parent 5bf8d54 commit 16d378f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions routers/web/org/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ func SettingsPost(ctx *context.Context) {
ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tplSettingsOptions, &form)
return
} else if err = user_model.ChangeUserName(org.AsUser(), form.Name); err != nil {
if db.IsErrNameReserved(err) || db.IsErrNamePatternNotAllowed(err) {
switch {
case db.IsErrNameReserved(err):
ctx.Data["OrgName"] = true
ctx.RenderWithErr(ctx.Tr("form.illegal_username"), tplSettingsOptions, &form)
} else {
ctx.RenderWithErr(ctx.Tr("repo.form.name_reserved", err.(db.ErrNameReserved).Name), tplSettingsOptions, &form)
case db.IsErrNamePatternNotAllowed(err):
ctx.Data["OrgName"] = true
ctx.RenderWithErr(ctx.Tr("repo.form.name_pattern_not_allowed", err.(db.ErrNamePatternNotAllowed).Pattern), tplSettingsOptions, &form)
default:
ctx.ServerError("ChangeUserName", err)
}
return
Expand Down

0 comments on commit 16d378f

Please sign in to comment.