   This file provides documentation for GNU `gettext' utilities.

   Copyright (C) 1995 Free Software Foundation, Inc.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be stated in a
translation approved by the Foundation.

Normalizing Strings in Entries
==============================

   There are many different ways for encoding a particular string into a
PO file entry, because there are so many different ways to split and
quote multi-line strings, and even, to represent special characters by
backslahsed escaped sequences.  Some features of PO mode rely on the
ability for PO mode to scan an already existing PO file for a
particular string encoded into the `msgid' field of some entry.  Even
if PO mode has internally all the built-in machinery for implementing
this recognition easily, doing it fast is technically difficult.  For
facilitating a solution to this efficiency problem, we decided for a
canonical representation for strings.

   A conventional representation of strings in a PO file is currently
under discussion, and PO mode experiments a canonical representation.
Having both `xgettext' and PO mode converging towards a uniform way of
representing equivalent strings would be useful, as the internal
normalization needed by PO mode could be automatically satisfied when
using `xgettext' from GNU `gettext'.  An explicit PO mode normalization
should then be only necessary for PO files imported from elsewhere, or
for when the convention itself evolves.

   So, for achieving normalization of at least the strings of a given
PO file needing a canonical representation, the following PO mode
command is available:

`M-x po-normalize'
     Tidy the whole PO file by making entries more uniform.

   The special command `M-x po-normalize', which has no associate keys,
revises all entries, ensuring that strings of both original and
translated entries use uniform internal quoting in the PO file.  It
also removes any crumb after the last entry.  This command may be
useful for PO files freshly imported from elsewhere, or if we ever
improve on the canonical quoting format we use.  This canonical format
is not only meant for getting cleaner PO files, but also for greatly
speeding up `msgid' string lookup for some other PO mode commands.

   `M-x po-normalize' presently makes three passes over the entries.
The first implements heuristics for converting PO files for GNU
`gettext' 0.6 and earlier, in which `msgid' and `msgstr' fields were
using K&R style C string syntax for multi-line strings.  These
heuristics may fail for comments not related to obsolete entries and
ending with a backslash; they also depend on subsequent passes for
finalizing the proper commenting of continued lines for obsolete
entries.  This first pass might disappear once all oldish PO files
would have been adjusted.  The second and third pass normalize all
`msgid' and `msgstr' strings respectively.  They also clean out those
trailing backslashes used by XView's `msgfmt' for continued lines.

   Having such an explicit normalizing command allows for importing PO
files from other sources, but also eases the evolution of the current
convention, evolution driven mostly by aesthetic concerns, as of now.
It is all easy to make suggested adjustments at a later time, as the
normalizing command and eventually, other GNU `gettext' tools should
greatly automate conformance.  A description of the canonical string
format is given below, for the particular benefit of those not having
GNU Emacs handy, and who would nevertheless want to handcraft their PO
files in nice ways.

   Right now, in PO mode, strings are single line or multi-line.  A
string goes multi-line if and only if it has *embedded* newlines, that
is, if it matches `[^\n]\n+[^\n]'.  So, we would have:

     msgstr "\n\nHello, world!\n\n\n"

   but, replacing the space by a newline, this becomes:

     msgstr ""
     "\n"
     "\n"
     "Hello,\n"
     "world!\n"
     "\n"
     "\n"

   We are deliberately using a caricatural example, here, to make the
point clearer.  Usually, multi-lines are not that bad looking.  It is
probable that we will implement the following suggestion.  We might
lump together all initial newlines into the empty string, and also all
newlines introducing empty lines (that is, for N > 1, the N-1'th last
newlines would go together on a separate string), so making the
previous example appear:

     msgstr "\n\n"
     "Hello,\n"
     "world!\n"
     "\n\n"

   There are a few yet undecided little points about string
normalization, to be documented in this manual, once these questions
settle.

Preparing Program Sources
*************************

   For the programmer, changes to the C source code fall into three
categories.  First, you have to make the localization functions known
to all modules needing message translation.  Second, you should
properly trigger the operation of GNU `gettext' when the program
initializes, usually from the `main' function.  Last, you should
identify and especially mark all constant strings in your program
needing translation.

   Presuming that your set of programs, or package, has been adjusted
so all needed GNU `gettext' files are available, and your `Makefile'
files are adjusted (see Maintainers.), each C module having
translated C strings should contain the line:

     #include <libintl.h>

   The remaining changes to your C sources are discussed in the further
