aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGusted2022-01-02 02:39:23 +0000
committerGitHub2022-01-02 02:39:23 +0000
commitf9bbed028cd13ff039f6cde227f3da2920c44e5e (patch)
tree8b12edcf6a7447c2dce23687e3e382db22fc7e2b
parent7e084341feeb584dbfdd6a4bb92f1d3c9ca6fb64 (diff)
Use correct translation key for error messages due to max repo limits (#18135 & #18153) (#18152)
- Backport #18135 - Backport #18153
-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 521a856da..91f3fb2e4 100644
--- a/routers/web/repo/migrate.go
+++ b/routers/web/repo/migrate.go
@@ -77,7 +77,14 @@ func handleMigrateError(ctx *context.Context, owner *models.User, err error, nam
case migrations.IsTwoFactorAuthError(err):
ctx.RenderWithErr(ctx.Tr("form.2fa_auth_required"), tpl, form)
case models.IsErrReachLimitOfRepo(err):
- ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.MaxCreationLimit()), tpl, form)
+ var msg string
+ maxCreationLimit := owner.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 models.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 0b300d32b..4aa4f2211 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -158,7 +158,14 @@ func Create(ctx *context.Context) {
func handleCreateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) {
switch {
case models.IsErrReachLimitOfRepo(err):
- ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.MaxCreationLimit()), tpl, form)
+ var msg string
+ maxCreationLimit := owner.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 models.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 f9a98adec..16a1cb039 100644
--- a/routers/web/repo/setting.go
+++ b/routers/web/repo/setting.go
@@ -533,7 +533,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.Repo.Owner.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
}