svn-gvsig-desktop / trunk / install / launcher / izpack-launcher-1.3 / src / gettext / share / doc / gettext / gettext_2.html @ 7940
History | View | Annotate | Download (33.2 KB)
1 |
<HTML>
|
---|---|
2 |
<HEAD>
|
3 |
<!-- This HTML file has been created by texi2html 1.52a
|
4 |
from gettext.texi on 9 December 2003 -->
|
5 |
|
6 |
<TITLE>GNU gettext utilities - 2 PO Files and PO Mode Basics</TITLE> |
7 |
</HEAD>
|
8 |
<BODY>
|
9 |
Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_1.html">previous</A>, <A HREF="gettext_3.html">next</A>, <A HREF="gettext_22.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>. |
10 |
<P><HR><P> |
11 |
|
12 |
|
13 |
<H1><A NAME="SEC7" HREF="gettext_toc.html#TOC7">2 PO Files and PO Mode Basics</A></H1> |
14 |
|
15 |
<P>
|
16 |
The GNU <CODE>gettext</CODE> toolset helps programmers and translators |
17 |
at producing, updating and using translation files, mainly those |
18 |
PO files which are textual, editable files. This chapter stresses |
19 |
the format of PO files, and contains a PO mode starter. PO mode |
20 |
description is spread throughout this manual instead of being concentrated |
21 |
in one place. Here we present only the basics of PO mode. |
22 |
|
23 |
</P>
|
24 |
|
25 |
|
26 |
|
27 |
<H2><A NAME="SEC8" HREF="gettext_toc.html#TOC8">2.1 Completing GNU <CODE>gettext</CODE> Installation</A></H2> |
28 |
|
29 |
<P>
|
30 |
<A NAME="IDX39"></A> |
31 |
<A NAME="IDX40"></A> |
32 |
Once you have received, unpacked, configured and compiled the GNU |
33 |
<CODE>gettext</CODE> distribution, the <SAMP>`make install´</SAMP> command puts in |
34 |
place the programs <CODE>xgettext</CODE>, <CODE>msgfmt</CODE>, <CODE>gettext</CODE>, and |
35 |
<CODE>msgmerge</CODE>, as well as their available message catalogs. To |
36 |
top off a comfortable installation, you might also want to make the |
37 |
PO mode available to your Emacs users. |
38 |
|
39 |
</P>
|
40 |
<P>
|
41 |
<A NAME="IDX41"></A> |
42 |
<A NAME="IDX42"></A> |
43 |
During the installation of the PO mode, you might want to modify your |
44 |
file <TT>`.emacs´</TT>, once and for all, so it contains a few lines looking |
45 |
like: |
46 |
|
47 |
</P>
|
48 |
|
49 |
<PRE>
|
50 |
(setq auto-mode-alist |
51 |
(cons '("\\.po\\'\\|\\.po\\." . po-mode) auto-mode-alist)) |
52 |
(autoload 'po-mode "po-mode" "Major mode for translators to edit PO files" t) |
53 |
</PRE>
|
54 |
|
55 |
<P>
|
56 |
Later, whenever you edit some <TT>`.po´</TT> |
57 |
file, or any file having the string <SAMP>`.po.´</SAMP> within its name, |
58 |
Emacs loads <TT>`po-mode.elc´</TT> (or <TT>`po-mode.el´</TT>) as needed, and |
59 |
automatically activates PO mode commands for the associated buffer. |
60 |
The string <EM>PO</EM> appears in the mode line for any buffer for |
61 |
which PO mode is active. Many PO files may be active at once in a |
62 |
single Emacs session. |
63 |
|
64 |
</P>
|
65 |
<P>
|
66 |
If you are using Emacs version 20 or newer, and have already installed |
67 |
the appropriate international fonts on your system, you may also tell |
68 |
Emacs how to determine automatically the coding system of every PO file. |
69 |
This will often (but not always) cause the necessary fonts to be loaded |
70 |
and used for displaying the translations on your Emacs screen. For this |
71 |
to happen, add the lines: |
72 |
|
73 |
</P>
|
74 |
|
75 |
<PRE>
|
76 |
(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." |
77 |
'po-find-file-coding-system) |
78 |
(autoload 'po-find-file-coding-system "po-mode") |
79 |
</PRE>
|
80 |
|
81 |
<P>
|
82 |
to your <TT>`.emacs´</TT> file. If, with this, you still see boxes instead |
83 |
of international characters, try a different font set (via Shift Mouse |
84 |
button 1). |
85 |
|
86 |
</P>
|
87 |
|
88 |
|
89 |
<H2><A NAME="SEC9" HREF="gettext_toc.html#TOC9">2.2 The Format of PO Files</A></H2> |
90 |
<P>
|
91 |
<A NAME="IDX43"></A> |
92 |
<A NAME="IDX44"></A> |
93 |
|
94 |
</P>
|
95 |
<P>
|
96 |
A PO file is made up of many entries, each entry holding the relation |
97 |
between an original untranslated string and its corresponding |
98 |
translation. All entries in a given PO file usually pertain |
99 |
to a single project, and all translations are expressed in a single |
100 |
target language. One PO file <EM>entry</EM> has the following schematic |
101 |
structure: |
102 |
|
103 |
</P>
|
104 |
|
105 |
<PRE>
|
106 |
<VAR>white-space</VAR> |
107 |
# <VAR>translator-comments</VAR> |
108 |
#. <VAR>automatic-comments</VAR> |
109 |
#: <VAR>reference</VAR>... |
110 |
#, <VAR>flag</VAR>... |
111 |
msgid <VAR>untranslated-string</VAR> |
112 |
msgstr <VAR>translated-string</VAR> |
113 |
</PRE>
|
114 |
|
115 |
<P>
|
116 |
The general structure of a PO file should be well understood by |
117 |
the translator. When using PO mode, very little has to be known |
118 |
about the format details, as PO mode takes care of them for her. |
119 |
|
120 |
</P>
|
121 |
<P>
|
122 |
A simple entry can look like this: |
123 |
|
124 |
</P>
|
125 |
|
126 |
<PRE>
|
127 |
#: lib/error.c:116 |
128 |
msgid "Unknown system error" |
129 |
msgstr "Error desconegut del sistema" |
130 |
</PRE>
|
131 |
|
132 |
<P>
|
133 |
Entries begin with some optional white space. Usually, when generated |
134 |
through GNU <CODE>gettext</CODE> tools, there is exactly one blank line |
135 |
between entries. Then comments follow, on lines all starting with the |
136 |
character <CODE>#</CODE>. There are two kinds of comments: those which have |
137 |
some white space immediately following the <CODE>#</CODE>, which comments are |
138 |
created and maintained exclusively by the translator, and those which |
139 |
have some non-white character just after the <CODE>#</CODE>, which comments |
140 |
are created and maintained automatically by GNU <CODE>gettext</CODE> tools. |
141 |
All comments, of either kind, are optional. |
142 |
|
143 |
</P>
|
144 |
<P>
|
145 |
<A NAME="IDX45"></A> |
146 |
<A NAME="IDX46"></A> |
147 |
After white space and comments, entries show two strings, namely |
148 |
first the untranslated string as it appears in the original program |
149 |
sources, and then, the translation of this string. The original |
150 |
string is introduced by the keyword <CODE>msgid</CODE>, and the translation, |
151 |
by <CODE>msgstr</CODE>. The two strings, untranslated and translated, |
152 |
are quoted in various ways in the PO file, using <CODE>"</CODE> |
153 |
delimiters and <CODE>\</CODE> escapes, but the translator does not really |
154 |
have to pay attention to the precise quoting format, as PO mode fully |
155 |
takes care of quoting for her. |
156 |
|
157 |
</P>
|
158 |
<P>
|
159 |
The <CODE>msgid</CODE> strings, as well as automatic comments, are produced |
160 |
and managed by other GNU <CODE>gettext</CODE> tools, and PO mode does not |
161 |
provide means for the translator to alter these. The most she can |
162 |
do is merely deleting them, and only by deleting the whole entry. |
163 |
On the other hand, the <CODE>msgstr</CODE> string, as well as translator |
164 |
comments, are really meant for the translator, and PO mode gives her |
165 |
the full control she needs. |
166 |
|
167 |
</P>
|
168 |
<P>
|
169 |
The comment lines beginning with <CODE>#,</CODE> are special because they are |
170 |
not completely ignored by the programs as comments generally are. The |
171 |
comma separated list of <VAR>flag</VAR>s is used by the <CODE>msgfmt</CODE> |
172 |
program to give the user some better diagnostic messages. Currently |
173 |
there are two forms of flags defined: |
174 |
|
175 |
</P>
|
176 |
<DL COMPACT> |
177 |
|
178 |
<DT><CODE>fuzzy</CODE> |
179 |
<DD>
|
180 |
<A NAME="IDX47"></A> |
181 |
This flag can be generated by the <CODE>msgmerge</CODE> program or it can be |
182 |
inserted by the translator herself. It shows that the <CODE>msgstr</CODE> |
183 |
string might not be a correct translation (anymore). Only the translator |
184 |
can judge if the translation requires further modification, or is |
185 |
acceptable as is. Once satisfied with the translation, she then removes |
186 |
this <CODE>fuzzy</CODE> attribute. The <CODE>msgmerge</CODE> program inserts this |
187 |
when it combined the <CODE>msgid</CODE> and <CODE>msgstr</CODE> entries after fuzzy |
188 |
search only. See section <A HREF="gettext_6.html#SEC50">6.3 Fuzzy Entries</A>. |
189 |
|
190 |
<DT><CODE>c-format</CODE> |
191 |
<DD>
|
192 |
<A NAME="IDX48"></A> |
193 |
<DT><CODE>no-c-format</CODE> |
194 |
<DD>
|
195 |
<A NAME="IDX49"></A> |
196 |
These flags should not be added by a human. Instead only the |
197 |
<CODE>xgettext</CODE> program adds them. In an automated PO file processing |
198 |
system as proposed here the user changes would be thrown away again as |
199 |
soon as the <CODE>xgettext</CODE> program generates a new template file. |
200 |
|
201 |
The <CODE>c-format</CODE> flag tells that the untranslated string and the |
202 |
translation are supposed to be C format strings. The <CODE>no-c-format</CODE> |
203 |
flag tells that they are not C format strings, even though the untranslated |
204 |
string happens to look like a C format string (with <SAMP>`%´</SAMP> directives). |
205 |
|
206 |
In case the <CODE>c-format</CODE> flag is given for a string the <CODE>msgfmt</CODE> |
207 |
does some more tests to check to validity of the translation. |
208 |
See section <A HREF="gettext_8.html#SEC134">8.1 Invoking the <CODE>msgfmt</CODE> Program</A>, section <A HREF="gettext_3.html#SEC18">3.5 Special Comments preceding Keywords</A> and section <A HREF="gettext_13.html#SEC221">13.3.1 C Format Strings</A>. |
209 |
|
210 |
<DT><CODE>objc-format</CODE> |
211 |
<DD>
|
212 |
<A NAME="IDX50"></A> |
213 |
<DT><CODE>no-objc-format</CODE> |
214 |
<DD>
|
215 |
<A NAME="IDX51"></A> |
216 |
Likewise for Objective C, see section <A HREF="gettext_13.html#SEC222">13.3.2 Objective C Format Strings</A>. |
217 |
|
218 |
<DT><CODE>sh-format</CODE> |
219 |
<DD>
|
220 |
<A NAME="IDX52"></A> |
221 |
<DT><CODE>no-sh-format</CODE> |
222 |
<DD>
|
223 |
<A NAME="IDX53"></A> |
224 |
Likewise for Shell, see section <A HREF="gettext_13.html#SEC223">13.3.3 Shell Format Strings</A>. |
225 |
|
226 |
<DT><CODE>python-format</CODE> |
227 |
<DD>
|
228 |
<A NAME="IDX54"></A> |
229 |
<DT><CODE>no-python-format</CODE> |
230 |
<DD>
|
231 |
<A NAME="IDX55"></A> |
232 |
Likewise for Python, see section <A HREF="gettext_13.html#SEC224">13.3.4 Python Format Strings</A>. |
233 |
|
234 |
<DT><CODE>lisp-format</CODE> |
235 |
<DD>
|
236 |
<A NAME="IDX56"></A> |
237 |
<DT><CODE>no-lisp-format</CODE> |
238 |
<DD>
|
239 |
<A NAME="IDX57"></A> |
240 |
Likewise for Lisp, see section <A HREF="gettext_13.html#SEC225">13.3.5 Lisp Format Strings</A>. |
241 |
|
242 |
<DT><CODE>elisp-format</CODE> |
243 |
<DD>
|
244 |
<A NAME="IDX58"></A> |
245 |
<DT><CODE>no-elisp-format</CODE> |
246 |
<DD>
|
247 |
<A NAME="IDX59"></A> |
248 |
Likewise for Emacs Lisp, see section <A HREF="gettext_13.html#SEC226">13.3.6 Emacs Lisp Format Strings</A>. |
249 |
|
250 |
<DT><CODE>librep-format</CODE> |
251 |
<DD>
|
252 |
<A NAME="IDX60"></A> |
253 |
<DT><CODE>no-librep-format</CODE> |
254 |
<DD>
|
255 |
<A NAME="IDX61"></A> |
256 |
Likewise for librep, see section <A HREF="gettext_13.html#SEC227">13.3.7 librep Format Strings</A>. |
257 |
|
258 |
<DT><CODE>smalltalk-format</CODE> |
259 |
<DD>
|
260 |
<A NAME="IDX62"></A> |
261 |
<DT><CODE>no-smalltalk-format</CODE> |
262 |
<DD>
|
263 |
<A NAME="IDX63"></A> |
264 |
Likewise for Smalltalk, see section <A HREF="gettext_13.html#SEC228">13.3.8 Smalltalk Format Strings</A>. |
265 |
|
266 |
<DT><CODE>java-format</CODE> |
267 |
<DD>
|
268 |
<A NAME="IDX64"></A> |
269 |
<DT><CODE>no-java-format</CODE> |
270 |
<DD>
|
271 |
<A NAME="IDX65"></A> |
272 |
Likewise for Java, see section <A HREF="gettext_13.html#SEC229">13.3.9 Java Format Strings</A>. |
273 |
|
274 |
<DT><CODE>awk-format</CODE> |
275 |
<DD>
|
276 |
<A NAME="IDX66"></A> |
277 |
<DT><CODE>no-awk-format</CODE> |
278 |
<DD>
|
279 |
<A NAME="IDX67"></A> |
280 |
Likewise for awk, see section <A HREF="gettext_13.html#SEC230">13.3.10 awk Format Strings</A>. |
281 |
|
282 |
<DT><CODE>object-pascal-format</CODE> |
283 |
<DD>
|
284 |
<A NAME="IDX68"></A> |
285 |
<DT><CODE>no-object-pascal-format</CODE> |
286 |
<DD>
|
287 |
<A NAME="IDX69"></A> |
288 |
Likewise for Object Pascal, see section <A HREF="gettext_13.html#SEC231">13.3.11 Object Pascal Format Strings</A>. |
289 |
|
290 |
<DT><CODE>ycp-format</CODE> |
291 |
<DD>
|
292 |
<A NAME="IDX70"></A> |
293 |
<DT><CODE>no-ycp-format</CODE> |
294 |
<DD>
|
295 |
<A NAME="IDX71"></A> |
296 |
Likewise for YCP, see section <A HREF="gettext_13.html#SEC232">13.3.12 YCP Format Strings</A>. |
297 |
|
298 |
<DT><CODE>tcl-format</CODE> |
299 |
<DD>
|
300 |
<A NAME="IDX72"></A> |
301 |
<DT><CODE>no-tcl-format</CODE> |
302 |
<DD>
|
303 |
<A NAME="IDX73"></A> |
304 |
Likewise for Tcl, see section <A HREF="gettext_13.html#SEC233">13.3.13 Tcl Format Strings</A>. |
305 |
|
306 |
<DT><CODE>perl-format</CODE> |
307 |
<DD>
|
308 |
<A NAME="IDX74"></A> |
309 |
<DT><CODE>no-perl-format</CODE> |
310 |
<DD>
|
311 |
<A NAME="IDX75"></A> |
312 |
Likewise for Perl, see section <A HREF="gettext_13.html#SEC234">13.3.14 Perl Format Strings</A>. |
313 |
|
314 |
<DT><CODE>perl-brace-format</CODE> |
315 |
<DD>
|
316 |
<A NAME="IDX76"></A> |
317 |
<DT><CODE>no-perl-brace-format</CODE> |
318 |
<DD>
|
319 |
<A NAME="IDX77"></A> |
320 |
Likewise for Perl brace, see section <A HREF="gettext_13.html#SEC234">13.3.14 Perl Format Strings</A>. |
321 |
|
322 |
<DT><CODE>php-format</CODE> |
323 |
<DD>
|
324 |
<A NAME="IDX78"></A> |
325 |
<DT><CODE>no-php-format</CODE> |
326 |
<DD>
|
327 |
<A NAME="IDX79"></A> |
328 |
Likewise for PHP, see section <A HREF="gettext_13.html#SEC235">13.3.15 PHP Format Strings</A>. |
329 |
|
330 |
<DT><CODE>gcc-internal-format</CODE> |
331 |
<DD>
|
332 |
<A NAME="IDX80"></A> |
333 |
<DT><CODE>no-gcc-internal-format</CODE> |
334 |
<DD>
|
335 |
<A NAME="IDX81"></A> |
336 |
Likewise for the GCC sources, see section <A HREF="gettext_13.html#SEC236">13.3.16 GCC internal Format Strings</A>. |
337 |
|
338 |
<DT><CODE>qt-format</CODE> |
339 |
<DD>
|
340 |
<A NAME="IDX82"></A> |
341 |
<DT><CODE>no-qt-format</CODE> |
342 |
<DD>
|
343 |
<A NAME="IDX83"></A> |
344 |
Likewise for Qt, see section <A HREF="gettext_13.html#SEC237">13.3.17 Qt Format Strings</A>. |
345 |
|
346 |
</DL>
|
347 |
|
348 |
<P>
|
349 |
<A NAME="IDX84"></A> |
350 |
<A NAME="IDX85"></A> |
351 |
A different kind of entries is used for translations which involve |
352 |
plural forms. |
353 |
|
354 |
</P>
|
355 |
|
356 |
<PRE>
|
357 |
<VAR>white-space</VAR> |
358 |
# <VAR>translator-comments</VAR> |
359 |
#. <VAR>automatic-comments</VAR> |
360 |
#: <VAR>reference</VAR>... |
361 |
#, <VAR>flag</VAR>... |
362 |
msgid <VAR>untranslated-string-singular</VAR> |
363 |
msgid_plural <VAR>untranslated-string-plural</VAR> |
364 |
msgstr[0] <VAR>translated-string-case-0</VAR> |
365 |
... |
366 |
msgstr[N] <VAR>translated-string-case-n</VAR> |
367 |
</PRE>
|
368 |
|
369 |
<P>
|
370 |
Such an entry can look like this: |
371 |
|
372 |
</P>
|
373 |
|
374 |
<PRE>
|
375 |
#: src/msgcmp.c:338 src/po-lex.c:699 |
376 |
#, c-format |
377 |
msgid "found %d fatal error" |
378 |
msgid_plural "found %d fatal errors" |
379 |
msgstr[0] "s'ha trobat %d error fatal" |
380 |
msgstr[1] "s'han trobat %d errors fatals" |
381 |
</PRE>
|
382 |
|
383 |
<P>
|
384 |
<A NAME="IDX86"></A> |
385 |
It happens that some lines, usually whitespace or comments, follow the |
386 |
very last entry of a PO file. Such lines are not part of any entry, |
387 |
and PO mode is unable to take action on those lines. By using the |
388 |
PO mode function <KBD>M-x po-normalize</KBD>, the translator may get |
389 |
rid of those spurious lines. See section <A HREF="gettext_2.html#SEC12">2.5 Normalizing Strings in Entries</A>. |
390 |
|
391 |
</P>
|
392 |
<P>
|
393 |
The remainder of this section may be safely skipped by those using |
394 |
PO mode, yet it may be interesting for everybody to have a better |
395 |
idea of the precise format of a PO file. On the other hand, those |
396 |
not having Emacs handy should carefully continue reading on. |
397 |
|
398 |
</P>
|
399 |
<P>
|
400 |
Each of <VAR>untranslated-string</VAR> and <VAR>translated-string</VAR> respects |
401 |
the C syntax for a character string, including the surrounding quotes |
402 |
and embedded backslashed escape sequences. When the time comes |
403 |
to write multi-line strings, one should not use escaped newlines. |
404 |
Instead, a closing quote should follow the last character on the |
405 |
line to be continued, and an opening quote should resume the string |
406 |
at the beginning of the following PO file line. For example: |
407 |
|
408 |
</P>
|
409 |
|
410 |
<PRE>
|
411 |
msgid "" |
412 |
"Here is an example of how one might continue a very long string\n" |
413 |
"for the common case the string represents multi-line output.\n" |
414 |
</PRE>
|
415 |
|
416 |
<P>
|
417 |
In this example, the empty string is used on the first line, to |
418 |
allow better alignment of the <CODE>H</CODE> from the word <SAMP>`Here´</SAMP> |
419 |
over the <CODE>f</CODE> from the word <SAMP>`for´</SAMP>. In this example, the |
420 |
<CODE>msgid</CODE> keyword is followed by three strings, which are meant |
421 |
to be concatenated. Concatenating the empty string does not change |
422 |
the resulting overall string, but it is a way for us to comply with |
423 |
the necessity of <CODE>msgid</CODE> to be followed by a string on the same |
424 |
line, while keeping the multi-line presentation left-justified, as |
425 |
we find this to be a cleaner disposition. The empty string could have |
426 |
been omitted, but only if the string starting with <SAMP>`Here´</SAMP> was |
427 |
promoted on the first line, right after <CODE>msgid</CODE>.<A NAME="DOCF2" HREF="gettext_foot.html#FOOT2">(2)</A> It was not really necessary |
428 |
either to switch between the two last quoted strings immediately after |
429 |
the newline <SAMP>`\n´</SAMP>, the switch could have occurred after <EM>any</EM> |
430 |
other character, we just did it this way because it is neater. |
431 |
|
432 |
</P>
|
433 |
<P>
|
434 |
<A NAME="IDX87"></A> |
435 |
One should carefully distinguish between end of lines marked as |
436 |
<SAMP>`\n´</SAMP> <EM>inside</EM> quotes, which are part of the represented |
437 |
string, and end of lines in the PO file itself, outside string quotes, |
438 |
which have no incidence on the represented string. |
439 |
|
440 |
</P>
|
441 |
<P>
|
442 |
<A NAME="IDX88"></A> |
443 |
Outside strings, white lines and comments may be used freely. |
444 |
Comments start at the beginning of a line with <SAMP>`#´</SAMP> and extend |
445 |
until the end of the PO file line. Comments written by translators |
446 |
should have the initial <SAMP>`#´</SAMP> immediately followed by some white |
447 |
space. If the <SAMP>`#´</SAMP> is not immediately followed by white space, |
448 |
this comment is most likely generated and managed by specialized GNU |
449 |
tools, and might disappear or be replaced unexpectedly when the PO |
450 |
file is given to <CODE>msgmerge</CODE>. |
451 |
|
452 |
</P>
|
453 |
|
454 |
|
455 |
<H2><A NAME="SEC10" HREF="gettext_toc.html#TOC10">2.3 Main PO mode Commands</A></H2> |
456 |
|
457 |
<P>
|
458 |
<A NAME="IDX89"></A> |
459 |
<A NAME="IDX90"></A> |
460 |
After setting up Emacs with something similar to the lines in |
461 |
section <A HREF="gettext_2.html#SEC8">2.1 Completing GNU <CODE>gettext</CODE> Installation</A>, PO mode is activated for a window when Emacs finds a |
462 |
PO file in that window. This puts the window read-only and establishes a |
463 |
po-mode-map, which is a genuine Emacs mode, in a way that is not derived |
464 |
from text mode in any way. Functions found on <CODE>po-mode-hook</CODE>, |
465 |
if any, will be executed. |
466 |
|
467 |
</P>
|
468 |
<P>
|
469 |
When PO mode is active in a window, the letters <SAMP>`PO´</SAMP> appear |
470 |
in the mode line for that window. The mode line also displays how |
471 |
many entries of each kind are held in the PO file. For example, |
472 |
the string <SAMP>`132t+3f+10u+2o´</SAMP> would tell the translator that the |
473 |
PO mode contains 132 translated entries (see section <A HREF="gettext_6.html#SEC49">6.2 Translated Entries</A>, |
474 |
3 fuzzy entries (see section <A HREF="gettext_6.html#SEC50">6.3 Fuzzy Entries</A>), 10 untranslated entries |
475 |
(see section <A HREF="gettext_6.html#SEC51">6.4 Untranslated Entries</A>) and 2 obsolete entries (see section <A HREF="gettext_6.html#SEC52">6.5 Obsolete Entries</A>). Zero-coefficients items are not shown. So, in this example, if |
476 |
the fuzzy entries were unfuzzied, the untranslated entries were translated |
477 |
and the obsolete entries were deleted, the mode line would merely display |
478 |
<SAMP>`145t´</SAMP> for the counters. |
479 |
|
480 |
</P>
|
481 |
<P>
|
482 |
The main PO commands are those which do not fit into the other categories of |
483 |
subsequent sections. These allow for quitting PO mode or for managing windows |
484 |
in special ways. |
485 |
|
486 |
</P>
|
487 |
<DL COMPACT> |
488 |
|
489 |
<DT><KBD>_</KBD> |
490 |
<DD>
|
491 |
<A NAME="IDX91"></A> |
492 |
Undo last modification to the PO file (<CODE>po-undo</CODE>). |
493 |
|
494 |
<DT><KBD>Q</KBD> |
495 |
<DD>
|
496 |
<A NAME="IDX92"></A> |
497 |
Quit processing and save the PO file (<CODE>po-quit</CODE>). |
498 |
|
499 |
<DT><KBD>q</KBD> |
500 |
<DD>
|
501 |
<A NAME="IDX93"></A> |
502 |
Quit processing, possibly after confirmation (<CODE>po-confirm-and-quit</CODE>). |
503 |
|
504 |
<DT><KBD>0</KBD> |
505 |
<DD>
|
506 |
<A NAME="IDX94"></A> |
507 |
Temporary leave the PO file window (<CODE>po-other-window</CODE>). |
508 |
|
509 |
<DT><KBD>?</KBD> |
510 |
<DD>
|
511 |
<DT><KBD>h</KBD> |
512 |
<DD>
|
513 |
<A NAME="IDX95"></A> |
514 |
<A NAME="IDX96"></A> |
515 |
Show help about PO mode (<CODE>po-help</CODE>). |
516 |
|
517 |
<DT><KBD>=</KBD> |
518 |
<DD>
|
519 |
<A NAME="IDX97"></A> |
520 |
Give some PO file statistics (<CODE>po-statistics</CODE>). |
521 |
|
522 |
<DT><KBD>V</KBD> |
523 |
<DD>
|
524 |
<A NAME="IDX98"></A> |
525 |
Batch validate the format of the whole PO file (<CODE>po-validate</CODE>). |
526 |
|
527 |
</DL>
|
528 |
|
529 |
<P>
|
530 |
<A NAME="IDX99"></A> |
531 |
<A NAME="IDX100"></A> |
532 |
The command <KBD>_</KBD> (<CODE>po-undo</CODE>) interfaces to the Emacs |
533 |
<EM>undo</EM> facility. See section `Undoing Changes' in <CITE>The Emacs Editor</CITE>. Each time <KBD>U</KBD> is typed, modifications which the translator |
534 |
did to the PO file are undone a little more. For the purpose of |
535 |
undoing, each PO mode command is atomic. This is especially true for |
536 |
the <KBD><KBD>RET</KBD></KBD> command: the whole edition made by using a single |
537 |
use of this command is undone at once, even if the edition itself |
538 |
implied several actions. However, while in the editing window, one |
539 |
can undo the edition work quite parsimoniously. |
540 |
|
541 |
</P>
|
542 |
<P>
|
543 |
<A NAME="IDX101"></A> |
544 |
<A NAME="IDX102"></A> |
545 |
<A NAME="IDX103"></A> |
546 |
<A NAME="IDX104"></A> |
547 |
The commands <KBD>Q</KBD> (<CODE>po-quit</CODE>) and <KBD>q</KBD> |
548 |
(<CODE>po-confirm-and-quit</CODE>) are used when the translator is done with the |
549 |
PO file. The former is a bit less verbose than the latter. If the file |
550 |
has been modified, it is saved to disk first. In both cases, and prior to |
551 |
all this, the commands check if any untranslated messages remain in the |
552 |
PO file and, if so, the translator is asked if she really wants to leave |
553 |
off working with this PO file. This is the preferred way of getting rid |
554 |
of an Emacs PO file buffer. Merely killing it through the usual command |
555 |
<KBD>C-x k</KBD> (<CODE>kill-buffer</CODE>) is not the tidiest way to proceed. |
556 |
|
557 |
</P>
|
558 |
<P>
|
559 |
<A NAME="IDX105"></A> |
560 |
<A NAME="IDX106"></A> |
561 |
The command <KBD>0</KBD> (<CODE>po-other-window</CODE>) is another, softer way, |
562 |
to leave PO mode, temporarily. It just moves the cursor to some other |
563 |
Emacs window, and pops one if necessary. For example, if the translator |
564 |
just got PO mode to show some source context in some other, she might |
565 |
discover some apparent bug in the program source that needs correction. |
566 |
This command allows the translator to change sex, become a programmer, |
567 |
and have the cursor right into the window containing the program she |
568 |
(or rather <EM>he</EM>) wants to modify. By later getting the cursor back |
569 |
in the PO file window, or by asking Emacs to edit this file once again, |
570 |
PO mode is then recovered. |
571 |
|
572 |
</P>
|
573 |
<P>
|
574 |
<A NAME="IDX107"></A> |
575 |
<A NAME="IDX108"></A> |
576 |
<A NAME="IDX109"></A> |
577 |
The command <KBD>h</KBD> (<CODE>po-help</CODE>) displays a summary of all available PO |
578 |
mode commands. The translator should then type any character to resume |
579 |
normal PO mode operations. The command <KBD>?</KBD> has the same effect |
580 |
as <KBD>h</KBD>. |
581 |
|
582 |
</P>
|
583 |
<P>
|
584 |
<A NAME="IDX110"></A> |
585 |
<A NAME="IDX111"></A> |
586 |
The command <KBD>=</KBD> (<CODE>po-statistics</CODE>) computes the total number of |
587 |
entries in the PO file, the ordinal of the current entry (counted from |
588 |
1), the number of untranslated entries, the number of obsolete entries, |
589 |
and displays all these numbers. |
590 |
|
591 |
</P>
|
592 |
<P>
|
593 |
<A NAME="IDX112"></A> |
594 |
<A NAME="IDX113"></A> |
595 |
The command <KBD>V</KBD> (<CODE>po-validate</CODE>) launches <CODE>msgfmt</CODE> in |
596 |
checking and verbose |
597 |
mode over the current PO file. This command first offers to save the |
598 |
current PO file on disk. The <CODE>msgfmt</CODE> tool, from GNU <CODE>gettext</CODE>, |
599 |
has the purpose of creating a MO file out of a PO file, and PO mode uses |
600 |
the features of this program for checking the overall format of a PO file, |
601 |
as well as all individual entries. |
602 |
|
603 |
</P>
|
604 |
<P>
|
605 |
<A NAME="IDX114"></A> |
606 |
The program <CODE>msgfmt</CODE> runs asynchronously with Emacs, so the |
607 |
translator regains control immediately while her PO file is being studied. |
608 |
Error output is collected in the Emacs <SAMP>`*compilation*´</SAMP> buffer, |
609 |
displayed in another window. The regular Emacs command <KBD>C-x`</KBD> |
610 |
(<CODE>next-error</CODE>), as well as other usual compile commands, allow the |
611 |
translator to reposition quickly to the offending parts of the PO file. |
612 |
Once the cursor is on the line in error, the translator may decide on |
613 |
any PO mode action which would help correcting the error. |
614 |
|
615 |
</P>
|
616 |
|
617 |
|
618 |
<H2><A NAME="SEC11" HREF="gettext_toc.html#TOC11">2.4 Entry Positioning</A></H2> |
619 |
|
620 |
<P>
|
621 |
<A NAME="IDX115"></A> |
622 |
The cursor in a PO file window is almost always part of |
623 |
an entry. The only exceptions are the special case when the cursor |
624 |
is after the last entry in the file, or when the PO file is |
625 |
empty. The entry where the cursor is found to be is said to be the |
626 |
current entry. Many PO mode commands operate on the current entry, |
627 |
so moving the cursor does more than allowing the translator to browse |
628 |
the PO file, this also selects on which entry commands operate. |
629 |
|
630 |
</P>
|
631 |
<P>
|
632 |
<A NAME="IDX116"></A> |
633 |
Some PO mode commands alter the position of the cursor in a specialized |
634 |
way. A few of those special purpose positioning are described here, |
635 |
the others are described in following sections (for a complete list try |
636 |
<KBD>C-h m</KBD>): |
637 |
|
638 |
</P>
|
639 |
<DL COMPACT> |
640 |
|
641 |
<DT><KBD>.</KBD> |
642 |
<DD>
|
643 |
<A NAME="IDX117"></A> |
644 |
Redisplay the current entry (<CODE>po-current-entry</CODE>). |
645 |
|
646 |
<DT><KBD>n</KBD> |
647 |
<DD>
|
648 |
<A NAME="IDX118"></A> |
649 |
Select the entry after the current one (<CODE>po-next-entry</CODE>). |
650 |
|
651 |
<DT><KBD>p</KBD> |
652 |
<DD>
|
653 |
<A NAME="IDX119"></A> |
654 |
Select the entry before the current one (<CODE>po-previous-entry</CODE>). |
655 |
|
656 |
<DT><KBD><</KBD> |
657 |
<DD>
|
658 |
<A NAME="IDX120"></A> |
659 |
Select the first entry in the PO file (<CODE>po-first-entry</CODE>). |
660 |
|
661 |
<DT><KBD>></KBD> |
662 |
<DD>
|
663 |
<A NAME="IDX121"></A> |
664 |
Select the last entry in the PO file (<CODE>po-last-entry</CODE>). |
665 |
|
666 |
<DT><KBD>m</KBD> |
667 |
<DD>
|
668 |
<A NAME="IDX122"></A> |
669 |
Record the location of the current entry for later use |
670 |
(<CODE>po-push-location</CODE>). |
671 |
|
672 |
<DT><KBD>r</KBD> |
673 |
<DD>
|
674 |
<A NAME="IDX123"></A> |
675 |
Return to a previously saved entry location (<CODE>po-pop-location</CODE>). |
676 |
|
677 |
<DT><KBD>x</KBD> |
678 |
<DD>
|
679 |
<A NAME="IDX124"></A> |
680 |
Exchange the current entry location with the previously saved one |
681 |
(<CODE>po-exchange-location</CODE>). |
682 |
|
683 |
</DL>
|
684 |
|
685 |
<P>
|
686 |
<A NAME="IDX125"></A> |
687 |
<A NAME="IDX126"></A> |
688 |
Any Emacs command able to reposition the cursor may be used |
689 |
to select the current entry in PO mode, including commands which |
690 |
move by characters, lines, paragraphs, screens or pages, and search |
691 |
commands. However, there is a kind of standard way to display the |
692 |
current entry in PO mode, which usual Emacs commands moving |
693 |
the cursor do not especially try to enforce. The command <KBD>.</KBD> |
694 |
(<CODE>po-current-entry</CODE>) has the sole purpose of redisplaying the |
695 |
current entry properly, after the current entry has been changed by |
696 |
means external to PO mode, or the Emacs screen otherwise altered. |
697 |
|
698 |
</P>
|
699 |
<P>
|
700 |
It is yet to be decided if PO mode helps the translator, or otherwise |
701 |
irritates her, by forcing a rigid window disposition while she |
702 |
is doing her work. We originally had quite precise ideas about |
703 |
how windows should behave, but on the other hand, anyone used to |
704 |
Emacs is often happy to keep full control. Maybe a fixed window |
705 |
disposition might be offered as a PO mode option that the translator |
706 |
might activate or deactivate at will, so it could be offered on an |
707 |
experimental basis. If nobody feels a real need for using it, or |
708 |
a compulsion for writing it, we should drop this whole idea. |
709 |
The incentive for doing it should come from translators rather than |
710 |
programmers, as opinions from an experienced translator are surely |
711 |
more worth to me than opinions from programmers <EM>thinking</EM> about |
712 |
how <EM>others</EM> should do translation. |
713 |
|
714 |
</P>
|
715 |
<P>
|
716 |
<A NAME="IDX127"></A> |
717 |
<A NAME="IDX128"></A> |
718 |
<A NAME="IDX129"></A> |
719 |
<A NAME="IDX130"></A> |
720 |
The commands <KBD>n</KBD> (<CODE>po-next-entry</CODE>) and <KBD>p</KBD> |
721 |
(<CODE>po-previous-entry</CODE>) move the cursor the entry following, |
722 |
or preceding, the current one. If <KBD>n</KBD> is given while the |
723 |
cursor is on the last entry of the PO file, or if <KBD>p</KBD> |
724 |
is given while the cursor is on the first entry, no move is done. |
725 |
|
726 |
</P>
|
727 |
<P>
|
728 |
<A NAME="IDX131"></A> |
729 |
<A NAME="IDX132"></A> |
730 |
<A NAME="IDX133"></A> |
731 |
<A NAME="IDX134"></A> |
732 |
The commands <KBD><</KBD> (<CODE>po-first-entry</CODE>) and <KBD>></KBD> |
733 |
(<CODE>po-last-entry</CODE>) move the cursor to the first entry, or last |
734 |
entry, of the PO file. When the cursor is located past the last |
735 |
entry in a PO file, most PO mode commands will return an error saying |
736 |
<SAMP>`After last entry´</SAMP>. Moreover, the commands <KBD><</KBD> and <KBD>></KBD> |
737 |
have the special property of being able to work even when the cursor |
738 |
is not into some PO file entry, and one may use them for nicely |
739 |
correcting this situation. But even these commands will fail on a |
740 |
truly empty PO file. There are development plans for the PO mode for it |
741 |
to interactively fill an empty PO file from sources. See section <A HREF="gettext_3.html#SEC17">3.4 Marking Translatable Strings</A>. |
742 |
|
743 |
</P>
|
744 |
<P>
|
745 |
The translator may decide, before working at the translation of |
746 |
a particular entry, that she needs to browse the remainder of the |
747 |
PO file, maybe for finding the terminology or phraseology used |
748 |
in related entries. She can of course use the standard Emacs idioms |
749 |
for saving the current cursor location in some register, and use that |
750 |
register for getting back, or else, use the location ring. |
751 |
|
752 |
</P>
|
753 |
<P>
|
754 |
<A NAME="IDX135"></A> |
755 |
<A NAME="IDX136"></A> |
756 |
<A NAME="IDX137"></A> |
757 |
<A NAME="IDX138"></A> |
758 |
PO mode offers another approach, by which cursor locations may be saved |
759 |
onto a special stack. The command <KBD>m</KBD> (<CODE>po-push-location</CODE>) |
760 |
merely adds the location of current entry to the stack, pushing |
761 |
the already saved locations under the new one. The command |
762 |
<KBD>r</KBD> (<CODE>po-pop-location</CODE>) consumes the top stack element and |
763 |
repositions the cursor to the entry associated with that top element. |
764 |
This position is then lost, for the next <KBD>r</KBD> will move the cursor |
765 |
to the previously saved location, and so on until no locations remain |
766 |
on the stack. |
767 |
|
768 |
</P>
|
769 |
<P>
|
770 |
If the translator wants the position to be kept on the location stack, |
771 |
maybe for taking a look at the entry associated with the top |
772 |
element, then go elsewhere with the intent of getting back later, she |
773 |
ought to use <KBD>m</KBD> immediately after <KBD>r</KBD>. |
774 |
|
775 |
</P>
|
776 |
<P>
|
777 |
<A NAME="IDX139"></A> |
778 |
<A NAME="IDX140"></A> |
779 |
The command <KBD>x</KBD> (<CODE>po-exchange-location</CODE>) simultaneously |
780 |
repositions the cursor to the entry associated with the top element of |
781 |
the stack of saved locations, and replaces that top element with the |
782 |
location of the current entry before the move. Consequently, repeating |
783 |
the <KBD>x</KBD> command toggles alternatively between two entries. |
784 |
For achieving this, the translator will position the cursor on the |
785 |
first entry, use <KBD>m</KBD>, then position to the second entry, and |
786 |
merely use <KBD>x</KBD> for making the switch. |
787 |
|
788 |
</P>
|
789 |
|
790 |
|
791 |
<H2><A NAME="SEC12" HREF="gettext_toc.html#TOC12">2.5 Normalizing Strings in Entries</A></H2> |
792 |
<P>
|
793 |
<A NAME="IDX141"></A> |
794 |
|
795 |
</P>
|
796 |
<P>
|
797 |
There are many different ways for encoding a particular string into a |
798 |
PO file entry, because there are so many different ways to split and |
799 |
quote multi-line strings, and even, to represent special characters |
800 |
by backslashed escaped sequences. Some features of PO mode rely on |
801 |
the ability for PO mode to scan an already existing PO file for a |
802 |
particular string encoded into the <CODE>msgid</CODE> field of some entry. |
803 |
Even if PO mode has internally all the built-in machinery for |
804 |
implementing this recognition easily, doing it fast is technically |
805 |
difficult. To facilitate a solution to this efficiency problem, |
806 |
we decided on a canonical representation for strings. |
807 |
|
808 |
</P>
|
809 |
<P>
|
810 |
A conventional representation of strings in a PO file is currently |
811 |
under discussion, and PO mode experiments with a canonical representation. |
812 |
Having both <CODE>xgettext</CODE> and PO mode converging towards a uniform |
813 |
way of representing equivalent strings would be useful, as the internal |
814 |
normalization needed by PO mode could be automatically satisfied |
815 |
when using <CODE>xgettext</CODE> from GNU <CODE>gettext</CODE>. An explicit |
816 |
PO mode normalization should then be only necessary for PO files |
817 |
imported from elsewhere, or for when the convention itself evolves. |
818 |
|
819 |
</P>
|
820 |
<P>
|
821 |
So, for achieving normalization of at least the strings of a given |
822 |
PO file needing a canonical representation, the following PO mode |
823 |
command is available: |
824 |
|
825 |
</P>
|
826 |
<P>
|
827 |
<A NAME="IDX142"></A> |
828 |
<DL COMPACT> |
829 |
|
830 |
<DT><KBD>M-x po-normalize</KBD> |
831 |
<DD>
|
832 |
<A NAME="IDX143"></A> |
833 |
Tidy the whole PO file by making entries more uniform. |
834 |
|
835 |
</DL>
|
836 |
|
837 |
<P>
|
838 |
The special command <KBD>M-x po-normalize</KBD>, which has no associated |
839 |
keys, revises all entries, ensuring that strings of both original |
840 |
and translated entries use uniform internal quoting in the PO file. |
841 |
It also removes any crumb after the last entry. This command may be |
842 |
useful for PO files freshly imported from elsewhere, or if we ever |
843 |
improve on the canonical quoting format we use. This canonical format |
844 |
is not only meant for getting cleaner PO files, but also for greatly |
845 |
speeding up <CODE>msgid</CODE> string lookup for some other PO mode commands. |
846 |
|
847 |
</P>
|
848 |
<P>
|
849 |
<KBD>M-x po-normalize</KBD> presently makes three passes over the entries. |
850 |
The first implements heuristics for converting PO files for GNU |
851 |
<CODE>gettext</CODE> 0.6 and earlier, in which <CODE>msgid</CODE> and <CODE>msgstr</CODE> |
852 |
fields were using K&R style C string syntax for multi-line strings.
|
853 |
These heuristics may fail for comments not related to obsolete |
854 |
entries and ending with a backslash; they also depend on subsequent |
855 |
passes for finalizing the proper commenting of continued lines for |
856 |
obsolete entries. This first pass might disappear once all oldish PO |
857 |
files would have been adjusted. The second and third pass normalize |
858 |
all <CODE>msgid</CODE> and <CODE>msgstr</CODE> strings respectively. They also |
859 |
clean out those trailing backslashes used by XView's <CODE>msgfmt</CODE> |
860 |
for continued lines. |
861 |
|
862 |
</P>
|
863 |
<P>
|
864 |
<A NAME="IDX144"></A> |
865 |
Having such an explicit normalizing command allows for importing PO |
866 |
files from other sources, but also eases the evolution of the current |
867 |
convention, evolution driven mostly by aesthetic concerns, as of now. |
868 |
It is easy to make suggested adjustments at a later time, as the |
869 |
normalizing command and eventually, other GNU <CODE>gettext</CODE> tools |
870 |
should greatly automate conformance. A description of the canonical |
871 |
string format is given below, for the particular benefit of those not |
872 |
having Emacs handy, and who would nevertheless want to handcraft |
873 |
their PO files in nice ways. |
874 |
|
875 |
</P>
|
876 |
<P>
|
877 |
<A NAME="IDX145"></A> |
878 |
Right now, in PO mode, strings are single line or multi-line. A string |
879 |
goes multi-line if and only if it has <EM>embedded</EM> newlines, that |
880 |
is, if it matches <SAMP>`[^\n]\n+[^\n]´</SAMP>. So, we would have: |
881 |
|
882 |
</P>
|
883 |
|
884 |
<PRE>
|
885 |
msgstr "\n\nHello, world!\n\n\n" |
886 |
</PRE>
|
887 |
|
888 |
<P>
|
889 |
but, replacing the space by a newline, this becomes: |
890 |
|
891 |
</P>
|
892 |
|
893 |
<PRE>
|
894 |
msgstr "" |
895 |
"\n" |
896 |
"\n" |
897 |
"Hello,\n" |
898 |
"world!\n" |
899 |
"\n" |
900 |
"\n" |
901 |
</PRE>
|
902 |
|
903 |
<P>
|
904 |
We are deliberately using a caricatural example, here, to make the |
905 |
point clearer. Usually, multi-lines are not that bad looking. |
906 |
It is probable that we will implement the following suggestion. |
907 |
We might lump together all initial newlines into the empty string, |
908 |
and also all newlines introducing empty lines (that is, for <VAR>n</VAR> |
909 |
> 1, the <VAR>n</VAR>-1'th last newlines would go together on a separate |
910 |
string), so making the previous example appear: |
911 |
|
912 |
</P>
|
913 |
|
914 |
<PRE>
|
915 |
msgstr "\n\n" |
916 |
"Hello,\n" |
917 |
"world!\n" |
918 |
"\n\n" |
919 |
</PRE>
|
920 |
|
921 |
<P>
|
922 |
There are a few yet undecided little points about string normalization, |
923 |
to be documented in this manual, once these questions settle. |
924 |
|
925 |
</P>
|
926 |
<P><HR><P> |
927 |
Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_1.html">previous</A>, <A HREF="gettext_3.html">next</A>, <A HREF="gettext_22.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>. |
928 |
</BODY>
|
929 |
</HTML>
|