sections of this chapter.

Triggering `gettext' Operations
===============================

   The initialization of locale data should be done with more or less
the same code in every program, as demonstrated below:

     int
     main (argc, argv)
          int argc;
          char argv;
     {
       ...
       setlocale (LC_ALL, "");
       bindtextdomain (PACKAGE, LOCALEDIR);
       textdomain (PACKAGE);
       ...
     }

   PACKAGE and LOCALEDIR should be provided either by `config.h' or by
the Makefile.  For now consult the `gettext' sources for more
information.

   The use of `LC_ALL' might not be appropriate for you.  `LC_ALL'
includes all locale categories and especially `LC_CTYPE'.  This later
category is responsible for determining character classes with the
`isalnum' etc. functions from `ctype.h' which could especially for
programs, which process some kind of input language, be wrong.  For
example this would mean that a source code using the c, (cedille
character) is runnable in France but not in the U.S.

   So it is sometimes necessary to replace the `LC_ALL' line in the
code above by a sequence of `setlocale' lines

     {
       ...
       setlocale (LC_TIME, "");
       setlocale (LC_MESSAGES, "");
       ...
     }

or to switch for and back to the character class in question.

How Marks Appears in Sources
============================

   The C sources should mark all strings requiring translation.  Marking
is done in such a way that each translatable string appears to be the
sole argument of some function or preprocessor macro.  There are only a
few such possible functions or macros meant for translation, and their
names are said to be marking keywords.  The marking is attached to
strings themselves, rather than to what we do with them.  This approach
has more uses.  A blatant example is an error message produced by
formatting.  The format string needs translation, as well as some
strings inserted through some `%s' specification in the format, while
the result from `sprintf' may have so many different instances that it
is unpractical to list them all in some `error_string_out()' routine,
say.

   This marking operation has two goals.  The first goal of marking is
for triggering the retrieval of the translation, at run time.  The
keyword are possibly resolved into a routine able to dynamically return
the proper translation, as far as possible or wanted, for the argument
string.  Most localizable strings are found into executable positions,
that is, affected to variables or given as parameter to functions.  But
this is not universal usage, and some translatable strings appear in
structured initializations.  See Special cases.

   The second goal of the marking operation is to help `xgettext' at
properly extracting all translatable strings when it scans a set of
program sources and produces PO file templates.

   The canonical keyword for marking translatable strings is `gettext',
it gave its name to the whole GNU `gettext' package.  For packages
making only light use of the `gettext' keyword, macro or function, it
is easily used *as is*.  However, for packages using the `gettext'
interface more heavily, it is usually more convenient giving the main
keyword a shorter, less obtrusive name.  Indeed, the keyword might
appear on a lot of strings all over the package, and programmers
usually do not want nor need that their program sources remind them
loud, all the time, that they are internationalized.  Further, a long
keyword has the disadvantage of using more horizontal space, forcing
more indentation work on sources for those trying to keep them within
79 or 80 columns.

   Many GNU packages use `_' (a simple underline) as a keyword, and
write `_("Translatable string")' instead of `gettext ("Translatable
string")'.  Further, the usual GNU coding rule wanting that there is a
space between the keyword and the opening parenthesis is relaxed, in
practice, for this particular usage.  So, the textual overhead per
translatable string is reduced to only three characters: the underline
and the two parentheses.  However, even if GNU `gettext' uses this
convention internally, it does not offer it officially.  The real,
genuine keyword is truly `gettext' indeed.  It is fairly easy for those
wanting to use `_' instead of `gettext' to declare:

     #include <libintl.h>
     #define _(String) gettext (String)

