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

[PATCH 2/5] gettext docs: add "Marking strings for translation" section in po/README

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 10, 2010, 19:35 UTC
Message-ID
<1284147353-18000-3-git-send-email-avarab@gmail.com>
In-Reply-To
<AANLkTikdHZFmXAdABvS9hPXtbXNJU5NdCOrw5_KP73bX@mail.gmail.com>

Add a "Marking strings for translation" section to po/README and mention it in Documentation/CodingGuidelines.

This section documents how the maintainers of Git's source code should go about properly marking strings for translation.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 Documentation/CodingGuidelines |    7 ++++++
 po/README                      |   41 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index b8bf618..2e114d6 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -70,6 +70,10 @@ For shell scripts specifically (not exhaustive):
      are ERE elements not BRE (note that \? and \+ are not even part
      of BRE -- making them accessible from BRE is a GNU extension).
 
+ - Use Git's gettext wrappers in git-sh-i18n to make the user
+   interface translatable. See "Marking strings for translation" in
+   po/README.
+
 For C programs:
 
  - We use tabs to indent, and interpret tabs as taking up to
@@ -132,3 +136,6 @@ For C programs:
 
  - When we pass <string, length> pair to functions, we should try to
    pass them in that order.
+
+ - Use Git's gettext wrappers to make the user interface
+   translatable. See "Marking strings for translation" in po/README.
diff --git a/po/README b/po/README
index 4d23ca6..372cb9c 100644
--- a/po/README
+++ b/po/README
@@ -2,7 +2,8 @@ Core GIT Translations
 =====================
 
 This directory holds the translations for the core of Git. This
-document describes how to add to and maintain these translations.
+document describes how to add to and maintain these translations, and
+how to mark source strings for translation.
 
 
 Generating a .pot file
@@ -80,3 +81,41 @@ changed PO file with `msgfmt --check`, the --check option flags many
 common errors, e.g. missing printf format strings, or translated
 messages that deviate from the originals in whether they begin/end
 with a newline or not.
