diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-01-20 16:18:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-20 15:18:46 +0000 |
commit | 16d378fefc0a569f2a7aed29e6c7f288b3d83f02 (patch) | |
tree | 2b59a5322adff6222bc64c114268bed5ddf60488 /routers | |
parent | 5bf8d5445e3e3ec6b2be156654dcb233d78a570e (diff) | |
download | gitea-16d378fefc0a569f2a7aed29e6c7f288b3d83f02.tar.gz gitea-16d378fefc0a569f2a7aed29e6c7f288b3d83f02.zip |
Use correct translation key for errors (#18342)
- Noted by:
https://github.com/go-gitea/gitea/issues/17876#issuecomment-1017503614
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/org/setting.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/routers/web/org/setting.go b/routers/web/org/setting.go index 081e103f79..747a5134b4 100644 --- a/routers/web/org/setting.go +++ b/routers/web/org/setting.go @@ -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 |