instead of merely using `#include <libintl.h>'.

   Later on, the maintenance is relatively easy.  If, as a programmer,
you add or modify a string, you will have to ask yourself if the new or
altered string requires translation, and include it within `_()' if you
think it should be translated.  `"%s: %d"' is an example of string
*not* requiring translation!

Marking Translatable Strings
============================

   In PO mode, one set of features is meant more for the programmer than
for the translator, and allows him to interactively mark which strings,
in a set of program sources, are translatable, and which are not.  Even
if it is a fairly easy job for a programmer to find and mark such
strings by other means, using any editor of his choice, PO mode makes
this work more comfortable.  Further, this gives translators who feel a
little like programmers, or programmers who feel a little like
translators, a tool letting them work at marking translatable strings
in the program sources, while simultaneously producing a set of
translation in some language, for the package being internationalized.

   The set of program sources, aimed by the PO mode commands describe
here, should have an Emacs tags table constructed for your project,
prior to using these PO file commands.  This is easy to do.  In any
shell window, change the directory to the root of your project, then
execute a command resembling:

     etags src/*.[hc] lib/*.[hc]

presuming here you want to process all `.h' and `.c' files from the
`src/' and `lib/' directories.  This command will explore all said
files and create a `TAGS' file in your root directory, somewhat
summarizing the contents using a special file format Emacs can
understand.

   For official GNU packages which follow the GNU coding standard there
is a make goal `tags' or `TAGS' which construct the tag files in all
directories and for all files containing source code.

   Once your `TAGS' file is ready, the following commands assist the
programmer at marking translatable strings in his set of sources.  But
these commands are necessarily driven from within a PO file window, and
it is likely that you do not even have such a PO file yet.  This is not
a problem at all, as you may safely open a new, empty PO file, mainly
for using these commands.  This empty PO file will slowly fill in while
you mark strings as translatable in your program sources.

`,'
     Search through program sources for a string which looks like a
     candidate for translation.

`M-,'
     Mark the last string found with `_()'.

`M-.'
     Mark the last string found with a keyword taken from a set of
     possible keywords.  This command with a prefix allows some
     management of these keywords.

   The `,' (`po-tags-search') command search for the next occurrence of
a string which looks like a possible candidate for translation, and
displays the program source in another Emacs window, positioned in such
a way that the string is near the top of this other window.  If the
string is to big to fit whole in this window, it is rather positioned
so only its end is shown.  In any case, the cursor is left in the PO
file window.  If the shown string would be better presented differently
in different native languages, you may mark it using `M-,' or `M-.'.
Otherwise, you might rather ignore it and skip to the next string by
merely repeating the `,' command.

   A string is a good candidate for translation if it contains a
sequence of three or more letters.  A string containing at most two
letters in a row will be considered as a candidate if it has more
letters than non-letters.  The command disregards strings containing no
letters, or isolated letters only.  It also disregards strings within
comments, or strings already marked with some keyword PO mode knows
(see below).

   If you have never told Emacs about some `TAGS' file to use, the
command will request that you specify one from the minibuffer, the
first time you use the command.  You may later change your `TAGS' file
by using the regular Emacs command `M-x visit-tags-table', which will
ask you to name the precise `TAGS' file you want to use.  See Tag Tables (emacs).

   Each time you use the `,' command, the search resumes where it was
left over by the previous search, and goes through all program sources,
obeying the `TAGS' file, until all sources have been processed.
However, by giving a prefix argument to the command (`C-u ,'), you may
request that the search be restarted all over again from the first
program source; but in this case, strings that you recently marked as
translatable will be automatically skipped.

   Using this `,' command does not prevent using of other regular Emacs
tags commands.  For example, regular `tags-search' or
`tags-query-replace' commands may be used without disrupting the
independent `,' search sequence.  However, as implemented, the
*initial* `,' command (or the `,' command is used with a prefix) might
also reinitialize the regular Emacs tags searching to the first tags
file, this reinitialization might be considered spurious.

   The `M-,' (`po-mark-translatable') command will mark the recently
