1
- <!-- $Header: /cvsroot/pgsql/doc/src/sgml/nls.sgml,v 1.5 2002/10/30 05:14:32 momjian Exp $ -->
1
+ <!--
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/nls.sgml,v 1.6 2003/05/19 21:38:23 tgl Exp $
3
+ -->
2
4
3
5
<chapter id="nls">
4
6
<docinfo>
@@ -241,20 +243,20 @@ gmake update-po
241
243
242
244
<listitem>
243
245
<para>
244
- If the original is a printf format string, the translation also
245
- needs to be. The translation also needs to have the same
246
+ If the original is a <function> printf</> format string, the translation
247
+ also needs to be. The translation also needs to have the same
246
248
format specifiers in the same order. Sometimes the natural
247
249
rules of the language make this impossible or at least awkward.
248
- In this case you can use this format:
250
+ In that case you can modify the format specifiers like this :
249
251
<programlisting>
250
252
msgstr "Die Datei %2$s hat %1$u Zeichen."
251
253
</programlisting>
252
254
Then the first placeholder will actually use the second
253
255
argument from the list. The
254
256
<literal><replaceable>digits</replaceable>$</literal> needs to
255
- follow the % and come before any other format manipulators.
257
+ follow the % immediately, before any other format manipulators.
256
258
(This feature really exists in the <function>printf</function>
257
- family of functions. You may not have heard of it because
259
+ family of functions. You may not have heard of it before because
258
260
there is little use for it outside of message
259
261
internationalization.)
260
262
</para>
@@ -279,6 +281,7 @@ msgstr "Die Datei %2$s hat %1$u Zeichen."
279
281
open file %s</literal>) should probably not start with a
280
282
capital letter (if your language distinguishes letter case) or
281
283
end with a period (if your language uses punctuation marks).
284
+ It may help to read <xref linkend="error-style-guide">.
282
285
</para>
283
286
</listitem>
284
287
@@ -301,8 +304,11 @@ msgstr "Die Datei %2$s hat %1$u Zeichen."
301
304
<sect1 id="nls-programmer">
302
305
<title>For the Programmer</title>
303
306
307
+ <sect2 id="nls-mechanics">
308
+ <title>Mechanics</title>
309
+
304
310
<para>
305
- This section describes how to support native language support in a
311
+ This section describes how to implement native language support in a
306
312
program or library that is part of the
307
313
<productname>PostgreSQL</> distribution.
308
314
Currently, it only applies to C programs.
@@ -348,15 +354,15 @@ fprintf(stderr, gettext("panic level %d\n"), lvl);
348
354
</para>
349
355
350
356
<para>
351
- This may tend to add a lot of clutter. One common shortcut is to
357
+ This may tend to add a lot of clutter. One common shortcut is to use
352
358
<programlisting>
353
- #define _(x) gettext((x) )
359
+ #define _(x) gettext(x )
354
360
</programlisting>
355
361
Another solution is feasible if the program does much of its
356
362
communication through one or a few functions, such as
357
- <function>elog ()</function> in the backend. Then you make this
363
+ <function>ereport ()</function> in the backend. Then you make this
358
364
function call <function>gettext</function> internally on all
359
- input values .
365
+ input strings .
360
366
</para>
361
367
</step>
362
368
@@ -430,19 +436,29 @@ fprintf(stderr, gettext("panic level %d\n"), lvl);
430
436
The build system will automatically take care of building and
431
437
installing the message catalogs.
432
438
</para>
439
+ </sect2>
440
+
441
+ <sect2 id="nls-guidelines">
442
+ <title>Message-writing guidelines</title>
433
443
434
444
<para>
435
- To ease the translation of messages, here are some guidelines:
445
+ Here are some guidelines for writing messages that are easily
446
+ translatable.
436
447
437
448
<itemizedlist>
438
449
<listitem>
439
450
<para>
440
- Do not construct sentences at run-time out of laziness , like
451
+ Do not construct sentences at run-time, like
441
452
<programlisting>
442
- printf("Files where %s.\n", flag ? "copied" : "removed");
453
+ printf("Files were %s.\n", flag ? "copied" : "removed");
443
454
</programlisting>
444
455
The word order within the sentence may be different in other
445
- languages.
456
+ languages. Also, even if you remember to call gettext() on each
457
+ fragment, the fragments may not translate well separately. It's
458
+ better to duplicate a little code so that each message to be
459
+ translated is a coherent whole. Only numbers, file names, and
460
+ such-like run-time variables should be inserted at runtime into
461
+ a message text.
446
462
</para>
447
463
</listitem>
448
464
462
478
</programlisting>
463
479
then be disappointed. Some languages have more than two forms,
464
480
with some peculiar rules. We may have a solution for this in
465
- the future, but for now this is best avoided altogether. You
466
- could write:
481
+ the future, but for now the matter is best avoided altogether.
482
+ You could write:
467
483
<programlisting>
468
484
printf("number of copied files: %d", n);
469
485
</programlisting>
@@ -485,6 +501,7 @@ printf("number of copied files: %d", n);
485
501
</listitem>
486
502
</itemizedlist>
487
503
</para>
504
+ </sect2>
488
505
</sect1>
489
506
490
507
</chapter>
0 commit comments