Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/share/doc/gettext/gettext_8.html @ 68:5028fdace37b
planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author | jpayne |
---|---|
date | Tue, 18 Mar 2025 16:23:26 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
67:0e9998148a16 | 68:5028fdace37b |
---|---|
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd"> | |
2 <html> | |
3 <!-- Created on February, 21 2024 by texi2html 1.78a --> | |
4 <!-- | |
5 Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) | |
6 Karl Berry <karl@freefriends.org> | |
7 Olaf Bachmann <obachman@mathematik.uni-kl.de> | |
8 and many others. | |
9 Maintained by: Many creative people. | |
10 Send bugs and suggestions to <texi2html-bug@nongnu.org> | |
11 | |
12 --> | |
13 <head> | |
14 <title>GNU gettext utilities: 8. Editing PO Files</title> | |
15 | |
16 <meta name="description" content="GNU gettext utilities: 8. Editing PO Files"> | |
17 <meta name="keywords" content="GNU gettext utilities: 8. Editing PO Files"> | |
18 <meta name="resource-type" content="document"> | |
19 <meta name="distribution" content="global"> | |
20 <meta name="Generator" content="texi2html 1.78a"> | |
21 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
22 <style type="text/css"> | |
23 <!-- | |
24 a.summary-letter {text-decoration: none} | |
25 pre.display {font-family: serif} | |
26 pre.format {font-family: serif} | |
27 pre.menu-comment {font-family: serif} | |
28 pre.menu-preformatted {font-family: serif} | |
29 pre.smalldisplay {font-family: serif; font-size: smaller} | |
30 pre.smallexample {font-size: smaller} | |
31 pre.smallformat {font-family: serif; font-size: smaller} | |
32 pre.smalllisp {font-size: smaller} | |
33 span.roman {font-family:serif; font-weight:normal;} | |
34 span.sansserif {font-family:sans-serif; font-weight:normal;} | |
35 ul.toc {list-style: none} | |
36 --> | |
37 </style> | |
38 | |
39 | |
40 </head> | |
41 | |
42 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> | |
43 | |
44 <table cellpadding="1" cellspacing="1" border="0"> | |
45 <tr><td valign="middle" align="left">[<a href="gettext_7.html#SEC53" title="Beginning of this chapter or previous chapter"> << </a>]</td> | |
46 <td valign="middle" align="left">[<a href="gettext_9.html#SEC87" title="Next chapter"> >> </a>]</td> | |
47 <td valign="middle" align="left"> </td> | |
48 <td valign="middle" align="left"> </td> | |
49 <td valign="middle" align="left"> </td> | |
50 <td valign="middle" align="left"> </td> | |
51 <td valign="middle" align="left"> </td> | |
52 <td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> | |
53 <td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td> | |
54 <td valign="middle" align="left">[<a href="gettext_21.html#SEC389" title="Index">Index</a>]</td> | |
55 <td valign="middle" align="left">[<a href="gettext_abt.html#SEC_About" title="About (help)"> ? </a>]</td> | |
56 </tr></table> | |
57 | |
58 <hr size="2"> | |
59 <a name="Editing"></a> | |
60 <a name="SEC63"></a> | |
61 <h1 class="chapter"> <a href="gettext_toc.html#TOC56">8. Editing PO Files</a> </h1> | |
62 | |
63 | |
64 | |
65 <a name="KBabel"></a> | |
66 <a name="SEC64"></a> | |
67 <h2 class="section"> <a href="gettext_toc.html#TOC57">8.1 KDE's PO File Editor</a> </h2> | |
68 | |
69 | |
70 <a name="Gtranslator"></a> | |
71 <a name="SEC65"></a> | |
72 <h2 class="section"> <a href="gettext_toc.html#TOC58">8.2 GNOME's PO File Editor</a> </h2> | |
73 | |
74 | |
75 <a name="PO-Mode"></a> | |
76 <a name="SEC66"></a> | |
77 <h2 class="section"> <a href="gettext_toc.html#TOC59">8.3 Emacs's PO File Editor</a> </h2> | |
78 | |
79 | |
80 <p>For those of you being | |
81 the lucky users of Emacs, PO mode has been specifically created | |
82 for providing a cozy environment for editing or modifying PO files. | |
83 While editing a PO file, PO mode allows for the easy browsing of | |
84 auxiliary and compendium PO files, as well as for following references into | |
85 the set of C program sources from which PO files have been derived. | |
86 It has a few special features, among which are the interactive marking | |
87 of program strings as translatable, and the validation of PO files | |
88 with easy repositioning to PO file lines showing errors. | |
89 </p> | |
90 <p>For the beginning, besides main PO mode commands | |
91 (see section <a href="#SEC68">Main PO mode Commands</a>), you should know how to move between entries | |
92 (see section <a href="#SEC69">Entry Positioning</a>), and how to handle untranslated entries | |
93 (see section <a href="#SEC73">Untranslated Entries</a>). | |
94 </p> | |
95 | |
96 | |
97 <a name="Installation"></a> | |
98 <a name="SEC67"></a> | |
99 <h3 class="subsection"> <a href="gettext_toc.html#TOC60">8.3.1 Completing GNU <code>gettext</code> Installation</a> </h3> | |
100 | |
101 <p>Once you have received, unpacked, configured and compiled the GNU | |
102 <code>gettext</code> distribution, the ‘<samp>make install</samp>’ command puts in | |
103 place the programs <code>xgettext</code>, <code>msgfmt</code>, <code>gettext</code>, and | |
104 <code>msgmerge</code>, as well as their available message catalogs. To | |
105 top off a comfortable installation, you might also want to make the | |
106 PO mode available to your Emacs users. | |
107 </p> | |
108 <a name="IDX312"></a> | |
109 <a name="IDX313"></a> | |
110 <p>During the installation of the PO mode, you might want to modify your | |
111 file ‘<tt>.emacs</tt>’, once and for all, so it contains a few lines looking | |
112 like: | |
113 </p> | |
114 <table><tr><td> </td><td><pre class="example">(setq auto-mode-alist | |
115 (cons '("\\.po\\'\\|\\.po\\." . po-mode) auto-mode-alist)) | |
116 (autoload 'po-mode "po-mode" "Major mode for translators to edit PO files" t) | |
117 </pre></td></tr></table> | |
118 | |
119 <p>Later, whenever you edit some ‘<tt>.po</tt>’ | |
120 file, or any file having the string ‘<samp>.po.</samp>’ within its name, | |
121 Emacs loads ‘<tt>po-mode.elc</tt>’ (or ‘<tt>po-mode.el</tt>’) as needed, and | |
122 automatically activates PO mode commands for the associated buffer. | |
123 The string <em>PO</em> appears in the mode line for any buffer for | |
124 which PO mode is active. Many PO files may be active at once in a | |
125 single Emacs session. | |
126 </p> | |
127 <p>If you are using Emacs version 20 or newer, and have already installed | |
128 the appropriate international fonts on your system, you may also tell | |
129 Emacs how to determine automatically the coding system of every PO file. | |
130 This will often (but not always) cause the necessary fonts to be loaded | |
131 and used for displaying the translations on your Emacs screen. For this | |
132 to happen, add the lines: | |
133 </p> | |
134 <table><tr><td> </td><td><pre class="example">(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." | |
135 'po-find-file-coding-system) | |
136 (autoload 'po-find-file-coding-system "po-mode") | |
137 </pre></td></tr></table> | |
138 | |
139 <p>to your ‘<tt>.emacs</tt>’ file. If, with this, you still see boxes instead | |
140 of international characters, try a different font set (via Shift Mouse | |
141 button 1). | |
142 </p> | |
143 | |
144 <a name="Main-PO-Commands"></a> | |
145 <a name="SEC68"></a> | |
146 <h3 class="subsection"> <a href="gettext_toc.html#TOC61">8.3.2 Main PO mode Commands</a> </h3> | |
147 | |
148 <p>After setting up Emacs with something similar to the lines in | |
149 <a href="#SEC67">Completing GNU <code>gettext</code> Installation</a>, PO mode is activated for a window when Emacs finds a | |
150 PO file in that window. This puts the window read-only and establishes a | |
151 po-mode-map, which is a genuine Emacs mode, in a way that is not derived | |
152 from text mode in any way. Functions found on <code>po-mode-hook</code>, | |
153 if any, will be executed. | |
154 </p> | |
155 <p>When PO mode is active in a window, the letters ‘<samp>PO</samp>’ appear | |
156 in the mode line for that window. The mode line also displays how | |
157 many entries of each kind are held in the PO file. For example, | |
158 the string ‘<samp>132t+3f+10u+2o</samp>’ would tell the translator that the | |
159 PO mode contains 132 translated entries (see section <a href="#SEC71">Translated Entries</a>, | |
160 3 fuzzy entries (see section <a href="#SEC72">Fuzzy Entries</a>), 10 untranslated entries | |
161 (see section <a href="#SEC73">Untranslated Entries</a>) and 2 obsolete entries (see section <a href="#SEC74">Obsolete Entries</a>). Zero-coefficients items are not shown. So, in this example, if | |
162 the fuzzy entries were unfuzzied, the untranslated entries were translated | |
163 and the obsolete entries were deleted, the mode line would merely display | |
164 ‘<samp>145t</samp>’ for the counters. | |
165 </p> | |
166 <p>The main PO commands are those which do not fit into the other categories of | |
167 subsequent sections. These allow for quitting PO mode or for managing windows | |
168 in special ways. | |
169 </p> | |
170 <dl compact="compact"> | |
171 <dt> <kbd>_</kbd></dt> | |
172 <dd><a name="IDX314"></a> | |
173 <p>Undo last modification to the PO file (<code>po-undo</code>). | |
174 </p> | |
175 </dd> | |
176 <dt> <kbd>Q</kbd></dt> | |
177 <dd><a name="IDX315"></a> | |
178 <p>Quit processing and save the PO file (<code>po-quit</code>). | |
179 </p> | |
180 </dd> | |
181 <dt> <kbd>q</kbd></dt> | |
182 <dd><a name="IDX316"></a> | |
183 <p>Quit processing, possibly after confirmation (<code>po-confirm-and-quit</code>). | |
184 </p> | |
185 </dd> | |
186 <dt> <kbd>0</kbd></dt> | |
187 <dd><a name="IDX317"></a> | |
188 <p>Temporary leave the PO file window (<code>po-other-window</code>). | |
189 </p> | |
190 </dd> | |
191 <dt> <kbd>?</kbd></dt> | |
192 <dt> <kbd>h</kbd></dt> | |
193 <dd><a name="IDX318"></a> | |
194 <a name="IDX319"></a> | |
195 <p>Show help about PO mode (<code>po-help</code>). | |
196 </p> | |
197 </dd> | |
198 <dt> <kbd>=</kbd></dt> | |
199 <dd><a name="IDX320"></a> | |
200 <p>Give some PO file statistics (<code>po-statistics</code>). | |
201 </p> | |
202 </dd> | |
203 <dt> <kbd>V</kbd></dt> | |
204 <dd><a name="IDX321"></a> | |
205 <p>Batch validate the format of the whole PO file (<code>po-validate</code>). | |
206 </p> | |
207 </dd> | |
208 </dl> | |
209 | |
210 <a name="IDX322"></a> | |
211 <a name="IDX323"></a> | |
212 <p>The command <kbd>_</kbd> (<code>po-undo</code>) interfaces to the Emacs | |
213 <em>undo</em> facility. See <a href="../emacs/Undo.html#Undo">(emacs)Undo</a> section `Undoing Changes' in <cite>The Emacs Editor</cite>. Each time <kbd>_</kbd> is typed, modifications which the translator | |
214 did to the PO file are undone a little more. For the purpose of | |
215 undoing, each PO mode command is atomic. This is especially true for | |
216 the <kbd><RET></kbd> command: the whole edition made by using a single | |
217 use of this command is undone at once, even if the edition itself | |
218 implied several actions. However, while in the editing window, one | |
219 can undo the edition work quite parsimoniously. | |
220 </p> | |
221 <a name="IDX324"></a> | |
222 <a name="IDX325"></a> | |
223 <a name="IDX326"></a> | |
224 <a name="IDX327"></a> | |
225 <p>The commands <kbd>Q</kbd> (<code>po-quit</code>) and <kbd>q</kbd> | |
226 (<code>po-confirm-and-quit</code>) are used when the translator is done with the | |
227 PO file. The former is a bit less verbose than the latter. If the file | |
228 has been modified, it is saved to disk first. In both cases, and prior to | |
229 all this, the commands check if any untranslated messages remain in the | |
230 PO file and, if so, the translator is asked if she really wants to leave | |
231 off working with this PO file. This is the preferred way of getting rid | |
232 of an Emacs PO file buffer. Merely killing it through the usual command | |
233 <kbd>C-x k</kbd> (<code>kill-buffer</code>) is not the tidiest way to proceed. | |
234 </p> | |
235 <a name="IDX328"></a> | |
236 <a name="IDX329"></a> | |
237 <p>The command <kbd>0</kbd> (<code>po-other-window</code>) is another, softer way, | |
238 to leave PO mode, temporarily. It just moves the cursor to some other | |
239 Emacs window, and pops one if necessary. For example, if the translator | |
240 just got PO mode to show some source context in some other, she might | |
241 discover some apparent bug in the program source that needs correction. | |
242 This command allows the translator to change sex, become a programmer, | |
243 and have the cursor right into the window containing the program she | |
244 (or rather <em>he</em>) wants to modify. By later getting the cursor back | |
245 in the PO file window, or by asking Emacs to edit this file once again, | |
246 PO mode is then recovered. | |
247 </p> | |
248 <a name="IDX330"></a> | |
249 <a name="IDX331"></a> | |
250 <a name="IDX332"></a> | |
251 <p>The command <kbd>h</kbd> (<code>po-help</code>) displays a summary of all available PO | |
252 mode commands. The translator should then type any character to resume | |
253 normal PO mode operations. The command <kbd>?</kbd> has the same effect | |
254 as <kbd>h</kbd>. | |
255 </p> | |
256 <a name="IDX333"></a> | |
257 <a name="IDX334"></a> | |
258 <p>The command <kbd>=</kbd> (<code>po-statistics</code>) computes the total number of | |
259 entries in the PO file, the ordinal of the current entry (counted from | |
260 1), the number of untranslated entries, the number of obsolete entries, | |
261 and displays all these numbers. | |
262 </p> | |
263 <a name="IDX335"></a> | |
264 <a name="IDX336"></a> | |
265 <p>The command <kbd>V</kbd> (<code>po-validate</code>) launches <code>msgfmt</code> in | |
266 checking and verbose | |
267 mode over the current PO file. This command first offers to save the | |
268 current PO file on disk. The <code>msgfmt</code> tool, from GNU <code>gettext</code>, | |
269 has the purpose of creating a MO file out of a PO file, and PO mode uses | |
270 the features of this program for checking the overall format of a PO file, | |
271 as well as all individual entries. | |
272 </p> | |
273 <a name="IDX337"></a> | |
274 <p>The program <code>msgfmt</code> runs asynchronously with Emacs, so the | |
275 translator regains control immediately while her PO file is being studied. | |
276 Error output is collected in the Emacs ‘<samp>*compilation*</samp>’ buffer, | |
277 displayed in another window. The regular Emacs command <kbd>C-x`</kbd> | |
278 (<code>next-error</code>), as well as other usual compile commands, allow the | |
279 translator to reposition quickly to the offending parts of the PO file. | |
280 Once the cursor is on the line in error, the translator may decide on | |
281 any PO mode action which would help correcting the error. | |
282 </p> | |
283 | |
284 <a name="Entry-Positioning"></a> | |
285 <a name="SEC69"></a> | |
286 <h3 class="subsection"> <a href="gettext_toc.html#TOC62">8.3.3 Entry Positioning</a> </h3> | |
287 | |
288 <p>The cursor in a PO file window is almost always part of | |
289 an entry. The only exceptions are the special case when the cursor | |
290 is after the last entry in the file, or when the PO file is | |
291 empty. The entry where the cursor is found to be is said to be the | |
292 current entry. Many PO mode commands operate on the current entry, | |
293 so moving the cursor does more than allowing the translator to browse | |
294 the PO file, this also selects on which entry commands operate. | |
295 </p> | |
296 <a name="IDX338"></a> | |
297 <p>Some PO mode commands alter the position of the cursor in a specialized | |
298 way. A few of those special purpose positioning are described here, | |
299 the others are described in following sections (for a complete list try | |
300 <kbd>C-h m</kbd>): | |
301 </p> | |
302 <dl compact="compact"> | |
303 <dt> <kbd>.</kbd></dt> | |
304 <dd><a name="IDX339"></a> | |
305 <p>Redisplay the current entry (<code>po-current-entry</code>). | |
306 </p> | |
307 </dd> | |
308 <dt> <kbd>n</kbd></dt> | |
309 <dd><a name="IDX340"></a> | |
310 <p>Select the entry after the current one (<code>po-next-entry</code>). | |
311 </p> | |
312 </dd> | |
313 <dt> <kbd>p</kbd></dt> | |
314 <dd><a name="IDX341"></a> | |
315 <p>Select the entry before the current one (<code>po-previous-entry</code>). | |
316 </p> | |
317 </dd> | |
318 <dt> <kbd><</kbd></dt> | |
319 <dd><a name="IDX342"></a> | |
320 <p>Select the first entry in the PO file (<code>po-first-entry</code>). | |
321 </p> | |
322 </dd> | |
323 <dt> <kbd>></kbd></dt> | |
324 <dd><a name="IDX343"></a> | |
325 <p>Select the last entry in the PO file (<code>po-last-entry</code>). | |
326 </p> | |
327 </dd> | |
328 <dt> <kbd>m</kbd></dt> | |
329 <dd><a name="IDX344"></a> | |
330 <p>Record the location of the current entry for later use | |
331 (<code>po-push-location</code>). | |
332 </p> | |
333 </dd> | |
334 <dt> <kbd>r</kbd></dt> | |
335 <dd><a name="IDX345"></a> | |
336 <p>Return to a previously saved entry location (<code>po-pop-location</code>). | |
337 </p> | |
338 </dd> | |
339 <dt> <kbd>x</kbd></dt> | |
340 <dd><a name="IDX346"></a> | |
341 <p>Exchange the current entry location with the previously saved one | |
342 (<code>po-exchange-location</code>). | |
343 </p> | |
344 </dd> | |
345 </dl> | |
346 | |
347 <a name="IDX347"></a> | |
348 <a name="IDX348"></a> | |
349 <p>Any Emacs command able to reposition the cursor may be used | |
350 to select the current entry in PO mode, including commands which | |
351 move by characters, lines, paragraphs, screens or pages, and search | |
352 commands. However, there is a kind of standard way to display the | |
353 current entry in PO mode, which usual Emacs commands moving | |
354 the cursor do not especially try to enforce. The command <kbd>.</kbd> | |
355 (<code>po-current-entry</code>) has the sole purpose of redisplaying the | |
356 current entry properly, after the current entry has been changed by | |
357 means external to PO mode, or the Emacs screen otherwise altered. | |
358 </p> | |
359 <p>It is yet to be decided if PO mode helps the translator, or otherwise | |
360 irritates her, by forcing a rigid window disposition while she | |
361 is doing her work. We originally had quite precise ideas about | |
362 how windows should behave, but on the other hand, anyone used to | |
363 Emacs is often happy to keep full control. Maybe a fixed window | |
364 disposition might be offered as a PO mode option that the translator | |
365 might activate or deactivate at will, so it could be offered on an | |
366 experimental basis. If nobody feels a real need for using it, or | |
367 a compulsion for writing it, we should drop this whole idea. | |
368 The incentive for doing it should come from translators rather than | |
369 programmers, as opinions from an experienced translator are surely | |
370 more worth to me than opinions from programmers <em>thinking</em> about | |
371 how <em>others</em> should do translation. | |
372 </p> | |
373 <a name="IDX349"></a> | |
374 <a name="IDX350"></a> | |
375 <a name="IDX351"></a> | |
376 <a name="IDX352"></a> | |
377 <p>The commands <kbd>n</kbd> (<code>po-next-entry</code>) and <kbd>p</kbd> | |
378 (<code>po-previous-entry</code>) move the cursor the entry following, | |
379 or preceding, the current one. If <kbd>n</kbd> is given while the | |
380 cursor is on the last entry of the PO file, or if <kbd>p</kbd> | |
381 is given while the cursor is on the first entry, no move is done. | |
382 </p> | |
383 <a name="IDX353"></a> | |
384 <a name="IDX354"></a> | |
385 <a name="IDX355"></a> | |
386 <a name="IDX356"></a> | |
387 <p>The commands <kbd><</kbd> (<code>po-first-entry</code>) and <kbd>></kbd> | |
388 (<code>po-last-entry</code>) move the cursor to the first entry, or last | |
389 entry, of the PO file. When the cursor is located past the last | |
390 entry in a PO file, most PO mode commands will return an error saying | |
391 ‘<samp>After last entry</samp>’. Moreover, the commands <kbd><</kbd> and <kbd>></kbd> | |
392 have the special property of being able to work even when the cursor | |
393 is not into some PO file entry, and one may use them for nicely | |
394 correcting this situation. But even these commands will fail on a | |
395 truly empty PO file. There are development plans for the PO mode for it | |
396 to interactively fill an empty PO file from sources. See section <a href="gettext_4.html#SEC29">Marking Translatable Strings</a>. | |
397 </p> | |
398 <p>The translator may decide, before working at the translation of | |
399 a particular entry, that she needs to browse the remainder of the | |
400 PO file, maybe for finding the terminology or phraseology used | |
401 in related entries. She can of course use the standard Emacs idioms | |
402 for saving the current cursor location in some register, and use that | |
403 register for getting back, or else, use the location ring. | |
404 </p> | |
405 <a name="IDX357"></a> | |
406 <a name="IDX358"></a> | |
407 <a name="IDX359"></a> | |
408 <a name="IDX360"></a> | |
409 <p>PO mode offers another approach, by which cursor locations may be saved | |
410 onto a special stack. The command <kbd>m</kbd> (<code>po-push-location</code>) | |
411 merely adds the location of current entry to the stack, pushing | |
412 the already saved locations under the new one. The command | |
413 <kbd>r</kbd> (<code>po-pop-location</code>) consumes the top stack element and | |
414 repositions the cursor to the entry associated with that top element. | |
415 This position is then lost, for the next <kbd>r</kbd> will move the cursor | |
416 to the previously saved location, and so on until no locations remain | |
417 on the stack. | |
418 </p> | |
419 <p>If the translator wants the position to be kept on the location stack, | |
420 maybe for taking a look at the entry associated with the top | |
421 element, then go elsewhere with the intent of getting back later, she | |
422 ought to use <kbd>m</kbd> immediately after <kbd>r</kbd>. | |
423 </p> | |
424 <a name="IDX361"></a> | |
425 <a name="IDX362"></a> | |
426 <p>The command <kbd>x</kbd> (<code>po-exchange-location</code>) simultaneously | |
427 repositions the cursor to the entry associated with the top element of | |
428 the stack of saved locations, and replaces that top element with the | |
429 location of the current entry before the move. Consequently, repeating | |
430 the <kbd>x</kbd> command toggles alternatively between two entries. | |
431 For achieving this, the translator will position the cursor on the | |
432 first entry, use <kbd>m</kbd>, then position to the second entry, and | |
433 merely use <kbd>x</kbd> for making the switch. | |
434 </p> | |
435 | |
436 <a name="Normalizing"></a> | |
437 <a name="SEC70"></a> | |
438 <h3 class="subsection"> <a href="gettext_toc.html#TOC63">8.3.4 Normalizing Strings in Entries</a> </h3> | |
439 | |
440 <p>There are many different ways for encoding a particular string into a | |
441 PO file entry, because there are so many different ways to split and | |
442 quote multi-line strings, and even, to represent special characters | |
443 by backslashed escaped sequences. Some features of PO mode rely on | |
444 the ability for PO mode to scan an already existing PO file for a | |
445 particular string encoded into the <code>msgid</code> field of some entry. | |
446 Even if PO mode has internally all the built-in machinery for | |
447 implementing this recognition easily, doing it fast is technically | |
448 difficult. To facilitate a solution to this efficiency problem, | |
449 we decided on a canonical representation for strings. | |
450 </p> | |
451 <p>A conventional representation of strings in a PO file is currently | |
452 under discussion, and PO mode experiments with a canonical representation. | |
453 Having both <code>xgettext</code> and PO mode converging towards a uniform | |
454 way of representing equivalent strings would be useful, as the internal | |
455 normalization needed by PO mode could be automatically satisfied | |
456 when using <code>xgettext</code> from GNU <code>gettext</code>. An explicit | |
457 PO mode normalization should then be only necessary for PO files | |
458 imported from elsewhere, or for when the convention itself evolves. | |
459 </p> | |
460 <p>So, for achieving normalization of at least the strings of a given | |
461 PO file needing a canonical representation, the following PO mode | |
462 command is available: | |
463 </p> | |
464 <a name="IDX363"></a> | |
465 <dl compact="compact"> | |
466 <dt> <kbd>M-x po-normalize</kbd></dt> | |
467 <dd><a name="IDX364"></a> | |
468 <p>Tidy the whole PO file by making entries more uniform. | |
469 </p> | |
470 </dd> | |
471 </dl> | |
472 | |
473 <p>The special command <kbd>M-x po-normalize</kbd>, which has no associated | |
474 keys, revises all entries, ensuring that strings of both original | |
475 and translated entries use uniform internal quoting in the PO file. | |
476 It also removes any crumb after the last entry. This command may be | |
477 useful for PO files freshly imported from elsewhere, or if we ever | |
478 improve on the canonical quoting format we use. This canonical format | |
479 is not only meant for getting cleaner PO files, but also for greatly | |
480 speeding up <code>msgid</code> string lookup for some other PO mode commands. | |
481 </p> | |
482 <p><kbd>M-x po-normalize</kbd> presently makes three passes over the entries. | |
483 The first implements heuristics for converting PO files for GNU | |
484 <code>gettext</code> 0.6 and earlier, in which <code>msgid</code> and <code>msgstr</code> | |
485 fields were using K&R style C string syntax for multi-line strings. | |
486 These heuristics may fail for comments not related to obsolete | |
487 entries and ending with a backslash; they also depend on subsequent | |
488 passes for finalizing the proper commenting of continued lines for | |
489 obsolete entries. This first pass might disappear once all oldish PO | |
490 files would have been adjusted. The second and third pass normalize | |
491 all <code>msgid</code> and <code>msgstr</code> strings respectively. They also | |
492 clean out those trailing backslashes used by XView's <code>msgfmt</code> | |
493 for continued lines. | |
494 </p> | |
495 <a name="IDX365"></a> | |
496 <p>Having such an explicit normalizing command allows for importing PO | |
497 files from other sources, but also eases the evolution of the current | |
498 convention, evolution driven mostly by aesthetic concerns, as of now. | |
499 It is easy to make suggested adjustments at a later time, as the | |
500 normalizing command and eventually, other GNU <code>gettext</code> tools | |
501 should greatly automate conformance. A description of the canonical | |
502 string format is given below, for the particular benefit of those not | |
503 having Emacs handy, and who would nevertheless want to handcraft | |
504 their PO files in nice ways. | |
505 </p> | |
506 <a name="IDX366"></a> | |
507 <p>Right now, in PO mode, strings are single line or multi-line. A string | |
508 goes multi-line if and only if it has <em>embedded</em> newlines, that | |
509 is, if it matches ‘<samp>[^\n]\n+[^\n]</samp>’. So, we would have: | |
510 </p> | |
511 <table><tr><td> </td><td><pre class="example">msgstr "\n\nHello, world!\n\n\n" | |
512 </pre></td></tr></table> | |
513 | |
514 <p>but, replacing the space by a newline, this becomes: | |
515 </p> | |
516 <table><tr><td> </td><td><pre class="example">msgstr "" | |
517 "\n" | |
518 "\n" | |
519 "Hello,\n" | |
520 "world!\n" | |
521 "\n" | |
522 "\n" | |
523 </pre></td></tr></table> | |
524 | |
525 <p>We are deliberately using a caricatural example, here, to make the | |
526 point clearer. Usually, multi-lines are not that bad looking. | |
527 It is probable that we will implement the following suggestion. | |
528 We might lump together all initial newlines into the empty string, | |
529 and also all newlines introducing empty lines (that is, for <var>n</var> | |
530 > 1, the <var>n</var>-1'th last newlines would go together on a separate | |
531 string), so making the previous example appear: | |
532 </p> | |
533 <table><tr><td> </td><td><pre class="example">msgstr "\n\n" | |
534 "Hello,\n" | |
535 "world!\n" | |
536 "\n\n" | |
537 </pre></td></tr></table> | |
538 | |
539 <p>There are a few yet undecided little points about string normalization, | |
540 to be documented in this manual, once these questions settle. | |
541 </p> | |
542 | |
543 <a name="Translated-Entries"></a> | |
544 <a name="SEC71"></a> | |
545 <h3 class="subsection"> <a href="gettext_toc.html#TOC64">8.3.5 Translated Entries</a> </h3> | |
546 | |
547 <p>Each PO file entry for which the <code>msgstr</code> field has been filled with | |
548 a translation, and which is not marked as fuzzy (see section <a href="#SEC72">Fuzzy Entries</a>), | |
549 is said to be a <em>translated</em> entry. Only translated entries will | |
550 later be compiled by GNU <code>msgfmt</code> and become usable in programs. | |
551 Other entry types will be excluded; translation will not occur for them. | |
552 </p> | |
553 <a name="IDX367"></a> | |
554 <p>Some commands are more specifically related to translated entry processing. | |
555 </p> | |
556 <dl compact="compact"> | |
557 <dt> <kbd>t</kbd></dt> | |
558 <dd><a name="IDX368"></a> | |
559 <p>Find the next translated entry (<code>po-next-translated-entry</code>). | |
560 </p> | |
561 </dd> | |
562 <dt> <kbd>T</kbd></dt> | |
563 <dd><a name="IDX369"></a> | |
564 <p>Find the previous translated entry (<code>po-previous-translated-entry</code>). | |
565 </p> | |
566 </dd> | |
567 </dl> | |
568 | |
569 <a name="IDX370"></a> | |
570 <a name="IDX371"></a> | |
571 <a name="IDX372"></a> | |
572 <a name="IDX373"></a> | |
573 <p>The commands <kbd>t</kbd> (<code>po-next-translated-entry</code>) and <kbd>T</kbd> | |
574 (<code>po-previous-translated-entry</code>) move forwards or backwards, chasing | |
575 for an translated entry. If none is found, the search is extended and | |
576 wraps around in the PO file buffer. | |
577 </p> | |
578 <a name="IDX374"></a> | |
579 <p>Translated entries usually result from the translator having edited in | |
580 a translation for them, <a href="#SEC75">Modifying Translations</a>. However, if the | |
581 variable <code>po-auto-fuzzy-on-edit</code> is not <code>nil</code>, the entry having | |
582 received a new translation first becomes a fuzzy entry, which ought to | |
583 be later unfuzzied before becoming an official, genuine translated entry. | |
584 See section <a href="#SEC72">Fuzzy Entries</a>. | |
585 </p> | |
586 | |
587 <a name="Fuzzy-Entries"></a> | |
588 <a name="SEC72"></a> | |
589 <h3 class="subsection"> <a href="gettext_toc.html#TOC65">8.3.6 Fuzzy Entries</a> </h3> | |
590 | |
591 <p>Each PO file entry may have a set of <em>attributes</em>, which are | |
592 qualities given a name and explicitly associated with the translation, | |
593 using a special system comment. One of these attributes | |
594 has the name <code>fuzzy</code>, and entries having this attribute are said | |
595 to have a fuzzy translation. They are called fuzzy entries, for short. | |
596 </p> | |
597 <p>Fuzzy entries, even if they account for translated entries for | |
598 most other purposes, usually call for revision by the translator. | |
599 Those may be produced by applying the program <code>msgmerge</code> to | |
600 update an older translated PO files according to a new PO template | |
601 file, when this tool hypothesises that some new <code>msgid</code> has | |
602 been modified only slightly out of an older one, and chooses to pair | |
603 what it thinks to be the old translation for the new modified entry. | |
604 The slight alteration in the original string (the <code>msgid</code> string) | |
605 should often be reflected in the translated string, and this requires | |
606 the intervention of the translator. For this reason, <code>msgmerge</code> | |
607 might mark some entries as being fuzzy. | |
608 </p> | |
609 <a name="IDX375"></a> | |
610 <p>Also, the translator may decide herself to mark an entry as fuzzy | |
611 for her own convenience, when she wants to remember that the entry | |
612 has to be later revisited. So, some commands are more specifically | |
613 related to fuzzy entry processing. | |
614 </p> | |
615 <dl compact="compact"> | |
616 <dt> <kbd>f</kbd></dt> | |
617 <dd><a name="IDX376"></a> | |
618 <p>Find the next fuzzy entry (<code>po-next-fuzzy-entry</code>). | |
619 </p> | |
620 </dd> | |
621 <dt> <kbd>F</kbd></dt> | |
622 <dd><a name="IDX377"></a> | |
623 <p>Find the previous fuzzy entry (<code>po-previous-fuzzy-entry</code>). | |
624 </p> | |
625 </dd> | |
626 <dt> <kbd><TAB></kbd></dt> | |
627 <dd><a name="IDX378"></a> | |
628 <p>Remove the fuzzy attribute of the current entry (<code>po-unfuzzy</code>). | |
629 </p> | |
630 </dd> | |
631 </dl> | |
632 | |
633 <a name="IDX379"></a> | |
634 <a name="IDX380"></a> | |
635 <a name="IDX381"></a> | |
636 <a name="IDX382"></a> | |
637 <p>The commands <kbd>f</kbd> (<code>po-next-fuzzy-entry</code>) and <kbd>F</kbd> | |
638 (<code>po-previous-fuzzy-entry</code>) move forwards or backwards, chasing for | |
639 a fuzzy entry. If none is found, the search is extended and wraps | |
640 around in the PO file buffer. | |
641 </p> | |
642 <a name="IDX383"></a> | |
643 <a name="IDX384"></a> | |
644 <a name="IDX385"></a> | |
645 <p>The command <kbd><TAB></kbd> (<code>po-unfuzzy</code>) removes the fuzzy | |
646 attribute associated with an entry, usually leaving it translated. | |
647 Further, if the variable <code>po-auto-select-on-unfuzzy</code> has not | |
648 the <code>nil</code> value, the <kbd><TAB></kbd> command will automatically chase | |
649 for another interesting entry to work on. The initial value of | |
650 <code>po-auto-select-on-unfuzzy</code> is <code>nil</code>. | |
651 </p> | |
652 <p>The initial value of <code>po-auto-fuzzy-on-edit</code> is <code>nil</code>. However, | |
653 if the variable <code>po-auto-fuzzy-on-edit</code> is set to <code>t</code>, any entry | |
654 edited through the <kbd><RET></kbd> command is marked fuzzy, as a way to | |
655 ensure some kind of double check, later. In this case, the usual paradigm | |
656 is that an entry becomes fuzzy (if not already) whenever the translator | |
657 modifies it. If she is satisfied with the translation, she then uses | |
658 <kbd><TAB></kbd> to pick another entry to work on, clearing the fuzzy attribute | |
659 on the same blow. If she is not satisfied yet, she merely uses <kbd><SPC></kbd> | |
660 to chase another entry, leaving the entry fuzzy. | |
661 </p> | |
662 <a name="IDX386"></a> | |
663 <a name="IDX387"></a> | |
664 <p>The translator may also use the <kbd><DEL></kbd> command | |
665 (<code>po-fade-out-entry</code>) over any translated entry to mark it as being | |
666 fuzzy, when she wants to easily leave a trace she wants to later return | |
667 working at this entry. | |
668 </p> | |
669 <p>Also, when time comes to quit working on a PO file buffer with the <kbd>q</kbd> | |
670 command, the translator is asked for confirmation, if fuzzy string | |
671 still exists. | |
672 </p> | |
673 | |
674 <a name="Untranslated-Entries"></a> | |
675 <a name="SEC73"></a> | |
676 <h3 class="subsection"> <a href="gettext_toc.html#TOC66">8.3.7 Untranslated Entries</a> </h3> | |
677 | |
678 <p>When <code>xgettext</code> originally creates a PO file, unless told | |
679 otherwise, it initializes the <code>msgid</code> field with the untranslated | |
680 string, and leaves the <code>msgstr</code> string to be empty. Such entries, | |
681 having an empty translation, are said to be <em>untranslated</em> entries. | |
682 Later, when the programmer slightly modifies some string right in | |
683 the program, this change is later reflected in the PO file | |
684 by the appearance of a new untranslated entry for the modified string. | |
685 </p> | |
686 <p>The usual commands moving from entry to entry consider untranslated | |
687 entries on the same level as active entries. Untranslated entries | |
688 are easily recognizable by the fact they end with ‘<samp>msgstr ""</samp>’. | |
689 </p> | |
690 <a name="IDX388"></a> | |
691 <p>The work of the translator might be (quite naively) seen as the process | |
692 of seeking for an untranslated entry, editing a translation for | |
693 it, and repeating these actions until no untranslated entries remain. | |
694 Some commands are more specifically related to untranslated entry | |
695 processing. | |
696 </p> | |
697 <dl compact="compact"> | |
698 <dt> <kbd>u</kbd></dt> | |
699 <dd><a name="IDX389"></a> | |
700 <p>Find the next untranslated entry (<code>po-next-untranslated-entry</code>). | |
701 </p> | |
702 </dd> | |
703 <dt> <kbd>U</kbd></dt> | |
704 <dd><a name="IDX390"></a> | |
705 <p>Find the previous untranslated entry (<code>po-previous-untransted-entry</code>). | |
706 </p> | |
707 </dd> | |
708 <dt> <kbd>k</kbd></dt> | |
709 <dd><a name="IDX391"></a> | |
710 <p>Turn the current entry into an untranslated one (<code>po-kill-msgstr</code>). | |
711 </p> | |
712 </dd> | |
713 </dl> | |
714 | |
715 <a name="IDX392"></a> | |
716 <a name="IDX393"></a> | |
717 <a name="IDX394"></a> | |
718 <a name="IDX395"></a> | |
719 <p>The commands <kbd>u</kbd> (<code>po-next-untranslated-entry</code>) and <kbd>U</kbd> | |
720 (<code>po-previous-untransted-entry</code>) move forwards or backwards, | |
721 chasing for an untranslated entry. If none is found, the search is | |
722 extended and wraps around in the PO file buffer. | |
723 </p> | |
724 <a name="IDX396"></a> | |
725 <a name="IDX397"></a> | |
726 <p>An entry can be turned back into an untranslated entry by | |
727 merely emptying its translation, using the command <kbd>k</kbd> | |
728 (<code>po-kill-msgstr</code>). See section <a href="#SEC75">Modifying Translations</a>. | |
729 </p> | |
730 <p>Also, when time comes to quit working on a PO file buffer | |
731 with the <kbd>q</kbd> command, the translator is asked for confirmation, | |
732 if some untranslated string still exists. | |
733 </p> | |
734 | |
735 <a name="Obsolete-Entries"></a> | |
736 <a name="SEC74"></a> | |
737 <h3 class="subsection"> <a href="gettext_toc.html#TOC67">8.3.8 Obsolete Entries</a> </h3> | |
738 | |
739 <p>By <em>obsolete</em> PO file entries, we mean those entries which are | |
740 commented out, usually by <code>msgmerge</code> when it found that the | |
741 translation is not needed anymore by the package being localized. | |
742 </p> | |
743 <p>The usual commands moving from entry to entry consider obsolete | |
744 entries on the same level as active entries. Obsolete entries are | |
745 easily recognizable by the fact that all their lines start with | |
746 <code>#</code>, even those lines containing <code>msgid</code> or <code>msgstr</code>. | |
747 </p> | |
748 <p>Commands exist for emptying the translation or reinitializing it | |
749 to the original untranslated string. Commands interfacing with the | |
750 kill ring may force some previously saved text into the translation. | |
751 The user may interactively edit the translation. All these commands | |
752 may apply to obsolete entries, carefully leaving the entry obsolete | |
753 after the fact. | |
754 </p> | |
755 <a name="IDX398"></a> | |
756 <p>Moreover, some commands are more specifically related to obsolete | |
757 entry processing. | |
758 </p> | |
759 <dl compact="compact"> | |
760 <dt> <kbd>o</kbd></dt> | |
761 <dd><a name="IDX399"></a> | |
762 <p>Find the next obsolete entry (<code>po-next-obsolete-entry</code>). | |
763 </p> | |
764 </dd> | |
765 <dt> <kbd>O</kbd></dt> | |
766 <dd><a name="IDX400"></a> | |
767 <p>Find the previous obsolete entry (<code>po-previous-obsolete-entry</code>). | |
768 </p> | |
769 </dd> | |
770 <dt> <kbd><DEL></kbd></dt> | |
771 <dd><a name="IDX401"></a> | |
772 <p>Make an active entry obsolete, or zap out an obsolete entry | |
773 (<code>po-fade-out-entry</code>). | |
774 </p> | |
775 </dd> | |
776 </dl> | |
777 | |
778 <a name="IDX402"></a> | |
779 <a name="IDX403"></a> | |
780 <a name="IDX404"></a> | |
781 <a name="IDX405"></a> | |
782 <p>The commands <kbd>o</kbd> (<code>po-next-obsolete-entry</code>) and <kbd>O</kbd> | |
783 (<code>po-previous-obsolete-entry</code>) move forwards or backwards, | |
784 chasing for an obsolete entry. If none is found, the search is | |
785 extended and wraps around in the PO file buffer. | |
786 </p> | |
787 <p>PO mode does not provide ways for un-commenting an obsolete entry | |
788 and making it active, because this would reintroduce an original | |
789 untranslated string which does not correspond to any marked string | |
790 in the program sources. This goes with the philosophy of never | |
791 introducing useless <code>msgid</code> values. | |
792 </p> | |
793 <a name="IDX406"></a> | |
794 <a name="IDX407"></a> | |
795 <a name="IDX408"></a> | |
796 <a name="IDX409"></a> | |
797 <p>However, it is possible to comment out an active entry, so making | |
798 it obsolete. GNU <code>gettext</code> utilities will later react to the | |
799 disappearance of a translation by using the untranslated string. | |
800 The command <kbd><DEL></kbd> (<code>po-fade-out-entry</code>) pushes the current entry | |
801 a little further towards annihilation. If the entry is active (it is a | |
802 translated entry), then it is first made fuzzy. If it is already fuzzy, | |
803 then the entry is merely commented out, with confirmation. If the entry | |
804 is already obsolete, then it is completely deleted from the PO file. | |
805 It is easy to recycle the translation so deleted into some other PO file | |
806 entry, usually one which is untranslated. See section <a href="#SEC75">Modifying Translations</a>. | |
807 </p> | |
808 <p>Here is a quite interesting problem to solve for later development of | |
809 PO mode, for those nights you are not sleepy. The idea would be that | |
810 PO mode might become bright enough, one of these days, to make good | |
811 guesses at retrieving the most probable candidate, among all obsolete | |
812 entries, for initializing the translation of a newly appeared string. | |
813 I think it might be a quite hard problem to do this algorithmically, as | |
814 we have to develop good and efficient measures of string similarity. | |
815 Right now, PO mode completely lets the decision to the translator, | |
816 when the time comes to find the adequate obsolete translation, it | |
817 merely tries to provide handy tools for helping her to do so. | |
818 </p> | |
819 | |
820 <a name="Modifying-Translations"></a> | |
821 <a name="SEC75"></a> | |
822 <h3 class="subsection"> <a href="gettext_toc.html#TOC68">8.3.9 Modifying Translations</a> </h3> | |
823 | |
824 <p>PO mode prevents direct modification of the PO file, by the usual | |
825 means Emacs gives for altering a buffer's contents. By doing so, | |
826 it pretends helping the translator to avoid little clerical errors | |
827 about the overall file format, or the proper quoting of strings, | |
828 as those errors would be easily made. Other kinds of errors are | |
829 still possible, but some may be caught and diagnosed by the batch | |
830 validation process, which the translator may always trigger by the | |
831 <kbd>V</kbd> command. For all other errors, the translator has to rely on | |
832 her own judgment, and also on the linguistic reports submitted to her | |
833 by the users of the translated package, having the same mother tongue. | |
834 </p> | |
835 <p>When the time comes to create a translation, correct an error diagnosed | |
836 mechanically or reported by a user, the translators have to resort to | |
837 using the following commands for modifying the translations. | |
838 </p> | |
839 <dl compact="compact"> | |
840 <dt> <kbd><RET></kbd></dt> | |
841 <dd><a name="IDX410"></a> | |
842 <p>Interactively edit the translation (<code>po-edit-msgstr</code>). | |
843 </p> | |
844 </dd> | |
845 <dt> <kbd><LFD></kbd></dt> | |
846 <dt> <kbd>C-j</kbd></dt> | |
847 <dd><a name="IDX411"></a> | |
848 <a name="IDX412"></a> | |
849 <p>Reinitialize the translation with the original, untranslated string | |
850 (<code>po-msgid-to-msgstr</code>). | |
851 </p> | |
852 </dd> | |
853 <dt> <kbd>k</kbd></dt> | |
854 <dd><a name="IDX413"></a> | |
855 <p>Save the translation on the kill ring, and delete it (<code>po-kill-msgstr</code>). | |
856 </p> | |
857 </dd> | |
858 <dt> <kbd>w</kbd></dt> | |
859 <dd><a name="IDX414"></a> | |
860 <p>Save the translation on the kill ring, without deleting it | |
861 (<code>po-kill-ring-save-msgstr</code>). | |
862 </p> | |
863 </dd> | |
864 <dt> <kbd>y</kbd></dt> | |
865 <dd><a name="IDX415"></a> | |
866 <p>Replace the translation, taking the new from the kill ring | |
867 (<code>po-yank-msgstr</code>). | |
868 </p> | |
869 </dd> | |
870 </dl> | |
871 | |
872 <a name="IDX416"></a> | |
873 <a name="IDX417"></a> | |
874 <p>The command <kbd><RET></kbd> (<code>po-edit-msgstr</code>) opens a new Emacs | |
875 window meant to edit in a new translation, or to modify an already existing | |
876 translation. The new window contains a copy of the translation taken from | |
877 the current PO file entry, all ready for edition, expunged of all quoting | |
878 marks, fully modifiable and with the complete extent of Emacs modifying | |
879 commands. When the translator is done with her modifications, she may use | |
880 <kbd>C-c C-c</kbd> to close the subedit window with the automatically requoted | |
881 results, or <kbd>C-c C-k</kbd> to abort her modifications. See section <a href="#SEC77">Details of Sub Edition</a>, | |
882 for more information. | |
883 </p> | |
884 <a name="IDX418"></a> | |
885 <a name="IDX419"></a> | |
886 <a name="IDX420"></a> | |
887 <p>The command <kbd><LFD></kbd> (<code>po-msgid-to-msgstr</code>) initializes, or | |
888 reinitializes the translation with the original string. This command is | |
889 normally used when the translator wants to redo a fresh translation of | |
890 the original string, disregarding any previous work. | |
891 </p> | |
892 <a name="IDX421"></a> | |
893 <p>It is possible to arrange so, whenever editing an untranslated | |
894 entry, the <kbd><LFD></kbd> command be automatically executed. If you set | |
895 <code>po-auto-edit-with-msgid</code> to <code>t</code>, the translation gets | |
896 initialised with the original string, in case none exists already. | |
897 The default value for <code>po-auto-edit-with-msgid</code> is <code>nil</code>. | |
898 </p> | |
899 <a name="IDX422"></a> | |
900 <p>In fact, whether it is best to start a translation with an empty | |
901 string, or rather with a copy of the original string, is a matter of | |
902 taste or habit. Sometimes, the source language and the | |
903 target language are so different that is simply best to start writing | |
904 on an empty page. At other times, the source and target languages | |
905 are so close that it would be a waste to retype a number of words | |
906 already being written in the original string. A translator may also | |
907 like having the original string right under her eyes, as she will | |
908 progressively overwrite the original text with the translation, even | |
909 if this requires some extra editing work to get rid of the original. | |
910 </p> | |
911 <a name="IDX423"></a> | |
912 <a name="IDX424"></a> | |
913 <a name="IDX425"></a> | |
914 <a name="IDX426"></a> | |
915 <a name="IDX427"></a> | |
916 <p>The command <kbd>k</kbd> (<code>po-kill-msgstr</code>) merely empties the | |
917 translation string, so turning the entry into an untranslated | |
918 one. But while doing so, its previous contents is put apart in | |
919 a special place, known as the kill ring. The command <kbd>w</kbd> | |
920 (<code>po-kill-ring-save-msgstr</code>) has also the effect of taking a | |
921 copy of the translation onto the kill ring, but it otherwise leaves | |
922 the entry alone, and does <em>not</em> remove the translation from the | |
923 entry. Both commands use exactly the Emacs kill ring, which is shared | |
924 between buffers, and which is well known already to Emacs lovers. | |
925 </p> | |
926 <p>The translator may use <kbd>k</kbd> or <kbd>w</kbd> many times in the course | |
927 of her work, as the kill ring may hold several saved translations. | |
928 From the kill ring, strings may later be reinserted in various | |
929 Emacs buffers. In particular, the kill ring may be used for moving | |
930 translation strings between different entries of a single PO file | |
931 buffer, or if the translator is handling many such buffers at once, | |
932 even between PO files. | |
933 </p> | |
934 <p>To facilitate exchanges with buffers which are not in PO mode, the | |
935 translation string put on the kill ring by the <kbd>k</kbd> command is fully | |
936 unquoted before being saved: external quotes are removed, multi-line | |
937 strings are concatenated, and backslash escaped sequences are turned | |
938 into their corresponding characters. In the special case of obsolete | |
939 entries, the translation is also uncommented prior to saving. | |
940 </p> | |
941 <a name="IDX428"></a> | |
942 <a name="IDX429"></a> | |
943 <p>The command <kbd>y</kbd> (<code>po-yank-msgstr</code>) completely replaces the | |
944 translation of the current entry by a string taken from the kill ring. | |
945 Following Emacs terminology, we then say that the replacement | |
946 string is <em>yanked</em> into the PO file buffer. | |
947 See <a href="../emacs/Yanking.html#Yanking">(emacs)Yanking</a> section `Yanking' in <cite>The Emacs Editor</cite>. | |
948 The first time <kbd>y</kbd> is used, the translation receives the value of | |
949 the most recent addition to the kill ring. If <kbd>y</kbd> is typed once | |
950 again, immediately, without intervening keystrokes, the translation | |
951 just inserted is taken away and replaced by the second most recent | |
952 addition to the kill ring. By repeating <kbd>y</kbd> many times in a row, | |
953 the translator may travel along the kill ring for saved strings, | |
954 until she finds the string she really wanted. | |
955 </p> | |
956 <p>When a string is yanked into a PO file entry, it is fully and | |
957 automatically requoted for complying with the format PO files should | |
958 have. Further, if the entry is obsolete, PO mode then appropriately | |
959 push the inserted string inside comments. Once again, translators | |
960 should not burden themselves with quoting considerations besides, of | |
961 course, the necessity of the translated string itself respective to | |
962 the program using it. | |
963 </p> | |
964 <p>Note that <kbd>k</kbd> or <kbd>w</kbd> are not the only commands pushing strings | |
965 on the kill ring, as almost any PO mode command replacing translation | |
966 strings (or the translator comments) automatically saves the old string | |
967 on the kill ring. The main exceptions to this general rule are the | |
968 yanking commands themselves. | |
969 </p> | |
970 <a name="IDX430"></a> | |
971 <p>To better illustrate the operation of killing and yanking, let's | |
972 use an actual example, taken from a common situation. When the | |
973 programmer slightly modifies some string right in the program, his | |
974 change is later reflected in the PO file by the appearance | |
975 of a new untranslated entry for the modified string, and the fact | |
976 that the entry translating the original or unmodified string becomes | |
977 obsolete. In many cases, the translator might spare herself some work | |
978 by retrieving the unmodified translation from the obsolete entry, | |
979 then initializing the untranslated entry <code>msgstr</code> field with | |
980 this retrieved translation. Once this done, the obsolete entry is | |
981 not wanted anymore, and may be safely deleted. | |
982 </p> | |
983 <p>When the translator finds an untranslated entry and suspects that a | |
984 slight variant of the translation exists, she immediately uses <kbd>m</kbd> | |
985 to mark the current entry location, then starts chasing obsolete | |
986 entries with <kbd>o</kbd>, hoping to find some translation corresponding | |
987 to the unmodified string. Once found, she uses the <kbd><DEL></kbd> command | |
988 for deleting the obsolete entry, knowing that <kbd><DEL></kbd> also <em>kills</em> | |
989 the translation, that is, pushes the translation on the kill ring. | |
990 Then, <kbd>r</kbd> returns to the initial untranslated entry, and <kbd>y</kbd> | |
991 then <em>yanks</em> the saved translation right into the <code>msgstr</code> | |
992 field. The translator is then free to use <kbd><RET></kbd> for fine | |
993 tuning the translation contents, and maybe to later use <kbd>u</kbd>, | |
994 then <kbd>m</kbd> again, for going on with the next untranslated string. | |
995 </p> | |
996 <p>When some sequence of keys has to be typed over and over again, the | |
997 translator may find it useful to become better acquainted with the Emacs | |
998 capability of learning these sequences and playing them back under request. | |
999 See <a href="../emacs/Keyboard-Macros.html#Keyboard-Macros">(emacs)Keyboard Macros</a> section `Keyboard Macros' in <cite>The Emacs Editor</cite>. | |
1000 </p> | |
1001 | |
1002 <a name="Modifying-Comments"></a> | |
1003 <a name="SEC76"></a> | |
1004 <h3 class="subsection"> <a href="gettext_toc.html#TOC69">8.3.10 Modifying Comments</a> </h3> | |
1005 | |
1006 <p>Any translation work done seriously will raise many linguistic | |
1007 difficulties, for which decisions have to be made, and the choices | |
1008 further documented. These documents may be saved within the | |
1009 PO file in form of translator comments, which the translator | |
1010 is free to create, delete, or modify at will. These comments may | |
1011 be useful to herself when she returns to this PO file after a while. | |
1012 </p> | |
1013 <p>Comments not having whitespace after the initial ‘<samp>#</samp>’, for example, | |
1014 those beginning with ‘<samp>#.</samp>’ or ‘<samp>#:</samp>’, are <em>not</em> translator | |
1015 comments, they are exclusively created by other <code>gettext</code> tools. | |
1016 So, the commands below will never alter such system added comments, | |
1017 they are not meant for the translator to modify. See section <a href="gettext_3.html#SEC16">The Format of PO Files</a>. | |
1018 </p> | |
1019 <p>The following commands are somewhat similar to those modifying translations, | |
1020 so the general indications given for those apply here. See section <a href="#SEC75">Modifying Translations</a>. | |
1021 </p> | |
1022 <dl compact="compact"> | |
1023 <dt> <kbd>#</kbd></dt> | |
1024 <dd><a name="IDX431"></a> | |
1025 <p>Interactively edit the translator comments (<code>po-edit-comment</code>). | |
1026 </p> | |
1027 </dd> | |
1028 <dt> <kbd>K</kbd></dt> | |
1029 <dd><a name="IDX432"></a> | |
1030 <p>Save the translator comments on the kill ring, and delete it | |
1031 (<code>po-kill-comment</code>). | |
1032 </p> | |
1033 </dd> | |
1034 <dt> <kbd>W</kbd></dt> | |
1035 <dd><a name="IDX433"></a> | |
1036 <p>Save the translator comments on the kill ring, without deleting it | |
1037 (<code>po-kill-ring-save-comment</code>). | |
1038 </p> | |
1039 </dd> | |
1040 <dt> <kbd>Y</kbd></dt> | |
1041 <dd><a name="IDX434"></a> | |
1042 <p>Replace the translator comments, taking the new from the kill ring | |
1043 (<code>po-yank-comment</code>). | |
1044 </p> | |
1045 </dd> | |
1046 </dl> | |
1047 | |
1048 <p>These commands parallel PO mode commands for modifying the translation | |
1049 strings, and behave much the same way as they do, except that they handle | |
1050 this part of PO file comments meant for translator usage, rather | |
1051 than the translation strings. So, if the descriptions given below are | |
1052 slightly succinct, it is because the full details have already been given. | |
1053 See section <a href="#SEC75">Modifying Translations</a>. | |
1054 </p> | |
1055 <a name="IDX435"></a> | |
1056 <a name="IDX436"></a> | |
1057 <p>The command <kbd>#</kbd> (<code>po-edit-comment</code>) opens a new Emacs window | |
1058 containing a copy of the translator comments on the current PO file entry. | |
1059 If there are no such comments, PO mode understands that the translator wants | |
1060 to add a comment to the entry, and she is presented with an empty screen. | |
1061 Comment marks (<code>#</code>) and the space following them are automatically | |
1062 removed before edition, and reinstated after. For translator comments | |
1063 pertaining to obsolete entries, the uncommenting and recommenting operations | |
1064 are done twice. Once in the editing window, the keys <kbd>C-c C-c</kbd> | |
1065 allow the translator to tell she is finished with editing the comment. | |
1066 See section <a href="#SEC77">Details of Sub Edition</a>, for further details. | |
1067 </p> | |
1068 <a name="IDX437"></a> | |
1069 <p>Functions found on <code>po-subedit-mode-hook</code>, if any, are executed after | |
1070 the string has been inserted in the edit buffer. | |
1071 </p> | |
1072 <a name="IDX438"></a> | |
1073 <a name="IDX439"></a> | |
1074 <a name="IDX440"></a> | |
1075 <a name="IDX441"></a> | |
1076 <a name="IDX442"></a> | |
1077 <a name="IDX443"></a> | |
1078 <p>The command <kbd>K</kbd> (<code>po-kill-comment</code>) gets rid of all | |
1079 translator comments, while saving those comments on the kill ring. | |
1080 The command <kbd>W</kbd> (<code>po-kill-ring-save-comment</code>) takes | |
1081 a copy of the translator comments on the kill ring, but leaves | |
1082 them undisturbed in the current entry. The command <kbd>Y</kbd> | |
1083 (<code>po-yank-comment</code>) completely replaces the translator comments | |
1084 by a string taken at the front of the kill ring. When this command | |
1085 is immediately repeated, the comments just inserted are withdrawn, | |
1086 and replaced by other strings taken along the kill ring. | |
1087 </p> | |
1088 <p>On the kill ring, all strings have the same nature. There is no | |
1089 distinction between <em>translation</em> strings and <em>translator | |
1090 comments</em> strings. So, for example, let's presume the translator | |
1091 has just finished editing a translation, and wants to create a new | |
1092 translator comment to document why the previous translation was | |
1093 not good, just to remember what was the problem. Foreseeing that she | |
1094 will do that in her documentation, the translator may want to quote | |
1095 the previous translation in her translator comments. To do so, she | |
1096 may initialize the translator comments with the previous translation, | |
1097 still at the head of the kill ring. Because editing already pushed the | |
1098 previous translation on the kill ring, she merely has to type <kbd>M-w</kbd> | |
1099 prior to <kbd>#</kbd>, and the previous translation will be right there, | |
1100 all ready for being introduced by some explanatory text. | |
1101 </p> | |
1102 <p>On the other hand, presume there are some translator comments already | |
1103 and that the translator wants to add to those comments, instead | |
1104 of wholly replacing them. Then, she should edit the comment right | |
1105 away with <kbd>#</kbd>. Once inside the editing window, she can use the | |
1106 regular Emacs commands <kbd>C-y</kbd> (<code>yank</code>) and <kbd>M-y</kbd> | |
1107 (<code>yank-pop</code>) to get the previous translation where she likes. | |
1108 </p> | |
1109 | |
1110 <a name="Subedit"></a> | |
1111 <a name="SEC77"></a> | |
1112 <h3 class="subsection"> <a href="gettext_toc.html#TOC70">8.3.11 Details of Sub Edition</a> </h3> | |
1113 | |
1114 <p>The PO subedit minor mode has a few peculiarities worth being described | |
1115 in fuller detail. It installs a few commands over the usual editing set | |
1116 of Emacs, which are described below. | |
1117 </p> | |
1118 <dl compact="compact"> | |
1119 <dt> <kbd>C-c C-c</kbd></dt> | |
1120 <dd><a name="IDX444"></a> | |
1121 <p>Complete edition (<code>po-subedit-exit</code>). | |
1122 </p> | |
1123 </dd> | |
1124 <dt> <kbd>C-c C-k</kbd></dt> | |
1125 <dd><a name="IDX445"></a> | |
1126 <p>Abort edition (<code>po-subedit-abort</code>). | |
1127 </p> | |
1128 </dd> | |
1129 <dt> <kbd>C-c C-a</kbd></dt> | |
1130 <dd><a name="IDX446"></a> | |
1131 <p>Consult auxiliary PO files (<code>po-subedit-cycle-auxiliary</code>). | |
1132 </p> | |
1133 </dd> | |
1134 </dl> | |
1135 | |
1136 <a name="IDX447"></a> | |
1137 <a name="IDX448"></a> | |
1138 <a name="IDX449"></a> | |
1139 <p>The window's contents represents a translation for a given message, | |
1140 or a translator comment. The translator may modify this window to | |
1141 her heart's content. Once this is done, the command <kbd>C-c C-c</kbd> | |
1142 (<code>po-subedit-exit</code>) may be used to return the edited translation into | |
1143 the PO file, replacing the original translation, even if it moved out of | |
1144 sight or if buffers were switched. | |
1145 </p> | |
1146 <a name="IDX450"></a> | |
1147 <a name="IDX451"></a> | |
1148 <p>If the translator becomes unsatisfied with her translation or comment, | |
1149 to the extent she prefers keeping what was existent prior to the | |
1150 <kbd><RET></kbd> or <kbd>#</kbd> command, she may use the command <kbd>C-c C-k</kbd> | |
1151 (<code>po-subedit-abort</code>) to merely get rid of edition, while preserving | |
1152 the original translation or comment. Another way would be for her to exit | |
1153 normally with <kbd>C-c C-c</kbd>, then type <code>U</code> once for undoing the | |
1154 whole effect of last edition. | |
1155 </p> | |
1156 <a name="IDX452"></a> | |
1157 <a name="IDX453"></a> | |
1158 <p>The command <kbd>C-c C-a</kbd> (<code>po-subedit-cycle-auxiliary</code>) | |
1159 allows for glancing through translations | |
1160 already achieved in other languages, directly while editing the current | |
1161 translation. This may be quite convenient when the translator is fluent | |
1162 at many languages, but of course, only makes sense when such completed | |
1163 auxiliary PO files are already available to her (see section <a href="#SEC79">Consulting Auxiliary PO Files</a>). | |
1164 </p> | |
1165 <p>Functions found on <code>po-subedit-mode-hook</code>, if any, are executed after | |
1166 the string has been inserted in the edit buffer. | |
1167 </p> | |
1168 <p>While editing her translation, the translator should pay attention to not | |
1169 inserting unwanted <kbd><RET></kbd> (newline) characters at the end of | |
1170 the translated string if those are not meant to be there, or to removing | |
1171 such characters when they are required. Since these characters are not | |
1172 visible in the editing buffer, they are easily introduced by mistake. | |
1173 To help her, <kbd><RET></kbd> automatically puts the character <code><</code> | |
1174 at the end of the string being edited, but this <code><</code> is not really | |
1175 part of the string. On exiting the editing window with <kbd>C-c C-c</kbd>, | |
1176 PO mode automatically removes such <kbd><</kbd> and all whitespace added after | |
1177 it. If the translator adds characters after the terminating <code><</code>, it | |
1178 looses its delimiting property and integrally becomes part of the string. | |
1179 If she removes the delimiting <code><</code>, then the edited string is taken | |
1180 <em>as is</em>, with all trailing newlines, even if invisible. Also, if | |
1181 the translated string ought to end itself with a genuine <code><</code>, then | |
1182 the delimiting <code><</code> may not be removed; so the string should appear, | |
1183 in the editing window, as ending with two <code><</code> in a row. | |
1184 </p> | |
1185 <a name="IDX454"></a> | |
1186 <p>When a translation (or a comment) is being edited, the translator may move | |
1187 the cursor back into the PO file buffer and freely move to other entries, | |
1188 browsing at will. If, with an edition pending, the translator wanders in the | |
1189 PO file buffer, she may decide to start modifying another entry. Each entry | |
1190 being edited has its own subedit buffer. It is possible to simultaneously | |
1191 edit the translation <em>and</em> the comment of a single entry, or to | |
1192 edit entries in different PO files, all at once. Typing <kbd><RET></kbd> | |
1193 on a field already being edited merely resumes that particular edit. Yet, | |
1194 the translator should better be comfortable at handling many Emacs windows! | |
1195 </p> | |
1196 <a name="IDX455"></a> | |
1197 <p>Pending subedits may be completed or aborted in any order, regardless | |
1198 of how or when they were started. When many subedits are pending and the | |
1199 translator asks for quitting the PO file (with the <kbd>q</kbd> command), subedits | |
1200 are automatically resumed one at a time, so she may decide for each of them. | |
1201 </p> | |
1202 | |
1203 <a name="C-Sources-Context"></a> | |
1204 <a name="SEC78"></a> | |
1205 <h3 class="subsection"> <a href="gettext_toc.html#TOC71">8.3.12 C Sources Context</a> </h3> | |
1206 | |
1207 <p>PO mode is particularly powerful when used with PO files | |
1208 created through GNU <code>gettext</code> utilities, as those utilities | |
1209 insert special comments in the PO files they generate. | |
1210 Some of these special comments relate the PO file entry to | |
1211 exactly where the untranslated string appears in the program sources. | |
1212 </p> | |
1213 <p>When the translator gets to an untranslated entry, she is fairly | |
1214 often faced with an original string which is not as informative as | |
1215 it normally should be, being succinct, cryptic, or otherwise ambiguous. | |
1216 Before choosing how to translate the string, she needs to understand | |
1217 better what the string really means and how tight the translation has | |
1218 to be. Most of the time, when problems arise, the only way left to make | |
1219 her judgment is looking at the true program sources from where this | |
1220 string originated, searching for surrounding comments the programmer | |
1221 might have put in there, and looking around for helping clues of | |
1222 <em>any</em> kind. | |
1223 </p> | |
1224 <p>Surely, when looking at program sources, the translator will receive | |
1225 more help if she is a fluent programmer. However, even if she is | |
1226 not versed in programming and feels a little lost in C code, the | |
1227 translator should not be shy at taking a look, once in a while. | |
1228 It is most probable that she will still be able to find some of the | |
1229 hints she needs. She will learn quickly to not feel uncomfortable | |
1230 in program code, paying more attention to programmer's comments, | |
1231 variable and function names (if he dared choosing them well), and | |
1232 overall organization, than to the program code itself. | |
1233 </p> | |
1234 <a name="IDX456"></a> | |
1235 <p>The following commands are meant to help the translator at getting | |
1236 program source context for a PO file entry. | |
1237 </p> | |
1238 <dl compact="compact"> | |
1239 <dt> <kbd>s</kbd></dt> | |
1240 <dd><a name="IDX457"></a> | |
1241 <p>Resume the display of a program source context, or cycle through them | |
1242 (<code>po-cycle-source-reference</code>). | |
1243 </p> | |
1244 </dd> | |
1245 <dt> <kbd>M-s</kbd></dt> | |
1246 <dd><a name="IDX458"></a> | |
1247 <p>Display of a program source context selected by menu | |
1248 (<code>po-select-source-reference</code>). | |
1249 </p> | |
1250 </dd> | |
1251 <dt> <kbd>S</kbd></dt> | |
1252 <dd><a name="IDX459"></a> | |
1253 <p>Add a directory to the search path for source files | |
1254 (<code>po-consider-source-path</code>). | |
1255 </p> | |
1256 </dd> | |
1257 <dt> <kbd>M-S</kbd></dt> | |
1258 <dd><a name="IDX460"></a> | |
1259 <p>Delete a directory from the search path for source files | |
1260 (<code>po-ignore-source-path</code>). | |
1261 </p> | |
1262 </dd> | |
1263 </dl> | |
1264 | |
1265 <a name="IDX461"></a> | |
1266 <a name="IDX462"></a> | |
1267 <a name="IDX463"></a> | |
1268 <a name="IDX464"></a> | |
1269 <p>The commands <kbd>s</kbd> (<code>po-cycle-source-reference</code>) and <kbd>M-s</kbd> | |
1270 (<code>po-select-source-reference</code>) both open another window displaying | |
1271 some source program file, and already positioned in such a way that | |
1272 it shows an actual use of the string to be translated. By doing | |
1273 so, the command gives source program context for the string. But if | |
1274 the entry has no source context references, or if all references | |
1275 are unresolved along the search path for program sources, then the | |
1276 command diagnoses this as an error. | |
1277 </p> | |
1278 <p>Even if <kbd>s</kbd> (or <kbd>M-s</kbd>) opens a new window, the cursor stays | |
1279 in the PO file window. If the translator really wants to | |
1280 get into the program source window, she ought to do it explicitly, | |
1281 maybe by using command <kbd>O</kbd>. | |
1282 </p> | |
1283 <p>When <kbd>s</kbd> is typed for the first time, or for a PO file entry which | |
1284 is different of the last one used for getting source context, then the | |
1285 command reacts by giving the first context available for this entry, | |
1286 if any. If some context has already been recently displayed for the | |
1287 current PO file entry, and the translator wandered off to do other | |
1288 things, typing <kbd>s</kbd> again will merely resume, in another window, | |
1289 the context last displayed. In particular, if the translator moved | |
1290 the cursor away from the context in the source file, the command will | |
1291 bring the cursor back to the context. By using <kbd>s</kbd> many times | |
1292 in a row, with no other commands intervening, PO mode will cycle to | |
1293 the next available contexts for this particular entry, getting back | |
1294 to the first context once the last has been shown. | |
1295 </p> | |
1296 <p>The command <kbd>M-s</kbd> behaves differently. Instead of cycling through | |
1297 references, it lets the translator choose a particular reference among | |
1298 many, and displays that reference. It is best used with completion, | |
1299 if the translator types <kbd><TAB></kbd> immediately after <kbd>M-s</kbd>, in | |
1300 response to the question, she will be offered a menu of all possible | |
1301 references, as a reminder of which are the acceptable answers. | |
1302 This command is useful only where there are really many contexts | |
1303 available for a single string to translate. | |
1304 </p> | |
1305 <a name="IDX465"></a> | |
1306 <a name="IDX466"></a> | |
1307 <a name="IDX467"></a> | |
1308 <a name="IDX468"></a> | |
1309 <p>Program source files are usually found relative to where the PO | |
1310 file stands. As a special provision, when this fails, the file is | |
1311 also looked for, but relative to the directory immediately above it. | |
1312 Those two cases take proper care of most PO files. However, it might | |
1313 happen that a PO file has been moved, or is edited in a different | |
1314 place than its normal location. When this happens, the translator | |
1315 should tell PO mode in which directory normally sits the genuine PO | |
1316 file. Many such directories may be specified, and all together, they | |
1317 constitute what is called the <em>search path</em> for program sources. | |
1318 The command <kbd>S</kbd> (<code>po-consider-source-path</code>) is used to interactively | |
1319 enter a new directory at the front of the search path, and the command | |
1320 <kbd>M-S</kbd> (<code>po-ignore-source-path</code>) is used to select, with completion, | |
1321 one of the directories she does not want anymore on the search path. | |
1322 </p> | |
1323 | |
1324 <a name="Auxiliary"></a> | |
1325 <a name="SEC79"></a> | |
1326 <h3 class="subsection"> <a href="gettext_toc.html#TOC72">8.3.13 Consulting Auxiliary PO Files</a> </h3> | |
1327 | |
1328 <p>PO mode is able to help the knowledgeable translator, being fluent in | |
1329 many languages, at taking advantage of translations already achieved | |
1330 in other languages she just happens to know. It provides these other | |
1331 language translations as additional context for her own work. Moreover, | |
1332 it has features to ease the production of translations for many languages | |
1333 at once, for translators preferring to work in this way. | |
1334 </p> | |
1335 <a name="IDX469"></a> | |
1336 <a name="IDX470"></a> | |
1337 <p>An <em>auxiliary</em> PO file is an existing PO file meant for the same | |
1338 package the translator is working on, but targeted to a different mother | |
1339 tongue language. Commands exist for declaring and handling auxiliary | |
1340 PO files, and also for showing contexts for the entry under work. | |
1341 </p> | |
1342 <p>Here are the auxiliary file commands available in PO mode. | |
1343 </p> | |
1344 <dl compact="compact"> | |
1345 <dt> <kbd>a</kbd></dt> | |
1346 <dd><a name="IDX471"></a> | |
1347 <p>Seek auxiliary files for another translation for the same entry | |
1348 (<code>po-cycle-auxiliary</code>). | |
1349 </p> | |
1350 </dd> | |
1351 <dt> <kbd>C-c C-a</kbd></dt> | |
1352 <dd><a name="IDX472"></a> | |
1353 <p>Switch to a particular auxiliary file (<code>po-select-auxiliary</code>). | |
1354 </p> | |
1355 </dd> | |
1356 <dt> <kbd>A</kbd></dt> | |
1357 <dd><a name="IDX473"></a> | |
1358 <p>Declare this PO file as an auxiliary file (<code>po-consider-as-auxiliary</code>). | |
1359 </p> | |
1360 </dd> | |
1361 <dt> <kbd>M-A</kbd></dt> | |
1362 <dd><a name="IDX474"></a> | |
1363 <p>Remove this PO file from the list of auxiliary files | |
1364 (<code>po-ignore-as-auxiliary</code>). | |
1365 </p> | |
1366 </dd> | |
1367 </dl> | |
1368 | |
1369 <a name="IDX475"></a> | |
1370 <a name="IDX476"></a> | |
1371 <a name="IDX477"></a> | |
1372 <a name="IDX478"></a> | |
1373 <p>Command <kbd>A</kbd> (<code>po-consider-as-auxiliary</code>) adds the current | |
1374 PO file to the list of auxiliary files, while command <kbd>M-A</kbd> | |
1375 (<code>po-ignore-as-auxiliary</code> just removes it. | |
1376 </p> | |
1377 <a name="IDX479"></a> | |
1378 <a name="IDX480"></a> | |
1379 <p>The command <kbd>a</kbd> (<code>po-cycle-auxiliary</code>) seeks all auxiliary PO | |
1380 files, round-robin, searching for a translated entry in some other language | |
1381 having an <code>msgid</code> field identical as the one for the current entry. | |
1382 The found PO file, if any, takes the place of the current PO file in | |
1383 the display (its window gets on top). Before doing so, the current PO | |
1384 file is also made into an auxiliary file, if not already. So, <kbd>a</kbd> | |
1385 in this newly displayed PO file will seek another PO file, and so on, | |
1386 so repeating <kbd>a</kbd> will eventually yield back the original PO file. | |
1387 </p> | |
1388 <a name="IDX481"></a> | |
1389 <a name="IDX482"></a> | |
1390 <p>The command <kbd>C-c C-a</kbd> (<code>po-select-auxiliary</code>) asks the translator | |
1391 for her choice of a particular auxiliary file, with completion, and | |
1392 then switches to that selected PO file. The command also checks if | |
1393 the selected file has an <code>msgid</code> field identical as the one for | |
1394 the current entry, and if yes, this entry becomes current. Otherwise, | |
1395 the cursor of the selected file is left undisturbed. | |
1396 </p> | |
1397 <p>For all this to work fully, auxiliary PO files will have to be normalized, | |
1398 in that way that <code>msgid</code> fields should be written <em>exactly</em> | |
1399 the same way. It is possible to write <code>msgid</code> fields in various | |
1400 ways for representing the same string, different writing would break the | |
1401 proper behaviour of the auxiliary file commands of PO mode. This is not | |
1402 expected to be much a problem in practice, as most existing PO files have | |
1403 their <code>msgid</code> entries written by the same GNU <code>gettext</code> tools. | |
1404 </p> | |
1405 <a name="IDX483"></a> | |
1406 <p>However, PO files initially created by PO mode itself, while marking | |
1407 strings in source files, are normalised differently. So are PO | |
1408 files resulting of the ‘<samp>M-x normalize</samp>’ command. Until these | |
1409 discrepancies between PO mode and other GNU <code>gettext</code> tools get | |
1410 fully resolved, the translator should stay aware of normalisation issues. | |
1411 </p> | |
1412 | |
1413 <a name="Compendium"></a> | |
1414 <a name="SEC80"></a> | |
1415 <h2 class="section"> <a href="gettext_toc.html#TOC73">8.4 Using Translation Compendia</a> </h2> | |
1416 | |
1417 <p>A <em>compendium</em> is a special PO file containing a set of | |
1418 translations recurring in many different packages. The translator can | |
1419 use gettext tools to build a new compendium, to add entries to her | |
1420 compendium, and to initialize untranslated entries, or to update | |
1421 already translated entries, from translations kept in the compendium. | |
1422 </p> | |
1423 | |
1424 | |
1425 <a name="Creating-Compendia"></a> | |
1426 <a name="SEC81"></a> | |
1427 <h3 class="subsection"> <a href="gettext_toc.html#TOC74">8.4.1 Creating Compendia</a> </h3> | |
1428 | |
1429 <p>Basically every PO file consisting of translated entries only can be | |
1430 declared as a valid compendium. Often the translator wants to have | |
1431 special compendia; let's consider two cases: <cite>concatenating PO | |
1432 files</cite> and <cite>extracting a message subset from a PO file</cite>. | |
1433 </p> | |
1434 | |
1435 <a name="SEC82"></a> | |
1436 <h4 class="subsubsection"> <a href="gettext_toc.html#TOC75">8.4.1.1 Concatenate PO Files</a> </h4> | |
1437 | |
1438 <p>To concatenate several valid PO files into one compendium file you can | |
1439 use ‘<samp>msgcomm</samp>’ or ‘<samp>msgcat</samp>’ (the latter preferred): | |
1440 </p> | |
1441 <table><tr><td> </td><td><pre class="example">msgcat -o compendium.po file1.po file2.po | |
1442 </pre></td></tr></table> | |
1443 | |
1444 <p>By default, <code>msgcat</code> will accumulate divergent translations | |
1445 for the same string. Those occurrences will be marked as <code>fuzzy</code> | |
1446 and highly visible decorated; calling <code>msgcat</code> on | |
1447 ‘<tt>file1.po</tt>’: | |
1448 </p> | |
1449 <table><tr><td> </td><td><pre class="example">#: src/hello.c:200 | |
1450 #, c-format | |
1451 msgid "Report bugs to <%s>.\n" | |
1452 msgstr "Comunicar `bugs' a <%s>.\n" | |
1453 </pre></td></tr></table> | |
1454 | |
1455 <p>and ‘<tt>file2.po</tt>’: | |
1456 </p> | |
1457 <table><tr><td> </td><td><pre class="example">#: src/bye.c:100 | |
1458 #, c-format | |
1459 msgid "Report bugs to <%s>.\n" | |
1460 msgstr "Comunicar \"bugs\" a <%s>.\n" | |
1461 </pre></td></tr></table> | |
1462 | |
1463 <p>will result in: | |
1464 </p> | |
1465 <table><tr><td> </td><td><pre class="example">#: src/hello.c:200 src/bye.c:100 | |
1466 #, fuzzy, c-format | |
1467 msgid "Report bugs to <%s>.\n" | |
1468 msgstr "" | |
1469 "#-#-#-#-# file1.po #-#-#-#-#\n" | |
1470 "Comunicar `bugs' a <%s>.\n" | |
1471 "#-#-#-#-# file2.po #-#-#-#-#\n" | |
1472 "Comunicar \"bugs\" a <%s>.\n" | |
1473 </pre></td></tr></table> | |
1474 | |
1475 <p>The translator will have to resolve this “conflict” manually; she | |
1476 has to decide whether the first or the second version is appropriate | |
1477 (or provide a new translation), to delete the “marker lines”, and | |
1478 finally to remove the <code>fuzzy</code> mark. | |
1479 </p> | |
1480 <p>If the translator knows in advance the first found translation of a | |
1481 message is always the best translation she can make use to the | |
1482 ‘<samp>--use-first</samp>’ switch: | |
1483 </p> | |
1484 <table><tr><td> </td><td><pre class="example">msgcat --use-first -o compendium.po file1.po file2.po | |
1485 </pre></td></tr></table> | |
1486 | |
1487 <p>A good compendium file must not contain <code>fuzzy</code> or untranslated | |
1488 entries. If input files are “dirty” you must preprocess the input | |
1489 files or postprocess the result using ‘<samp>msgattrib --translated --no-fuzzy</samp>’. | |
1490 </p> | |
1491 | |
1492 <a name="SEC83"></a> | |
1493 <h4 class="subsubsection"> <a href="gettext_toc.html#TOC76">8.4.1.2 Extract a Message Subset from a PO File</a> </h4> | |
1494 | |
1495 <p>Nobody wants to translate the same messages again and again; thus you | |
1496 may wish to have a compendium file containing ‘<tt>getopt.c</tt>’ messages. | |
1497 </p> | |
1498 <p>To extract a message subset (e.g., all ‘<tt>getopt.c</tt>’ messages) from an | |
1499 existing PO file into one compendium file you can use ‘<samp>msggrep</samp>’: | |
1500 </p> | |
1501 <table><tr><td> </td><td><pre class="example">msggrep --location src/getopt.c -o compendium.po file.po | |
1502 </pre></td></tr></table> | |
1503 | |
1504 | |
1505 <a name="Using-Compendia"></a> | |
1506 <a name="SEC84"></a> | |
1507 <h3 class="subsection"> <a href="gettext_toc.html#TOC77">8.4.2 Using Compendia</a> </h3> | |
1508 | |
1509 <p>You can use a compendium file to initialize a translation from scratch | |
1510 or to update an already existing translation. | |
1511 </p> | |
1512 | |
1513 <a name="SEC85"></a> | |
1514 <h4 class="subsubsection"> <a href="gettext_toc.html#TOC78">8.4.2.1 Initialize a New Translation File</a> </h4> | |
1515 | |
1516 <p>Since a PO file with translations does not exist the translator can | |
1517 merely use ‘<tt>/dev/null</tt>’ to fake the “old” translation file. | |
1518 </p> | |
1519 <table><tr><td> </td><td><pre class="example">msgmerge --compendium compendium.po -o file.po /dev/null file.pot | |
1520 </pre></td></tr></table> | |
1521 | |
1522 | |
1523 <a name="SEC86"></a> | |
1524 <h4 class="subsubsection"> <a href="gettext_toc.html#TOC79">8.4.2.2 Update an Existing Translation File</a> </h4> | |
1525 | |
1526 <p>Concatenate the compendium file(s) and the existing PO, merge the | |
1527 result with the POT file and remove the obsolete entries (optional, | |
1528 here done using ‘<samp>msgattrib</samp>’): | |
1529 </p> | |
1530 <table><tr><td> </td><td><pre class="example">msgcat --use-first -o update.po compendium1.po compendium2.po file.po | |
1531 msgmerge update.po file.pot | msgattrib --no-obsolete > file.po | |
1532 </pre></td></tr></table> | |
1533 | |
1534 | |
1535 <table cellpadding="1" cellspacing="1" border="0"> | |
1536 <tr><td valign="middle" align="left">[<a href="#SEC63" title="Beginning of this chapter or previous chapter"> << </a>]</td> | |
1537 <td valign="middle" align="left">[<a href="gettext_9.html#SEC87" title="Next chapter"> >> </a>]</td> | |
1538 <td valign="middle" align="left"> </td> | |
1539 <td valign="middle" align="left"> </td> | |
1540 <td valign="middle" align="left"> </td> | |
1541 <td valign="middle" align="left"> </td> | |
1542 <td valign="middle" align="left"> </td> | |
1543 <td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> | |
1544 <td valign="middle" align="left">[<a href="gettext_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td> | |
1545 <td valign="middle" align="left">[<a href="gettext_21.html#SEC389" title="Index">Index</a>]</td> | |
1546 <td valign="middle" align="left">[<a href="gettext_abt.html#SEC_About" title="About (help)"> ? </a>]</td> | |
1547 </tr></table> | |
1548 <p> | |
1549 <font size="-1"> | |
1550 This document was generated by <em>Bruno Haible</em> on <em>February, 21 2024</em> using <a href="https://www.nongnu.org/texi2html/"><em>texi2html 1.78a</em></a>. | |
1551 </font> | |
1552 <br> | |
1553 | |
1554 </p> | |
1555 </body> | |
1556 </html> |