found string with the `_' keyword.  The `M-.'
(`po-select-mark-and-mark') command will request that you type one
keyword from the minibuffer and use that keyword for marking the
string.  Both commands will automatically create a new PO file
untranslated entry for the string being marked, and make it the current
entry (making it easy for you to immediately proceed to its
translation, if you feel like doing it right away).  It is possible
that the modifications made to the program source by `M-,' or `M-.'
render some source line longer than 80 columns, forcing you to break
and re-indent this line differently.  You may use the `o' command from
PO mode, or any other window changing command from GNU Emacs, to break
out into the program source window, and do any needed adjustments.  You
will have to use some regular Emacs command to return the cursor to the
PO file window, if you want commanding `,' for the next string, say.

   The `M-.' command has a few built-in speedups, so you do not have to
explicitly type all keywords all the time.  The first such speedup is
that you are presented with a *preferred* keyword, which you may accept
by merely typing `RET' at the prompt.  The second speedup is that you
may type any non-ambiguous prefix of the keyword you really mean, and
the command will complete it automatically for you.  This also means
that PO mode has to *know* all your possible keywords, and that it will
not accept mistyped keywords.

   If you reply `?' to the keyword request, the command gives a list of
all known keywords, from which you may choose.  When the command is
prefixed by an argument (`C-u M-.'), it inhibits updating any program
source or PO file buffer, and does some simple keyword management
instead.  In this case, the command asks for a keyword, written in
full, which becomes a new allowed keyword for later `M-.' commands.
Moreover, this new keyword automatically becomes the *preferred*
keyword for later commands.  By typing an already known keyword in
response to `C-u M-.', one merely changes the *preferred* keyword and
does nothing more.

   All keywords known for `M-.' are recognized by the `,' command when
scanning for strings, and strings already marked by any of those known
keywords are automatically skipped.  If many PO files are opened
simultaneously, each one has its own independent set of known keywords.
There is no provision in PO mode, currently, for deleting a known
keyword, you have to quit the file (maybe using `q') and reopen it
afresh.  When a PO file is newly brought up in an Emacs window, only
`gettext' and `_' are known as keywords, and `gettext' is preferred for
the `M-.' command.  In fact, this is not useful to prefer `_', as this
one is already built in the `M-,' command.

Special Cases of Translatable Strings
=====================================

   The attentive reader might now point out that it is not always
possible to mark translatable string with `gettext' or something like
this.  Consider the following case:

     {
       static const char *messages[] = {
         "some very meaningful message",
         "and another one"
       };
       const char *string;
       ...
       string
         = index > 1 ? "a default message" : messages[index];

       fputs (string);
       ...
     }

   While it is no problem to mark the string `"a default message"' it
is not possible to mark the string initializers for `messages'.  What
is to do?  We have to fulfill two tasks.  First we have to mark the
strings so that the `xgettext' program (see xgettext Invocation.)
can find them, and second we have to translate the string at runtime
before printing them.

   The first task can be fulfilled by creating a new keyword, which
names a no-op.  For the second we have to mark all access points to a
string from the array.  So one solution can look like this:

     #define gettext_noop(String) (String)

     {
       static const char *messages[] = {
         gettext_noop ("some very meaningful message"),
         gettext_noop ("and another one")
       };
       const char *string;
       ...
       string
         = index > 1 ? gettext ("a default message") : gettext (messages[index]);

       fputs (string);
       ...
     }

   Please convince yourself that the string which is written by `fputs'
is translated in any case.  How to get `xgettext' know the additional
keyword `gettext_noop' is explained in xgettext Invocation.

   The above is of course not the only solution.  You could also come
along with the following one:

     #define gettext_noop(String) (String)

     {
       static const char *messages[] = {
         gettext_noop ("some very meaningful message",
         gettext_noop ("and another one")
       };
       const char *string;
       ...
       string
         = index > 1 ? gettext_noop ("a default message") : messages[index];

       fputs (gettext (string));
       ...
     }

   But this has some drawbacks.  First the programmer has to take care
that he uses `gettext_noop' for the string `"a default message"'.  A
use of `gettext' could have in rare cases unpredictable results.  The
second reason is found in the internals of the GNU `gettext' Library
which will make this solution less efficient.

   One advantage is that you need not make control flow analysis to make
sure the output is really translated in any case.  But this analysis is
generally not very difficult.  If it should be in any situation you can
use this second method in this situation.

Making the Initial PO File
**************************

Invoking the `xgettext' Program
===============================

     xgettext [OPTION] INPUTFILE ...

`-a'
`--extract-all'
     Extract all strings.

`-c [TAG]'
`--add-comments[=TAG]'
     Place comment block with TAG (or those preceding keyword lines) in
     output file.

`-C'
`--c++'
     Recognize C++ style comments.

`-d NAME'
`--default-domain=NAME'
     Use `NAME.po' for output (instead of `messages.po').

`-D DIRECTORY'
`--directory=DIRECTORY'
     Change to DIRECTORY before beginning to search and scan source
     files.  The resulting `.po' file will be written relative to the
     original directory, though.

`-f FILE'
`--files-from=FILE'
     Read the names of the input files from FILE instead of getting
     them from the command line.

`-h'
`--help'
     Display this help and exit.

`-I LIST'
`--input-path=LIST'
     List of directories searched for input files.

`-j'
`--join-existing'
     Join messages with existing file.

`-k WORD'
`--keyword[=WORD]'
     Additonal keyword to be looked for (without WORD means not to use
     default keywords).

     The default keywords, which are always looked for if not explicitly
     disabled, are `gettext', `dgettext', `dcgettext' and
     `gettext_noop'.

`-m [STRING]'
`--msgstr-prefix[=STRING]'
     Use STRING or "" as prefix for msgstr entries.

`-M [STRING]'
`--msgstr-suffix[=STRING]'
     Use STRING or "" as suffix for msgstr entries.

`--no-location'
     Do not write `#: FILENAME:LINE' lines.

`-n'
`--add-location'
     Generate `#: FILENAME:LINE' lines (default).

`--omit-header'
     Don't write header with `msgid ""' entry.

     This is useful for testing purposes because it eliminates a source
     of variance for generated `.gmo' files.  We can ship some of these
     files in the GNU `gettext' package, and the result of regenerating
     them through `msgfmt' should yield the same values.

`-p DIR'
`--output-dir=DIR'
     Output files will be placed in directory DIR.

`-s'
`--sort-output'
     Generate sorted output and remove duplicates.

`--strict'
     Write out strict Uniforum conforming PO file.

`-v'
`--version'
     Output version information and exit.

`-x FILE'
`--exclude-file=FILE'
     Entries from FILE are not extracted.

   Search path for supplementary PO files is:
`/usr/local/share/nls/src/'.

   If INPUTFILE is `-', standard input is read.

   This implementation of `xgettext' is able to process a few awkward
cases, like strings in preprocessor macros, ANSI concatenation of
adjacent strings, and escaped end of lines for continued strings.

C Sources Context
=================

   PO mode is particularily powerful when used with PO files created
through GNU `gettext' utilities, as those utilities insert special
comments in the PO files they generate.  Some of these special comments
relate the PO file entry to exactly where the untranslated string
appears in the program sources.

   When the translator gets to an untranslated entry, she is fairly
often faced with an original string which is not as informative as it
normally should, being succinct, cryptic, or otherwise ambiguous.
Before chosing how to translate the string, she needs to understand
better what the string really means and how tight the translation has
to be.  Most of times, when problems arise, the only way left to make
her judgment is looking at the true program sources from where this
string originated, searching for surrounding comments the programmer
might have put in there, and looking around for helping clues of *any*
kind.

   Surely, when looking at program sources, the translator will receive
more help if she is a fluent programmer.  However, even if she is not
versed in programming and feels a little lost in C code, the translator
should not be shy at taking a look, once in a while.  It is most
probable that she will still be able to find some of the hints she
needs.  She will learn quickly to not feel uncomfortable in program
code, paying more attention to programmer's comments, variable and
function names (if he dared chosing them well), and overall
organization, than to programmation itself.

   The following commands are meant to help the translator at getting
program source context for a PO file entry.

`c'
     Resume the display of a program source context, or cycle through
     them.

`M-c'
     Display of a program source context selected by menu.

`d'
     Add a directory to the search path for source files.

`M-d'
     Delete a directory from the search path for source files.

   The commands `c' (`po-cycle-reference') and `M-c'
(`po-select-reference') both open another window displaying some source
program file, and already positioned in such a way that it shows an
actual use of the current string to translate.  By doing so, the
command gives source program context for the string.  But if the entry
has no source context references, or if all references are unresolved
along the search path for program sources, then the command diagnoses
this as an error.

   Even if `c' (or `M-c') opens a new window, the cursor stays in the
PO file window.  If the translator really wants to get into the program
source window, she ought to do it explicitly, maybe by using command
`o'.

   When `c' is typed for the first time, or for a PO file entry which
is different of the last one used for getting source context, then the
command reacts by giving the first context available for this entry, if
any.  If some context has already been recently displayed for the
current PO file entry, and the translator wandered to do other things,
typing `c' again will merely resume, in another window, the context
last displayed.  In particular, if the translator moved the cursor away
from the context in the source file, the command will bring the cursor
back to the context.  By using `c' many times in a row, with no
interning other commands, PO mode will cycle to the next available
contexts for this particular entry, getting back to the first context
once the last has been shown.

   The command `M-c' behaves differently.  Instead of cycling through
references, it lets the translator choose of particular reference among
many, and displays that reference.  It is best used with completion, if
the translator types `TAB' immediately after `M-c', in response to the
question, she will be offered a menu of all possible references, as a
reminder of which are the acceptable answers.  This command is useful
only where there are really many contexts available for a single string
to translate.

   Program source files are usually found relative to where the PO file
stands.  As a special provision, when this fails, the file is also
looked for, but relative to the directory immediately above it.  Those
two cases take proper care of most PO files.  However, it might happen
that a PO file has been moved, or is edited in a different place than
its normal location.  When this happens, the translator should tell PO
mode in which directory normally sits the genuine PO file.  Many such
directories may be specified, and all together, they constitute what is
called the "search path" for program sources.  The command `d'
(`po-add-path') is used to interactively enter a new directory at the
front of the search path, and the command `M-d' (`po-delete-path') is
used to select, with completion, one of the directories she does not
want anymore on the search path.

Using Translation Compendiums
=============================

   Compendiums are yet to be implemented.

   An incoming PO mode feature will let the translator maintain a
compendium of already achieved translations.  A "compendium" is a
special PO file containing a set of translations recurring in many
different packages.  The translator will be given commands for adding
entries to her compendium, and later initializing untranslated entries,
or updating already translated entries, from translations kept in the
compendium.  For this to work, however, the compendium would have to be
normalized.  See Normalizing.

Updating Existing PO Files
**************************

Invoking the `tupdate' Program
==============================

     tupdate --help
     tupdate --version
     tupdate NEW OLD

   File NEW is the last created PO file (generally by `xgettext').  It
need not contain any translations.  File OLD is the PO file including
the old translations which will be taken over to the newly created file
as long as they still match.

   When English messages change in the programs, this is reflected in
the PO file as extracted by `xgettext'.  In large messages, that can be
hard to detect, and will obviously result in an incomplete translation.
One of the virtues of `tupdate' is that it detects such changes,
saving the previous translation into a PO file comment, so marking the
entry as obsolete, and giving the modified string with an empty
translation, that is, marking the entry as untranslated.

Untranslated Entries
====================

   When `xgettext' originally creates a PO file, unless told otherwise,
it initializes the `msgid' field with the untranslated string, and
leaves the `msgstr' string to be empty.  Such entries, having an empty
translation, are said to be "untranslated" entries.  Later, when the
programmer slightly modifies some string right in the program, this
change is later reflected in the PO file by the appearance of a new
untranslated entry for the modified string.

   The usual commands moving from entry to entry consider untranslated
entries on the same level as active entries.  Untranslated entries are
easily recognizable by the fact they end with `msgstr ""'.

   The work of the translator might be (quite naively) seen as the
process of seeking after an untranslated entry, editing a translation
for it, and repeating these actions until no untranslated entries
remain.  Some commands are more specifically related to untranslated
entry processing.

`e'
     Find the next untranslated entry.

`M-e'
     Find the previous untranslated entry.

`k'
     Turn the current entry into an untranslated one.

   The commands `e' (`po-next-empty-entry') and `M-e'
(`po-previous-empty') move forwards or backwards, chasing for an
obsolete entry.  If none is found, the search is extended and wraps
around in the PO file buffer.

   An entry can be turned back into an untranslated entry by merely
emptying its translation, using the command `k' (`po-kill-msgstr').
See Modifying Translations.

   Also, when time comes to quit working on a PO file buffer with the
`q' command, the translator is asked for confirmation, if some
untranslated string still exists.

Obsolete Entries
================

   By "obsolete" PO file entries, we mean those entries which are
commented out, usually by `tupdate' when it found that the translation
is not needed anymore by the package being localized.

   The usual commands moving from entry to entry consider obsolete
entries on the same level as active entries.  Obsolete entries are
easily recognizable by the fact that all their lines start with `#',
even those lines containing `msgid' or `msgstr'.

   Commands exist for emptying the translation or reinitializing it to
the original untranslated string.  Commands interfacing with the kill
ring may force some previously saved text into the translation.  The
user may interactively edit the translation.  All these commands may
apply to obsolete entries, carefully leaving the entry obsolete after
the fact.

   Moreover, some commands are more specifically related to obsolete
entry processing.

`M-n'
`M-SPC'
     Find the next obsolete entry.

`M-p'
`M-DEL'
     Find the previous obsolete entry.

`z'
     Make an active entry obsolete, or zap out an obsolete entry.

   The commands `M-n' (`po-next-obsolete-entry') and `M-p'
(`po-previous-obsolete-entry') move forwards or backwards, chasing for
an obsolete entry.  If none is found, the search is extended and wraps
around in the PO file buffer.  The commands `M-SPC' and `M-DEL' are
synonymous to `M-n' and `M-p', respectively.

   PO mode does not provide ways for un-commenting an obsolete entry
