| PostgreSQL 8.1.19 Documentation | ||||
|---|---|---|---|---|
| Prev | Fast Backward | Fast Forward | Next | |
PostgreSQL programs (server and client) can issue their messages in your favorite language — if the messages have been translated. Creating and maintaining translated message sets needs the help of people who speak their own language well and want to contribute to the PostgreSQL effort. You do not have to be a programmer at all to do this. This section explains how to help.
We won't judge your language skills — this section is about software tools. Theoretically, you only need a text editor. But this is only in the unlikely event that you do not want to try out your translated messages. When you configure your source tree, be sure to use the --enable-nls option. This will also check for the libintl library and the msgfmt program, which all end users will need anyway. To try out your work, follow the applicable portions of the installation instructions.
If you want to start a new translation effort or want to do a
message catalog merge (described later), you t your wolls contain
translatable strings. By default, only
gettext() calls are known. If you used
_ or other identifiers you need to list
them here. If the translatable string is not the first
argument, the item needs to be of the form
func:2 (for the second argument).
The build system will automatically take care of building and installing the message catalogs.
Here are some guidelines for writing messages that are easily translatable.
Do not construct sentences at run-time, like
printf("Files were %s.\n", flag ? "copied" : "removed");The word order within the sentence may be different in other languages. Also, even if you remember to call gettext() on each fragment, the fragments may not translate well separately. It's better to duplicate a little code so that each message to be translated is a coherent whole. Only numbers, file names, and such-like run-time variables should be inserted at run time into a message text.
For similar reasons, this won't work:
printf("copied %d file%s", n, n!=1 ? "s" : "");because it assumes how the plural is formed. If you figured you could solve it like this
if (n==1)
printf("copied 1 file");
else
printf("copied %d files", n):then be disappointed. Some languages have more than two forms, with some peculiar rules. We may have a solution for this in the future, but for now the matter is best avoided altogether. You could write:
printf("number of copied files: %d", n);
If you want to communicate something to the translator, such as about how a message is intended to line up with other output, precede the occurrence of the string with a comment that starts with translator, e.g.,
/* translator: This message is not what it seems to be. */
These comments are copied to the message catalog files so that the translators can see them.