lang-ini.mkxl /size: 28 Kb    last modification: 2021-10-28 13:51
1
%D \module
2
%D [ file=lang-ini,
3
%D version=1996.01.25,
4
%D title=\CONTEXT\ Language Macros,
5
%D subtitle=Initialization,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
% \cldcontext{languages.numbers[tex.count.mainlanguagenumber]}
15 16
%D This module implements multi||language support of \CONTEXT, which should not be
17
%D confused with the multi||lingual interface. This support will be extended when
18
%D needed. Properties of languages are defined in \TEX\ files as well as \LUA\
19
%D files.
20 21
\writestatus
{
loading
}
{
ConTeXt
Language
Macros
/
Initialization
}
22 23
\registerctxluafile
{
lang
-
ini
}
{
autosuffix
}
24
\registerctxluafile
{
lang
-
def
}
{
}
25
\registerctxluafile
{
lang
-
cnt
}
{
}
26 27
\unprotect
28 29
\ifdefined
\nonfrenchspacing
\else
\let
\nonfrenchspacing
\relax
\fi
30
\ifdefined
\frenchspacing
\else
\let
\frenchspacing
\relax
\fi
31 32
%D When loading hyphenation patterns, \TEX\ assign a number to each loaded table,
33
%D starting with~0. Switching to a specific table is done by assigning the relevant
34
%D number to the predefined \COUNTER\ \type {\language}. However, in \MKIV\ a lot
35
%D of management is delegated to \LUA.
36 37
%D We keep track of the last loaded patterns by means of a pseudo \COUNTER. This
38
%D just one of those situations in which we don't want to spent a real one. Language
39
%D zero has no patterns, first of all because I like to start numbering at one. It
40
%D may come in handy for special purposes as well.
41 42
\normallanguage
\zerocount
43 44
%D \macros
45
%D {currentlanguage, setupcurrentlanguage}
46
%D
47
%D Instead of numbers,we are going to use symbolic names for the languages. The
48
%D current langage is saved in the macro \type {\currentlanguage}. The setup macro
49
%D is mainly used for cosmetic purposes.
50
%D
51
%D \starttyping
52
%D \dorecurse{3}
53
%D {\language[nl]
54
%D \startmode[*en] english \stopmode
55
%D \startmode[*nl] dutch \stopmode
56
%D \language[en]
57
%D \startmode[*en] english \stopmode
58
%D \startmode[*nl] dutch \stopmode}
59
%D \stoptyping
60 61
\mutable
\let
\askedlanguage
\empty
62
\mutable
\let
\currentlanguage
\empty
63
\mutable
\let
\currentmainlanguage
\empty
64 65
%D \macros
66
%D {defaultlanguage,languageparameter,specificlanguageparameter}
67
%D
68
%D We don't use the commandhandler here (yet) because we have a rather special
69
%D fallback mechanism so quite some compatibility testing is needed.
70 71
\installcorenamespace
{
language
}
72
\installcorenamespace
{
languagelinked
}
73 74
\mutable
\def
\currentusedlanguage
{
\currentlanguage
}
75 76
\permanent
\def
\defaultlanguage
#
1
%
77
{
\ifcsname
\??language
#
1
\s!default
\endcsname
78
\expandafter
\defaultlanguage
\lastnamedcs
79
\else
80
#
1
%
81
\fi
}
82 83
\permanent
\def
\languageparameter
#
1
%
84
{
\ifcsname
\??language
\currentlanguage
#
1
\endcsname
85
\lastnamedcs
86
\orelse
\ifcsname
\??language
\currentlanguage
\s!default
\endcsname
87
\expandafter
\specificlanguageparameter
\lastnamedcs
{
#
1
}
%
88
\orelse
\ifcsname
\??language
\s!default
#
1
\endcsname
89
\lastnamedcs
90
\fi
}
91 92
\permanent
\def
\specificlanguageparameter
#
1
#
2
%
93
{
\ifcsname
\??language
#
1
#
2
\endcsname
94
\lastnamedcs
95
\orelse
\ifcsname
\??language
#
1
\s!default
\endcsname
96
\expandafter
\specificlanguageparameter
\lastnamedcs
{
#
2
}
%
97
\orelse
\ifcsname
\??language
\s!default
#
2
\endcsname
98
\lastnamedcs
99
\fi
}
100 101
\permanent
\def
\mainlanguageparameter
#
1
%
102
{
\ifcsname
\??language
\currentmainlanguage
#
1
\endcsname
103
\lastnamedcs
104
\orelse
\ifcsname
\??language
\currentmainlanguage
\s!default
\endcsname
105
\expandafter
\specificlanguageparameter
\lastnamedcs
{
#
1
}
%
106
\orelse
\ifcsname
\??language
\s!default
#
1
\endcsname
107
\lastnamedcs
108
\fi
}
109 110
\aliased
\let
\usedlanguageparameter
\languageparameter
111 112
\permanent
\def
\askedlanguageparameter
#
1
% assumes \currentusedlanguage being set
113
{
\ifcsname
\??language
\currentusedlanguage
#
1
\endcsname
114
\lastnamedcs
115
\orelse
\ifcsname
\??language
\currentusedlanguage
\s!default
\endcsname
116
\expandafter
\specificlanguageparameter
\lastnamedcs
{
#
1
}
%
117
\orelse
\ifcsname
\??language
\s!default
#
1
\endcsname
118
\lastnamedcs
119
\fi
}
120 121
\permanent
\protected
\def
\setusedlanguage
#
1
%
122
{
\edef
\currentusedlanguage
{
\reallanguagetag
{
#
1
}
}
%
123
\ifempty
\currentusedlanguage
124
\let
\currentusedlanguage
\currentlanguage
125
\enforced
\let
\usedlanguageparameter
\languageparameter
126
\orelse
\ifx
\currentusedlanguage
\v!global
127
\let
\currentusedlanguage
\currentmainlanguage
128
\enforced
\let
\usedlanguageparameter
\mainlanguageparameter
129
\orelse
\ifx
\currentusedlanguage
\v!local
130
\let
\currentusedlanguage
\currentlanguage
131
\enforced
\let
\usedlanguageparameter
\languageparameter
132
\else
133
\enforced
\let
\usedlanguageparameter
\askedlanguageparameter
134
\fi
}
135 136
\permanent
\protected
\def
\setupcurrentlanguage
[
#
1
]
%
137
{
\setcurrentlanguage
\currentmainlanguage
{
#
1
}
}
138 139
\permanent
\protected
\def
\setcurrentlanguage
#
1
#
2
% sets modes: **id (currentmain) *id (current)
140
{
\edef
\p_askedlanguage
{
#
1
}
% otherwise clash with \askedlanguage
141
\ifempty
\p_askedlanguage
\else
142
\ifempty
\currentmainlanguage
\else
\resetsystemmode
{
\systemmodeprefix
\currentmainlanguage
}
\fi
143
\let
\currentmainlanguage
\p_askedlanguage
144
\setsystemmode
{
\systemmodeprefix
\currentmainlanguage
}
%
145
\fi
146
\edef
\p_askedlanguage
{
#
2
}
%
147
\ifempty
\p_askedlanguage
\else
148
\ifempty
\currentlanguage
\else
\resetsystemmode
\currentlanguage
\fi
149
\let
\currentlanguage
\p_askedlanguage
150
\setsystemmode
\currentlanguage
151
\fi
}
152 153
%D The internal macros will be defined later.
154 155
%D \macros
156
%D {installlanguage}
157
%D
158
%D Hyphenation patterns can only be loaded when the format file is prepared. The
159
%D next macro takes care of this loading. A language is specified with
160
%D
161
%D \showsetup{installlanguage}
162
%D
163
%D When \type {state} equals \type {start}, both patterns and additional hyphenation
164
%D specifications are loaded. These files are seached for in the patterns path
165
%D have names like \type {lang-nl.lua}.
166
%D
167
%D The \type {spacing} variable specifies how the spaces after punctuation has to be
168
%D handled. English is by tradition more tolerant to inter||sentence spacing than
169
%D other languages.
170
%D
171
%D This macro also defines \type {\identifier} as a shortcut switch to the language.
172
%D Furthermore the command defined as being language specific, are executed. With
173
%D \type {default} we can default to another language (patterns) at format
174
%D generation time. Patterns are loaded at runtime.
175 176
\newtoks
\everysetuplanguage
177 178
\aliased
\let
\installedlanguages
\clf_installedlanguages
% no need for \clf_
179 180
\permanent
\protected
\def
\doifelselanguage
#
1
%
181
{
\ifcsname
\??language
#
1
\c!state
\endcsname
182
\expandafter
\firstoftwoarguments
183
\else
184
\expandafter
\secondoftwoarguments
185
\fi
}
186 187
\aliased
\let
\doiflanguageelse
\doifelselanguage
188 189
\permanent
\def
\reallanguagetag
#
1
%
190
{
\ifcsname
\??languagelinked
#
1
\endcsname
\lastnamedcs
\else
#
1
\fi
}
191 192
% \language[#1] gave unwanted side effect of loading language specifics
193 194
\mutable
\let
\currentsetuplanguage
\empty
195 196
\permanent
\tolerant
\protected
\def
\installlanguage
[
#
1
]
#
*
[
#
2
]
%
197
{
\ifcondition
\validassignment
{
#
2
}
%
198
\doifelselanguage
{
#
1
}
199
{
\getparameters
[
\??language
#
1
]
[
#
2
]
}
200
{
\defcsname
\??languagelinked
#
1
\endcsname
{
#
1
}
%
201
\getparameters
[
\??language
#
1
]
[
\c!state
=
\v!start
,
#
2
]
%
202
\lang_basics_install_indeed
{
#
1
}
{
#
1
}
}
%
203
\edef
\currentsetuplanguage
{
#
1
}
%
204
\clf_definelanguage
{
#
1
}
{
\specificlanguageparameter
{
#
1
}
\s!default
}
%
205
\the
\everysetuplanguage
206
\else
207
\defcsname
\??languagelinked
#
1
\endcsname
{
#
2
}
%
208
\clf_setlanguagesynonym
{
#
1
}
{
#
2
}
%
209
\lang_basics_install_indeed
{
#
1
}
{
#
2
}
%
210
\fi
}
211 212
\def
\lang_basics_install_indeed
#
1
#
2
%
213
{
\ifcstok
{
\specificlanguageparameter
{
#
1
}
\c!command
}
\v!no
\orelse
\ifcsname
#
1
\endcsname
\else
214
\frozen
\instance
\protected
\defcsname
#
1
\endcsname
{
\lang_basics_set_current
[
#
2
]
}
%
215
\fi
}
216 217
%D When the second argument is a language identifier, a synonym is created. This
218
%D feature is present because we used dutch mnemonics in the dutch version, but
219
%D nowadays conform a standard.
220 221
\permanent
\protected
\def
\doifelsepatterns
#
1
%
222
{
\begingroup
% will change
223
\lang_basics_set_current
[
#
1
]
%
224
\ifnum
\normallanguage
>
\zerocount
225
\endgroup
\expandafter
\firstoftwoarguments
226
\else
227
\endgroup
\expandafter
\secondoftwoarguments
228
\fi
}
229 230
\aliased
\let
\doifpatternselse
\doifelsepatterns
231 232
%D \macros
233
%D {setuplanguage}
234
%D
235
%D Quick and dirty, but useful:
236
%D
237
%D \showsetup{setuplanguage}
238
%D
239
%D Beware, this command can only be used when a language is installed.
240 241
\ifdefined
\lang_basics_synchronize
\else
242
\let
\lang_basics_synchronize
\relax
% be nice for setups till we have one
243
\fi
244 245
\installmacrostack
\currentlanguage
246 247
\permanent
\tolerant
\protected
\def
\setuplanguage
[
#
1
]
#
*
[
#
2
]
%
248
{
\ifarguments
249
% only synchronize
250
\or
251
\let
\currentsetuplanguage
\currentlanguage
252
\getparameters
[
\??language
\currentsetuplanguage
]
[
#
1
]
%
253
\the
\everysetuplanguage
254
\or
255
\push_macro_currentlanguage
% can be default
256
\edef
\currentsetuplanguage
{
\reallanguagetag
{
#
1
}
}
%
257
\getparameters
[
\??language
\currentsetuplanguage
]
[
#
2
]
%
258
\the
\everysetuplanguage
259
\pop_macro_currentlanguage
260
%\doif\currentsetuplanguage\currentlanguage we can have influenced inheritance (default)
261
\fi
262
\lang_basics_synchronize
}
263 264
\appendtoks
265
\clf_unloadlanguage
{
\currentsetuplanguage
}
%
266
\to
\everysetuplanguage
267 268
\setuplanguage
269
[
\s!default
]
270
[
\s!patterns
=
,
271
\s!goodies
=
,
272
\s!lefthyphenmin
=
2
,
273
\s!righthyphenmin
=
2
,
274
\s!lefthyphenchar
=
-
1
,
275
\s!righthyphenchar
=
4
5
,
276
% used in compound i.e. interfaced with c! and can be anything so no numbers
277
\c!lefthyphen
=
,
278
\c!righthyphen
=
-
,
279
\c!hyphen
=
-
,
280
\c!spacing
=
\v!packed
,
281
\c!compoundhyphen
=
\compoundhyphen
,
282
\c!rightcompoundhyphen
=
\compoundhyphen
,
283
\c!leftcompoundhyphen
=
,
284
\c!midsentence
=
-
-
-
,
285
\c!leftsentence
=
-
-
-
,
286
\c!rightsentence
=
-
-
-
,
287
\c!leftsubsentence
=
-
-
-
,
288
\c!rightsubsentence
=
-
-
-
,
289
\c!leftquote
=
\upperleftsinglesixquote
,
290
\c!rightquote
=
\upperrightsingleninequote
,
291
\c!leftquotation
=
\upperleftdoublesixquote
,
292
\c!rightquotation
=
\upperrightdoubleninequote
,
293
\c!leftspeech
=
\languageparameter
\c!leftquotation
,
294
\c!middlespeech
=
,
295
\c!rightspeech
=
\languageparameter
\c!rightquotation
,
296
\c!limittext
=
\unknown
,
297
\c!time
=
{
h
,
:
,
m
}
,
298
\c!date
=
{
\v!year
,
\
,
\v!month
,
\
,
\v!day
}
,
299
\c!text
=
Ag
,
300
\c!font
=
]
% \v!auto : experimental !
301 302
% to be tested:
303
%
304
% \setuplanguage
305
% [\s!default]
306
% [\c!righthyphenchar="AD]
307 308
%D The values \type {leftsentence} and \type {rightsentence} can be (and are) used
309
%D to implement automatic subsentence boundary glyphs, like in {\fr |<|french
310
%D guillemots|>|} or {\de |<|german guillemots|>|} or {\nl |<|dutch dashes|>|} like
311
%D situations. Furthermore \type {leftquotation} and \type {leftquote} come into
312
%D view \quotation {when we quote} or \quote {quote} something.
313 314
%D \macros
315
%D {currentdatespecification, currenttimespecification}
316
%D
317
%D Just to make things easy we can ask for the current date specification by saying:
318 319
\permanent
\def
\currentdatespecification
{
\languageparameter
\c!date
}
320
\permanent
\def
\currenttimespecification
{
\languageparameter
\c!time
}
321 322
%D Carefull reading of these macros shows that it's legal to say
323
%D
324
%D \starttyping
325
%D \installlanguage [du] [de]
326
%D \stoptyping
327 328
%D \macros
329
%D {language,mainlanguage}
330
%D
331
%D Switching to another language (actually another hyphenation pattern) is done
332
%D with:
333
%D
334
%D \starttyping
335
%D \language[identifier]
336
%D \stoptyping
337
%D
338
%D or with \type {\identifier}. Just to be compatible with \PLAIN\ \TEX, we still
339
%D support the original meaning, so
340
%D
341
%D \starttyping
342
%D \language=1
343
%D \stoptyping
344
%D
345
%D is a valid operation, where the relation between number and language depends on
346
%D the order in installing languages.
347
%D
348
%D \showsetup{language}
349
%D \showsetup{mainlanguage}
350
%D
351
%D Both commands take a predefined language identifier as argument. We can use \type
352
%D {\mainlanguage[identifier]} for setting the (indeed) main language. This is the
353
%D language used for translating labels like {\em figure} and {\em table}. The main
354
%D language defaults to the current language.
355 356
\newtoks
\everylanguage
357 358
\installcorenamespace
{
languagenumbers
}
359 360
\appendtoks
361
% we need to reassign the number because new patterns can be defined later on
362
% so let's hope not that many \setups happen during a run
363
\gletcsname
\??languagenumbers
\currentlanguage
\endcsname
\undefined
364
\to
\everysetuplanguage
365 366
\def
\lang_basics_synchronize_yes
367
{
\zerocount
% see below
368
\global
\expandafter
\chardef
\csname
\??languagenumbers
\currentlanguage
\endcsname
369
\clf_languagenumber
370
{
\currentlanguage
}
%
371
{
\defaultlanguage
\currentlanguage
}
%
372
{
\languageparameter
\s!patterns
}
%
373
{
\languageparameter
\s!goodies
}
%
374
{
\languageparameter
\c!factor
}
%
375
\relax
376
\normallanguage
\csname
\??languagenumbers
\currentlanguage
\endcsname
}
377 378
\let
\lang_basics_synchronize_nop
\zerocount
% not loaded anyway
379 380
\letvalue
{
\??languagenumbers
}
\lang_basics_synchronize_nop
% initime
381 382
\appendtoks
383
\letvalue
{
\??languagenumbers
}
\lang_basics_synchronize_yes
% runtime
384
\to
\everydump
385 386
\def
\lang_basics_synchronize
387
{
\normallanguage
\csname
\??languagenumbers
388
\ifcsname
\??languagenumbers
\currentlanguage
\endcsname
389
\currentlanguage
390
\fi
391
\endcsname
392
\relax
393
\the
\everylanguage
394
\relax
}
395 396
\newcount
\hyphenstate
397
\newcount
\hyphenminoffset
398 399
% This is the old implementation: a hack that sets the min values, because we want
400
% to keep the language set:
401
%
402
% \protected\def\nohyphens % nicer for url's
403
% {\ifrelax\dohyphens
404
% \protected\edef\dohyphens
405
% {\hyphenminoffset\the\hyphenminoffset\relax
406
% \lang_basics_synchronize_min_max}%
407
% \fi
408
% \hyphenminoffset\plusthousand
409
% \lang_basics_synchronize_min_max}
410
%
411
% \let\dohyphens\relax
412 413
% But this one is nicer because we do keep the language set as well as don't mess
414
% with the min values (it's more efficient too). We might get some more bits in
415
% this mode (engine specific).
416 417
\exhyphenchar
4
5
% to permit breaking at explicit hyphens
418 419
% \uchyph\plusone :
420 421
% \chardef \completehyphenationcode \numexpr
422
\permanent
\integerdef
\completehyphenationcode
\numexpr
423
\normalhyphenationcode
% \discretionary
424
+
\automatichyphenationcode
% -
425
+
\explicithyphenationcode
% \-
426
+
\syllablehyphenationcode
% pattern driven
427
+
\uppercasehyphenationcode
% replaces \uchyph
428
+
\compoundhyphenationcode
% replaces \compoundhyphenmode
429
% \strictstarthyphenationcode % replaces \hyphenationbounds (strict = original tex)
430
% \strictendhyphenationcode % replaces \hyphenationbounds (strict = original tex)
431
+
\automaticpenaltyhyphenationcode
% replaces \hyphenpenaltymode (otherwise use \exhyphenpenalty)
432
+
\explicitpenaltyhyphenationcode
% replaces \hyphenpenaltymode (otherwise use \exhyphenpenalty)
433
+
\permitgluehyphenationcode
% turn glue into kern in \discretionary
434
+
\permitallhyphenationcode
% okay, let's be even more tolerant
435
+
\permitmathreplacehyphenationcode
% and again we're more permissive
436
+
\forcehandlerhyphenationcode
% kick in the handler (could be an option)
437
+
\feedbackcompoundhyphenationcode
% feedback compound snippets
438
+
\ignoreboundshyphenationcode
% just in case we have hyphens at the edges
439
+
\collapsehyphenationcode
% collapse -- and ---
440
\relax
441 442
\permanent
\integerdef
\partialhyphenationcode
\numexpr
443
\ignoreboundshyphenationcode
% just in case we have hyphens at the edges
444
% + \explicithyphenationcode % \-
445
+
\collapsehyphenationcode
% collapse -- and ---
446
\relax
447 448
\hccode
"
0
0
2
D
"
0
0
2
D
449 450
\permanent
\protected
\def
\keephyphensequences
451
{
\hccode
"
2
0
1
0
\zerocount
452
\hccode
"
2
0
1
3
\zerocount
453
\hccode
"
2
0
1
4
\zerocount
}
454 455
\permanent
\protected
\def
\collapsehyphensequences
456
{
\hccode
"
2
0
1
0
"
2
0
1
0
\relax
457
\hccode
"
2
0
1
3
"
2
0
1
3
\relax
458
\hccode
"
2
0
1
4
"
2
0
1
4
\relax
}
459 460
\collapsehyphensequences
461 462
% maybe a (un)setter for handlers
463 464
\permanent
\protected
\def
\dohyphens
{
\hyphenationmode
\completehyphenationcode
}
465
\permanent
\protected
\def
\nohyphens
{
\hyphenationmode
\partialhyphenationcode
}
466 467
% \permanent\protected\def\dohyphens
468
% {\ifbitwiseand\hyphenationmode\collapsehyphenationcode
469
% \hyphenationmode\completehyphenationcode
470
% \else
471
% \hyphenationmode\numexpr\completehyphenationcode-\collapsehyphenationcode\relax
472
% \fi}
473 474
% \permanent\protected\def\nohyphens
475
% {\ifbitwiseand\hyphenationmode\collapsehyphenationcode
476
% \hyphenationmode\partialhyphenationcode
477
% \else
478
% \hyphenationmode\numexpr\partialhyphenationcode-\collapsehyphenationcode\relax
479
% \fi}
480 481
\permanent
\protected
\def
\dohyphencollapsing
{
\hyphenationmode
\bitwiseflip
\hyphenationmode
\collapsehyphenationcode
}
482
\permanent
\protected
\def
\nohyphencollapsing
{
\hyphenationmode
\bitwiseflip
\hyphenationmode
-
\collapsehyphenationcode
}
483 484
\permanent
\protected
\def
\doexplicithyphens
{
\hyphenationmode
\bitwiseflip
\hyphenationmode
\explicithyphenationcode
}
485
\permanent
\protected
\def
\noexplicithyphens
{
\hyphenationmode
\bitwiseflip
\hyphenationmode
-
\explicithyphenationcode
}
486 487
\permanent
\protected
\def
\usehyphensparameter
#
1
%
488
{
\edef
\p_hyphens
{
#
1
\c!hyphens
}
%
489
\ifx
\p_hyphens
\v!no
490
\ifbitwiseand
\hyphenationmode
\collapsehyphenationcode
491
\nohyphens
492
\else
493
\nohyphens
494
\nohyphencollapsing
495
\fi
496
\fi
}
497 498
\dohyphens
499 500
%D The rest stays the same as in mkiv:
501 502
\permanent
\protected
\def
\lesshyphens
503
{
\advance
\hyphenminoffset
\plusone
504
\lang_basics_synchronize_min_max
}
505 506
\permanent
\protected
\def
\morehyphens
507
{
\ifcase
\hyphenminoffset
\else
508
\advance
\hyphenminoffset
\minusone
509
\fi
510
\lang_basics_synchronize_min_max
}
511 512
\protected
\def
\lang_basics_synchronize_min_max
% maybe store this at the lua end
513
{
% these values are stored along with glyph nodes
514
\lefthyphenmin
\numexpr
0
\languageparameter
\s!lefthyphenmin
+
\hyphenminoffset
\relax
515
\righthyphenmin
\numexpr
0
\languageparameter
\s!righthyphenmin
+
\hyphenminoffset
\relax
516
\hyphenationmin
\numexpr
0
\languageparameter
\s!hyphenmin
\relax
517
% these values are stored with the language (global!)
518
\prehyphenchar
\languageparameter
\s!righthyphenchar
\relax
519
\posthyphenchar
\languageparameter
\s!lefthyphenchar
\relax
}
520 521
\appendtoks
522
\lang_basics_synchronize_min_max
523
\to
\everylanguage
524 525
\permanent
\protected
\def
\unhyphenated
526
{
\groupedcommand
{
\lefthyphenmin
\maxdimen
}
\donothing
}
527 528
% \appendtoks
529
% \setups[\languageparameter\c!setups]%
530
% \to \everylanguage
531 532
%D You can setup the default language to reset settings.
533 534
\mutable
\let
\currentlanguagesetups
\empty
535 536
\appendtoks
537
\edef
\currentlanguagesetups
{
\languageparameter
\c!setups
}
%
538
\ifempty
\currentlanguagesetups
\else
539
\setups
[
\currentlanguagesetups
]
%
540
\fi
541
\to
\everylanguage
542 543
% new
544 545
\appendtoks
546
\usebidiparameter
\languageparameter
547
\to
\everylanguage
548 549
% this will move to core-spa !
550 551
\appendtoks
552
\edef
\p_spacing
{
\languageparameter
\c!spacing
}
%
553
\ifx
\p_spacing
\v!broad
554
\nonfrenchspacing
555
\else
556
\frenchspacing
557
\fi
558
\to
\everylanguage
559 560
% \mainlanguage[nl] \setuplanguage[nl][lefthyphen=,righthyphen=?]
561
%
562
% \dorecurse{100}{dit is toch wel een heel\normalhyphendiscretionary lang\normalhyphendiscretionary woord \recurselevel\ }
563
% \dorecurse{100}{dit is toch wel een heellangwoord \recurselevel\ }
564 565
% new experimental feature
566 567
\permanent
\protected
\def
\setuplanguages
568
{
\setuplanguage
[
\s!default
]
}
569 570
% \setuplanguages[\c!font=\v!auto]
571
% \setuplanguage[\s!default][\c!font=\v!auto]
572
% \setuplanguage[nl][\c!font=\v!auto]
573 574
\appendtoks
575
\edef
\p_language_font
{
\languageparameter
\c!font
}
%
576
\ifempty
\p_language_font
577
\orelse
\ifx
\p_language_font
\v!auto
578
\doaddfeature
\currentlanguage
579
\else
580
\doaddfeature
\p_language_font
581
\fi
582
\to
\everylanguage
583 584
%D Fast switcher
585 586
\def
\lang_basics_switch_asked
587
{
\ifcsname
\??languagelinked
\askedlanguage
\endcsname
588
\edef
\askedlanguage
{
\lastnamedcs
}
%
589
\ifx
\currentlanguage
\askedlanguage
\else
590
\setcurrentlanguage
\currentmainlanguage
\askedlanguage
591
\lang_basics_synchronize
592
\fi
593
\fi
}
594 595
\permanent
\protected
\def
\uselanguageparameter
#
1
%
596
{
\edef
\askedlanguage
{
#
1
\c!language
}
%
597
\ifempty
\askedlanguage
\else
\lang_basics_switch_asked
\fi
}
598 599
\permanent
\protected
\def
\douselanguageparameter
#
1
% fast setter
600
{
\edef
\askedlanguage
{
#
1
}
%
601
\ifempty
\askedlanguage
\else
\lang_basics_switch_asked
\fi
}
602 603
\protected
\def
\lang_basics_set_current
[
#
1
]
%
604
{
\edef
\askedlanguage
{
#
1
}
%
605
\ifempty
\askedlanguage
\else
\lang_basics_switch_asked
\fi
}
606 607
\pushoverloadmode
608 609
\permanent
\protected
\def
\language
610
{
\doifelsenextoptionalcs
\lang_basics_set_current
\normallanguage
}
611 612
\aliased
\let
\setlanguage
\language
% we make these synonyms
613 614
\aliased
\let
\patterns
\gobbleoneargument
615 616
\popoverloadmode
617 618
\newcount
\mainlanguagenumber
619 620
%D Beware: you might need to use \type {\dontleavehmode} outside and|/|or \type {\par}
621
%D inside the group!
622 623
\permanent
\protected
\def
\startlanguage
624
{
\begingroup
\language
}
625 626
\permanent
\let
\stoplanguage
\endgroup
627 628
\permanent
\protected
\def
\mainlanguage
[
#
1
]
%
629
{
\edef
\askedlanguage
{
#
1
}
%
630
\ifempty
\askedlanguage
631
\orelse
\ifcsname
\??languagelinked
\askedlanguage
\endcsname
632
%\edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}%
633
\edef
\askedlanguage
{
\lastnamedcs
}
%
634
\ifx
\currentlanguage
\askedlanguage
635
\ifx
\currentmainlanguage
\askedlanguage
\else
636
\setcurrentlanguage
\askedlanguage
\askedlanguage
637
\lang_basics_synchronize
638
\fi
639
\else
640
\setcurrentlanguage
\askedlanguage
\askedlanguage
641
\lang_basics_synchronize
642
\fi
643
\fi
644
\mainlanguagenumber
\normallanguage
}
645 646
\appendtoks
647
\normallanguage
\mainlanguagenumber
648
\to
\everybeforepagebody
649 650
%D Used at all?
651 652
\permanent
\def
\splitsequence
#
1
#
2
%
653
{
\doifelse
{
#
1
}
\v!no
{
#
2
}
{
\doifelse
{
#
1
}
\v!yes
{
\languageparameter
\c!limittext
}
{
#
1
}
}
}
654 655
\permanent
\def
\splitsymbol
#
1
%
656
{
\splitsequence
{
#
1
}
{
\languageparameter
\c!limittext
}
}
657 658
%D Just like with subsentence boundary symbols, quotes placement depends on the
659
%D current language, therefore we show the defaults here.
660
%D
661
%D \def\ShowLanguageValues [#1] [#2] #3 #4
662
%D {\blank
663
%D \startlinecorrection
664
%D \vbox\bgroup
665
%D \language[#1]
666
%D \midaligned{\bf#2 subsentence symbol and quotes}
667
%D \framed[width=\hsize,frame=off,topframe=on,bottomframe=on,offset=.5ex]
668
%D {\hfil\quotation{#3 #4}\hfil\quote{#2}\hfil
669
%D \startsubsentence\startsubsentence#3\stopsubsentence#4\stopsubsentence\hfil}
670
%D \egroup
671
%D \stoplinecorrection
672
%D \blank}
673
%D
674
%D \ShowLanguageValues [af] [afrikaans] afrikaanse ...
675
%D \ShowLanguageValues [ca] [catalan] catalan ...
676
%D \ShowLanguageValues [cs] [czech] tjechisch tex
677
%D \ShowLanguageValues [cs] [slovak] slowaakse ...
678
%D \ShowLanguageValues [da] [danish] deense ...
679
%D \ShowLanguageValues [de] [german] duitse degelijkheid
680
%D \ShowLanguageValues [en] [english] engelse humor
681
%D \ShowLanguageValues [et] [estonian] ...
682
%D \ShowLanguageValues [fi] [finnish] finse ...
683
%D \ShowLanguageValues [fr] [french] franse slag
684
%D \ShowLanguageValues [it] [italian] italiaanse ...
685
%D \ShowLanguageValues [la] [latin] latijnse missen
686
%D \ShowLanguageValues [nl] [dutch] nederlandse zuinigheid
687
%D \ShowLanguageValues [nb] [bokmal] noorse zalm
688
%D \ShowLanguageValues [nn] [nnynorsk] noorse zalm
689
%D \ShowLanguageValues [pl] [polish] poolse vlag
690
%D \ShowLanguageValues [pt] [portuguese] portugese ...
691
%D \ShowLanguageValues [es] [spanish] spaans benauwd
692
%D \ShowLanguageValues [sv] [swedish] zweedse ...
693
%D \ShowLanguageValues [tr] [turkish] turks fruit
694 695
%D We support a lot of languages. These are specified and loaded in separate files,
696
%D according to their roots. Here we only take care of (postponed) setting of the
697
%D current language.
698
%D
699
%D \unprotect
700
%D \placetable{The germanic languages (\type{lang-ger})}
701
%D \starttable[||||]
702
%D \HL
703
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
704
%D \HL
705
%D \NC \s!nl \NC dutch \NC germanic \NC\FR
706
%D \NC \s!en \NC english \NC germanic \NC\MR
707
%D \NC \s!de \NC german \NC germanic \NC\MR
708
%D \NC \s!da \NC danish \NC germanic \NC\MR
709
%D \NC \s!sv \NC swedish \NC germanic \NC\MR
710
%D \NC \s!af \NC afrikaans \NC germanic \NC\MR
711
%D \NC \s!nb \NC bokmal \NC germanic \NC\LR
712
%D \NC \s!nn \NC nynorsk \NC germanic \NC\LR
713
%D \HL
714
%D \stoptable
715
%D \protect
716
%D
717
%D \unprotect
718
%D \placetable{The italic languages (\type{lang-ita})}
719
%D \starttable[||||]
720
%D \HL
721
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
722
%D \HL
723
%D \NC \s!fr \NC french \NC italic \NC\FR
724
%D \NC \s!ca \NC catalan \NC italic \NC\MR
725
%D \NC \s!es \NC spanish \NC italic \NC\MR
726
%D \NC \s!it \NC italian \NC italic \NC\MR
727
%D \NC \s!la \NC latin \NC italic \NC\MR
728
%D \NC \s!pt \NC portuguese \NC italic \NC\LR
729
%D \HL
730
%D \stoptable
731
%D \protect
732
%D
733
%D \unprotect
734
%D \placetable{The slavic languages (\type{lang-sla})}
735
%D \starttable[||||]
736
%D \HL
737
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
738
%D \HL
739
%D \NC \s!pl \NC polish \NC slavic \NC\FR
740
%D \NC \s!cs \NC czech \NC slavic \NC\MR
741
%D \NC \s!sk \NC slavik \NC slavic \NC\LR
742
%D \HL
743
%D \stoptable
744
%D \protect
745
%D \unprotect
746
%D
747
%D \placetable{The altaic languages (\type{lang-alt})}
748
%D \starttable[||||]
749
%D \HL
750
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
751
%D \HL
752
%D \NC \s!tr \NC turkish \NC altaic \NC\SR
753
%D \HL
754
%D \stoptable
755
%D
756
%D \placetable{The uralic languages (\type{lang-ura})}
757
%D \starttable[||||]
758
%D \HL
759
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
760
%D \HL
761
%D \NC \s!fi \NC finnish \NC uralic \NC\SR
762
%D \HL
763
%D \stoptable
764
%D \protect
765 766
\permanent
\protected
\def
\nopatterns
{
\normallanguage
\minusone
}
767 768
%D We default to the language belonging to the interface. This is one of the few
769
%D places outside the interface modules where \type {\startinterface} is used.
770 771
\setupcurrentlanguage
[
\s!en
]
772 773
\permanent
\protected
\def
\initializemainlanguage
774
{
\mainlanguage
[
\currentlanguage
]
%
775
\showmessage
\m!languages
9
\currentlanguage
}
776 777
%D New:
778 779
\permanent
\let
\stopexceptions
\relax
780 781
\tolerant
\permanent
\protected
\def
\startexceptions
[
#
1
]
#
:
#
2
\stopexceptions
782
{
\begingroup
783
\edef
\askedlanguage
{
\reallanguagetag
{
#
1
}
}
%
784
\ifempty
\askedlanguage
785
\let
\askedlanguage
\currentlanguage
786
\fi
787
\clf_setlanguageexceptions
{
\askedlanguage
}
{
#
2
}
%
788
\endgroup
}
789 790
\permanent
\let
\stoppatterns
\relax
791 792
\tolerant
\permanent
\protected
\def
\startpatterns
[
#
1
]
#
:
#
2
\stoppatterns
793
{
\begingroup
794
\edef
\askedlanguage
{
\reallanguagetag
{
#
1
}
}
%
795
\ifempty
\askedlanguage
796
\let
\askedlanguage
\currentlanguage
797
\fi
798
\clf_setlanguagepatterns
{
\askedlanguage
}
{
#
2
}
%
799
\endgroup
}
800 801 802
\pushoverloadmode
803 804
\permanent
\protected
\def
\hyphenation
{
\clf_setlanguageexceptions
{
\currentlanguage
}
}
805
\permanent
\protected
\def
\patterns
{
\clf_setlanguagepatterns
{
\currentlanguage
}
}
806 807
\popoverloadmode
808 809
%D New:
810 811
\permanent
\protected
\def
\traceddiscretionary
#
1
#
%
812
{
\dontleavehmode
\lang_basics_traced_discretionary
{
#
1
}
}
813 814
\protected
\def
\lang_basics_traced_discretionary
#
1
#
2
#
3
#
4
%
815
{
\normaldiscretionary
#
1
{
\darkred
#
2
}
{
\darkgreen
#
3
}
{
\darkblue
#
4
}
}
816 817
\def
\lang_basics_trace_discretionary_yes
{
\enforced
\let
\discretionary
\traceddiscretionary
}
% indirect because of overload
818
\def
\lang_basics_trace_discretionary_nop
{
\enforced
\let
\discretionary
\normaldiscretionary
}
% indirect because of overload
819 820 821
\installtextracker
822
{
discretionaries
}
823
{
\lang_basics_trace_discretionary_yes
}
824
{
\lang_basics_trace_discretionary_nop
}
825 826
\permanent
\protected
\def
\samplediscretionary
827
{
\traceddiscretionary
828
{
pre
\clf_currentprehyphenchar
}
%
829
{
\clf_currentposthyphenchar
post
}
%
830
{
replace
}
}
831 832
%D A typical \LMTX\ feature:
833
%D
834
%D \starttyping
835
%D whatever\par
836
%D {\nokerning whatever}\par
837
%D efficient ff fi\par
838
%D {\noligaturing efficient ff fi}\par
839
%D {\nokerning\noligaturing efficient ff fi}\par
840
%D {e{\noligaturing ffi}cient}\par
841
%D {ef{\noleftligaturing f}icient ff fi}\par
842
%D {ef{\norightligaturing f}icient ff fi}\par
843
%D \stoptyping
844 845
\immutable
\chardef
\nokerningcode
\numexpr
\noleftkernglyphoptioncode
+
\norightkernglyphoptioncode
\relax
846
\immutable
\chardef
\noligaturingcode
\numexpr
\noleftligatureglyphoptioncode
+
\norightligatureglyphoptioncode
\relax
847 848
\permanent
\protected
\def
\nokerning
{
\bitwiseflip
\glyphoptions
\nokerningcode
}
849
\permanent
\protected
\def
\noligaturing
{
\bitwiseflip
\glyphoptions
\noligaturingcode
}
850 851
\permanent
\protected
\def
\noleftkerning
{
\bitwiseflip
\glyphoptions
\noleftkernglyphoptioncode
}
852
\permanent
\protected
\def
\noleftligaturing
{
\bitwiseflip
\glyphoptions
\noleftligatureglyphoptioncode
}
853
\permanent
\protected
\def
\norightkerning
{
\bitwiseflip
\glyphoptions
\norightkernglyphoptioncode
}
854
\permanent
\protected
\def
\norightligaturing
{
\bitwiseflip
\glyphoptions
\norightligatureglyphoptioncode
}
855 856
% This is not really language related but let's define it here:
857 858
\permanent
\protected
\def
\noitaliccorrection
{
\bitwiseflip
\glyphoptions
\noitaliccorrectionglyphoptioncode
}
859 860
%D Also \LMTX:
861 862
% \startlanguageoptions[de]
863
% Zapf|innovation
864
% \stoplanguageoptions
865 866
\permanent
\let
\stoplanguageoptions
\relax
867 868
\permanent
\protected
\def
\startlanguageoptions
869
{
\begingroup
870
\catcode
`
|
\othercatcode
871
\lang_startlanguageoptions
}
872 873
\tolerant
\def
\lang_startlanguageoptions
[
#
1
]
#
:
#
2
\stoplanguageoptions
874
{
\edef
\askedlanguage
{
\reallanguagetag
{
#
1
}
}
%
875
\ifempty
\askedlanguage
876
\let
\askedlanguage
\currentlanguage
877
\fi
878
\clf_setlanguageoptions
{
\askedlanguage
}
{
#
2
}
%
879
\endgroup
}
880 881
\protect
\endinput
882