46
46
<filename>msgmerge</filename>, respectively, in a GNU-compatible
47
47
implementation. Later, we will try to arrange it so that if you
48
48
use a packaged source distribution, you won't need
49
<filename>xgettext</filename>. (From CVS, you will still need
49
<filename>xgettext</filename>. (If working from CVS, you will still need
50
50
it.) <application>GNU Gettext 0.10.36</application> or later is currently recommended.
152
152
If there are already some <filename>.po</filename> files, then
153
153
someone has already done some translation work. The files are
154
154
named <filename><replaceable>language</replaceable>.po</filename>,
155
where <replaceable>language</replaceable> is the
155
where <replaceable>language</replaceable> is the
156
156
<ulink url="http://lcweb.loc.gov/standards/iso639-2/englangn.html">
157
157
ISO 639-1 two-letter language code (in lower case)</ulink>, e.g.,
158
158
<filename>fr.po</filename> for French. If there is really a need
224
224
that gives room for other people to pick up your work. However,
225
225
you are encouraged to give priority to removing fuzzy entries
226
226
after doing a merge. Remember that fuzzy entries will not be
227
installed; they only serve as reference what might be the right
227
installed; they only serve as reference for what might be the right
421
421
them here. If the translatable string is not the first
422
422
argument, the item needs to be of the form
423
423
<literal>func:2</literal> (for the second argument).
424
If you have a function that supports pluralized messages,
425
the item should look like <literal>func:1,2</literal>
426
(identifying the singular and plural message arguments).
451
454
printf("Files were %s.\n", flag ? "copied" : "removed");
452
455
</programlisting>
453
456
The word order within the sentence might be different in other
454
languages. Also, even if you remember to call gettext() on each
455
fragment, the fragments might not translate well separately. It's
457
languages. Also, even if you remember to call <function>gettext()</> on
458
each fragment, the fragments might not translate well separately. It's
456
459
better to duplicate a little code so that each message to be
457
460
translated is a coherent whole. Only numbers, file names, and
458
461
such-like run-time variables should be inserted at run time into
475
478
printf("copied %d files", n):
476
479
</programlisting>
477
480
then be disappointed. Some languages have more than two forms,
478
with some peculiar rules. We might have a solution for this in
479
the future, but for now the matter is best avoided altogether.
481
with some peculiar rules. It's often best to design the message
482
to avoid the issue altogether, for instance like this:
482
484
printf("number of copied files: %d", n);
483
485
</programlisting>
489
If you really want to construct a properly pluralized message,
490
there is support for this, but it's a bit awkward. When generating
491
a primary or detail error message in <function>ereport()</>, you can
492
write something like this:
494
errmsg_plural("copied %d file",
499
The first argument is the format string appropriate for English
500
singular form, the second is the format string appropriate for
501
English plural form, and the third is the integer control value
502
that determines which plural form to use. Subsequent arguments
503
are formatted per the format string as usual. (Normally, the
504
pluralization control value will also be one of the values to be
505
formatted, so it has to be written twice.) In English it only
506
matters whether <replaceable>n</> is 1 or not 1, but in other
507
languages there can be many different plural forms. The translator
508
sees the two English forms as a group and has the opportunity to
509
supply multiple substitute strings, with the appropriate one being
510
selected based on the run-time value of <replaceable>n</>.
514
If you need to pluralize a message that isn't going directly to an
515
<function>errmsg</> or <function>errdetail</> report, you have to use
516
the underlying function <function>ngettext</>. See the gettext