]> git.ipfire.org Git - thirdparty/git.git/blame - po/README.md
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / po / README.md
CommitLineData
cb92e283 1# Core GIT Translations
5e9637c6 2
271ce198
JH
3This directory holds the translations for the core of Git. This document
4describes how you can contribute to the effort of enhancing the language
5coverage and maintaining the translation.
6
7The localization (l10n) coordinator, Jiang Xin <worldhello.net@gmail.com>,
75b182ae 8coordinates our localization effort in the l10 coordinator repository:
271ce198 9
cb92e283 10 https://github.com/git-l10n/git-po/
271ce198 11
cb92e283 12The two character language translation codes are defined by ISO\_639-1, as
a6926b83
PO
13stated in the gettext(1) full manual, appendix A.1, Usual Language Codes.
14
15
cb92e283
JX
16## Contributing to an existing translation
17
75b182ae
JX
18As a contributor for a language XX, you should first check TEAMS file in
19this directory to see whether a dedicated repository for your language XX
20exists. Fork the dedicated repository and start to work if it exists.
21
a6926b83
PO
22Sometime, contributors may find that the translations of their Git
23distributions are quite different with the translations of the
24corresponding version from Git official. This is because some Git
25distributions (such as from Ubuntu, etc.) have their own l10n workflow.
26For this case, wrong translations should be reported and fixed through
27their workflows.
28
29
cb92e283
JX
30## Creating a new language translation
31
75b182ae 32If you are the first contributor for the language XX, please fork this
cb92e283 33repository, prepare and/or update the translated message file "po/XX.po"
75b182ae 34(described later), and ask the l10n coordinator to pull your work.
271ce198
JH
35
36If there are multiple contributors for the same language, please first
37coordinate among yourselves and nominate the team leader for your
38language, so that the l10n coordinator only needs to interact with one
39person per language.
40
a6926b83 41
cb92e283
JX
42## Core translation
43
2fb9d259
BS
44The core translation is the smallest set of work that must be completed
45for a new language translation. Because there are more than 5000 messages
46in the template message file "po/git.pot" that need to be translated,
47this is not a piece of cake for the contributor for a new language.
48
49The core template message file which contains a small set of messages
50will be generated in "po-core/core.pot" automatically by running a helper
51program named "git-po-helper" (described later).
52
cb92e283
JX
53```shell
54git-po-helper init --core XX.po
55```
2fb9d259
BS
56
57After translating the generated "po-core/XX.po", you can merge it to
58"po/XX.po" using the following commands:
59
cb92e283
JX
60```shell
61msgcat po-core/XX.po po/XX.po -s -o /tmp/XX.po
62mv /tmp/XX.po po/XX.po
63git-po-helper update XX.po
64```
2fb9d259
BS
65
66Edit "po/XX.po" by hand to fix "fuzzy" messages, which may have misplaced
67translated messages and duplicate messages.
68
69
cb92e283
JX
70## Translation Process Flow
71
271ce198
JH
72The overall data-flow looks like this:
73
74 +-------------------+ +------------------+
75 | Git source code | ---(1)---> | L10n coordinator |
76 | repository | <---(4)--- | repository |
77 +-------------------+ +------------------+
78 | ^
79 (2) (3)
80 V |
81 +------------------+
82 | Language Team XX |
83 +------------------+
84
cb92e283
JX
85- Translatable strings are marked in the source file.
86- L10n coordinator pulls from the source (1)
87- L10n coordinator updates the message template "po/git.pot"
88- Language team pulls from L10n coordinator (2)
89- Language team updates the message file "po/XX.po"
90- L10n coordinator pulls from Language team (3)
91- L10n coordinator asks the result to be pulled (4).
271ce198
JH
92
93
cb92e283 94## Maintaining the "po/git.pot" file
5e9637c6 95
271ce198 96(This is done by the l10n coordinator).
5e9637c6 97
cb92e283 98The "po/git.pot" file contains a message catalog extracted from Git's
271ce198
JH
99sources. The l10n coordinator maintains it by adding new translations with
100msginit(1), or update existing ones with msgmerge(1). In order to update
101the Git sources to extract the messages from, the l10n coordinator is
102expected to pull from the main git repository at strategic point in
103history (e.g. when a major release and release candidates are tagged),
104and then run "make pot" at the top-level directory.
5e9637c6 105
271ce198
JH
106Language contributors use this file to prepare translations for their
107language, but they are not expected to modify it.
5e9637c6 108
5e9637c6 109
cb92e283 110## Initializing a "XX.po" file
5e9637c6 111
271ce198 112(This is done by the language teams).
5e9637c6 113
cb92e283 114If your language XX does not have translated message file "po/XX.po" yet,
271ce198 115you add a translation for the first time by running:
5e9637c6 116
cb92e283
JX
117```shell
118msginit --locale=XX
119```
5e9637c6 120
cb92e283
JX
121in the "po/" directory, where XX is the locale, e.g. "de", "is", "pt\_BR",
122"zh\_CN", etc.
5e9637c6 123
cb92e283 124Then edit the automatically generated copyright info in your new "XX.po"
5e9637c6
ÆAB
125to be correct, e.g. for Icelandic:
126
cb92e283
JX
127```diff
128@@ -1,6 +1,6 @@
129-# Icelandic translations for PACKAGE package.
130-# Copyright (C) 2010 THE PACKAGE'S COPYRIGHT HOLDER
131-# This file is distributed under the same license as the PACKAGE package.
132+# Icelandic translations for Git.
133+# Copyright (C) 2010 Ævar Arnfjörð Bjarmason <avarab@gmail.com>
134+# This file is distributed under the same license as the Git package.
135 # Ævar Arnfjörð Bjarmason <avarab@gmail.com>, 2010.
136```
5e9637c6
ÆAB
137
138And change references to PACKAGE VERSION in the PO Header Entry to
139just "Git":
140
cb92e283
JX
141```shell
142perl -pi -e 's/(?<="Project-Id-Version: )PACKAGE VERSION/Git/' XX.po
143```
5e9637c6 144
271ce198
JH
145Once you are done testing the translation (see below), commit the result
146and ask the l10n coordinator to pull from you.
147
148
cb92e283 149## Updating a "XX.po" file
271ce198
JH
150
151(This is done by the language teams).
5e9637c6 152
cb92e283 153If you are replacing translation strings in an existing "XX.po" file to
271ce198 154improve the translation, just edit the file.
5e9637c6 155
cb92e283
JX
156If there's an existing "XX.po" file for your language, but the repository
157of the l10n coordinator has newer "po/git.pot" file, you would need to first
271ce198
JH
158pull from the l10n coordinator (see the beginning of this document for its
159URL), and then update the existing translation by running:
5e9637c6 160
cb92e283
JX
161```shell
162msgmerge --add-location --backup=off -U XX.po git.pot
163```
5e9637c6 164
cb92e283 165in the "po/" directory, where "XX.po" is the file you want to update.
271ce198
JH
166
167Once you are done testing the translation (see below), commit the result
168and ask the l10n coordinator to pull from you.
169
cb92e283
JX
170
171## Fuzzy translation
3714fbcb
BS
172
173Fuzzy translation is a translation marked by comment "fuzzy" to let you
174know that the translation is out of date because the "msgid" has been
175changed. A fuzzy translation will be ignored when compiling using "msgfmt".
176Fuzzy translation can be marked by hands, but for most cases they are
177marked automatically when running "msgmerge" to update your "XX.po" file.
178
179After fixing the corresponding translation, you must remove the "fuzzy"
180tag in the comment.
181
5e9637c6 182
cb92e283 183## Testing your changes
5e9637c6 184
cb92e283 185(This is done by the language teams, after creating or updating "XX.po" file).
271ce198 186
5e9637c6
ÆAB
187Before you submit your changes go back to the top-level and do:
188
cb92e283
JX
189```shell
190make
191```
5e9637c6
ÆAB
192
193On systems with GNU gettext (i.e. not Solaris) this will compile your
194changed PO file with `msgfmt --check`, the --check option flags many
195common errors, e.g. missing printf format strings, or translated
196messages that deviate from the originals in whether they begin/end
197with a newline or not.
198
199
cb92e283 200## Marking strings for translation
5e9637c6 201
271ce198
JH
202(This is done by the core developers).
203
5e9637c6
ÆAB
204Before strings can be translated they first have to be marked for
205translation.
206
207Git uses an internationalization interface that wraps the system's
208gettext library, so most of the advice in your gettext documentation
209(on GNU systems `info gettext` in a terminal) applies.
210
211General advice:
212
cb92e283
JX
213- Don't mark everything for translation, only strings which will be
214 read by humans (the porcelain interface) should be translated.
5e9637c6 215
cb92e283
JX
216 The output from Git's plumbing utilities will primarily be read by
217 programs and would break scripts under non-C locales if it was
218 translated. Plumbing strings should not be translated, since
219 they're part of Git's API.
5e9637c6 220
cb92e283
JX
221- Adjust the strings so that they're easy to translate. Most of the
222 advice in `info '(gettext)Preparing Strings'` applies here.
5e9637c6 223
786eb1ba
JS
224- Strings referencing numbers of items may need to be split into singular and
225 plural forms; see the Q\_() wrapper in the C sub-section below for an
226 example.
227
cb92e283
JX
228- If something is unclear or ambiguous you can use a "TRANSLATORS"
229 comment to tell the translators what to make of it. These will be
230 extracted by xgettext(1) and put in the "po/\*.po" files, e.g. from
231 git-am.sh:
5e9637c6 232
cb92e283
JX
233 ```shell
234 # TRANSLATORS: Make sure to include [y], [n], [e], [v] and [a]
235 # in your translation. The program will only accept English
236 # input at this point.
237 gettext "Apply? [y]es/[n]o/[e]dit/[v]iew patch/[a]ccept all "
238 ```
5e9637c6 239
cb92e283 240 Or in C, from builtin/revert.c:
5e9637c6 241
cb92e283
JX
242 ```c
243 /* TRANSLATORS: %s will be "revert" or "cherry-pick" */
244 die(_("%s: Unable to write new index file"), action_name(opts));
245 ```
5e9637c6
ÆAB
246
247We provide wrappers for C, Shell and Perl programs. Here's how they're
248used:
249
5e9637c6 250
cb92e283
JX
251### C
252
253Include builtin.h at the top, it'll pull in gettext.h, which
254defines the gettext interface. Consult with the list if you need to
255use gettext.h directly.
256
257The C interface is a subset of the normal GNU gettext
258interface. We currently export these functions:
259
260- \_()
5e9637c6 261
cb92e283 262 Mark and translate a string. E.g.:
5e9637c6 263
cb92e283
JX
264 ```c
265 printf(_("HEAD is now at %s"), hex);
266 ```
5e9637c6 267
cb92e283 268- Q\_()
5e9637c6 269
cb92e283 270 Mark and translate a plural string. E.g.:
5e9637c6 271
cb92e283
JX
272 ```c
273 printf(Q_("%d commit", "%d commits", number_of_commits));
274 ```
5e9637c6 275
cb92e283 276 This is just a wrapper for the ngettext() function.
5e9637c6 277
cb92e283 278- N\_()
5e9637c6 279
cb92e283
JX
280 A no-op pass-through macro for marking strings inside static
281 initializations, e.g.:
5e9637c6 282
cb92e283
JX
283 ```c
284 static const char *reset_type_names[] = {
285 N_("mixed"), N_("soft"), N_("hard"), N_("merge"), N_("keep"), NULL
286 };
287 ```
5e9637c6 288
cb92e283 289 And then, later:
5e9637c6 290
cb92e283
JX
291 ```c
292 die(_("%s reset is not allowed in a bare repository"),
293 _(reset_type_names[reset_type]));
294 ```
5e9637c6 295
cb92e283
JX
296 Here `_()` couldn't have statically determined what the translation
297 string will be, but since it was already marked for translation
298 with `N_()` the look-up in the message catalog will succeed.
5e9637c6 299
5e9637c6 300
cb92e283 301### Shell
5e9637c6 302
cb92e283
JX
303The Git gettext shell interface is just a wrapper for
304gettext.sh. Import it right after git-sh-setup like this:
5e9637c6 305
cb92e283
JX
306```shell
307. git-sh-setup
308. git-sh-i18n
309```
5e9637c6 310
cb92e283 311And then use the `gettext` or `eval_gettext` functions:
5e9637c6 312
cb92e283
JX
313```shell
314# For constant interface messages:
315gettext "A message for the user"; echo
5e9637c6 316
cb92e283
JX
317# To interpolate variables:
318details="oh noes"
319eval_gettext "An error occurred: \$details"; echo
320```
5e9637c6 321
cb92e283
JX
322In addition we have wrappers for messages that end with a trailing
323newline. I.e. you could write the above as:
5e9637c6 324
cb92e283
JX
325```shell
326# For constant interface messages:
327gettextln "A message for the user"
5e9637c6 328
cb92e283
JX
329# To interpolate variables:
330details="oh noes"
331eval_gettextln "An error occurred: \$details"
332```
5e9637c6 333
cb92e283
JX
334More documentation about the interface is available in the GNU info
335page: `info '(gettext)sh'`. Looking at git-am.sh (the first shell
336command to be translated) for examples is also useful:
5e9637c6 337
cb92e283
JX
338```shell
339git log --reverse -p --grep=i18n git-am.sh
340```
5e9637c6 341
5e9637c6 342
cb92e283 343### Perl
5e9637c6 344
cb92e283
JX
345The Git::I18N module provides a limited subset of the
346Locale::Messages functionality, e.g.:
5e9637c6 347
cb92e283
JX
348```perl
349use Git::I18N;
350print __("Welcome to Git!\n");
351printf __("The following error occurred: %s\n"), $error;
352```
5e9637c6 353
cb92e283 354Run `perldoc perl/Git/I18N.pm` for more info.
5e9637c6
ÆAB
355
356
cb92e283 357## Testing marked strings
5e9637c6 358
cb92e283 359Git's tests are run under `LANG=C LC_ALL=C`. So the tests do not need be
d162b25f 360changed to account for translations as they're added.
6d09c530
BS
361
362
cb92e283 363## PO helper
6d09c530 364
cb92e283 365To make the maintenance of "XX.po" easier, the l10n coordinator and l10n
6d09c530
BS
366team leaders can use a helper program named "git-po-helper". It is a
367wrapper to gettext suite, specifically written for the purpose of Git
368l10n workflow.
369
370To build and install the helper program from source, see
371[git-po-helper/README][].
372
373Usage for git-po-helper:
374
cb92e283 375- To start a new language translation:
6d09c530 376
cb92e283
JX
377 ```shell
378 git-po-helper init XX.po
379 ```
6d09c530 380
cb92e283 381- To update your "XX.po" file:
6d09c530 382
cb92e283
JX
383 ```shell
384 git-po-helper update XX.po
385 ```
6d09c530 386
cb92e283 387- To check commit log and syntax of "XX.po":
6d09c530 388
cb92e283
JX
389 ```shell
390 git-po-helper check-po XX.po
391 git-po-helper check-commits
392 ```
6d09c530
BS
393
394Run "git-po-helper" without arguments to show usage.
395
69c13a78 396
cb92e283 397## Conventions
69c13a78
BS
398
399There are some conventions that l10n contributors must follow:
400
cb92e283 401- The subject of each l10n commit should be prefixed with "l10n: ".
69c13a78 402
cb92e283 403- Do not use non-ASCII characters in the subject of a commit.
69c13a78 404
cb92e283
JX
405- The length of commit subject (first line of the commit log) should
406 be less than 50 characters, and the length of other lines of the
407 commit log should be no more than 72 characters.
69c13a78 408
cb92e283
JX
409- Add "Signed-off-by" trailer to your commit log, like other commits
410 in Git. You can automatically add the trailer by committing with
411 the following command:
412
413 ```shell
414 git commit -s
415 ```
416
417- Check syntax with "msgfmt" or the following command before creating
418 your commit:
419
420 ```shell
421 git-po-helper check-po <XX.po>
422 ```
423
424- Squash trivial commits to make history clear.
425
426- DO NOT edit files outside "po/" directory.
427
428- Other subsystems ("git-gui", "gitk", and Git itself) have their
429 own workflow. See [Documentation/SubmittingPatches][] for
430 instructions on how to contribute patches to these subsystems.
69c13a78 431
69c13a78
BS
432
433To contribute for a new l10n language, contributor should follow
434additional conventions:
435
cb92e283
JX
436- Initialize proper filename of the "XX.po" file conforming to
437 iso-639 and iso-3166.
438
439- Must complete a minimal translation based on the "po-core/core.pot"
440 template. Using the following command to initialize the minimal
441 "po-core/XX.po" file:
69c13a78 442
cb92e283
JX
443 ```shell
444 git-po-helper init --core <your-language>
445 ```
69c13a78 446
cb92e283
JX
447- Add a new entry in the "po/TEAMS" file with proper format, and check
448 the syntax of "po/TEAMS" by running the following command:
69c13a78 449
cb92e283
JX
450 ```shell
451 git-po-helper team --check
452 ```
69c13a78
BS
453
454
6d09c530 455[git-po-helper/README]: https://github.com/git-l10n/git-po-helper#readme
69c13a78 456[Documentation/SubmittingPatches]: Documentation/SubmittingPatches