# Re: broken strings in localization (was: How to run git-gui always in English?)

3 messages from 2007-10-30 to 2007-10-30. Participants: Christian Stimming, Johannes Schindelin.
Thread: https://gitlist.dev/t/10525

## Christian Stimming, 2007-10-30 10:16

Subject: Re: broken strings in localization (was: How to run git-gui always in English?)
Message-ID: <20071030111626.0mbeh417tw4wos0s@webmail.tu-harburg.de>
URL: https://gitlist.dev/e/20071030111626.0mbeh417tw4wos0s%40webmail.tu-harburg.de

```
Steffen Prohaska wrote:
> And it's even worse. An error in the localization can completely
> break git-gui. Apparently the German localization included in
> msysgit's Git-1.5.3-preview20071019.exe _is_ broken (see
> attached png).
>
> Shouldn't the localization code be a bit more fault tolerant?

Thanks for this error description. However, this isn't a fault of the  
localization per se; rather, it's a bad side-effects of git-gui using  
its own script po2msg.sh instead of gettext's msgfmt to prepare  
translations for inclusion in the program - and additionally the fact  
that this po2msg.sh script is used by the creator of the setup.exe,  
whereas the translators use msgfmt which will not exhibit this error.

Here's what happened: The program code changed from using the string  
"Prune from %s" to "Prune from" (just like program code changes  
often). Before, the translation had a translation like this:

msgid "Prune from %s"
msgstr "Abschneiden von %s"

or similar, in any case with the including "%s". After the string  
changed in the program, the next update of the translation file will  
record the fact that the original string changed by changing the  
translation like this:

#, fuzzy
msgid "Prune from"
msgstr "Abschneiden von %s"

Note that the msgstr-translation has not been changed yet - this can  
only be done by a human. For that reason, the update inserted the  
"fuzzy" marker. Here's where the error came in: All strings marked as  
"fuzzy" MUST NOT BE USED by msgfmt! And git-gui's script po2msg.sh  
doesn't adhere to this rule. Boo, that's why such erroneous  
translations made it into the msgcat catalog.

In other words: The tcl msgcat procedure is the wrong end to deal with  
that problem. Instead, those string argument checks should be done  
when "compiling" the foo.po files into the foo.msg files. And that's  
precisely what the msgfmt program is for: It correctly ignores all  
"fuzzy" strings and it additionally checks the %s et al string formats  
for correct translation (when used with the "-c" switch, as the  
"shift-V" command in emacs po-mode or any other po file editor will  
use).

@Dscho: That's why I'm rather unhappy with the addition of the  
po2msg.sh script. Not adhering to the "fuzzy" marker is clearly a bug  
and needs to be fixed there, but additionally you lose all format  
checking that msgfmt gives to you. Syntax errors in the translator's  
foo.po file should really be dealt with at msgfmt compile time, not  
later at runtime. That's the whole point of that compile step.

Regards,

Christian

```

## Johannes Schindelin, 2007-10-30 10:45

Subject: Re: broken strings in localization (was: How to run git-gui always in English?)
Message-ID: <Pine.LNX.4.64.0710301040490.4362@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0710301040490.4362%40racer.site
In-Reply-To: <20071030111626.0mbeh417tw4wos0s@webmail.tu-harburg.de>

```
Hi,

On Tue, 30 Oct 2007, Christian Stimming wrote:

> Note that the msgstr-translation has not been changed yet - this can 
> only be done by a human. For that reason, the update inserted the 
> "fuzzy" marker. Here's where the error came in: All strings marked as 
> "fuzzy" MUST NOT BE USED by msgfmt! And git-gui's script po2msg.sh 
> doesn't adhere to this rule. Boo, that's why such erroneous translations 
> made it into the msgcat catalog.

My bad.  I thought I handled that, but obviously I did not.  Will fix.

Ciao,
Dscho

```

## Christian Stimming, 2007-10-30 12:59

Subject: Re: broken strings in localization (was: How to run git-gui always in English?)
Message-ID: <20071030135913.h0c6jdn2xw8w0ccs@webmail.tu-harburg.de>
URL: https://gitlist.dev/e/20071030135913.h0c6jdn2xw8w0ccs%40webmail.tu-harburg.de
In-Reply-To: <Pine.LNX.4.64.0710301040490.4362@racer.site>

```
Quoting Johannes Schindelin <Johannes.Schindelin@gmx.de>:
>> Note that the msgstr-translation has not been changed yet - this can
>> only be done by a human. For that reason, the update inserted the
>> "fuzzy" marker. Here's where the error came in: All strings marked as
>> "fuzzy" MUST NOT BE USED by msgfmt! And git-gui's script po2msg.sh
>> doesn't adhere to this rule. Boo, that's why such erroneous translations
>> made it into the msgcat catalog.
>
> My bad.  I thought I handled that, but obviously I did not.  Will fix.

Patch looks good.

Note that "msgfmt" with the "-c" option still does more checking and  
should probably be enabled by default. Currently I can use the "-c"  
option by running make MSGFMT="msgfmt -c". We can just call msgfmt  
always with the option -c (it was added in gettext-0.10.35 in 1998) so  
that Shawn or everyone else gets immediate notice if there is a format  
string problem in the file.

@nanako3: In particular, with the current git-gui.git master msgfmt  
will complain about an error in ja.po, which is a rather tricky one.  
(All the rest is fine.) The fix looks as follows (ignoring the  
non-european characters):

diff --git a/po/ja.po b/po/ja.po
index f65e460..2713c9e 100644
--- a/po/ja.po
+++ b/po/ja.po
@@ -1781,3 +1781,3 @@ msgstr "??????????:"
  msgid "%s ... %*i of %*i %s (%3i%%)"
-msgstr "%1$s ... %3$*i %4$s ?? %$2*i (%5$3i%%)"
+msgstr "%1$s ... %4$*i %6$s ?? %2$*i (%7$3i%%)"

Two errors: The easy one #1 is the confused '$' and '2' - the format  
string in the middle should start with '%2$'. The difficult one #2 is  
that one has to know that a format specification with a '*' (asterisk)  
suddenly refers to *two* arguments instead of one, hence the suceeding  
argument number is two higher instead of one. This way, the argument  
numbers count up to 7.

Regards,

Christian

```