+
+
+Marking strings for translation
+-------------------------------
+
+Before strings can be translated they first have to be marked for
+translation.
+
+Git uses an internationalization interface that wraps the system's
+gettext library, so most of the advice in your gettext documentation
+(on GNU systems `info gettext` in a terminal) applies.
+
+General advice:
+
+ - Don't mark everything for translation, only strings which will be
+   read by humans (the porcelain interface) should be translated.
+
+   The output from Git's plumbing utilities will primarily be read by
+   programs and would break scripts under non-C locales. These strings
+   should not be translated.
+
+ - Adjust the strings so that they're easy to translate. Most of the
+   advice in `info '(gettext)Preparing Strings'` applies here.
+
+ - If something is unclear or ambiguous you can use a "TRANSLATORS"
+   comment to tell the translators what to make of it. These will be
+   extracted by xgettext(1) and put in the po/*.po files, e.g. from
+   git-am.sh:
+
+       # TRANSLATORS: Make sure to include [y], [n], [e], [v] and [a]
+       # in your translation. The program will only accept English
+       # input at this point.
+       gettext "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all "
+
+   Or in C, from builtin/revert.c:
+
+       /* TRANSLATORS: %s will be "revert" or "cherry-pick" */
+       die(_("%s: Unable to write new index file"), me);
-- 
1.7.2.3.313.gcd15
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 34 of 47 in “[CONTINUE] Add gettext support to Git”
  1. 00/20 [CONTINUE] Add gettext support to GitÆvar Arnfjörð Bjarmason, Sep 7, 2010
  2. 01/20 gettextize: git-clean clean.requireForce bracesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  3. 02/20 gettextize: git-clone "Cloning into" message bracesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  4. 04/20 Makefile: add GNU_GETTEXT, set when we expect GNU gettextÆvar Arnfjörð Bjarmason, Sep 7, 2010
  5. 05/20 Makefile: MSGFMT="msgfmt --check" under GNU_GETTEXTÆvar Arnfjörð Bjarmason, Sep 7, 2010
  6. 06/20 Revert "gettextize: git-revert mark the "me" variable for translation"Ævar Arnfjörð Bjarmason, Sep 7, 2010
  7. 07/20 gettextize: git-revert "Your local changes" messageÆvar Arnfjörð Bjarmason, Sep 7, 2010
  8. 08/20 gettextize: git-revert literal "me" messagesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  9. 09/20 gettext: add GETTEXT_POISON support for shell scriptsÆvar Arnfjörð Bjarmason, Sep 7, 2010
  10. 10/20 gettext: add GETTEXT_POISON tests for shell scriptsÆvar Arnfjörð Bjarmason, Sep 7, 2010
  11. 11/20 gettextize: git-am add git-sh-i18nÆvar Arnfjörð Bjarmason, Sep 7, 2010
  12. 12/20 gettextize: git-am one-line gettext $msg; echoÆvar Arnfjörð Bjarmason, Sep 7, 2010
  13. 13/20 gettextize: git-am multi-line getttext $msg; echoÆvar Arnfjörð Bjarmason, Sep 7, 2010
  14. 14/20 gettextize: git-am eval_gettext messagesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  15. 15/20 gettextize: git-am die messagesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  16. 16/20 gettextize: git-am cannot_fallback messagesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  17. 17/20 gettextize: git-am clean_abort messagesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  18. 18/20 gettextize: git-am "Apply?" messageÆvar Arnfjörð Bjarmason, Sep 7, 2010
  19. 19/20 gettextize: git-am core say messagesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  20. 20/20 gettextize: git-am printf(1) message to eval_gettextÆvar Arnfjörð Bjarmason, Sep 7, 2010
  21. Jonathan NiederSep 7, 2010
  22. Ævar Arnfjörð BjarmasonSep 7, 2010
  23. Jonathan NiederSep 7, 2010
  24. 20/20 gettextize: git-am printf(1) message to eval_gettextÆvar Arnfjörð Bjarmason, Sep 7, 2010
  25. 19/20 gettextize: git-am core say messagesÆvar Arnfjörð Bjarmason, Sep 7, 2010
  26. Junio C HamanoSep 8, 2010
  27. Ævar Arnfjörð BjarmasonSep 8, 2010
  28. Ævar Arnfjörð BjarmasonSep 10, 2010
  29. Junio C HamanoSep 10, 2010
  30. Ævar Arnfjörð BjarmasonSep 10, 2010
  31. 0/5 gettext docs: programmer docs in po/READMEÆvar Arnfjörð Bjarmason, Sep 10, 2010
  32. Ævar Arnfjörð BjarmasonSep 10, 2010
  33. 1/5 gettext docs: add a "Testing your changes" section to po/READMEÆvar Arnfjörð Bjarmason, Sep 10, 2010
  34. 2/5 gettext docs: add "Marking strings for translation" section in po/READMEÆvar Arnfjörð Bjarmason, Sep 10, 2010
  35. Junio C HamanoSep 10, 2010
  36. Ævar Arnfjörð BjarmasonSep 10, 2010
  37. 3/5 gettext docs: the gettext.h C interfaceÆvar Arnfjörð Bjarmason, Sep 10, 2010
  38. Junio C HamanoSep 10, 2010
  39. Ævar Arnfjörð BjarmasonSep 10, 2010
  40. Junio C HamanoSep 10, 2010
  41. Ævar Arnfjörð BjarmasonSep 10, 2010
  42. Junio C HamanoSep 10, 2010
  43. Ævar Arnfjörð BjarmasonSep 10, 2010
  44. 4/5 gettext docs: the git-sh-i18n.sh Shell interfaceÆvar Arnfjörð Bjarmason, Sep 10, 2010
  45. Junio C HamanoSep 10, 2010
  46. Ævar Arnfjörð BjarmasonSep 10, 2010
  47. 5/5 gettext docs: the Git::I18N Perl interfaceÆvar Arnfjörð Bjarmason, Sep 10, 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.