From ca7d1c6f78bce9d9be1d1d5e763aa295fcdfc717 Mon Sep 17 00:00:00 2001 From: erik Date: Mon, 25 Mar 2024 16:30:02 +0100 Subject: [PATCH] Localize error messages --- models/repo/repo_repository.go | 2 ++ options/locale/locale_de-DE.ini | 2 ++ options/locale/locale_en-US.ini | 3 +++ routers/web/repo/setting/setting.go | 7 ++++--- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/models/repo/repo_repository.go b/models/repo/repo_repository.go index 756b223c14..2fb5f7484b 100644 --- a/models/repo/repo_repository.go +++ b/models/repo/repo_repository.go @@ -15,6 +15,7 @@ func init() { db.RegisterModel(new(FederatedRepo)) } +// ToDo: Validate before returning func FindFederatedRepoByRepoID(ctx context.Context, repoId int64) ([]*FederatedRepo, error) { maxFederatedRepos := 10 sess := db.GetEngine(ctx).Where("repo_id=?", repoId) @@ -23,6 +24,7 @@ func FindFederatedRepoByRepoID(ctx context.Context, repoId int64) ([]*FederatedR return federatedRepoList, sess.Find(&federatedRepoList) } +// ToDo: Name this ...repos func UpdateFederatedRepo(ctx context.Context, localRepoId int64, federatedRepoList []*FederatedRepo) error { for _, federatedRepo := range federatedRepoList { if res, err := validation.IsValid(*federatedRepo); !res { diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini index 15bb4a4f5c..4b4f27b84f 100644 --- a/options/locale/locale_de-DE.ini +++ b/options/locale/locale_de-DE.ini @@ -1064,6 +1064,7 @@ form.reach_limit_of_creation_1=Du hast bereits dein Limit von %d Repository erre form.reach_limit_of_creation_n=Du hast bereits dein Limit von %d Repositories erreicht. form.name_reserved=Der Repository-Name "%s" ist reserviert. form.name_pattern_not_allowed=Das Muster "%s" ist in Repository-Namen nicht erlaubt. +form.string_too_long=Der angegebene String ist länger als %d Zeichen. need_auth=Authentifizierung migrate_options=Migrationsoptionen @@ -1993,6 +1994,7 @@ settings.githooks=Git-Hooks settings.basic_settings=Grundeinstellungen settings.federation_settings=Föderationseinstellungen settings.federation_labelname_repo=URLs der föderierten Repositories. Getrennt mittels ";", keine Leerzeichen. +settings.federation_not_enabled=Föderierung ist auf deiner Instanz nicht aktiviert. settings.mirror_settings=Mirror-Einstellungen settings.mirror_settings.docs=Richte Dein Repository so ein, dass es automatisch Commits, Tags und Branches mit einem anderen Repository synchronisieren kann. settings.mirror_settings.docs.disabled_pull_mirror.instructions=Richte Dein Projekt so ein, dass es automatisch Commits, Tags und Branches in ein anderes Repository pusht. Pull-Mirrors wurden von Deinem Website-Administrator deaktiviert. diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 7a42b4d1e1..6fdda4238b 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1096,6 +1096,8 @@ form.reach_limit_of_creation_1 = The owner has already reached the limit of %d r form.reach_limit_of_creation_n = The owner has already reached the 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. +form.string_too_long=The given string is longer than %d characters. + need_auth = Authorization migrate_options = Migration Options @@ -2044,6 +2046,7 @@ settings.githooks = Git Hooks settings.basic_settings = Basic Settings settings.federation_settings=Federation Settings settings.federation_labelname_repo=URLs of Federated Repositories. Separated by ";", no whitespace. +settings.federation_not_enabled=Federation is not enabled on your instance. settings.mirror_settings = Mirror Settings settings.mirror_settings.docs = Set up your repository to automatically synchronize commits, tags and branches with another repository. settings.mirror_settings.docs.disabled_pull_mirror.instructions = Set up your project to automatically push commits, tags and branches to another repository. Pull mirrors have been disabled by your site administrator. diff --git a/routers/web/repo/setting/setting.go b/routers/web/repo/setting/setting.go index f7e6568cc3..de69f45d1d 100644 --- a/routers/web/repo/setting/setting.go +++ b/routers/web/repo/setting/setting.go @@ -189,16 +189,17 @@ func SettingsPost(ctx *context.Context) { case "federation": if !setting.Federation.Enabled { ctx.NotFound("", nil) - ctx.Flash.Info("Federation Not enabled") + ctx.Flash.Info(ctx.Tr("repo.settings.federation_not_enabled")) return } federationRepos := form.FederationRepos - errs := validation.ValidateMaxLen(federationRepos, 2048, "federationRepos") + maxFederatedRepoStrLength := 2048 + errs := validation.ValidateMaxLen(federationRepos, maxFederatedRepoStrLength, "federationRepos") if len(errs) > 0 { ctx.Data["ERR_FederationRepos"] = true - ctx.Flash.Error("The given string was larger than 2048 bytes") + ctx.Flash.Error(ctx.Tr("repo.form.string_too_long", maxFederatedRepoStrLength)) ctx.Redirect(repo.Link() + "/settings") return }