Unify and simplify TrN for i18n (#18141)
Refer: https://github.com/go-gitea/gitea/pull/18135#issuecomment-1003246099 Now we have a unique and simple `TrN`, and make the fix of PR #18135 also use the better `TrN` logic.
This commit is contained in:
parent
88da7a7174
commit
e61b390d54
19 changed files with 148 additions and 136 deletions
|
@ -81,13 +81,8 @@ func handleMigrateError(ctx *context.Context, owner *user_model.User, err error,
|
|||
case migrations.IsTwoFactorAuthError(err):
|
||||
ctx.RenderWithErr(ctx.Tr("form.2fa_auth_required"), tpl, form)
|
||||
case repo_model.IsErrReachLimitOfRepo(err):
|
||||
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)
|
||||
}
|
||||
msg := ctx.TrN(maxCreationLimit, "repo.form.reach_limit_of_creation_1", "repo.form.reach_limit_of_creation_n", maxCreationLimit)
|
||||
ctx.RenderWithErr(msg, tpl, form)
|
||||
case repo_model.IsErrRepoAlreadyExist(err):
|
||||
ctx.Data["Err_RepoName"] = true
|
||||
|
|
|
@ -162,13 +162,8 @@ func Create(ctx *context.Context) {
|
|||
func handleCreateError(ctx *context.Context, owner *user_model.User, err error, name string, tpl base.TplName, form interface{}) {
|
||||
switch {
|
||||
case repo_model.IsErrReachLimitOfRepo(err):
|
||||
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)
|
||||
}
|
||||
msg := ctx.TrN(maxCreationLimit, "repo.form.reach_limit_of_creation_1", "repo.form.reach_limit_of_creation_n", maxCreationLimit)
|
||||
ctx.RenderWithErr(msg, tpl, form)
|
||||
case repo_model.IsErrRepoAlreadyExist(err):
|
||||
ctx.Data["Err_RepoName"] = true
|
||||
|
|
|
@ -610,11 +610,8 @@ func SettingsPost(ctx *context.Context) {
|
|||
|
||||
if !ctx.Repo.Owner.CanCreateRepo() {
|
||||
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))
|
||||
}
|
||||
msg := ctx.TrN(maxCreationLimit, "repo.form.reach_limit_of_creation_1", "repo.form.reach_limit_of_creation_n", maxCreationLimit)
|
||||
ctx.Flash.Error(msg)
|
||||
ctx.Redirect(repo.Link() + "/settings")
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue