Go to the first, previous, next, last section, table of contents.


Modifying Translations

PO mode prevents direct edition of the PO file, by the usual means Emacs give for altering a buffer's contents. By doing so, it pretends helping the translator to avoid little clerical errors about the overall file format, or the proper quoting of strings, as those errors would be easily made. Other kinds of errors are still possible, but some may be catched and diagnosed by the batch validation process, which the translator may always trigger by the v command. For all other errors, the translator has to rely on her own judgment, and also on the linguistic reports submitted to her by the users of the translated package, having the same mother tongue.

When the time comes to create a translation, correct a error diagnosed mechanically or reported by a user, the translator have to resort to using the following commands for modifying the translations.

RET
Interactively edit the translation.
TAB
Reinitialize the translation with the original, untranslated string.
k
Save the translation on the kill ring, and delete it.
w
Save the translation on the kill ring, without deleting it.
y
Replace the translation, taking the new from the kill ring.

The command RET (po-edit-msgstr) opens a new Emacs window containing a copy of the translation taken from the current PO file entry, all ready for edition, fully modifiable and with the complete extent of GNU Emacs modifying commands. The string is presented to the translator expunged of all quoting marks, and she will modify the unquoted string in this window to heart's content. Once done, the regular Emacs command M-C-c (exit-recursive-edit) may be used to return the edited translation into the PO file, replacing the original translation. The keys C-c C-c are bound so they have the same effect as M-C-c.

If the translator becomes unsatisfied with her translation to the extent she prefers keeping the translation which was existent prior to the RET command, she may use the regular Emacs command C-] (abort-recursive-edit) to merely get rid of edition, while preserving the original translation. Another way would be for her to exit normally with C-c C-c, then type u once for undoing the whole effect of last edition.

While editing her translation, the translator should pay attention at not inserting unwanted RET (carriage returns) characters at the end of the translated string if those are not meant to be there, or removing such characters when they are required. Since these characters are not visible in the editing buffer, they are easily to introduce by mistake. To help her, RET automatically puts the character < at the end of the string being edited, but this < is not really part of the string. On exiting the editing window with C-c C-c, PO mode automatically removes such < and all whitespace added after it. If the translator adds characters after the terminating <, it looses its delimiting property and integrally becomes part of the string. If she removes the delimiting <, then the edited string is taken as is, with all trailing newlines, even if invisible. Also, if the translated string ought to end itself with a genuine <, then the delimiting < may not be removed; so the string should appear, in the editing window, as ending with two < in a row.

When a translation (or a comment) is being edited, the translator may move the cursor back into the PO file buffer and freely move to other entries, and browsing at will. The edited entry will be recovered as soon as the edit ceases, because this is this entry only which is being modified. If, with an edition still opened, the translator wanders in the PO file buffer, she cannot modify any other entry. If she tries to, PO mode will react by suggesting that she aborts the current edit, or else, by inviting her to finish the current edit prior to any other modification.

The command TAB (po-msgid-to-msgstr) initializes, or reinitializes the translation with the original string. This command is normally used when the translator wants to redo a fresh translation of the original string, disregarding any previous work.

In fact, whether it is best to start a translation with an empty string, or rather with a copy of the original string, is a matter of taste or habit. Sometimes, the source mother tongue language and the target language are so different that is simply best to start writing on an empty page. At other times, the source and target languages are so close that it would be a waste to retype a number of words already being written in the original string. A translator may also like having the original string right under her eyes, as she will progressively overwrite the original text with the translation, even if this requires some extra editing work to get rid of the original.

The command k (po-kill-msgstr) merely empties the translation string, so turning the entry into an untranslated one. But while doing so, its previous contents is put apart in a special place, known as the kill ring. The command w (po-kill-ring-save-msgstr) has also the effect of taking a copy of the translation onto the kill ring, but it otherwise leaves the entry alone, and does not remove the translation from the entry. Both commands use exactly the Emacs kill ring, which is shared between buffers, and which is well known already to GNU Emacs lovers.

The translator may use k or w many times in the course of her work, as the kill ring may hold several saved translations. From the kill ring, strings may later be reinserted in various Emacs buffers. In particular, the kill ring may be used for moving translation strings between different entries of a single PO file buffer, or if the translator is handling many such buffers at once, even between PO files.

To facilitate exchanges with buffers which are not in PO mode, the translation string put on the kill ring by the k command is fully unquoted before being saved: external quotes are removed, multi-lines strings are concatenated, and backslashed escaped sequences are turned into their corresponding characters. In the special case of obsolete entries, the translation is also uncommented prior to saving.

The command y (po-yank-msgstr) completely replaces the translation of the current entry by a string taken from the kill ring. Following GNU Emacs terminology, we then say that the replacement string is yanked into the PO file buffer. See section `Yanking' in The Emacs Editor. The first time y is used, the translation receives the value of the most recent addition to the kill ring. If y is typed once again, immediately, without intervening keystrokes, the translation just inserted is taken away and replaced by the second most recent addition to the kill ring. By repeating y many times in a row, the translator may travel along the kill ring for saved strings, until she finds the string she really wanted.

When a string is yanked into a PO file entry, it is fully and automatically requoted for complying with the format PO files should have. Further, if the entry is obsolete, PO mode then appropriately push the inserted string inside comments. Once again, translators should not burden themselves with quoting considerations besides, of course, the necessity of the translated string itself respective to the program using it.

Note that k or w are not the only commands pushing strings on the kill ring, as almost any PO mode command replacing translation strings (or the translator comments) automatically save the old string on the kill ring. The main exceptions to this general rule are the yanking commands themselves.

To better illustrate the operation of killing and yanking, let's use an actual example, taken from a common situation. When the programmer slightly modifies some string right in the program, his change is later reflected in the PO file by the appearance of a new untranslated entry for the modified string, and the fact that the entry translating the original or unmodified string becomes obsolete. In many cases, the translator might spare herself some work by retrieving the unmodified translation from the obsolete entry, then initializing the untranslated entry msgstr field with this retrieved translation. Once this done, the obsolete entry is not wanted anymore, and may be safely deleted.

When the translator finds an untranslated entry and suspects that a slight variant of the translation exists, she immediately uses m to mark the current entry location, then starts chasing obsolete entries with M-SPC, hoping to find some translation corresponding to the unmodified string. Once found, she uses the z command for deleting the obsolete entry, knowing that z also kills the translation, that is, pushes the translation on the kill ring. Then, l returns to the initial untranslated entry, y then yanks the saved translation right into the msgstr field. The translator is then free to use RET for fine tuning the translation contents, and maybe to later use e, then m again, for going on with the next untranslated string.

When some sequence of keys has to be typed over and over again, the translator may find comfortable to become more acquainted with the GNU Emacs capability of learning these sequences and playing them back under request. See section `Keyboard Macros' in The Emacs Editor.


Go to the first, previous, next, last section, table of contents.