Skip to contentSkip to conversation

i18n: Enable percentage l10n for more strings

PATCH New Emir SARI 1 participant 1 message Jun 23, 2023

lore
Share & tools
lore

Emir SARI

author
#0 lore raw

PATCH v2 1/1 i18n: Enable percentage l10n for more strings

This enables percentage localization in more progress views, and provides a more cohesive l10n environment among the translated messages.

---
 progress.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
progress.c +16 -2
index f695798aca..1f8d372284 100644
@@ -124,10 +124,24 @@ static void display(struct progress *progress, uint64_t n, const char *done)
 			progress->last_percent = percent;
 
 			strbuf_reset(counters_sb);
-			strbuf_addf(counters_sb,
-				    "%3u%% (%"PRIuMAX"/%"PRIuMAX")%s", percent,
+
+			struct strbuf progress_sb = STRBUF_INIT;
+			strbuf_addf(&progress_sb,
+				_("%u%% (%"PRIuMAX"/%"PRIuMAX")%s"), percent,
 				    (uintmax_t)n, (uintmax_t)progress->total,
 				    tp);
+			struct strbuf progress_str = STRBUF_INIT;
+			strbuf_addstr(&progress_str, progress_sb.buf);
+			strbuf_release(&progress_sb);
+
+			if (percent < 10)
+			    strbuf_insert(&progress_str, 0, "  ", 2);
+			else if (percent < 100)
+			    strbuf_insert(&progress_str, 0, " ", 1);
+
+			strbuf_addf(counters_sb, "%s", progress_str.buf);
+			strbuf_release(&progress_str);
+
 			show_update = 1;
 		}
 	} else if (progress_update) {
Signature · 1 line
2.41.0