Subject: Re: Feature Request - Better i18n support

From: Junio C Hamano <[email-masked]>
Date: Thu, 09 Mar 2023 14:16:14 -0800

Emir SARI <[email-masked]> writes:

> For instance, in Turkish (and in French AFAIK), percentages are indicated
> in different formats. In Turkish it precedes the number like %54. However,
> all the percentages use the standard 54%. By marking these as translatable,
> we could easily provide the correct formats.

Interesting.  Let's take a look to see how bad it is.

$ git grep '[fd]%%' \*.[ch] ':!compat/' ':!t/'
apply.c:		printf(" %s %.*s{%s => %s} (%d%%)\n", renamecopy,
apply.c:		printf(" %s %s => %s (%d%%)\n", renamecopy,
apply.c:					printf(" rewrite %s (%d%%)\n",

These are currently not even marked with _() to be translatable, and
it should be just the matter of enclosing them in _().

If these should be translated in the first place, that is.  I do not
think these are originally meant to be machine parseable (it is
shown as part of "git apply --summary"), but existing users may
already be abusing them as such.

diff.c:				fprintf(opt->file, "%s%4d.%01d%% %.*s\n", line_prefix,

This is part of "git diff --dirstat" output.  I do not think it
should be translated, even though it probably is not machine
parseable.

diff.c:		strbuf_addf(msg, "%s%ssimilarity index %d%%",
diff.c:		strbuf_addf(msg, "%s%ssimilarity index %d%%",
diff.c:			strbuf_addf(msg, "%s%sdissimilarity index %d%%%s\n",
diff.c:	strbuf_addf(&sb, " %s %s (%d%%)\n",

These are part of the extended diff headers (e.g. "rename A to B
with similarity index of X%") that are very much designed to be
machine parseable, and cannot be touched.

diff.c:			strbuf_addf(&sb, " (%d%%)\n", similarity_index(p));

This is part of "git diff --summary" to show "rewrite", similarly to
"rename" and "copy" that we saw earlier.

wt-status.c:				_("You are in a sparse checkout with %d%% of tracked files present."),

This is already marked _(translatable) and your l10n files should be
able to do "%d%%" -> "%%%d" as needed.