Skip to content

Commit f9bbed0

Browse files
author
Gusted
authored
Use correct translation key for error messages due to max repo limits (#18135 & #18153) (#18152)
- Backport #18135 - Backport #18153
1 parent 7e08434 commit f9bbed0

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

Diff for: routers/web/repo/migrate.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ func handleMigrateError(ctx *context.Context, owner *models.User, err error, nam
7777
case migrations.IsTwoFactorAuthError(err):
7878
ctx.RenderWithErr(ctx.Tr("form.2fa_auth_required"), tpl, form)
7979
case models.IsErrReachLimitOfRepo(err):
80-
ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.MaxCreationLimit()), tpl, form)
80+
var msg string
81+
maxCreationLimit := owner.MaxCreationLimit()
82+
if maxCreationLimit == 1 {
83+
msg = ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit)
84+
} else {
85+
msg = ctx.Tr("repo.form.reach_limit_of_creation_n", maxCreationLimit)
86+
}
87+
ctx.RenderWithErr(msg, tpl, form)
8188
case models.IsErrRepoAlreadyExist(err):
8289
ctx.Data["Err_RepoName"] = true
8390
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tpl, form)

Diff for: routers/web/repo/repo.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,14 @@ func Create(ctx *context.Context) {
158158
func handleCreateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) {
159159
switch {
160160
case models.IsErrReachLimitOfRepo(err):
161-
ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", owner.MaxCreationLimit()), tpl, form)
161+
var msg string
162+
maxCreationLimit := owner.MaxCreationLimit()
163+
if maxCreationLimit == 1 {
164+
msg = ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit)
165+
} else {
166+
msg = ctx.Tr("repo.form.reach_limit_of_creation_n", maxCreationLimit)
167+
}
168+
ctx.RenderWithErr(msg, tpl, form)
162169
case models.IsErrRepoAlreadyExist(err):
163170
ctx.Data["Err_RepoName"] = true
164171
ctx.RenderWithErr(ctx.Tr("form.repo_name_been_taken"), tpl, form)

Diff for: routers/web/repo/setting.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,12 @@ func SettingsPost(ctx *context.Context) {
533533
}
534534

535535
if !ctx.Repo.Owner.CanCreateRepo() {
536-
ctx.Flash.Error(ctx.Tr("repo.form.reach_limit_of_creation", ctx.User.MaxCreationLimit()))
536+
maxCreationLimit := ctx.Repo.Owner.MaxCreationLimit()
537+
if maxCreationLimit == 1 {
538+
ctx.Flash.Error(ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit))
539+
} else {
540+
ctx.Flash.Error(ctx.Tr("repo.form.reach_limit_of_creation_n", maxCreationLimit))
541+
}
537542
ctx.Redirect(repo.Link() + "/settings")
538543
return
539544
}

0 commit comments

Comments
 (0)