Git Mailing List Archive mirror
 help / color / mirror / Atom feed
* [PATCH] i18n: Enable percentage l10n for more strings
@ 2023-05-16 10:19 Emir SARI
  2023-06-02 19:36 ` Emir SARI
  0 siblings, 1 reply; 2+ messages in thread
From: Emir SARI @ 2023-05-16 10:19 UTC (permalink / raw)
  To: git; +Cc: Emir SARI

This enables percentage localization in more progress views, and
provides a more cohesive l10n environment among the translated messages.
---
 apply.c    |  8 ++++----
 progress.c | 18 ++++++++++++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/apply.c b/apply.c
index 6212ab3..3e1d08d 100644
--- a/apply.c
+++ b/apply.c
@@ -4247,11 +4247,11 @@ static void show_rename_copy(struct patch *p)
 	 * new_name through the end of names are renames
 	 */
 	if (old_name != p->old_name)
-		printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
+		printf(_(" %s %.*s{%s => %s} (%d%%)\n"), renamecopy,
 		       (int)(old_name - p->old_name), p->old_name,
 		       old_name, new_name, p->score);
 	else
-		printf(" %s %s => %s (%d%%)\n", renamecopy,
+		printf(_(" %s %s => %s (%d%%)\n"), renamecopy,
 		       p->old_name, p->new_name, p->score);
 	show_mode_change(p, 0);
 }
@@ -4270,8 +4270,8 @@ static void summary_patch_list(struct patch *patch)
 				show_rename_copy(p);
 			else {
 				if (p->score) {
-					printf(" rewrite %s (%d%%)\n",
-					       p->new_name, p->score);
+					printf(" rewrite %s ", p->new_name);
+					printf(_("(%d%%)\n"), p->score);
 					show_mode_change(p, 0);
 				}
 				else
diff --git a/progress.c b/progress.c
index f695798..1f8d372 100644
--- a/progress.c
+++ b/progress.c
@@ -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) {
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i18n: Enable percentage l10n for more strings
  2023-05-16 10:19 [PATCH] i18n: Enable percentage l10n for more strings Emir SARI
@ 2023-06-02 19:36 ` Emir SARI
  0 siblings, 0 replies; 2+ messages in thread
From: Emir SARI @ 2023-06-02 19:36 UTC (permalink / raw)
  To: git

Hello,

Ping, in case this got buried down the list.

> Emir SARI <emir_sari@icloud.com> şunları yazdı (16 May 2023 13:19):
> 
> This enables percentage localization in more progress views, and
> provides a more cohesive l10n environment among the translated messages.
> ---
> apply.c    |  8 ++++----
> progress.c | 18 ++++++++++++++++--
> 2 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/apply.c b/apply.c
> index 6212ab3..3e1d08d 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -4247,11 +4247,11 @@ static void show_rename_copy(struct patch *p)
> * new_name through the end of names are renames
> */
> if (old_name != p->old_name)
> - printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
> + printf(_(" %s %.*s{%s => %s} (%d%%)\n"), renamecopy,
>       (int)(old_name - p->old_name), p->old_name,
>       old_name, new_name, p->score);
> else
> - printf(" %s %s => %s (%d%%)\n", renamecopy,
> + printf(_(" %s %s => %s (%d%%)\n"), renamecopy,
>       p->old_name, p->new_name, p->score);
> show_mode_change(p, 0);
> }
> @@ -4270,8 +4270,8 @@ static void summary_patch_list(struct patch *patch)
> show_rename_copy(p);
> else {
> if (p->score) {
> - printf(" rewrite %s (%d%%)\n",
> -       p->new_name, p->score);
> + printf(" rewrite %s ", p->new_name);
> + printf(_("(%d%%)\n"), p->score);
> show_mode_change(p, 0);
> }
> else
> diff --git a/progress.c b/progress.c
> index f695798..1f8d372 100644
> --- a/progress.c
> +++ b/progress.c
> @@ -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) {
> -- 
> 2.40.1
> 

Best regards,
Emir (𐰽𐰺𐰍)

** E-mail needs to stay simple
** Use plain text e-mail


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-02 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-16 10:19 [PATCH] i18n: Enable percentage l10n for more strings Emir SARI
2023-06-02 19:36 ` Emir SARI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).