aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-06-08 13:39:22 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-06-08 13:39:22 +0000
commite258acb7419001ee0fb03d33d3d2c755dc0bd5af (patch)
tree744195074e6fb11ce9b2ebeea374d08061779f93 /doc
parent1e007b08dcb6751ae6f26638e354325b90a7f875 (diff)
downloadmailfromd-e258acb7419001ee0fb03d33d3d2c755dc0bd5af.tar.gz
mailfromd-e258acb7419001ee0fb03d33d3d2c755dc0bd5af.tar.bz2
Update
git-svn-id: file:///svnroot/mailfromd/trunk@1489 7a8a7f39-df28-0410-adc6-e0d955640f24
Diffstat (limited to 'doc')
-rw-r--r--doc/mailfromd.texi73
1 files changed, 73 insertions, 0 deletions
diff --git a/doc/mailfromd.texi b/doc/mailfromd.texi
index 6206f67c..7f0cbbe2 100644
--- a/doc/mailfromd.texi
+++ b/doc/mailfromd.texi
@@ -7283,6 +7283,76 @@ the decision based on the cached data, or to @samp{0} otherwise.
@subsubsection National Language Support Functions
@UNREVISED{}
+ The @dfn{National Language Support} functions allow you to write
+your scripts in such a way, that any textual messages they display are
+automatically translated to your native language, or, more precisely,
+to the language required by your current locale.
+
+ This section assumes the reader is familiar with the concepts of program
+@dfn{internationalization} and @dfn{localization}. If not, please
+refer to @ref{Why, The Purpose of GNU @command{gettext}, The Purpose of GNU
+@command{gettext}, gettext, GNU gettext manual}, before continuing
+reading this section.
+
+@flindex nls.mf
+ In general, internationalization of any @acronym{MFL} script
+follows the same rules as described in the @cite{GNU gettext manual}.
+First of all, you select the program @dfn{message domain}, i.e. the
+identifier of a set of translatable messages your script contain.
+This identifier is then used to select the appropriate translation.
+The message domain is set using @code{textdomain} function. For the
+purposes of this section, let's suppose the domain name is
+@samp{myfilter}. All @acronym{NLS} functions are provided by
+@file{nls.mf} module, so you must require this module prior to using
+any of them.
+
+ To find translations of textual message to the current locale, the
+underlying @command{gettext} mechanism will look for file
+@file{@var{dirname}/@var{locale}/LC_MESSAGES/@var{domainname}.mo},
+where @var{dirname} is the message catalog hierarchy name,
+@var{locale} is the locale name, and @var{domainname} is the name of
+the message domain. By default @var{dirname} is
+@file{/usr/local/share/locale}, but you may change it using
+@code{bindtextdomain} function. The right place for this initial
+@acronym{NLS} setup is in the @samp{begin} block. To summarize all
+the above, the usual @acronym{NLS} setup will look like:
+
+@smallexample
+#require nls
+
+begin
+do
+ textdomain ("myfilter")
+ bindtextdomain ("myfilter", "/usr/share/locale");
+done
+@end smallexample
+
+ For example, given the settings above, and the environment variable
+@env{LC_ALL} set to @samp{pl}, translations will be looked in file
+@file{/usr/share/locale/pl/LC_MESSAGES/myfilter.mo}.
+
+ Once this preparatory work is done, you can request each message to
+be translated by using @code{gettext} function, or @code{_()} macro.
+For example, the following statement will produce translated textual
+description for @samp{450} response:
+
+@smallexample
+tempfail 450 4.1.0 _("Try again later")
+@end smallexample
+
+ Of course it assumes that the appropriate @file{myfile.mo} file
+already exists. If it does not, nothing bad happens: in this case the
+macro @command{_} (as well as @code{gettext} function) will simply
+return its argument unchanged, so that the remote party will get the
+textual message in English.
+
+ The @samp{mo} files are binary files created from @samp{po} source
+files using @command{msgfmt} utility, as described in @ref{Binaries,
+Producing Binary MO Files, Producing Binary MO Files, gettext, GNU
+gettext manual}. In turn, the format of @samp{po} files is described
+in @ref{PO Files, The Format of PO Files, The Format of PO Files,
+gettext, GNU gettext manual}.
+
@deftypefn {Built-in Function} string bindtextdomain (string @var{domain}, @
string @var{dirname})
This function sets the base directory of the hierarchy containing
@@ -7298,6 +7368,9 @@ If @var{domain} is @samp{""}, @code{bindtextdomain} returns the
previously set base directory for domain @var{domain}.
@end deftypefn
+ The rest of this section describes the @acronym{NLS} functions
+supplied by the @file{nls.mf} module.
+
@deftypefn {Built-in Function} string dgettext (string @var{domain}, @
string @var{msgid})
@code{dgettext} attempts to translate the string @var{msgid} into the

Return to:

Send suggestions and report system problems to the System administrator.