and making it active, because this would reintroduce an original
untranslated string which does not correspond to any marked string in
the program sources.  This goes with the philosophy of never
introducing useless `msgid' values.

   However, it is possible to comment out an active entry, so making it
obsolete.  GNU `gettext' utilities will later react to the
disappearance of a translation by using the untranslated string.  The
command `z' (`po-fade-out-entry') pushes the current entry a little
further towards annihilation.  If the entry is active, then the entry
is merely commented out.  If the entry is already obsolete, then it is
completely deleted from the PO file.  It is easy to recycle the
translation so deleted into some other PO file entry, usually one which
is untranslated.  See Modifying Translations.

   Here is a quite interesting problem to solve for later development of
PO mode, for those nights you are not sleepy.  The idea would be that
PO mode might become bright enough, one of these days, to make good
guesses at retrieving the most probable candidate, among all obsolete
entries, for initializing the translation of a newly appeared string.
I think it might be a quite hard problem to do this algorithmically, as
we have to develop good and efficient measures of string similarity.
Right now, PO mode completely lets the decision to the translator, when
the time comes to find the adequate obsolete translation, it merely
tries to provide handy tools for helping her to do so.

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 Yanking (emacs).
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 Keyboard Macros (emacs).

Modifying Comments
==================

   Any translation work done seriously will raise many linguistic
