2 @c This is part of the SXEmacs Lisp Reference Manual.
3 @c Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
4 @c Copyright (C) 2005 Sebastian Freundt <hroptatyr@sxemacs.org>
5 @c See the file lispref.texi for copying conditions.
6 @setfilename ../../info/internationalization.info
8 @node Internationalization, Foreign Functions, Enhanced Number Types, Top
9 @chapter Internationalization
12 * I18N Levels 1 and 2:: Support for different time, date, and currency formats.
13 * I18N Level 3:: Support for localized messages.
14 * I18N Level 4:: Support for Asian languages.
18 @node I18N Levels 1 and 2, I18N Level 3, Internationalization, Internationalization
19 @section I18N Levels 1 and 2
21 SXEmacs is now compliant with I18N levels 1 and 2. Specifically, this means
22 that it is 8-bit clean and correctly handles time and date functions. SXEmacs
23 will correctly display the entire ISO-Latin 1 character set.
25 The compose key may now be used to create any character in the ISO-Latin 1
26 character set not directly available via the keyboard.. In order for the
27 compose key to work it is necessary to load the file @file{x-compose.el}.
28 At any time while composing a character, @code{C-h} will display all valid
29 completions and the character which would be produced.
37 * Level 3 Primitives::
39 * Domain Specification::
40 * Documentation String Extraction::
45 @subsection Level 3 Basics
47 SXEmacs now provides alpha-level functionality for I18N Level 3. This means
48 that everything necessary for full messaging is available, but not every
49 file has been converted.
51 @c wtf is this about here?
52 The two message files which have been created are @file{src/emacs.po} and
53 @file{lisp/packages/mh-e.po}. Both files need to be converted using
54 @code{msgfmt}, and the resulting @file{.mo} files placed in some locale's
55 @code{LC_MESSAGES} directory. The test ``translations'' in these files are
56 the original messages prefixed by @code{TRNSLT_}.
58 The domain for a variable is stored on the variable's property list under
59 the property name @var{variable-domain}. The function
60 @code{documentation-property} uses this information when translating a
61 variable's documentation.
64 @node Level 3 Primitives
65 @subsection Level 3 Primitives
68 This function looks up @var{string} in the default message domain and
69 returns its translation. If @code{I18N3} was not enabled when XEmacs was
70 compiled, it just returns @var{string}.
73 @defun dgettext domain string
74 This function looks up @var{string} in the specified message domain and
75 returns its translation. If @code{I18N3} was not enabled when SXEmacs was
76 compiled, it just returns @var{string}.
79 @defun bind-text-domain domain pathname
80 This function associates a pathname with a message domain.
81 Here's how the path to message file is constructed under SunOS 5.x:
84 @code{@{pathname@}/@{LANG@}/LC_MESSAGES/@{domain@}.mo}
87 If @code{I18N3} was not enabled when SXEmacs was compiled, this function does
91 @defspec domain string
92 This function specifies the text domain used for translating documentation
93 strings and interactive prompts of a function. For example, write:
96 (defun foo (arg) "Doc string" (domain "emacs-foo") @dots{})
99 to specify @code{emacs-foo} as the text domain of the function @code{foo}.
100 The ``call'' to @code{domain} is actually a declaration rather than a
101 function; when actually called, @code{domain} just returns @code{nil}.
104 @defun domain-of function
105 This function returns the text domain of @var{function}; it returns
106 @code{nil} if it is the default domain. If @code{I18N3} was not enabled
107 when SXEmacs was compiled, it always returns @code{nil}.
108 @c hm, even worse: It does not exist here!
112 @node Dynamic Messaging
113 @subsection Dynamic Messaging
115 The @code{format} function has been extended to permit you to change the
116 order of parameter insertion. For example, the conversion format
117 @code{%1$s} inserts parameter one as a string, while @code{%2$s} inserts
118 parameter two. This is useful when creating translations which require you
119 to change the word order.
122 @node Domain Specification
123 @subsection Domain Specification
125 The default message domain of SXEmacs is `emacs'. For add-on packages, it is
126 best to use a different domain. For example, let us say we want to convert
127 the ``gorilla'' package to use the domain `emacs-gorilla'.
128 To translate the message ``What gorilla?'', use @code{dgettext} as follows:
131 (dgettext "emacs-gorilla" "What gorilla?")
134 A function (or macro) which has a documentation string or an interactive
135 prompt needs to be associated with the domain in order for the documentation
136 or prompt to be translated. This is done with the @code{domain} special
141 (defun scratch (location)
142 "Scratch the specified location."
143 (domain "emacs-gorilla")
144 (interactive "sScratch: ")
148 It is most efficient to specify the domain in the first line of the
149 function body, before the @code{interactive} form.
151 For variables and constants which have documentation strings, specify the
152 domain after the documentation.
154 @defspec defvar symbol [value [doc-string [domain]]]
157 (defvar weight 250 "Weight of gorilla, in pounds." "emacs-gorilla")
161 @defspec defconst symbol [value [doc-string [domain]]]
164 (defconst limbs 4 "Number of limbs" "emacs-gorilla")
168 @defun autoload function filename &optional docstring interactive type
169 This function defines @var{function} to autoload from @var{filename}
172 (autoload 'explore "jungle" "Explore the jungle." nil nil "emacs-gorilla")
177 @node Documentation String Extraction
178 @subsection Documentation String Extraction
180 The utility @file{etc/make-po} scans the file @code{DOC} to extract
181 documentation strings and creates a message file @code{doc.po}. This file
182 may then be inserted within @code{emacs.po}.
184 Currently, @code{make-po} is hard-coded to read from @code{DOC} and write
185 to @code{doc.po}. In order to extract documentation strings from an add-on
186 package, first run @code{make-docfile} on the package to produce the
187 @code{DOC} file. Then run @code{make-po -p} with the @code{-p} argument to
188 indicate that we are extracting documentation for an add-on package.
190 (The @code{-p} argument is a kludge to make up for a subtle difference
191 between pre-loaded documentation and add-on documentation: For add-on
192 packages, the final carriage returns in the strings produced by
193 @code{make-docfile} must be ignored.)
195 @node I18N Level 4, , I18N Level 3, Internationalization
196 @section I18N Level 4
198 The Asian-language support in XEmacs is called ``MULE''. @xref{MULE}.