From af7054511efdf1e0b36bd9e8c5744bce6ea1a5b9 Mon Sep 17 00:00:00 2001 From: EV3R4 <63237520+EV3R4@users.noreply.github.com> Date: Fri, 22 Jan 2021 00:44:37 +0100 Subject: [PATCH] Add TrN for repository limit (#12492) * Added TrN for repository limit * Removed form.reach_limit_of_creation_0 * disable Create Button if user can not create Co-authored-by: 6543 <6543@obermui.de> --- options/locale/locale_en-US.ini | 3 ++- routers/repo/repo.go | 9 ++++----- templates/repo/create.tmpl | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 69cfb2904..53cee057c 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -741,7 +741,8 @@ archive.title = This repo is archived. You can view files and clone it, but cann archive.issue.nocomment = This repo is archived. You cannot comment on issues. archive.pull.nocomment = This repo is archived. You cannot comment on pull requests. -form.reach_limit_of_creation = You have already reached your limit of %d repositories. +form.reach_limit_of_creation_1 = You have already reached your limit of %d repository. +form.reach_limit_of_creation_n = You have already reached your limit of %d repositories. form.name_reserved = The repository name '%s' is reserved. form.name_pattern_not_allowed = The pattern '%s' is not allowed in a repository name. diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 2614389aa..3832b8997 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -144,11 +144,10 @@ func Create(ctx *context.Context) { } } - if !ctx.User.CanCreateRepo() { - ctx.RenderWithErr(ctx.Tr("repo.form.reach_limit_of_creation", ctx.User.MaxCreationLimit()), tplCreate, nil) - } else { - ctx.HTML(200, tplCreate) - } + ctx.Data["CanCreateRepo"] = ctx.User.CanCreateRepo() + ctx.Data["MaxCreationLimit"] = ctx.User.MaxCreationLimit() + + ctx.HTML(200, tplCreate) } func handleCreateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form interface{}) { diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 7d71043c3..ad795387d 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -9,6 +9,11 @@
{{template "base/alert" .}} + {{if not .CanCreateRepo}} +
+

{{.i18n.Tr (TrN .i18n.Lang .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n") .MaxCreationLimit}}

+
+ {{end}}