From e258acb7419001ee0fb03d33d3d2c755dc0bd5af Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 8 Jun 2007 13:39:22 +0000 Subject: Update git-svn-id: file:///svnroot/mailfromd/trunk@1489 7a8a7f39-df28-0410-adc6-e0d955640f24 --- ChangeLog | 5 ++++ doc/mailfromd.texi | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ elisp/mfl-mode.el | 8 ++---- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 501ffd7f..e049d381 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-06-08 Sergey Poznyakoff + + * doc/mailfromd.texi (NLS Functions): Update + * elisp/mfl-mode.el (mfl-mode-syntax-table): Update + 2007-06-01 Sergey Poznyakoff * src/lex.l: Fix line counting within here-documents 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 diff --git a/elisp/mfl-mode.el b/elisp/mfl-mode.el index e9488001..b9f5af43 100644 --- a/elisp/mfl-mode.el +++ b/elisp/mfl-mode.el @@ -44,13 +44,9 @@ (unless mfl-mode-syntax-table (setq mfl-mode-syntax-table (make-syntax-table)) -; (modify-syntax-entry ?\# "<" mfl-mode-syntax-table) -; (modify-syntax-entry ?\n ">" mfl-mode-syntax-table) (modify-syntax-entry ?\t "-" mfl-mode-syntax-table) - (modify-syntax-entry ?\( "(" mfl-mode-syntax-table) - (modify-syntax-entry ?\) ")" mfl-mode-syntax-table) -; (modify-syntax-entry ?\` "(" mfl-mode-syntax-table) -; (modify-syntax-entry ?\' ")\"" mfl-mode-syntax-table) + (modify-syntax-entry ?\( "()" mfl-mode-syntax-table) + (modify-syntax-entry ?\) ")(" mfl-mode-syntax-table) (modify-syntax-entry ?\' "\"" mfl-mode-syntax-table) (modify-syntax-entry ?\" "\"" mfl-mode-syntax-table) (modify-syntax-entry ?\\ "\\" mfl-mode-syntax-table) -- cgit v1.2.1