4 This directory holds the translations for the core of Git. This document
5 describes how you can contribute to the effort of enhancing the language
6 coverage and maintaining the translation.
8 The localization (l10n) coordinator, Jiang Xin <worldhello.net@gmail.com>,
9 coordinates our localization effort in the l10 coordinator repository:
11 https://github.com/git-l10n/git-po/
13 The two character language translation codes are defined by ISO_639-1, as
14 stated in the gettext(1) full manual, appendix A.1, Usual Language Codes.
17 Contributing to an existing translation
18 ---------------------------------------
19 As a contributor for a language XX, you should first check TEAMS file in
20 this directory to see whether a dedicated repository for your language XX
21 exists. Fork the dedicated repository and start to work if it exists.
23 Sometime, contributors may find that the translations of their Git
24 distributions are quite different with the translations of the
25 corresponding version from Git official. This is because some Git
26 distributions (such as from Ubuntu, etc.) have their own l10n workflow.
27 For this case, wrong translations should be reported and fixed through
31 Creating a new language translation
32 -----------------------------------
33 If you are the first contributor for the language XX, please fork this
34 repository, prepare and/or update the translated message file po/XX.po
35 (described later), and ask the l10n coordinator to pull your work.
37 If there are multiple contributors for the same language, please first
38 coordinate among yourselves and nominate the team leader for your
39 language, so that the l10n coordinator only needs to interact with one
45 The core translation is the smallest set of work that must be completed
46 for a new language translation. Because there are more than 5000 messages
47 in the template message file "po/git.pot" that need to be translated,
48 this is not a piece of cake for the contributor for a new language.
50 The core template message file which contains a small set of messages
51 will be generated in "po-core/core.pot" automatically by running a helper
52 program named "git-po-helper" (described later).
54 git-po-helper init --core XX.po
56 After translating the generated "po-core/XX.po", you can merge it to
57 "po/XX.po" using the following commands:
59 msgcat po-core/XX.po po/XX.po -s -o /tmp/XX.po
60 mv /tmp/XX.po po/XX.po
61 git-po-helper update XX.po
63 Edit "po/XX.po" by hand to fix "fuzzy" messages, which may have misplaced
64 translated messages and duplicate messages.
67 Translation Process Flow
68 ------------------------
69 The overall data-flow looks like this:
71 +-------------------+ +------------------+
72 | Git source code | ---(1)---> | L10n coordinator |
73 | repository | <---(4)--- | repository |
74 +-------------------+ +------------------+
82 * Translatable strings are marked in the source file.
83 * L10n coordinator pulls from the source (1)
84 * L10n coordinator updates the message template po/git.pot
85 * Language team pulls from L10n coordinator (2)
86 * Language team updates the message file po/XX.po
87 * L10n coordinator pulls from Language team (3)
88 * L10n coordinator asks the result to be pulled (4).
91 Maintaining the po/git.pot file
92 -------------------------------
94 (This is done by the l10n coordinator).
96 The po/git.pot file contains a message catalog extracted from Git's
97 sources. The l10n coordinator maintains it by adding new translations with
98 msginit(1), or update existing ones with msgmerge(1). In order to update
99 the Git sources to extract the messages from, the l10n coordinator is
100 expected to pull from the main git repository at strategic point in
101 history (e.g. when a major release and release candidates are tagged),
102 and then run "make pot" at the top-level directory.
104 Language contributors use this file to prepare translations for their
105 language, but they are not expected to modify it.
108 Initializing a XX.po file
109 -------------------------
111 (This is done by the language teams).
113 If your language XX does not have translated message file po/XX.po yet,
114 you add a translation for the first time by running:
118 in the po/ directory, where XX is the locale, e.g. "de", "is", "pt_BR",
121 Then edit the automatically generated copyright info in your new XX.po
122 to be correct, e.g. for Icelandic:
125 -# Icelandic translations for PACKAGE package.
126 -# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
127 -# This file is distributed under the same license as the PACKAGE package.
128 +# Icelandic translations for Git.
129 +# Copyright (C) 2010 Ævar Arnfjörð Bjarmason <avarab@gmail.com>
130 +# This file is distributed under the same license as the Git package.
131 # Ævar Arnfjörð Bjarmason <avarab@gmail.com>, 2010.
133 And change references to PACKAGE VERSION in the PO Header Entry to
136 perl -pi -e 's/(?<="Project-Id-Version: )PACKAGE VERSION/Git/' XX.po
138 Once you are done testing the translation (see below), commit the result
139 and ask the l10n coordinator to pull from you.
142 Updating a XX.po file
143 ---------------------
145 (This is done by the language teams).
147 If you are replacing translation strings in an existing XX.po file to
148 improve the translation, just edit the file.
150 If there's an existing XX.po file for your language, but the repository
151 of the l10n coordinator has newer po/git.pot file, you would need to first
152 pull from the l10n coordinator (see the beginning of this document for its
153 URL), and then update the existing translation by running:
155 msgmerge --add-location --backup=off -U XX.po git.pot
157 in the po/ directory, where XX.po is the file you want to update.
159 Once you are done testing the translation (see below), commit the result
160 and ask the l10n coordinator to pull from you.
165 Fuzzy translation is a translation marked by comment "fuzzy" to let you
166 know that the translation is out of date because the "msgid" has been
167 changed. A fuzzy translation will be ignored when compiling using "msgfmt".
168 Fuzzy translation can be marked by hands, but for most cases they are
169 marked automatically when running "msgmerge" to update your "XX.po" file.
171 After fixing the corresponding translation, you must remove the "fuzzy"
178 (This is done by the language teams, after creating or updating XX.po file).
180 Before you submit your changes go back to the top-level and do:
184 On systems with GNU gettext (i.e. not Solaris) this will compile your
185 changed PO file with `msgfmt --check`, the --check option flags many
186 common errors, e.g. missing printf format strings, or translated
187 messages that deviate from the originals in whether they begin/end
188 with a newline or not.
191 Marking strings for translation
192 -------------------------------
194 (This is done by the core developers).
196 Before strings can be translated they first have to be marked for
199 Git uses an internationalization interface that wraps the system's
200 gettext library, so most of the advice in your gettext documentation
201 (on GNU systems `info gettext` in a terminal) applies.
205 - Don't mark everything for translation, only strings which will be
206 read by humans (the porcelain interface) should be translated.
208 The output from Git's plumbing utilities will primarily be read by
209 programs and would break scripts under non-C locales if it was
210 translated. Plumbing strings should not be translated, since
211 they're part of Git's API.
213 - Adjust the strings so that they're easy to translate. Most of the
214 advice in `info '(gettext)Preparing Strings'` applies here.
216 - If something is unclear or ambiguous you can use a "TRANSLATORS"
217 comment to tell the translators what to make of it. These will be
218 extracted by xgettext(1) and put in the po/*.po files, e.g. from
221 # TRANSLATORS: Make sure to include [y], [n], [e], [v] and [a]
222 # in your translation. The program will only accept English
223 # input at this point.
224 gettext "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all "
226 Or in C, from builtin/revert.c:
228 /* TRANSLATORS: %s will be "revert" or "cherry-pick" */
229 die(_("%s: Unable to write new index file"), action_name(opts));
231 We provide wrappers for C, Shell and Perl programs. Here's how they're
236 - Include builtin.h at the top, it'll pull in gettext.h, which
237 defines the gettext interface. Consult with the list if you need to
238 use gettext.h directly.
240 - The C interface is a subset of the normal GNU gettext
241 interface. We currently export these functions:
245 Mark and translate a string. E.g.:
247 printf(_("HEAD is now at %s"), hex);
251 Mark and translate a plural string. E.g.:
253 printf(Q_("%d commit", "%d commits", number_of_commits));
255 This is just a wrapper for the ngettext() function.
259 A no-op pass-through macro for marking strings inside static
260 initializations, e.g.:
262 static const char *reset_type_names[] = {
263 N_("mixed"), N_("soft"), N_("hard"), N_("merge"), N_("keep"), NULL
268 die(_("%s reset is not allowed in a bare repository"),
269 _(reset_type_names[reset_type]));
271 Here _() couldn't have statically determined what the translation
272 string will be, but since it was already marked for translation
273 with N_() the look-up in the message catalog will succeed.
277 - The Git gettext shell interface is just a wrapper for
278 gettext.sh. Import it right after git-sh-setup like this:
283 And then use the gettext or eval_gettext functions:
285 # For constant interface messages:
286 gettext "A message for the user"; echo
288 # To interpolate variables:
290 eval_gettext "An error occurred: \$details"; echo
292 In addition we have wrappers for messages that end with a trailing
293 newline. I.e. you could write the above as:
295 # For constant interface messages:
296 gettextln "A message for the user"
298 # To interpolate variables:
300 eval_gettextln "An error occurred: \$details"
302 More documentation about the interface is available in the GNU info
303 page: `info '(gettext)sh'`. Looking at git-am.sh (the first shell
304 command to be translated) for examples is also useful:
306 git log --reverse -p --grep=i18n git-am.sh
310 - The Git::I18N module provides a limited subset of the
311 Locale::Messages functionality, e.g.:
314 print __("Welcome to Git!\n");
315 printf __("The following error occurred: %s\n"), $error;
317 Run `perldoc perl/Git/I18N.pm` for more info.
320 Testing marked strings
321 ----------------------
323 Git's tests are run under LANG=C LC_ALL=C. So the tests do not need be
324 changed to account for translations as they're added.
330 To make the maintenance of XX.po easier, the l10n coordinator and l10n
331 team leaders can use a helper program named "git-po-helper". It is a
332 wrapper to gettext suite, specifically written for the purpose of Git
335 To build and install the helper program from source, see
336 [git-po-helper/README][].
338 Usage for git-po-helper:
340 - To start a new language translation:
342 git-po-helper init XX.po
344 - To update your XX.po file:
346 git-po-helper update XX.po
348 - To check commit log and syntax of XX.po:
350 git-po-helper check-po XX.po
351 git-po-helper check-commits
353 Run "git-po-helper" without arguments to show usage.
359 There are some conventions that l10n contributors must follow:
361 1. The subject of each l10n commit should be prefixed with "l10n: ".
362 2. Do not use non-ASCII characters in the subject of a commit.
363 3. The length of commit subject (first line of the commit log) should
364 be less than 50 characters, and the length of other lines of the
365 commit log should be no more than 72 characters.
366 4. Add "Signed-off-by" trailer to your commit log, like other commits
367 in Git. You can automatically add the trailer by committing with
368 the following command:
372 5. Check syntax with "msgfmt" or the following command before creating
375 git-po-helper check-po <XX.po>
377 6. Squash trivial commits to make history clear.
378 7. DO NOT edit files outside "po/" directory.
379 8. Other subsystems ("git-gui", "gitk", and Git itself) have their
380 own workflow. See [Documentation/SubmittingPatches][] for
381 instructions on how to contribute patches to these subsystems.
383 To contribute for a new l10n language, contributor should follow
384 additional conventions:
386 1. Initialize proper filename of the "XX.po" file conforming to
387 iso-639 and iso-3166.
388 2. Must complete a minimal translation based on the "po-core/core.pot"
389 template. Using the following command to initialize the minimal
390 "po-core/XX.po" file:
392 git-po-helper init --core <your-language>
394 3. Add a new entry in the "po/TEAMS" file with proper format, and check
395 the syntax of "po/TEAMS" by runnning the following command:
397 git-po-helper team --check
400 [git-po-helper/README]: https://github.com/git-l10n/git-po-helper#readme
401 [Documentation/SubmittingPatches]: Documentation/SubmittingPatches