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
|
%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 / Hans Hagen \& Ton Otten}]
%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 A regular \CONTEXT\ stores some 1500 labels at most.
\let\handletextprefix\relax
\newconditional\protecttextprefixes
\let\currenttextprefixtag \s!unknown
\let\currenttextprefixclass\s!unknown
\def\setupheadtext {\setfalse\protecttextprefixes\let\currenttextprefixclass\??mh\dodoubleempty\dosetupsometextprefix}
\def\setuplabeltext{\setfalse\protecttextprefixes\let\currenttextprefixclass\??ml\dodoubleempty\dosetupsometextprefix}
\def\dosetupsometextprefix[#1][#2]%
{\ifsecondargument
\edef\currenttextprefixtag{\reallanguagetag{#1}}%
\processcommalist[#2]\dodosetupsometextprefix
\else
\edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
\processcommalist[#1]\dodosetupsometextprefix
\fi}
\def\dodosetupsometextprefix#1%
{\dododosetupsometextprefix[#1]}
\def\dododosetupsometextprefix[#1=#2]%
{\doassignsometextprefix{#1}[#2,,]}
\def\doassignsometextprefix#1%
{\ifconditional\protecttextprefixes
\ifcsname\currenttextprefixclass\currenttextprefixtag#1\endcsname
\expandafter\expandafter\expandafter\doassignsometextprefixnop
\else
\expandafter\expandafter\expandafter\doassignsometextprefixyes
\fi
\else
\expandafter\doassignsometextprefixyes
\fi{#1}}
\ifdefined\Word\else \let\Word\relax \fi
% Checking saves some 8K in the compressed format and getting rid of the embedded
% \handletextprefix was good for another 6K. In the end the new solution is not
% even that inefficient. And the checking is done at format generation time anyway.
\def\doassignsometextprefixyes#1[#2,#3,#4]%
{\edef\!!stringa{#2}%
\edef\!!stringb{#3}%
\ifx\!!stringb\empty
\ifx\!!stringa\empty
\expandafter\def\csname\currenttextprefixclass\currenttextprefixtag#1\endcsname{\empty\empty}%
\else
\expandafter\def\csname\currenttextprefixclass\currenttextprefixtag#1\endcsname{{#2}\empty}%
\fi
\else
\expandafter\def\csname\currenttextprefixclass\currenttextprefixtag#1\endcsname{{#2}{#3}}%
\fi}
\def\doassignsometextprefixnop#1[#2]%
{}
%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{\reallanguagetag{\defaultlanguage\currentmainlanguage}}
\def\headlanguage {\reallanguagetag{\defaultlanguage\currentmainlanguage}}
\appendtoks \let\labellanguage\currentlanguage \to \everycurrentdate
\def\dummytextprefix{\empty\empty}
\def\dogetupsomelabeltext{\dodogetupsomelabeltext\labellanguage} % second argument is textlabel
\def\dogetupsomeheadtext {\dodogetupsomeheadtext \headlanguage } % second argument is headlabel
\def\dodogetupsomelabeltext#1#2%
{\ifcsname\??ml#1#2\endcsname
\expandafter\let\expandafter\thetextprefix\csname\??ml#1#2\endcsname
\else\ifcsname\??la\labellanguage\s!default\endcsname
\expandafter\dodogetupsomelabeltext\csname\??la\labellanguage\s!default\endcsname{#2}%
\else\ifcsname\??ml#2\endcsname
\expandafter\let\expandafter\thetextprefix\csname\??ml#2\endcsname
\else\ifcsname\??ml\s!en#2\endcsname
\expandafter\let\expandafter\thetextprefix\csname\??ml\s!en#2\endcsname
\else
\let\thetextprefix\dummytextprefix
\fi\fi\fi\fi}
\def\dodogetupsomeheadtext#1#2%
{\ifcsname\??mh#1#2\endcsname
\expandafter\let\expandafter\thetextprefix\csname\??mh#1#2\endcsname
\else\ifcsname\??la\headlanguage\s!default\endcsname
\expandafter\dodogetupsomeheadtext\csname\??la\headlanguage\s!default\endcsname{#2}%
\else\ifcsname\??mh#2\endcsname
\expandafter\let\expandafter\thetextprefix\csname\??mh#2\endcsname
\else\ifcsname\??mh\s!en#2\endcsname
\expandafter\let\expandafter\thetextprefix\csname\??mh\s!en#2\endcsname
\else
\let\thetextprefix\dummytextprefix
\fi\fi\fi\fi}
% The WORD variants are a bit inefficient when #1/#2 are empty but they are
% seldom used (one can better set the style).
\let\flushleftlabeltext \firstoftwoarguments
\let\flushrightlabeltext\secondoftwoarguments
\def\flushleftlabelWORD #1#2{\WORD{#1}}
\def\flushrightlabelWORD#1#2{\WORD{#2}}
\def\flushbothlabeltexts#1#2#3{#1#3#2}
\def\flushbothlabelTEXTS#1#2#3{\WORD{#1}#3\WORD{#2}}
\unexpanded\def\headtext #1{\dogetupsomeheadtext {#1}\expandafter\flushleftlabeltext \thetextprefix}
\unexpanded\def\leftlabeltext #1{\dogetupsomelabeltext{#1}\expandafter\flushleftlabeltext \thetextprefix}
\unexpanded\def\rightlabeltext#1{\dogetupsomelabeltext{#1}\expandafter\flushrightlabeltext\thetextprefix}
\unexpanded\def\LEFTLABELTEXT #1{\dogetupsomelabeltext{#1}\expandafter\flushleftlabelWORD \thetextprefix}
\unexpanded\def\RIGHTLABELTEXT#1{\dogetupsomelabeltext{#1}\expandafter\flushrightlabelWORD\thetextprefix}
\unexpanded\def\labeltexts #1{\dogetupsomelabeltext{#1}\expandafter\flushbothlabeltexts\thetextprefix} % #2
\unexpanded\def\LABELTEXTS #1{\dogetupsomelabeltext{#1}\expandafter\flushbothlabelTEXTS\thetextprefix} % #2
\let\labeltext\leftlabeltext
\let\LABELTEXT\LEFTLABELTEXT
\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\presetheadtext {\settrue\protecttextprefixes\let\currenttextprefixclass\??mh\dodoubleempty\dosetupsometextprefix}
\def\presetlabeltext{\settrue\protecttextprefixes\let\currenttextprefixclass\??ml\dodoubleempty\dosetupsometextprefix}
%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
|