From 2fff6c255d3654c2aed02e8380b6f3d363948c6b Mon Sep 17 00:00:00 2001
From: 0ko <0ko@noreply.codeberg.org>
Date: Thu, 4 Apr 2024 19:16:00 +0500
Subject: [PATCH] [I18N] Provide plural support for release download count

Following https://codeberg.org/forgejo/forgejo/pulls/2899 and my review

See https://codeberg.org/forgejo/forgejo/pulls/3031#issuecomment-1733158 for why older strings were dropped
---
 options/locale/locale_en-US.ini  | 3 ++-
 templates/repo/release/list.tmpl | 2 +-
 templates/repo/release/new.tmpl  | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 56a866bae5..dc03ebc8d4 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -2635,7 +2635,8 @@ release.tag_name_invalid = The tag name is not valid.
 release.tag_name_protected = The tag name is protected.
 release.tag_already_exist = This tag name already exists.
 release.downloads = Downloads
-release.download_count = %s downloads
+release.download_count_one = %s download
+release.download_count_few = %s downloads
 release.add_tag_msg = Use the title and content of release as tag message.
 release.add_tag = Create Tag Only
 release.releases_for = Releases for %s
diff --git a/templates/repo/release/list.tmpl b/templates/repo/release/list.tmpl
index ba5cea0729..f1e6ffda9e 100644
--- a/templates/repo/release/list.tmpl
+++ b/templates/repo/release/list.tmpl
@@ -89,7 +89,7 @@
 											<strong>{{svg "octicon-package" 16 "tw-mr-1"}}{{.Name}}</strong>
 										</a>
 										<div>
-											<span class="text grey">{{ctx.Locale.Tr "repo.release.download_count" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span>
+											<span class="text grey">{{ctx.Locale.TrN .DownloadCount "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span>
 										</div>
 									</li>
 								{{end}}
diff --git a/templates/repo/release/new.tmpl b/templates/repo/release/new.tmpl
index b5f4535b1b..425cc2c87a 100644
--- a/templates/repo/release/new.tmpl
+++ b/templates/repo/release/new.tmpl
@@ -64,7 +64,7 @@
 						<div class="flex-text-inline tw-flex-1">
 							<input name="attachment-edit-{{.UUID}}"  class="attachment_edit" required value="{{.Name}}">
 							<input name="attachment-del-{{.UUID}}" type="hidden" value="false">
-							<span class="ui text grey tw-whitespace-nowrap">{{ctx.Locale.Tr "repo.release.download_count" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span>
+							<span class="ui text grey tw-whitespace-nowrap">{{ctx.Locale.TrN .DownloadCount "repo.release.download_count_one" "repo.release.download_count_few" (ctx.Locale.PrettyNumber .DownloadCount)}} · {{.Size | ctx.Locale.TrSize}}</span>
 						</div>
 						<a class="ui mini compact red button remove-rel-attach" data-id="{{.ID}}" data-uuid="{{.UUID}}">
 							{{ctx.Locale.Tr "remove"}}