1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
|
%D \module
%D [ file=lang-lab,
%D version=1997.08.27,
%D title=\CONTEXT\ Language Macros,
%D subtitle=Labels,
%D author=Hans Hagen / Tobias Burnus,
%D date=\currentdate,
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\unprotect
%D In this module we deal with language dependant labels and
%D prefixes, like in {\em Figure~12} and {\em Chapter 1}. In
%D this file we set the default values. Users can easily
%D overrule these.
%D
%D This module is dedicated to the grandfather of Tobias
%D Burnus, who's extensive languages oriented library helped us
%D a lot in finding the right translations. All those labels
%D are collected in files that reflect their common ancestor.
%D
%D Not all languages can be satisfied with the labeling
%D mechanism as provided here. Chinese for instance put a label
%D in front as well as after a part number. This is why the
%D current implementation of labels supports two labels too.
%D \macros
%D {setupheadtext, setuplabeltext}
%D
%D First we present some macros that deal with what we will
%D call head and label texts. Such texts are defines by:
%D
%D \showsetup{setupheadtext}
%D \showsetup{setuplabeltext}
%D
%D In a few paragraphs we'll show quite a lot of examples
%D of its use.
\let\handletextprefix\relax
\def\setupheadtext {\dosetupsometextprefix[\c!title]}
\def\setuplabeltext{\dosetupsometextprefix[\c!label]}
\def\dosetupsometextprefix
{\let\dodocommand\xdosetupsometextprefix
\dotripleempty\dodosetupsometextprefix}
% \def\dodosetupsometextprefix[#1][#2][#3]%
% {\ifthirdargument
% \def\docommand##1{\dodocommand[#1#2][##1]}%
% \processcommalist[#3]\docommand
% \else
% \def\docommand##1{\dodocommand[#1\currentmainlanguage][##1]}%
% \processcommalist[#2]\docommand
% \fi}
\def\dodosetupsometextprefix[#1][#2][#3]%
{\ifthirdargument
\def\docommand##1{\expanded{\dodocommand[#1\reallanguagetag{#2}]}[##1]}%
\processcommalist[#3]\docommand
\else
\def\docommand##1{\expanded{\dodocommand[#1\reallanguagetag\currentmainlanguage]}[##1]}%
\processcommalist[#2]\docommand
\fi}
\def\doassignsometextprefix[#1][#2,#3,#4]%
{\setvalue{#1}{\handletextprefix{#2}{#3}}}
\def\xdosetupsometextprefix[#1][#2=#3]%
{\doassignsometextprefix[#1#2][#3,,]}
%D By changing the meaning of \type {\handletextprefix} we
%D can filter the left and right labeltext as well as convert
%D labels to uppercase.
%D
%D These commands accept all kind of inputs:
%D
%D \starttyping
%D \setuplabeltext [language] [labellabel=text]
%D \setuplabeltext [language] [labellabel=text,labellabel=text,...]
%D \setuplabeltext [labellabel=text]
%D \setuplabeltext [labellabel=text,labellabel=text,...]
%D \stoptyping
%D
%D The last two cases concern the current language.
%D \macros
%D {headtext,
%D labeltext, leftlabeltext, rightlabeltext, labeltexts,
%D LABELTEXT, LEFTLABELTEXT, RIGHTLABELTEXT, LABELTEXTS}
%D
%D Once defined, head and label texts can be called upon using:
%D
%D \showsetup{headtext}
%D \showsetup{labeltext}
%D
%D The latter one has an upcased alternative \type{\LABELTEXT}.
% \def\labellanguage{\currentmainlanguage}
% \def\headlanguage {\currentmainlanguage}
% \def\labellanguage{\defaultlanguage\currentmainlanguage}
% \def\headlanguage {\defaultlanguage\currentmainlanguage}
\def\labellanguage{\reallanguagetag{\defaultlanguage\currentmainlanguage}}
\def\headlanguage {\reallanguagetag{\defaultlanguage\currentmainlanguage}}
\appendtoks \let\labellanguage\currentlanguage \to \everycurrentdate
\unexpanded\def\headtext
{\let\handletextprefix\firstoftwoarguments
\let\reporttextprefixerror\doreporttextprefixerror
\global\labeltextdonetrue
\dogetupsometextprefix\headlanguage\c!title}
\unexpanded\def\leftlabeltext
{\let\handletextprefix\firstoftwoarguments
\let\reporttextprefixerror\doreporttextprefixerror
\global\labeltextdonetrue
\dogetupsometextprefix\labellanguage\c!label}
\unexpanded\def\rightlabeltext
{\let\handletextprefix\secondoftwoarguments
\let\reporttextprefixerror\doreporttextprefixerror
\global\labeltextdonetrue
\dogetupsometextprefix\labellanguage\c!label}
\unexpanded\def\LEFTLABELTEXT
{\def\handletextprefix##1##2{\uppercase{##1}}\DOLABELTEXT}
\unexpanded\def\RIGHTLABELTEXT
{\def\handletextprefix##1##2{\uppercase{##2}}\DOLABELTEXT}
\def\DOLABELTEXT#1%
{\bgroup
\the\everyuppercase
\let\reporttextprefixerror\doreporttextprefixerror
\global\labeltextdonetrue
\dogetupsometextprefix\labellanguage\c!label{#1}% not \labeltext (see \MONTH)
\egroup}
\let\labeltext \leftlabeltext
\let\LABELTEXT \LEFTLABELTEXT
\unexpanded\def\labeltexts#1#2{\leftlabeltext{#1}#2\rightlabeltext{#1}}
\unexpanded\def\LABELTEXTS#1#2{\LEFTLABELTEXT{#1}#2\RIGHTLABELTEXT{#1}}
\newif\iflabeltextdone % needs to be reset elsewhere
\newif\iftracelabels % shows missing labels
\def\doreporttextprefixerror#1#2#3%
{\iftracelabels{\tttf[#2:~#3/#1]~}\fi}
\def\dosetexpandedheadlabeltext#1#2#3%
{\bgroup
\let\handletextprefix\firstoftwoarguments
\let\reporttextprefixerror\gobblethreearguments
\keepencodedtokens % test on multilingual pascal, ok in stretched
%\dontexpandencodedtokens % not usable in token handler
\expanded
{\egroup\noexpand\def\noexpand#2% watch out, no \edef
{\dogetupsometextprefix{\headlanguage}{#1}{#3}}}}
\def\setexpandedheadtext {\dosetexpandedheadlabeltext\c!title}
\def\setexpandedlabeltext{\dosetexpandedheadlabeltext\c!label}
% \def\dogetupsometextprefix#1#2#3%
% {\ifcsname#2#1#3\endcsname
% \csname#2#1#3\endcsname \else
% \ifcsname#2#3\endcsname
% \csname#2#3\endcsname \else
% \ifcsname#2\defaultlanguage#1#3\endcsname
% \csname#2\defaultlanguage#1#3\endcsname \else
% \ifcsname#2\s!en#3\endcsname
% \csname#2\s!en#3\endcsname \else
% \ifcsname#2\s!nl#3\endcsname
% \csname#2\s!nl#3\endcsname \else
% \reporttextprefixerror{#1}{#2}{#3}%
% \fi\fi\fi\fi\fi}
%
% \def\dogetupsometextprefix#1#2#3% must be expandable !
% {\ifcsname#2#1#3\endcsname
% \csname#2#1#3\endcsname
% \else\@EA\ifx\csname\??la#1\c!default\endcsname\empty
% \ifcsname#2#3\endcsname
% \csname#2#3\endcsname
% \else\ifcsname#2\s!en#3\endcsname
% \csname#2\s!en#3\endcsname
% \else
% \reporttextprefixerror{#1}{#2}{#3}%
% \fi\fi
% \else
% \dogetupsometextprefix{\csname\??la#1\c!default\endcsname}{#2}{#3}%
% \fi\fi}
\def\dogetupsometextprefix#1#2#3% must be expandable ! #1 == language
{\ifcsname#2#1#3\endcsname
\csname#2#1#3\endcsname
\else\ifcsname\??la#1\s!default\endcsname
\expandafter\dogetupsometextprefix\csname\??la#1\s!default\endcsname{#2}{#3}%
\else\ifcsname#2#3\endcsname
\csname#2#3\endcsname
\else\ifcsname#1\s!en#3\endcsname
\csname#2\s!en#3\endcsname
\else
\reporttextprefixerror{#1}{#2}{#3}%
\fi\fi\fi\fi}
\ifx\simplifiedcommands\undefined \newtoks\simplifiedcommands \fi
\appendtoks
\let \headtext \firstofoneargument
\let \labeltext \firstofoneargument
\let \leftlabeltext \firstofoneargument
\let \rightlabeltext \firstofoneargument
\let \HEADTEXT \firstofoneargument
\let \LABELTEXT \firstofoneargument
\let \LEFTLABELTEXT \firstofoneargument
\let \RIGHTLABELTEXT \firstofoneargument
\to \simplifiedcommands
%D \macros
%D {presetheadtext,presetlabeltext}
%D
%D The next two macros enable us to automatically define
%D head and label texts without replacing predefined ones.
%D These are internal macros.
\def\xdopresetsometextprefix[#1][#2=#3]%
{\ifundefined{#1#2}\doassignsometextprefix[#1\reallanguagetag{#2}][#3,,]\fi}
\def\dopresetsometextprefix
{\let\dodocommand\xdopresetsometextprefix
\dotripleempty\dodosetupsometextprefix}
\def\presetheadtext {\dopresetsometextprefix[\c!title]}
\def\presetlabeltext{\dopresetsometextprefix[\c!label]}
%D \macros
%D {translate}
%D
%D Sometismes macros contain language specific words that are to
%D be typeset. Such macros can be made (more) language
%D independant by using:
%D
%D \showsetup{translate}
%D
%D like for instance:
%D
%D \starttyping
%D \translate[en=something,nl=iets]
%D \stoptyping
%D
%D which expands to {\em something} or {\em iets}, depending on
%D de current language.
\def\dotranslate[#1]%
{\getparameters[\??lg][#1]%
\ifcsname\??lg\currentlanguage\endcsname
\csname\??lg\currentlanguage\endcsname
\else\ifcsname\??lg\s!en\endcsname
\csname\??lg\s!en\endcsname
\else
[translation #1]%
\fi\fi}
\unexpanded\def\translate
{\dosingleempty\dotranslate}
%D When used without argument, the last defined values are
%D used. This enables repetitive use like
%D
%D \starttyping
%D \en \translate\ means \nl \translate
%D \stoptyping
%D \macros
%D {assigntranslation}
%D
%D This macro is a system macro, and can be used to assign a
%D translation to a macro. Its form is:
%D
%D \starttyping
%D \assigntranslation[en=something,nl=iets]\to\command
%D \stoptyping
\def\assigntranslation[#1]\to#2%
{\getparameters[\??lg][#1]%
\edef#2{\csname\??lg\currentlanguage\endcsname}}
\protect \endinput
|