summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2021-12-31 08:43:03 +0000
committerGitHub <noreply@github.com>2021-12-31 16:43:03 +0800
commit7eb380baa49e76e8fc396872f943b5396019a9bd (patch)
tree091f958cf14b16a736f7ece3659746eee35f7e02 /routers
parenta3d685077f5ce331d6899426eb70c89e0fe6443a (diff)
downloadgitea-7eb380baa49e76e8fc396872f943b5396019a9bd.tar.gz
gitea-7eb380baa49e76e8fc396872f943b5396019a9bd.zip
Use correct translation key (#18135)
- Resolves #18122 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/migrate.go9
-rw-r--r--routers/web/repo/repo.go9
-rw-r--r--routers/web/repo/setting.go7
3 files changed, 22 insertions, 3 deletions
diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go
index 4284734102..9b12653839 100644
--- a/routers/web/repo/migrate.go
+++ b/routers/web/repo/migrate.go
@@ -81,7 +81,14 @@ func handleMigrateError(ctx *context.Context, owner *user_model.User, err error,
case migrations.IsTwoFactorAuthError(err):
ctx.RenderWithErr(ctx.Tr("form.2fa_auth_required"), tpl, form)
case repo_model.IsErrReachLimitOfRepo(err):
- ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.MaxCreationLimit()), tpl, form)
+ var msg string
+ maxCreationLimit := ctx.User.MaxCreationLimit()
+ if maxCreationLimit == 1 {
+ msg = ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit)
+ } else {
+ msg = ctx.Tr("repo.form.reach_limit_of_creation_n", maxCreationLimit)
+ }
+ ctx.RenderWithErr(msg, tpl, form)
case repo_model.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tpl, form)
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 9a36e6ee1d..0d8c6d374f 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -162,7 +162,14 @@ func Create(ctx *context.Context) {
func handleCreateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl base.TplName, form interface{}) {
switch {
case repo_model.IsErrReachLimitOfRepo(err):
- ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.MaxCreationLimit()), tpl, form)
+ var msg string
+ maxCreationLimit := ctx.User.MaxCreationLimit()
+ if maxCreationLimit == 1 {
+ msg = ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit)
+ } else {
+ msg = ctx.Tr("repo.form.reach_limit_of_creation_n", maxCreationLimit)
+ }
+ ctx.RenderWithErr(msg, tpl, form)
case repo_model.IsErrRepoAlreadyExist(err):
ctx.Data["Err_RepoName"] = true
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tpl, form)
diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go
index ff38f61d8b..5457e651d3 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -609,7 +609,12 @@ func SettingsPost(ctx *context.Context) {
}
if !ctx.Repo.Owner.CanCreateRepo() {
- ctx.Flash.Error(ctx.Tr("repo.form.reach_limit_of_creation", ctx.User.MaxCreationLimit()))
+ maxCreationLimit := ctx.User.MaxCreationLimit()
+ if maxCreationLimit == 1 {
+ ctx.Flash.Error(ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit))
+ } else {
+ ctx.Flash.Error(ctx.Tr("repo.form.reach_limit_of_creation_n", maxCreationLimit))
+ }
ctx.Redirect(repo.Link() + "/settings")
return
}