difficulties, for which decisions have to be made, and the choices
further documented.  These documents may be saved within the PO file in
form of translator comments, which the translator is free to create,
delete, or modify at will.  These comments may be useful to herself
when she returns to this PO file after a while.  Memory forgets!

   These commands are somewhat similar to those modifying translations,
so the general indications given for these apply here.  See Modifying Translations.

`M-RET'
     Interactively edit the translator comments.

`M-k'
     Save the translator comments on the kill ring, and delete it.

`M-w'
     Save the translator comments on the kill ring, without deleting it.

`M-y'
     Replace the translator comments, taking the new from the kill ring.

   Those commands parallel PO mode commands for modifying the
translation strings, and behave much the same way as them, except that
they handle this part of PO file comments meant for translator usage,
rather than the translation strings.  So, the descriptions given below
are slightly succinct, because the full details have already been given.
See Modifying Translations.

   The command `M-RET' (`po-edit-comment') opens a new Emacs window
containing a copy of the translator comments the current PO file entry.
If there is no such comments, PO mode understands that the translator
wants to add a comment to the entry, and she is presented an empty
screen.  Comment marks (`#') and the space following them are
automatically removed before edition, and reinstated after.  For
translator comments pertaining to obsolete entries, the uncommenting
and recommenting operations are done twice.  The command `#' also has
the same effect as `M-RET', and might be easier to type.  Once in the
editing window, the keys `C-c C-c' allow the translator to tell she is
finished with editing the comment.

   The command `M-k' (`po-kill-comment') get rid of all translator
comments, while saving those comments on the kill ring.  The command
`M-w' (`po-kill-ring-save-comment') takes a copy of the translator
comments on the kill ring, but leaves them undisturbed in the current
entry.  The command `M-y' (`po-yank-comment') completely replaces the
translator comments by a string taken at the front of the kill ring.
When this command is immediately repeated, the comments just inserted
are withdrawn, and replaced by other strings taken along the kill ring.

   On the kill ring, all strings have the same nature.  There is no
distinction between *translation* strings and *translator comments*
strings.  So, for example, let's presume the translator has just
finished editing a translation, and wants to create a new translator
comments for documenting why the previous translation was not good,
just to remember what was the problem.  Foreseeing that she will do
that in her documentation, the translator will want to quote the
previous translation in her translator comments.  For doing so, she may
initialize the translator comments with the previous translation, still
at the head of the kill ring.  Because editing already pushed the
previous translation on the kill ring, she just has to type `M-w' prior
to `#', and the previous translation will be right there, all ready for
being introduced by some explanatory text.

   On the other hand, presume there are some translator comments already
and that the translator wants to add to those comments, instead of
wholly replacing them.  Then, she should edit the comment right away
with `#'.  Once inside the editing window, she can use the regular GNU
Emacs commands `C-y' (`yank') and `M-y' (`yank-pop') for getting the
previous translation where she likes.