git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFC v4 1/7] Add infrastructure for translating Git with gettext

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jun 2, 2010, 09:29 UTC
Message-ID
<AANLkTilClUTkrpnMhBTlcBZC-r2OemT4m22bDnc6fRPy@mail.gmail.com>
In-Reply-To
<alpine.DEB.2.00.1006021006590.23247@ds9.cixit.se>
On Wed, Jun 2, 2010 at 09:12, Peter Krefting <peter@softwolves.pp.se> wrote:
Show 74 quoted lines
> Ævar Arnfjörð Bjarmason:
>
>> +               color_fprintf_ln(s->fp, c, _("#   (use \"git rm --cached
>> <file>...\" to unstage)"));
>> +       color_fprintf_ln(s->fp, c, _("#   (use \"git add/rm <file>...\" as
>> appropriate to mark resolution)"));
>> +       color_fprintf_ln(s->fp, c, _("#"));
>
> This is a multi-line string, and should be translated as such.
>
> The trailing "#" should either be part of the translated multi-line string,
> or be added explicitely, and untranslated, at the end.
>
>> +               color_fprintf_ln(s->fp, c, _("#   (use \"git rm --cached
>> <file>...\" to unstage)"));
>> +       color_fprintf_ln(s->fp, c, _("#"));
>
> Determine how to handle the trailing "#" as above.
>
>> +               color_fprintf_ln(s->fp, c, _("#   (use \"git add/rm
>> <file>...\" to update what will be committed)"));
>> +       color_fprintf_ln(s->fp, c, _("#   (use \"git checkout --
>> <file>...\" to discard changes in working directory)"));
>
> Multi-line.
>
>> +               color_fprintf_ln(s->fp, c, _("#   (commit or discard the
>> untracked or modified content in submodules)"));
>> +       color_fprintf_ln(s->fp, c, _("#"));
>
> Trailing "#".
>
>> +       color_fprintf_ln(s->fp, c, _("#   (use \"git %s <file>...\" to
>> include in what will be committed)"), how);
>> +       color_fprintf_ln(s->fp, c, _("#"));
>
> Ditto.
>
>> +       case 1: how = _("both deleted:"); break;
>> +       case 2: how = _("added by us:"); break;
>> +       case 3: how = _("deleted by them:"); break;
>> +       case 4: how = _("added by them:"); break;
>> +       case 5: how = _("deleted by us:"); break;
>> +       case 6: how = _("both added:"); break;
>> +       case 7: how = _("both modified:"); break;
>>        }
>> -       color_fprintf(s->fp, c, "%-20s%s\n", how, one);
>> +       color_fprintf(s->fp, c, _("%-20s%s\n"), how, one);
>
> does color_fprintf() gracefully handle cutting text for multi-byte
> encodings, and text width? Otherwise I can see this bite us for all
> non-ASCII locales in general (if long translated are needed), and for CJK
> locales in particular (for variable character widths).
>
>> -               color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "%s",
>> extra.buf);
>> +               color_fprintf(s->fp, color(WT_STATUS_HEADER, s), _("%s"),
>> extra.buf);
>
> Should not be in _()
>
>> -       fprintf(s->fp, "\n");
>> +       fprintf(s->fp, _("\n"));
>
> Ditto.
>
>> +               color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
>> _("#"));
>> +               color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s), _("#
>> Initial commit"));
>> +               color_fprintf_ln(s->fp, color(WT_STATUS_HEADER, s),
>> _("#"));
>
> Either a multi-line string, or untranslate the "#"s.

All of the points you raised are correct. This is a bad way to do things.

It was added in Jeff in his original WIP patch as an example of translation being possible, but I should just remove it. It's not ready to go in for the reasons you cited.

I'll just remove the wt-status.c chunk out of the patch completely in the next submission, and instead translate a few select strings in some C program well.

Making things like wt-status.c translatable is going to be hard to do properly. It uses a lot of lego (sticking strings incrementally together), and due to the coloring of output this'll be particularly hard to convert.

(Also, for reference, here's a general guide on how to translate C programs well):

    http://gnu.april.org/software/automake/manual/gettext/Preparing-Strings.html
Previous: Peter KreftingNext: Peter Krefting
Message 32 of 56 in “Add internationalization support to Git”
  1. 0/5 Add internationalization support to GitÆvar Arnfjörð Bjarmason, May 29, 2010
  2. 1/5 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, May 29, 2010
  3. 2/5 gitignore: Ignore files generated by gettextÆvar Arnfjörð Bjarmason, May 29, 2010
  4. 3/5 Makefile: Remove Gettext files on make cleanÆvar Arnfjörð Bjarmason, May 29, 2010
  5. 4/5 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, May 29, 2010
  6. 5/5 Add infrastructure to make shellscripts translatableÆvar Arnfjörð Bjarmason, May 29, 2010
  7. Jonathan NiederMay 30, 2010
  8. Ævar Arnfjörð BjarmasonMay 30, 2010
  9. Jonathan NiederMay 30, 2010
  10. Ævar Arnfjörð BjarmasonMay 31, 2010
  11. 0/6 Add internationalization support to GitÆvar Arnfjörð Bjarmason, May 30, 2010
  12. 1/6 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, May 30, 2010
  13. Jakub NarebskiJun 1, 2010
  14. autoconf: Check if <libintl.h> exists and set NO_GETTEXTÆvar Arnfjörð Bjarmason, Jun 1, 2010
  15. Jakub NarebskiJun 1, 2010
  16. 2/6 gitignore: Ignore files generated by gettextÆvar Arnfjörð Bjarmason, May 30, 2010
  17. 3/6 Makefile: Remove Gettext files on make cleanÆvar Arnfjörð Bjarmason, May 30, 2010
  18. 4/6 gettext: Add a Gettext interface for shell scriptsÆvar Arnfjörð Bjarmason, May 30, 2010
  19. 5/6 gettext: Add a Gettext interface for PerlÆvar Arnfjörð Bjarmason, May 30, 2010
  20. Jakub NarebskiJun 1, 2010
  21. Ævar Arnfjörð BjarmasonJun 1, 2010
  22. Jakub NarebskiJun 2, 2010
  23. 6/6 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, May 30, 2010
  24. Jonathan NiederMay 30, 2010
  25. Jonathan NiederMay 30, 2010
  26. Ævar Arnfjörð BjarmasonMay 31, 2010
  27. 0/7 Add internationalization support to GitÆvar Arnfjörð Bjarmason, Jun 1, 2010
  28. Ævar Arnfjörð BjarmasonJun 2, 2010
  29. 0/7 Add internationalization support to GitÆvar Arnfjörð Bjarmason, Jun 2, 2010
  30. 1/7 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 2, 2010
  31. Peter KreftingJun 2, 2010
  32. Ævar Arnfjörð BjarmasonJun 2, 2010
  33. Peter KreftingJun 2, 2010
  34. Ævar Arnfjörð BjarmasonJun 2, 2010
  35. Peter KreftingJun 2, 2010
  36. 2/7 gettext: Add a Gettext interface for shell scriptsÆvar Arnfjörð Bjarmason, Jun 2, 2010
  37. 3/7 gettext: Add a Gettext interface for PerlÆvar Arnfjörð Bjarmason, Jun 2, 2010
  38. 4/7 Makefile: Don't install Gettext .mo files if NO_GETTEXTÆvar Arnfjörð Bjarmason, Jun 2, 2010
  39. 5/7 Makefile: Override --keyword= for all languagesÆvar Arnfjörð Bjarmason, Jun 2, 2010
  40. 6/7 gettext: Sanity tests for Git's Gettext supportÆvar Arnfjörð Bjarmason, Jun 2, 2010
  41. 7/7 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, Jun 2, 2010
  42. Johannes SixtJun 2, 2010
  43. 0/2 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 2, 2010
  44. 1/2 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 2, 2010
  45. 2/2 Add initial C, Shell and Perl gettext translationsÆvar Arnfjörð Bjarmason, Jun 2, 2010
  46. 1/7 Add infrastructure for translating Git with gettextÆvar Arnfjörð Bjarmason, Jun 1, 2010
  47. 2/7 gettext: Add a Gettext interface for shell scriptsÆvar Arnfjörð Bjarmason, Jun 1, 2010
  48. Johannes SixtJun 2, 2010
  49. Ævar Arnfjörð BjarmasonJun 2, 2010
  50. Johannes SixtJun 2, 2010
  51. 3/7 gettext: Add a Gettext interface for PerlÆvar Arnfjörð Bjarmason, Jun 1, 2010
  52. 4/7 Makefile: Don't install Gettext .mo files if NO_GETTEXTÆvar Arnfjörð Bjarmason, Jun 1, 2010
  53. 5/7 Makefile: Override --keyword= for all languagesÆvar Arnfjörð Bjarmason, Jun 1, 2010
  54. 6/7 gettext: Basic sanity tests for Git's Gettext supportÆvar Arnfjörð Bjarmason, Jun 1, 2010
  55. Johannes SixtJun 2, 2010
  56. 7/7 gettext: Add a skeleton po/is.poÆvar Arnfjörð Bjarmason, Jun 1, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.