~ubuntu-branches/ubuntu/lucid/postgresql-8.4/lucid-proposed

« back to all changes in this revision

Viewing changes to doc/src/sgml/nls.sgml

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!-- $PostgreSQL: pgsql/doc/src/sgml/nls.sgml,v 1.17 2009/01/09 10:54:07 petere Exp $ -->
 
1
<!-- $PostgreSQL: pgsql/doc/src/sgml/nls.sgml,v 1.18 2009/06/04 18:33:06 tgl Exp $ -->
2
2
 
3
3
<chapter id="nls">
4
4
 <chapterinfo>
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.
51
51
   </para>
52
52
 
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
228
228
    translation.
229
229
   </para>
230
230
 
347
347
<programlisting>
348
348
fprintf(stderr, gettext("panic level %d\n"), lvl);
349
349
</programlisting>
350
 
     (<symbol>gettext</symbol> is defined as a no-op if no NLS is
351
 
     configured.)
 
350
     (<symbol>gettext</symbol> is defined as a no-op if NLS support is
 
351
     not configured.)
352
352
    </para>
353
353
 
354
354
    <para>
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).
424
427
        </para>
425
428
       </listitem>
426
429
      </varlistentry>
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.
480
 
      You could write:
 
481
      with some peculiar rules.  It's often best to design the message
 
482
      to avoid the issue altogether, for instance like this:
481
483
<programlisting>
482
484
printf("number of copied files: %d", n);
483
485
</programlisting>
484
486
     </para>
 
487
 
 
488
     <para>
 
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:
 
493
<programlisting>
 
494
errmsg_plural("copied %d file",
 
495
              "copied %d files",
 
496
              n,
 
497
              n)
 
498
</programlisting>
 
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</>.
 
511
     </para>
 
512
 
 
513
     <para>
 
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
 
517
      documentation.
 
518
     </para>
485
519
    </listitem>
486
520
 
487
521
    <listitem>