annotate man/lispref/internationalization.texi @ 177:6075d714658b r20-3b15

Import from CVS: tag r20-3b15
author cvs
date Mon, 13 Aug 2007 09:51:16 +0200
parents ac2d302a0011
children 70ad99077275
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 @c -*-texinfo-*-
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 @c This is part of the XEmacs Lisp Reference Manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 @c Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 @c See the file lispref.texi for copying conditions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 @setfilename ../../info/internationalization.info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 @node Internationalization, MULE, ToolTalk Support, top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 @chapter Internationalization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 * I18N Levels 1 and 2:: Support for different time, date, and currency formats.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 * I18N Level 3:: Support for localized messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 * I18N Level 4:: Support for Asian languages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 @node I18N Levels 1 and 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 @section I18N Levels 1 and 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 XEmacs is now compliant with I18N levels 1 and 2. Specifically, this means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 that it is 8-bit clean and correctly handles time and date functions. XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 will correctly display the entire ISO-Latin 1 character set.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 The compose key may now be used to create any character in the ISO-Latin 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 character set not directly available via the keyboard.. In order for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 compose key to work it is necessary to load the file @file{x-compose.el}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 At any time while composing a character, @code{C-h} will display all valid
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 completions and the character which would be produced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 @node I18N Level 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 @section I18N Level 3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 @menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 * Level 3 Basics::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 * Level 3 Primitives::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 * Dynamic Messaging::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 * Domain Specification::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 * Documentation String Extraction::
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 @end menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 @node Level 3 Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 @subsection Level 3 Basics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 XEmacs now provides alpha-level functionality for I18N Level 3. This means
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 that everything necessary for full messaging is available, but not every
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 file has been converted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 The two message files which have been created are @file{src/emacs.po} and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 @file{lisp/packages/mh-e.po}. Both files need to be converted using
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 @code{msgfmt}, and the resulting @file{.mo} files placed in some locale's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 @code{LC_MESSAGES} directory. The test ``translations'' in these files are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 the original messages prefixed by @code{TRNSLT_}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 The domain for a variable is stored on the variable's property list under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 the property name @var{variable-domain}. The function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 @code{documentation-property} uses this information when translating a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 variable's documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 @node Level 3 Primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 @subsection Level 3 Primitives
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 @defun gettext string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 This function looks up @var{string} in the default message domain and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 returns its translation. If @code{I18N3} was not enabled when XEmacs was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 compiled, it just returns @var{string}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 @defun dgettext domain string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 This function looks up @var{string} in the specified message domain and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 returns its translation. If @code{I18N3} was not enabled when XEmacs was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 compiled, it just returns @var{string}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 @defun bind-text-domain domain pathname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 This function associates a pathname with a message domain.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 Here's how the path to message file is constructed under SunOS 5.x:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 @code{@{pathname@}/@{LANG@}/LC_MESSAGES/@{domain@}.mo}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 If @code{I18N3} was not enabled when XEmacs was compiled, this function does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 nothing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 @defspec domain string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 This function specifies the text domain used for translating documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 strings and interactive prompts of a function. For example, write:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun foo (arg) "Doc string" (domain "emacs-foo") @dots{})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 to specify @code{emacs-foo} as the text domain of the function @code{foo}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 The ``call'' to @code{domain} is actually a declaration rather than a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 function; when actually called, @code{domain} just returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 @end defspec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 @defun domain-of function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 This function returns the text domain of @var{function}; it returns
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 @code{nil} if it is the default domain. If @code{I18N3} was not enabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 when XEmacs was compiled, it always returns @code{nil}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 @node Dynamic Messaging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 @subsection Dynamic Messaging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 The @code{format} function has been extended to permit you to change the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 order of parameter insertion. For example, the conversion format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 @code{%1$s} inserts parameter one as a string, while @code{%2$s} inserts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 parameter two. This is useful when creating translations which require you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 to change the word order.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 @node Domain Specification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 @subsection Domain Specification
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 The default message domain of XEmacs is `emacs'. For add-on packages, it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 best to use a different domain. For example, let us say we want to convert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 the ``gorilla'' package to use the domain `emacs-gorilla'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 To translate the message ``What gorilla?'', use @code{dgettext} as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (dgettext "emacs-gorilla" "What gorilla?")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 A function (or macro) which has a documentation string or an interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 prompt needs to be associated with the domain in order for the documentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 or prompt to be translated. This is done with the @code{domain} special
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 form as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 @page
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defun scratch (location)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "Scratch the specified location."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (domain "emacs-gorilla")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (interactive "sScratch: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 @dots{} )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
143 It is most efficient to specify the domain in the first line of the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 function body, before the @code{interactive} form.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 For variables and constants which have documentation strings, specify the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 domain after the documentation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 @defspec defvar symbol [value [doc-string [domain]]]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 Example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defvar weight 250 "Weight of gorilla, in pounds." "emacs-gorilla")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 @end defspec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 @defspec defconst symbol [value [doc-string [domain]]]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 Example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defconst limbs 4 "Number of limbs" "emacs-gorilla")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 @end defspec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 Autoloaded functions which are specified in @file{loaddefs.el} do not need
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 to have a domain specification, because their documentation strings are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 extracted into the main message base. However, for autoloaded functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 which are specified in a separate package, use following syntax:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 @defun autoload symbol filename &optional docstring interactive macro domain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 Example:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 @example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (autoload 'explore "jungle" "Explore the jungle." nil nil "emacs-gorilla")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 @end example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 @end defun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 @node Documentation String Extraction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 @subsection Documentation String Extraction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 The utility @file{etc/make-po} scans the file @code{DOC} to extract
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 documentation strings and creates a message file @code{doc.po}. This file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 may then be inserted within @code{emacs.po}.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 Currently, @code{make-po} is hard-coded to read from @code{DOC} and write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 to @code{doc.po}. In order to extract documentation strings from an add-on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 package, first run @code{make-docfile} on the package to produce the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 @code{DOC} file. Then run @code{make-po -p} with the @code{-p} argument to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 indicate that we are extracting documentation for an add-on package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (The @code{-p} argument is a kludge to make up for a subtle difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 between pre-loaded documentation and add-on documentation: For add-on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 packages, the final carriage returns in the strings produced by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 @code{make-docfile} must be ignored.)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 @node I18N Level 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 @section I18N Level 4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 The Asian-language support in XEmacs is called ``MULE''. @xref{MULE}.