From 811f39e76b4b618b31389076936986f6606dfd0d Mon Sep 17 00:00:00 2001 From: rtoy <rtoy> Date: Wed, 21 Apr 2010 02:31:16 +0000 Subject: [PATCH] Update localization chapter with new functions. Change example to show how to use the new functions to enable recording of translatable strings. --- docs/cmu-user/extensions.tex | 56 ++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/docs/cmu-user/extensions.tex b/docs/cmu-user/extensions.tex index f418a03fb..1b57ec2d3 100644 --- a/docs/cmu-user/extensions.tex +++ b/docs/cmu-user/extensions.tex @@ -2887,19 +2887,21 @@ ends at the end of each line. \subsection{Example Usage} \label{sec:localization-usage} -Here is a simple example of how to localize your code. This assumes -that you've installed the reader macros via \code{intl::install}. +Here is a simple example of how to localize your code. Let the file +\code{intl-ex.lisp} contain: \begin{example} (intl:textdomain "example") (defun foo (x y) - _N"Cool function foo of x and y" + "Cool function foo of x and y" (let ((result (bar x y))) + ;; TRANSLATORS: One line comment about bar. (format t _"bar of ~A and ~A = ~A~%" x y result) - ;; TRANSLATORS: Do the right thing here. - ;; TRANSLATORS: Whatever that might be. + #| TRANSLATORS: Multiline comment about + how many Xs there are + |# (format t (intl:ngettext "There is one X" "There are many Xs" x)) @@ -2909,19 +2911,33 @@ that you've installed the reader macros via \code{intl::install}. The call to \code{textdomain} sets the default domain for all translatable strings following the call. -When this file is compiled, all of the translatable strings are -recorded. This includes the docstring for \code{foo}, the string for -the first \code{format}, and the string marked by the call to -\code{intl:ngettext}. +Here is a sample session for creating a template file: -After all of the files have been compiled, we can dump the recorded -strings. In this case, \begin{example} -* (intl::dump-pot-files :output-directory "dir/") +* (intl:install) + +T +* (intl:translation-enable) + +T +* (compile-file "intl-ex") + +#P"/Volumes/share/cmucl/cvs/intl-ex.sse2f" +NIL +NIL +* (intl::dump-pot-files :output-directory "./") + Dumping 3 messages for domain "example" NIL +* \end{example} -will create a file named ``example.pot'' in the directory ``dir/''. + +When this file is compiled, all of the translatable strings are +recorded. This includes the docstring for \code{foo}, the string for +the first \code{format}, and the string marked by the call to +\code{intl:ngettext}. + +A file named ``example.pot'' in the directory ``./'' is created. The contents of this file are: \begin{example} #@ example @@ -2941,16 +2957,18 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8" "Content-Transfer-Encoding: 8bit" -#: /tmp/foo.lisp -msgid "Cool function foo of x and y" +#. One line comment about bar. +#: intl-ex.lisp +msgid "bar of ~A and ~A = ~A~%" msgstr "" -#. Whatever that might be. -#: /tmp/foo.lisp -msgid "bar of ~A and ~A = ~A~%" +#. Multiline comment about + how many Xs there are +#: intl-ex.lisp +msgid "Cool function foo of x and y" msgstr "" -#: /tmp/foo.lisp +#: intl-ex.lisp msgid "There is one X" msgid_plural "There are many Xs" msgstr[0] "" -- GitLab