From a40df1205bafb31ac4fa6386a80a839df14b0a0d Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 1 Jan 2022 23:54:28 +0100 Subject: [PATCH 1/2] backport: Use correct translation key - Backport of #18135 --- routers/web/repo/migrate.go | 9 ++++++++- routers/web/repo/repo.go | 9 ++++++++- routers/web/repo/setting.go | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go index 521a856dae444..74f02cbaec4d8 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 := 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 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 0b300d32bcc51..4aa4f2211cbc9 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 f9a98adece8f4..067df8b176194 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.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 } From 2914a13932de88248364653e1c7472c809f9c889 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 2 Jan 2022 01:49:33 +0100 Subject: [PATCH 2/2] Nothing to see --- routers/web/repo/migrate.go | 2 +- routers/web/repo/setting.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go index 74f02cbaec4d8..91f3fb2e49c64 100644 --- a/routers/web/repo/migrate.go +++ b/routers/web/repo/migrate.go @@ -78,7 +78,7 @@ func handleMigrateError(ctx *context.Context, owner *models.User, err error, nam ctx.RenderWithErr(ctx.Tr("form.2fa_auth_required"), tpl, form) case models.IsErrReachLimitOfRepo(err): var msg string - maxCreationLimit := ctx.User.MaxCreationLimit() + maxCreationLimit := owner.MaxCreationLimit() if maxCreationLimit == 1 { msg = ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit) } else { diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index 067df8b176194..16a1cb039bdda 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -533,7 +533,7 @@ func SettingsPost(ctx *context.Context) { } if !ctx.Repo.Owner.CanCreateRepo() { - maxCreationLimit := 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 {