CMUCL commit: src/docs/cmu-user (extensions.tex)
Raymond Toy
rtoy at common-lisp.net
Wed Apr 21 04:31:16 CEST 2010
Date: Tuesday, April 20, 2010 @ 22:31:16
Author: rtoy
Path: /project/cmucl/cvsroot/src/docs/cmu-user
Modified: extensions.tex
Update localization chapter with new functions. Change example to
show how to use the new functions to enable recording of translatable
strings.
----------------+
extensions.tex | 56 ++++++++++++++++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 19 deletions(-)
Index: src/docs/cmu-user/extensions.tex
diff -u src/docs/cmu-user/extensions.tex:1.44 src/docs/cmu-user/extensions.tex:1.45
--- src/docs/cmu-user/extensions.tex:1.44 Sun Apr 18 13:24:29 2010
+++ src/docs/cmu-user/extensions.tex Tue Apr 20 22:31:16 2010
@@ -2887,19 +2887,21 @@
\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 @@
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 @@
"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] ""
More information about the cmucl-commit
mailing list