1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>56.1. For the Translator</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="nls.html" title="Chapter 56. Native Language Support" /><link rel="next" href="nls-programmer.html" title="56.2. For the Programmer" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">56.1. For the Translator</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="nls.html" title="Chapter 56. Native Language Support">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="nls.html" title="Chapter 56. Native Language Support">Up</a></td><th width="60%" align="center">Chapter 56. Native Language Support</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="nls-programmer.html" title="56.2. For the Programmer">Next</a></td></tr></table><hr /></div><div class="sect1" id="NLS-TRANSLATOR"><div class="titlepage"><div><div><h2 class="title" style="clear: both">56.1. For the Translator <a href="#NLS-TRANSLATOR" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="nls-translator.html#NLS-TRANSLATOR-REQUIREMENTS">56.1.1. Requirements</a></span></dt><dt><span class="sect2"><a href="nls-translator.html#NLS-TRANSLATOR-CONCEPTS">56.1.2. Concepts</a></span></dt><dt><span class="sect2"><a href="nls-translator.html#NLS-TRANSLATOR-MESSAGE-CATALOGS">56.1.3. Creating and Maintaining Message Catalogs</a></span></dt><dt><span class="sect2"><a href="nls-translator.html#NLS-TRANSLATOR-EDITING-PO">56.1.4. Editing the PO Files</a></span></dt></dl></div><p>
3 <span class="productname">PostgreSQL</span>
4 programs (server and client) can issue their messages in
5 your favorite language — if the messages have been translated.
6 Creating and maintaining translated message sets needs the help of
7 people who speak their own language well and want to contribute to
8 the <span class="productname">PostgreSQL</span> effort. You do not have to be a
10 to do this. This section explains how to help.
11 </p><div class="sect2" id="NLS-TRANSLATOR-REQUIREMENTS"><div class="titlepage"><div><div><h3 class="title">56.1.1. Requirements <a href="#NLS-TRANSLATOR-REQUIREMENTS" class="id_link">#</a></h3></div></div></div><p>
12 We won't judge your language skills — this section is about
13 software tools. Theoretically, you only need a text editor. But
14 this is only in the unlikely event that you do not want to try out
15 your translated messages. When you configure your source tree, be
16 sure to use the <code class="option">--enable-nls</code> option. This will
17 also check for the <span class="application">libintl</span> library and the
18 <code class="filename">msgfmt</code> program, which all end users will need
19 anyway. To try out your work, follow the applicable portions of
20 the installation instructions.
22 If you want to start a new translation effort or want to do a
23 message catalog merge (described later), you will need the
24 programs <code class="filename">xgettext</code> and
25 <code class="filename">msgmerge</code>, respectively, in a GNU-compatible
26 implementation. Later, we will try to arrange it so that if you
27 use a packaged source distribution, you won't need
28 <code class="filename">xgettext</code>. (If working from Git, you will still need
29 it.) <span class="application">GNU Gettext 0.10.36</span> or later is currently recommended.
31 Your local gettext implementation should come with its own
32 documentation. Some of that is probably duplicated in what
33 follows, but for additional details you should look there.
34 </p></div><div class="sect2" id="NLS-TRANSLATOR-CONCEPTS"><div class="titlepage"><div><div><h3 class="title">56.1.2. Concepts <a href="#NLS-TRANSLATOR-CONCEPTS" class="id_link">#</a></h3></div></div></div><p>
35 The pairs of original (English) messages and their (possibly)
36 translated equivalents are kept in <em class="firstterm">message
37 catalogs</em>, one for each program (although related
38 programs can share a message catalog) and for each target
39 language. There are two file formats for message catalogs: The
40 first is the <span class="quote">“<span class="quote">PO</span>”</span> file (for Portable Object), which
41 is a plain text file with special syntax that translators edit.
42 The second is the <span class="quote">“<span class="quote">MO</span>”</span> file (for Machine Object),
43 which is a binary file generated from the respective PO file and
44 is used while the internationalized program is run. Translators
45 do not deal with MO files; in fact hardly anyone does.
47 The extension of the message catalog file is to no surprise either
48 <code class="filename">.po</code> or <code class="filename">.mo</code>. The base
49 name is either the name of the program it accompanies, or the
50 language the file is for, depending on the situation. This is a
51 bit confusing. Examples are <code class="filename">psql.po</code> (PO file
52 for psql) or <code class="filename">fr.mo</code> (MO file in French).
54 The file format of the PO files is illustrated here:
55 </p><pre class="programlisting">
58 msgid "original string"
59 msgstr "translated string"
62 msgstr "another translated"
63 "string can be broken up like this"
67 The msgid lines are extracted from the program source. (They need not
68 be, but this is the most common way.) The msgstr lines are
69 initially empty and are filled in with useful strings by the
70 translator. The strings can contain C-style escape characters and
71 can be continued across lines as illustrated. (The next line must
72 start at the beginning of the line.)
74 The # character introduces a comment. If whitespace immediately
75 follows the # character, then this is a comment maintained by the
76 translator. There can also be automatic comments, which have a
77 non-whitespace character immediately following the #. These are
78 maintained by the various tools that operate on the PO files and
79 are intended to aid the translator.
80 </p><pre class="programlisting">
85 The #. style comments are extracted from the source file where the
86 message is used. Possibly the programmer has inserted information
87 for the translator, such as about expected alignment. The #:
88 comments indicate the exact locations where the message is used
89 in the source. The translator need not look at the program
90 source, but can if there is doubt about the correct
91 translation. The #, comments contain flags that describe the
92 message in some way. There are currently two flags:
93 <code class="literal">fuzzy</code> is set if the message has possibly been
94 outdated because of changes in the program source. The translator
95 can then verify this and possibly remove the fuzzy flag. Note
96 that fuzzy messages are not made available to the end user. The
97 other flag is <code class="literal">c-format</code>, which indicates that
98 the message is a <code class="function">printf</code>-style format
99 template. This means that the translation should also be a format
100 string with the same number and type of placeholders. There are
101 tools that can verify this, which key off the c-format flag.
102 </p></div><div class="sect2" id="NLS-TRANSLATOR-MESSAGE-CATALOGS"><div class="titlepage"><div><div><h3 class="title">56.1.3. Creating and Maintaining Message Catalogs <a href="#NLS-TRANSLATOR-MESSAGE-CATALOGS" class="id_link">#</a></h3></div></div></div><p>
103 OK, so how does one create a <span class="quote">“<span class="quote">blank</span>”</span> message
104 catalog? First, go into the directory that contains the program
105 whose messages you want to translate. If there is a file
106 <code class="filename">nls.mk</code>, then this program has been prepared
109 If there are already some <code class="filename">.po</code> files, then
110 someone has already done some translation work. The files are
111 named <code class="filename"><em class="replaceable"><code>language</code></em>.po</code>,
112 where <em class="replaceable"><code>language</code></em> is the
113 <a class="ulink" href="https://www.loc.gov/standards/iso639-2/php/English_list.php" target="_top">
114 ISO 639-1 two-letter language code (in lower case)</a>, e.g.,
115 <code class="filename">fr.po</code> for French. If there is really a need
116 for more than one translation effort per language then the files
118 <code class="filename"><em class="replaceable"><code>language</code></em>_<em class="replaceable"><code>region</code></em>.po</code>
119 where <em class="replaceable"><code>region</code></em> is the
120 <a class="ulink" href="https://www.iso.org/iso-3166-country-codes.html" target="_top">
121 ISO 3166-1 two-letter country code (in upper case)</a>,
123 <code class="filename">pt_BR.po</code> for Portuguese in Brazil. If you
124 find the language you wanted you can just start working on that
127 If you need to start a new translation effort, then first run the
129 </p><pre class="programlisting">
132 This will create a file
133 <code class="filename"><em class="replaceable"><code>progname</code></em>.pot</code>.
134 (<code class="filename">.pot</code> to distinguish it from PO files that
135 are <span class="quote">“<span class="quote">in production</span>”</span>. The <code class="literal">T</code> stands for
136 <span class="quote">“<span class="quote">template</span>”</span>.)
138 <code class="filename"><em class="replaceable"><code>language</code></em>.po</code> and
139 edit it. To make it known that the new language is available,
140 also edit the file <code class="filename">po/LINGUAS</code> and add the
141 language (or language and country) code next to languages already listed,
143 </p><pre class="programlisting">
146 (Other languages can appear, of course.)
148 As the underlying program or library changes, messages might be
149 changed or added by the programmers. In this case you do not need
150 to start from scratch. Instead, run the command:
151 </p><pre class="programlisting">
154 which will create a new blank message catalog file (the pot file
155 you started with) and will merge it with the existing PO files.
156 If the merge algorithm is not sure about a particular message it
157 marks it <span class="quote">“<span class="quote">fuzzy</span>”</span> as explained above. The new PO file
158 is saved with a <code class="filename">.po.new</code> extension.
159 </p></div><div class="sect2" id="NLS-TRANSLATOR-EDITING-PO"><div class="titlepage"><div><div><h3 class="title">56.1.4. Editing the PO Files <a href="#NLS-TRANSLATOR-EDITING-PO" class="id_link">#</a></h3></div></div></div><p>
160 The PO files can be edited with a regular text editor. There are also
161 several specialized editors for PO files which can help the process with
162 translation-specific features.
163 There is (unsurprisingly) a PO mode for Emacs, which can be quite
166 The translator should only change the area between the quotes after
167 the msgstr directive, add comments, and alter the fuzzy flag.
169 The PO files need not be completely filled in. The software will
170 automatically fall back to the original string if no translation
171 (or an empty translation) is available. It is no problem to
172 submit incomplete translations for inclusions in the source tree;
173 that gives room for other people to pick up your work. However,
174 you are encouraged to give priority to removing fuzzy entries
175 after doing a merge. Remember that fuzzy entries will not be
176 installed; they only serve as reference for what might be the right
179 Here are some things to keep in mind while editing the
181 </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
182 Make sure that if the original ends with a newline, the
183 translation does, too. Similarly for tabs, etc.
184 </p></li><li class="listitem"><p>
185 If the original is a <code class="function">printf</code> format string, the translation
186 also needs to be. The translation also needs to have the same
187 format specifiers in the same order. Sometimes the natural
188 rules of the language make this impossible or at least awkward.
189 In that case you can modify the format specifiers like this:
190 </p><pre class="programlisting">
191 msgstr "Die Datei %2$s hat %1$u Zeichen."
193 Then the first placeholder will actually use the second
194 argument from the list. The
195 <code class="literal"><em class="replaceable"><code>digits</code></em>$</code> needs to
196 follow the % immediately, before any other format manipulators.
197 (This feature really exists in the <code class="function">printf</code>
198 family of functions. You might not have heard of it before because
199 there is little use for it outside of message
200 internationalization.)
201 </p></li><li class="listitem"><p>
202 If the original string contains a linguistic mistake, report
203 that (or fix it yourself in the program source) and translate
204 normally. The corrected string can be merged in when the
205 program sources have been updated. If the original string
206 contains a factual mistake, report that (or fix it yourself)
207 and do not translate it. Instead, you can mark the string with
208 a comment in the PO file.
209 </p></li><li class="listitem"><p>
210 Maintain the style and tone of the original string.
211 Specifically, messages that are not sentences (<code class="literal">cannot
212 open file %s</code>) should probably not start with a
213 capital letter (if your language distinguishes letter case) or
214 end with a period (if your language uses punctuation marks).
215 It might help to read <a class="xref" href="error-style-guide.html" title="55.3. Error Message Style Guide">Section 55.3</a>.
216 </p></li><li class="listitem"><p>
217 If you don't know what a message means, or if it is ambiguous,
218 ask on the developers' mailing list. Chances are that English
219 speaking end users might also not understand it or find it
220 ambiguous, so it's best to improve the message.
221 </p></li></ul></div><p>
222 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="nls.html" title="Chapter 56. Native Language Support">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="nls.html" title="Chapter 56. Native Language Support">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="nls-programmer.html" title="56.2. For the Programmer">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 56. Native Language Support </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 56.2. For the Programmer</td></tr></table></div></body></html>