From 01a862292c42a4024f35b46e3fd2413c3e7692cc Mon Sep 17 00:00:00 2001 From: EV3R4 Date: Wed, 23 Sep 2020 16:09:42 +0200 Subject: [PATCH 1/4] Added TrN for repository limit --- options/locale/locale_en-US.ini | 4 +++- routers/repo/repo.go | 9 ++++----- templates/repo/create.tmpl | 6 +++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index ea76d4cb6a7c5..7b7c43813fd87 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -706,7 +706,9 @@ 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_0 = You have are not allowed to create 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 4a088ff9cd111..bba55bc4e2fd4 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -146,11 +146,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 d5c540724b515..53aca11f7e72b 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -8,7 +8,11 @@ {{.i18n.Tr "new_repo"}}
- {{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}}