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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
|
%D \module
%D [ file=lang-ini,
%D version=1996.01.25,
%D title=\CONTEXT\ Language Macros,
%D subtitle=Initialization,
%D author=Hans Hagen,
%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.
%D This module needs a further cleanup (real split between ii/iv).
% \cldcontext{languages.numbers[tex.count.mainlanguagenumber]}
%D This module implements the (for the moment still simple)
%D multi||language support of \CONTEXT, which should not be
%D confused with the multi||lingual interface. This support
%D will be extended when needed.
\writestatus{loading}{ConTeXt Language Macros / Initialization}
\registerctxluafile{lang-ini}{1.001}
\registerctxluafile{lang-def}{1.001}
\registerctxluafile{lang-cnt}{1.001}
\unprotect
% \def\testlanguage[#1]%
% {\start
% \language[#1]
% \number\normallanguage/\the\lefthyphenmin/\the\righthyphenmin:
% \input tufte
% \hyphenatedword{effetestenofditwerkt}
% \par
% \stop}
%
% \testlanguage[de] \testlanguage[de-de] \testlanguage[de-at] \testlanguage[de-ch] \page
% \testlanguage[en] \testlanguage[us] \testlanguage[en-us] \testlanguage[uk] \testlanguage[en-gb] \page
\ifdefined\nonfrenchspacing\else \let\nonfrenchspacing\relax \fi
\ifdefined\frenchspacing \else \let\frenchspacing \relax \fi
%D When loading hyphenation patterns, \TEX\ assign a number to
%D each loaded table, starting with~0. Switching to a specific
%D table is done by assigning the relevant number to the
%D predefined \COUNTER\ \type{\language}.
%D We keep track of the last loaded patterns by means of a
%D pseudo \COUNTER. This just one of those situations in which
%D we don't want to spent a real one. Language zero has no
%D patterns, first of all because I like to start numbering
%D at one. It may come in handy for special purposes as well.
\normallanguage\zerocount \def\loadedlanguage{1}
%D \macros
%D {currentlanguage, setupcurrentlanguage}
%D
%D Instead of numbers,we are going to use symbolic names for
%D the languages. The current langage is saved in the macro
%D \type {\currentlanguage}. The setup macro is mainly used
%D for cosmetic purposes.
%D
%D \starttyping
%D \dorecurse{3}
%D {\language[nl]
%D \startmode[*en] english \stopmode
%D \startmode[*nl] dutch \stopmode
%D \language[en]
%D \startmode[*en] english \stopmode
%D \startmode[*nl] dutch \stopmode}
%D \stoptyping
\let\currentlanguage \empty
\let\currentmainlanguage\empty
%D \macros
%D {defaultlanguage,languageparameter,specificlanguageparameter}
%D We don't use the commandhandler here (yet) because we have
%D a rather special fallback mechanism so quite some compatibility
%D testing is needed.
\installcorenamespace{language}
\installcorenamespace{languagelinked}
\def\currentusedlanguage{\currentlanguage}
\def\defaultlanguage#1%
{\ifcsname\??language#1\s!default\endcsname
\expandafter\defaultlanguage\lastnamedcs
\else
#1%
\fi}
% \def\languageparameter#1%
% {\ifcsname\??language\currentlanguage#1\endcsname
% \csname\??language\currentlanguage#1\endcsname
% \else\ifcsname\??language\currentlanguage\s!default\endcsname
% \expandafter\specificlanguageparameter\csname\??language\currentlanguage\s!default\endcsname{#1}%
% \else\ifcsname\??language\s!default#1\endcsname
% \csname\??language\s!default#1\endcsname
% \fi\fi\fi}
%
% \def\specificlanguageparameter#1#2%
% {\ifcsname\??language#1#2\endcsname
% \csname\??language#1#2\endcsname
% \else\ifcsname\??language#1\s!default\endcsname
% \expandafter\specificlanguageparameter\csname\??language#1\s!default\endcsname{#2}%
% \else\ifcsname\??language\s!default#2\endcsname
% \csname\??language\s!default#2\endcsname
% \fi\fi\fi}
%
% \def\mainlanguageparameter#1%
% {\ifcsname\??language\currentmainlanguage#1\endcsname
% \csname\??language\currentmainlanguage#1\endcsname
% \else\ifcsname\??language\currentmainlanguage\s!default\endcsname
% \expandafter\specificlanguageparameter\csname\??language\currentmainlanguage\s!default\endcsname{#1}%
% \else\ifcsname\??language\s!default#1\endcsname
% \csname\??language\s!default#1\endcsname
% \fi\fi\fi}
\def\languageparameter#1%
{\ifcsname\??language\currentlanguage#1\endcsname
\lastnamedcs
\else\ifcsname\??language\currentlanguage\s!default\endcsname
\expandafter\specificlanguageparameter\lastnamedcs{#1}%
\else\ifcsname\??language\s!default#1\endcsname
\lastnamedcs
\fi\fi\fi}
\def\specificlanguageparameter#1#2%
{\ifcsname\??language#1#2\endcsname
\lastnamedcs
\else\ifcsname\??language#1\s!default\endcsname
\expandafter\specificlanguageparameter\lastnamedcs{#2}%
\else\ifcsname\??language\s!default#2\endcsname
\lastnamedcs
\fi\fi\fi}
\def\mainlanguageparameter#1%
{\ifcsname\??language\currentmainlanguage#1\endcsname
\lastnamedcs
\else\ifcsname\??language\currentmainlanguage\s!default\endcsname
\expandafter\specificlanguageparameter\lastnamedcs{#1}%
\else\ifcsname\??language\s!default#1\endcsname
\lastnamedcs
\fi\fi\fi}
\let\usedlanguageparameter\languageparameter
% \def\askedlanguageparameter#1% assumes \currentusedlanguage being set
% {\ifcsname\??language\currentusedlanguage#1\endcsname
% \csname\??language\currentusedlanguage#1\endcsname
% \else\ifcsname\??language\currentusedlanguage\s!default\endcsname
% \expandafter\specificlanguageparameter\csname\??language\currentusedlanguage\s!default\endcsname{#1}%
% \else\ifcsname\??language\s!default#1\endcsname
% \csname\??language\s!default#1\endcsname
% \fi\fi\fi}
\def\askedlanguageparameter#1% assumes \currentusedlanguage being set
{\ifcsname\??language\currentusedlanguage#1\endcsname
\lastnamedcs
\else\ifcsname\??language\currentusedlanguage\s!default\endcsname
\expandafter\specificlanguageparameter\lastnamedcs{#1}%
\else\ifcsname\??language\s!default#1\endcsname
\lastnamedcs
\fi\fi\fi}
\unexpanded\def\setusedlanguage#1%
% {\edef\currentusedlanguage{\reallanguagetag{#1\c!language}}%
{\edef\currentusedlanguage{\reallanguagetag{#1}}%
\ifx\currentusedlanguage\empty
\let\currentusedlanguage \currentlanguage
\let\usedlanguageparameter\languageparameter
\else\ifx\currentusedlanguage\v!global
\let\currentusedlanguage \currentmainlanguage
\let\usedlanguageparameter\mainlanguageparameter
\else\ifx\currentusedlanguage\v!local
\let\currentusedlanguage \currentlanguage
\let\usedlanguageparameter\languageparameter
\else
\let\usedlanguageparameter\askedlanguageparameter
\fi\fi\fi}
\unexpanded\def\setupcurrentlanguage[#1]%
{\setcurrentlanguage\currentmainlanguage{#1}}
\unexpanded\def\setcurrentlanguage#1#2% sets modes: **id (currentmain) *id (current)
{\edef\xaskedlanguage{#1}% otherwise clash with \askedlanguage
\ifx\xaskedlanguage\empty \else
\ifx\currentmainlanguage\empty\else\resetsystemmode{\systemmodeprefix\currentmainlanguage}\fi
\let\currentmainlanguage\xaskedlanguage
\setsystemmode{\systemmodeprefix\currentmainlanguage}%
\fi
\edef\xaskedlanguage{#2}%
\ifx\xaskedlanguage\empty \else
\ifx\currentlanguage\empty\else\resetsystemmode\currentlanguage\fi
\let\currentlanguage\xaskedlanguage
\setsystemmode\currentlanguage
\fi}
%D The internal macros will be defined later.
%D \macros
%D {installlanguage}
%D
%D Hyphenation patterns can only be loaded when the format file
%D is prepared. The next macro takes care of this loading. A
%D language is specified with
%D
%D \showsetup{installlanguage}
%D
%D When \type {state} equals \type {start}, both patterns
%D and additional hyphenation specifications are loaded. These
%D files are seached for on the system path and are to be
%D named:
%D
%D \starttyping
%D \f!languageprefix-identifier.\f!patternsextension
%D \f!languageprefix-identifier.\f!hyhensextension
%D \stoptyping
%D
%D The \type{spacing} variable specifies how the spaces after
%D punctuation has to be handled. English is by tradition more
%D tolerant to inter||sentence spacing than other languages.
%D
%D This macro also defines \type {\identifier} as a shortcut
%D switch to the language. Furthermore the command defined as
%D being language specific, are executed. With
%D \type {default} we can default to another language
%D (patterns) at format generation time. This default language
%D is overruled when the appropriate patterns are loaded (some
%D implementations support run time addition of patterns to a
%D preloaded format).
%D \macros
%D {preloadlanguages}
%D
%D We first try to load the files defined as file synonym
%D for \type {lang-*.pat} and \type {lang-*.hyp}. After that we
%D fall back on those files. The macro \type {\preloadpatterns}
%D reports which patterns are loaded and what hyphenmin
%D values are set.
\newtoks \everysetuplanguage
\def\installedlanguages{\clf_installedlanguages}
\unexpanded\def\doifelselanguage#1%
{\ifcsname\??language#1\c!state\endcsname
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
\let\doiflanguageelse\doifelselanguage
\def\reallanguagetag#1%
%{\ifcsname\??languagelinked#1\endcsname\csname\??languagelinked#1\endcsname\else#1\fi}
{\ifcsname\??languagelinked#1\endcsname\lastnamedcs\else#1\fi}
% \language[#1] gave unwanted side effect of loading language specifics
\unexpanded\def\installlanguage
{\dodoubleargument\lang_basics_install}
\def\lang_basics_install[#1][#2]%
{\doifelseassignment{#2}
{\doifelselanguage{#1}
{\getparameters[\??language#1][#2]}
{\setvalue{\??languagelinked#1}{#1}%
\lang_basics_install_indeed{#1}{#1}%
\getparameters[\??language#1][\c!state=\v!start,#2]}%
\edef\currentsetuplanguage{#1}%
\clf_definelanguage{#1}{\specificlanguageparameter{#1}\s!default}%
\the\everysetuplanguage}
{\setvalue{\??languagelinked#1}{#2}%
\clf_setlanguagesynonym{#1}{#2}%
\lang_basics_install_indeed{#1}{#2}}}
\def\lang_basics_install_indeed#1#2%
{\ifcsname#1\endcsname\else\setuvalue{#1}{\lang_basics_set_current[#2]}\fi}
%D When the second argument is a language identifier, a
%D synonym is created. This feature is present because we
%D used dutch mnemonics in the dutch version, but nowadays
%D conform a standard.
\unexpanded\def\doifelsepatterns#1%
{\begingroup % will change
\lang_basics_set_current[#1]%
\ifnum\normallanguage>\zerocount
\endgroup\expandafter\firstoftwoarguments
\else
\endgroup\expandafter\secondoftwoarguments
\fi}
\let\doifpatternselse\doifelsepatterns
%D \macros
%D {setuplanguage}
%D
%D Quick and dirty, but useful:
%D
%D \showsetup{setuplanguage}
%D
%D Beware, this command can only be used when a language is installed.
\unexpanded\def\setuplanguage
{\dodoubleempty\lang_basics_setup}
\ifdefined\lang_basics_synchronize \else
\let\lang_basics_synchronize\relax % be nice for setups till we have one
\fi
\def\lang_basics_setup[#1][#2]%
{\ifsecondargument
\pushmacro\currentlanguage % can be default
\edef\currentsetuplanguage{\reallanguagetag{#1}}%
\getparameters[\??language\currentsetuplanguage][#2]%
\the\everysetuplanguage
\popmacro\currentlanguage
%\doif\currentsetuplanguage\currentlanguage we can have influenced inheritance (default)
\else
\let\currentsetuplanguage\currentlanguage
\getparameters[\??language\currentsetuplanguage][#1]%
\the\everysetuplanguage
\fi
\lang_basics_synchronize}
\appendtoks
\clf_unloadlanguage{\currentsetuplanguage}%
\to \everysetuplanguage
\setuplanguage
[\s!default]
[\s!patterns=,
\s!lefthyphenmin=2,
\s!righthyphenmin=2,
\s!lefthyphenchar=-1,
\s!righthyphenchar=45,
% used in compound i.e. interfaced with c! and can be anything so no numbers
\c!lefthyphen=,
\c!righthyphen=-,
\c!hyphen=-,
\c!spacing=\v!packed,
\c!compoundhyphen=\compoundhyphen,
\c!rightcompoundhyphen=\compoundhyphen,
\c!leftcompoundhyphen=,
\c!midsentence=---,
\c!leftsentence=---,
\c!rightsentence=---,
\c!leftsubsentence=---,
\c!rightsubsentence=---,
\c!leftquote=\upperleftsinglesixquote,
\c!rightquote=\upperrightsingleninequote,
\c!leftquotation=\upperleftdoublesixquote,
\c!rightquotation=\upperrightdoubleninequote,
\c!leftspeech=\languageparameter\c!leftquotation,
\c!middlespeech=,
\c!rightspeech=\languageparameter\c!rightquotation,
\c!limittext=\unknown,
\c!date={\v!year,\ ,\v!month,\ ,\v!day},
\c!text=Ag,
\s!font=] % \v!auto : experimental !
% to be tested:
%
% \setuplanguage
% [\s!default]
% [\c!righthyphenchar="AD]
%D The values \type {leftsentence} and \type
%D {rightsentence} can be (and are) used to implement
%D automatic subsentence boundary glyphs, like in {\fr
%D |<|french guillemots|>|} or {\de |<|german guillemots|>|} or
%D {\nl |<|dutch dashes|>|} like situations. Furthermore \type
%D {leftquotation} and \type {leftquote} come into view
%D \quotation {when we quote} or \quote {quote} something.
%D \macros
%D {currentdatespecification}
%D
%D Just to make things easy we can ask for the current date
%D specification by saying:
\def\currentdatespecification{\languageparameter\c!date}
%D This command is not meant for users.
%D Carefull reading of these macros shows that it's legal to
%D say
%D
%D \starttyping
%D \installlanguage [du] [de]
%D \stoptyping
%D \macros
%D {language,mainlanguage}
%D
%D Switching to another language (actually another hyphenation
%D pattern) is done with:
%D
%D \starttyping
%D \language[identifier]
%D \stoptyping
%D
%D or with \type{\identifier}. Just to be compatible with
%D \PLAIN\ \TEX, we still support the original meaning, so
%D
%D \starttyping
%D \language=1
%D \stoptyping
%D
%D is a valid operation, where the relation between number
%D and language depends on the order in installing languages.
%D
%D \showsetup{language}
%D \showsetup{mainlanguage}
%D
%D Both commands take a predefined language identifier as
%D argument. We can use \type{\mainlanguage[identifier]} for
%D setting the (indeed) main language. This is the language
%D used for translating labels like {\em figure} and {\em
%D table}. The main language defaults to the current language.
%D
%D We take care of local as well as standardized language
%D switching (fr and fa, de and du, but nl and nl).
\newtoks \everylanguage
% \def\lang_basics_synchronize% assumes that \currentlanguage is set % % % use different name as complex
% {\normallanguage\ctxcommand{languagenumber(%
% "\currentlanguage",%
% "\defaultlanguage\currentlanguage",%
% "\languageparameter\s!patterns"%
% )}\relax
% \the\everylanguage\relax}
% (some 20%) faster but code jungle (the publication code can have excessive
% switching
\installcorenamespace{languagenumbers}
\appendtoks
% we need to reassign the number because new patterns can be defined later on
% so let's hope not that many \setups happen during a run
\global\expandafter\let\csname\??languagenumbers\currentlanguage\endcsname\undefined
\to \everysetuplanguage
\def\lang_basics_synchronize_yes
{\zerocount % see below
\global\expandafter\chardef\csname\??languagenumbers\currentlanguage\endcsname
\clf_languagenumber
{\currentlanguage}%
{\defaultlanguage\currentlanguage}%
{\languageparameter\s!patterns}%
{\languageparameter\c!factor}%
\relax
\normallanguage\csname\??languagenumbers\currentlanguage\endcsname}
\let\lang_basics_synchronize_nop\zerocount % not loaded anyway
\letvalue{\??languagenumbers}\lang_basics_synchronize_nop % initime
\appendtoks
\letvalue{\??languagenumbers}\lang_basics_synchronize_yes % runtime
\to \everydump
\def\lang_basics_synchronize% assumes that \currentlanguage is set % % % use different name as complex
{\normallanguage\csname\??languagenumbers
\ifcsname\??languagenumbers\currentlanguage\endcsname
\currentlanguage
\fi
\endcsname
\relax
\the\everylanguage
\relax}
% experimental
\newcount\hyphenstate
% so far
\newcount\hyphenminoffset
\unexpanded\def\lesshyphens
{\advance\hyphenminoffset\plusone
\lang_basics_synchronize_min_max}
\unexpanded\def\morehyphens
{\ifcase\hyphenminoffset \else
\advance\hyphenminoffset\minusone
\fi
\lang_basics_synchronize_min_max}
% \unexpanded\def\nohyphens % % % % % not clever, we still hyphenate but supress application
% {\ifx\dohyphens\relax
% \unexpanded\edef\dohyphens
% {\hyphenpenalty \the\hyphenpenalty
% \exhyphenpenalty\the\exhyphenpenalty
% \relax}%
% \fi
% \hyphenpenalty \plustenthousand
% \exhyphenpenalty\plustenthousand}
\unexpanded\def\nohyphens % nicer for url's
{\ifx\dohyphens\relax
\unexpanded\edef\dohyphens
{\hyphenminoffset\the\hyphenminoffset\relax
\lang_basics_synchronize_min_max}%
\fi
\hyphenminoffset\plusthousand
\lang_basics_synchronize_min_max}
\let\dohyphens\relax
\unexpanded\def\lang_basics_synchronize_min_max % maybe store this at the lua end
{% these values are stored along with glyph nodes
\lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin +\hyphenminoffset\relax
\righthyphenmin\numexpr0\languageparameter\s!righthyphenmin+\hyphenminoffset\relax
\hyphenationmin\numexpr0\languageparameter\s!hyphenmin\relax
% these values are stored with the language (global!)
\prehyphenchar \languageparameter\s!righthyphenchar\relax
\posthyphenchar\languageparameter\s!lefthyphenchar \relax}
\appendtoks
\lang_basics_synchronize_min_max
\to \everylanguage
\unexpanded\def\unhyphenated
{\groupedcommand{\lefthyphenmin\maxdimen}\donothing}
% \appendtoks
% \setups[\languageparameter\c!setups]%
% \to \everylanguage
%D You can setup the 'default' language to reset settings.
\appendtoks
\edef\currentlanguagesetups{\languageparameter\c!setups}%
\ifx\currentlanguagesetups\empty \else
\setups[\currentlanguagesetups]%
\fi
\to \everylanguage
% this will move to core-spa !
\appendtoks
\doifelse{\languageparameter\c!spacing}\v!broad\nonfrenchspacing\frenchspacing
\to \everylanguage
% \mainlanguage[nl] \setuplanguage[nl][lefthyphen=,righthyphen=?]
%
% \dorecurse{100}{dit is toch wel een heel\normalhyphendiscretionary lang\normalhyphendiscretionary woord \recurselevel\ }
% \dorecurse{100}{dit is toch wel een heellangwoord \recurselevel\ }
% new experimental feature
\unexpanded\def\setuplanguages
{\setuplanguage[\s!default]}
% \setuplanguages[\s!font=\v!auto]
% \setuplanguage[\s!default][\s!font=\v!auto]
% \setuplanguage[nl][\s!font=\v!auto]
\ifdefined\feature \else \let\feature\gobbleoneargument \fi
\appendtoks
\edef\p_language_font{\languageparameter\s!font}%
\ifx\p_language_font\v!auto
\doaddfeature\currentlanguage
\fi
\to \everylanguage
% The following may be a solution for the fact that one cannot
% change catcodes of characters like : and ; inside an environment.
% we will also permit access by the other names
%D Fast switcher
\def\lang_basics_switch_asked
{\ifcsname\??languagelinked\askedlanguage\endcsname
\edef\askedlanguage{\lastnamedcs}%
\ifx\currentlanguage\askedlanguage \else
\setcurrentlanguage\currentmainlanguage\askedlanguage
\lang_basics_synchronize
\fi
\fi}
\unexpanded\def\uselanguageparameter#1%
{\edef\askedlanguage{#1\c!language}%
\ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
\unexpanded\def\douselanguageparameter#1% fast setter
{\edef\askedlanguage{#1}%
\ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
\unexpanded\def\lang_basics_set_current[#1]%
{\edef\askedlanguage{#1}%
\ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
\unexpanded\def\language
{\doifelsenextoptionalcs\lang_basics_set_current\normallanguage}
\let\setlanguage\language % we make these synonyms
\let\patterns\gobbleoneargument
\newcount\mainlanguagenumber
% \unexpanded\def\mainlanguage[#1]%
% {\edef\askedlanguage{#1}%
% \ifx\askedlanguage\empty \else
% \ifcsname\??languagelinked\askedlanguage\endcsname
% \edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}%
% \ifx\currentlanguage\askedlanguage
% \ifx\currentmainlanguage\askedlanguage \else
% \setcurrentlanguage\askedlanguage\askedlanguage
% \lang_basics_synchronize
% \fi
% \else
% \setcurrentlanguage\askedlanguage\askedlanguage
% \lang_basics_synchronize
% \fi
% \fi
% \fi
% \mainlanguagenumber\normallanguage}
\unexpanded\def\mainlanguage[#1]%
{\edef\askedlanguage{#1}%
\ifx\askedlanguage\empty \else
\ifcsname\??languagelinked\askedlanguage\endcsname
%\edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}%
\edef\askedlanguage{\lastnamedcs}%
\ifx\currentlanguage\askedlanguage
\ifx\currentmainlanguage\askedlanguage \else
\setcurrentlanguage\askedlanguage\askedlanguage
\lang_basics_synchronize
\fi
\else
\setcurrentlanguage\askedlanguage\askedlanguage
\lang_basics_synchronize
\fi
\fi
\fi
\mainlanguagenumber\normallanguage}
\appendtoks
\normallanguage\mainlanguagenumber
\to \everybeforepagebody
%D Used at all?
\def\splitsequence#1#2%
{\doifelse{#1}\v!no{#2}{\doifelse{#1}\v!yes{\languageparameter\c!limittext}{#1}}}
\def\splitsymbol#1%
{\splitsequence{#1}{\languageparameter\c!limittext}}
%D Just like with subsentence boundary symbols, quotes
%D placement depends on the current language, therefore we show
%D the defaults here.
%D
%D \def\ShowLanguageValues [#1] [#2] #3 #4
%D {\blank
%D \startlinecorrection
%D \vbox\bgroup
%D \language[#1]
%D \midaligned{\bf#2 subsentence symbol and quotes}
%D \framed[width=\hsize,frame=off,topframe=on,bottomframe=on,offset=.5ex]
%D {\hfil\quotation{#3 #4}\hfil\quote{#2}\hfil
%D \startsubsentence\startsubsentence#3\stopsubsentence#4\stopsubsentence\hfil}
%D \egroup
%D \stoplinecorrection
%D \blank}
%D
%D \ShowLanguageValues [af] [afrikaans] afrikaanse ...
%D \ShowLanguageValues [ca] [catalan] catalan ...
%D \ShowLanguageValues [cs] [czech] tjechisch tex
%D \ShowLanguageValues [cs] [slovak] slowaakse ...
%D \ShowLanguageValues [da] [danish] deense ...
%D \ShowLanguageValues [de] [german] duitse degelijkheid
%D \ShowLanguageValues [en] [english] engelse humor
%D \ShowLanguageValues [fi] [finnish] finse ...
%D \ShowLanguageValues [fr] [french] franse slag
%D \ShowLanguageValues [it] [italian] italiaanse ...
%D \ShowLanguageValues [la] [latin] latijnse missen
%D \ShowLanguageValues [nl] [dutch] nederlandse zuinigheid
%D \ShowLanguageValues [nb] [bokmal] noorse zalm
%D \ShowLanguageValues [nn] [nnynorsk] noorse zalm
%D \ShowLanguageValues [pl] [polish] poolse vlag
%D \ShowLanguageValues [pt] [portuguese] portugese ...
%D \ShowLanguageValues [es] [spanish] spaans benauwd
%D \ShowLanguageValues [sv] [swedish] zweedse ...
%D \ShowLanguageValues [tr] [turkish] turks fruit
%D We support a lot of languages. These are specified and
%D loaded in separate files, according to their roots. Here
%D we only take care of (postponed) setting of the current
%D language.
%D
%D \unprotect
%D \placetable{The germanic languages (\type{lang-ger})}
%D \starttable[||||]
%D \HL
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
%D \HL
%D \NC \s!nl \NC dutch \NC germanic \NC\FR
%D \NC \s!en \NC english \NC germanic \NC\MR
%D \NC \s!de \NC german \NC germanic \NC\MR
%D \NC \s!da \NC danish \NC germanic \NC\MR
%D \NC \s!sv \NC swedish \NC germanic \NC\MR
%D \NC \s!af \NC afrikaans \NC germanic \NC\MR
%D \NC \s!nb \NC bokmal \NC germanic \NC\LR
%D \NC \s!nn \NC nynorsk \NC germanic \NC\LR
%D \HL
%D \stoptable
%D \protect
%D
%D \unprotect
%D \placetable{The italic languages (\type{lang-ita})}
%D \starttable[||||]
%D \HL
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
%D \HL
%D \NC \s!fr \NC french \NC italic \NC\FR
%D \NC \s!ca \NC catalan \NC italic \NC\MR
%D \NC \s!es \NC spanish \NC italic \NC\MR
%D \NC \s!it \NC italian \NC italic \NC\MR
%D \NC \s!la \NC latin \NC italic \NC\MR
%D \NC \s!pt \NC portuguese \NC italic \NC\LR
%D \HL
%D \stoptable
%D \protect
%D
%D \unprotect
%D \placetable{The slavic languages (\type{lang-sla})}
%D \starttable[||||]
%D \HL
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
%D \HL
%D \NC \s!pl \NC polish \NC slavic \NC\FR
%D \NC \s!cs \NC czech \NC slavic \NC\MR
%D \NC \s!sk \NC slavik \NC slavic \NC\LR
%D \HL
%D \stoptable
%D \protect
%D \unprotect
%D
%D \placetable{The altaic languages (\type{lang-alt})}
%D \starttable[||||]
%D \HL
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
%D \HL
%D \NC \s!tr \NC turkish \NC altaic \NC\SR
%D \HL
%D \stoptable
%D
%D \placetable{The uralic languages (\type{lang-ura})}
%D \starttable[||||]
%D \HL
%D \NC \bf mnemonic \NC \bf language \NC \bf group \NC\SR
%D \HL
%D \NC \s!fi \NC finnish \NC uralic \NC\SR
%D \HL
%D \stoptable
%D \protect
\unexpanded\def\nopatterns{\normallanguage\minusone}
%D We default to the language belonging to the interface. This
%D is one of the few places outside the interface modules where
%D \type{\startinterface} is used.
\setupcurrentlanguage[\s!en]
\unexpanded\def\initializemainlanguage
{\mainlanguage[\currentlanguage]%
\showmessage\m!languages9\currentlanguage}
%D New:
\let\stopexceptions\relax
\unexpanded\def\startexceptions
{\dosingleempty\lang_basics_start_exceptions}
\def\lang_basics_start_exceptions[#1]#2\stopexceptions % multilingual or not?
{\begingroup
\edef\askedlanguage{\reallanguagetag{#1}}%
\ifx\askedlanguage\empty
\let\askedlanguage\currentlanguage
\fi
\clf_setlanguageexceptions{\askedlanguage}{#2}%
\endgroup}
\unexpanded\def\hyphenation
{\clf_setlanguageexceptions{\currentlanguage}}
%D For the moment here:
\uchyph 1 % also treat uppercase
\exhyphenchar 45 % to permit breaking at explicit hyphens
%D New:
\unexpanded\def\traceddiscretionary#1#2#3%
{\dontleavehmode
\discretionary{\darkred#1}{\darkgreen#2}{\darkblue#3}}
\unexpanded\def\samplediscretionary
{\traceddiscretionary
{pre\clf_currentprehyphenchar}%
{\clf_currentposthyphenchar post}%
{replace}}
% todo: make this configurable
\protect \endinput
|