To produce a translatable program, do the following
MSG_Bmacros, giving each message a unique
.mfile in each source file using the
MSG_xmacros. This file is generally named
directory.mwhere directory is the name of the current directory.
_dict.c. The content of this file is shown below.
make msg" to extract the messages. This produces/updates the dictionary file
directory.dicand produces the include file
make msg.eng" to produce the English binary dictionary. The file produced should be placed where your program expects it.
We will now describe further the different steps involved.
make msgcommand and
make msg command invokes the
msgscan utility. This utility
scan a set of
C++ source file, updates a dictionary
file and produces one include file.
Here is the command use to update the dictionary of the sub-project
uucp of the Linuxconf project.
../translate/msgscan uucp \ ../messages/sources/uucp.dic uucp.m EF *.c
The first argument is the name of the dictionary. The second argument is the path of the dictionary file. As you see, dictionary file are kept in a single directory for all projects. They are seldom. This eases the works of translators. The third argument is the path of the include file, which is produced in the current directory.
The fourth argument is the letter tags used to identify messages
defined with the macro
MSG_U will be tagged with the letter E (English)
and messages defined with
MSG_B will be tagged with
E for the first value and
F (French) for the second.
It is good practice to place the DICTIONARY_REQUEST macro in a file _dict.c. There is generally one such a file per directory. Its contents is generally:
#include "this_directory.m" #include <translat.h> DICTIONARY_REQUEST
At least this dependency should be placed in your
_dict.o: _dict.c this_directory.m
This will ensure that each time you update your dictionary (and
m header file),
_dict.c will be recompile, ensuring
proper recording of the dictionary revision and number of message.
This will avoid executing a program with an obsolete
or incompatible binary dictionary.
_dict.c is small, the compilation is pretty
Once you have compiled and linked your program, you must "compiled"
all the dictionaries used in your program into one binary dictionary.
This is done by the
msgcomp utility. Here is the command
used when doing "
make msg.eng" for the Linuxconf project.
This produces the English binary dictionary.
../translate/msgcomp -p../messages/sources/ \ /tmp/linuxconf-msg-1.3.eng eE \ askrunlevel dialog dnsconf fstab \ misc main netconf mailconf uucp userconf
This commands take all dictionaries for sub-projects
askrunlevel dialog dnsconf fstab misc main netconf mailconf
userconf and produce a single binary dictionary.
-p option tells msgcomp to look for those dic files (
askrunlevel.dic dialog.dic ...)
in the directory
/tmp/linuxconf-msg-1.3.eng is the file to produce.
msgcomp to extract message's values with
e' tag. If there is no such value for a given message, the
value with the '
E' tag will be used.
Dictionary file contain the definition for all messages. Each messages may have different values, identified by a tag letter. When messages are extracted by msgscan, it is instructed to associate values with given tags. By convention, we use upper case letter to identify message's value extracted from the source code. Lower case value are used by translators.
We assume here that programmers are bad writers. We let them give
their best shots for messages and we are allowed to override their
work without overwriting it. By giving precedence to '
E' we are saying that translators work override the
work of programmers, but we are not forcing the translators to
msgscan utility maintains dictionary. At some point
some messages may become obsolete (Unused in any source files). The
msgclean is used to clean messages without values in the
For the Linuxconf project, the
is defined for that purpose.
Be aware that applying msgclean on a dictionary file with obsolete
message has an important side effect. Some message being deleted, the
numbering of all following message will be changed. All source using
m include file should be recompiled.
To avoid problems, the
msgclean utility automaticly increases
the revision number of the dictionary. This prevents using a
dictionary with an incompatible program.