1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21\writestatus{loading}{ConTeXt Language Macros Initialization}
22
23\registerctxluafile{langini}{autosuffix}
24\registerctxluafile{langdef}{}
25\registerctxluafile{langcnt}{}
26
27\unprotect
28
29\ifdefined\nonfrenchspacing\else \let\nonfrenchspacing\relax \fi
30\ifdefined\frenchspacing \else \let\frenchspacing \relax \fi
31
32
33
34
35
36
37
38
39
40
41
42\normallanguage\zerocount
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61\mutable\lettonothing\askedlanguage
62\mutable\lettonothing\currentlanguage
63\mutable\lettonothing\currentmainlanguage
64
65
66
67
68
69
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
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 {\cdef\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
140 {\edef\p_askedlanguage{#1}
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176\newtoks \everysetuplanguage
177
178\aliased\let\installedlanguages\clf_installedlanguages
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
193
194\mutable\lettonothing\currentsetuplanguage
195
196\permanent\tolerant\protected\def\installlanguage[#1]#*[#S#2]
197 {\ifhastok={#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 \cdef\currentsetuplanguage{#1}
204 \clf_definelanguage{#1}{\specificlanguageparameter{#1}\s!default}
205 \expand\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!define}\v!no\orelse\ifcsname#1\endcsname\else
214 \frozen\instance\protected\defcsname#1\endcsname{\lang_basics_set_current[#2]}
215 \fi}
216
217
218
219
220
221\permanent\protected\def\doifelsepatterns#1
222 {\begingroup
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
233
234
235
236
237
238
239
240
241\ifdefined\lang_basics_synchronize \else
242 \let\lang_basics_synchronize\relax
243\fi
244
245\installmacrostack\currentlanguage
246
247\permanent\tolerant\protected\def\setuplanguage[#S#1]#*[#S#2]
248 {\ifarguments
249
250 \or
251 \let\currentsetuplanguage\currentlanguage
252 \getparameters[\??language\currentsetuplanguage][#1]
253 \expand\everysetuplanguage
254 \or
255 \push_macro_currentlanguage
256 \cdef\currentsetuplanguage{\reallanguagetag{#1}}
257 \getparameters[\??language\currentsetuplanguage][#2]
258 \expand\everysetuplanguage
259 \pop_macro_currentlanguage
260 \fi
261 \lang_basics_synchronize}
262
263\appendtoks
264 \clf_unloadlanguage{\currentsetuplanguage}
265\to \everysetuplanguage
266
267\setuplanguage
268 [\s!default]
269 [\s!patterns=,
270 \s!goodies=,
271 \s!lefthyphenmin=2,
272 \s!righthyphenmin=2,
273 \s!lefthyphenchar=1,
274 \s!righthyphenchar=45,
275 \s!explicitlefthyphenchar=\languageparameter\s!lefthyphenchar,
276 \s!explicitrighthyphenchar=\languageparameter\s!righthyphenchar,
277
278 \c!lefthyphen=,
279 \c!righthyphen=,
280 \c!hyphen=,
281 \c!spacing=\v!packed,
282 \c!compoundhyphen=\compoundhyphen,
283 \c!rightcompoundhyphen=\compoundhyphen,
284 \c!leftcompoundhyphen=,
285 \c!midsentence=,
286 \c!leftsentence=,
287 \c!rightsentence=,
288 \c!leftsubsentence=,
289 \c!rightsubsentence=,
290 \c!leftquote=\upperleftsinglesixquote,
291 \c!rightquote=\upperrightsingleninequote,
292 \c!leftquotation=\upperleftdoublesixquote,
293 \c!rightquotation=\upperrightdoubleninequote,
294 \c!leftspeech=\languageparameter\c!leftquotation,
295 \c!middlespeech=,
296 \c!rightspeech=\languageparameter\c!rightquotation,
297 \c!limittext=\unknown,
298 \c!time={h,:,m},
299 \c!date={\v!year,\ ,\v!month,\ ,\v!day},
300 \c!text=Ag,
301 \c!font=]
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320\permanent\def\currentdatespecification{\languageparameter\c!date}
321\permanent\def\currenttimespecification{\languageparameter\c!time}
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\newtoks \everylanguage
358
359\installcorenamespace{languagenumbers}
360
361\appendtoks
362
363
364 \gletcsname\??languagenumbers\currentlanguage\endcsname\undefined
365\to \everysetuplanguage
366
367\def\lang_basics_synchronize_yes
368 {\zerocount
369 \global\expandafter\chardef\csname\??languagenumbers\currentlanguage\endcsname
370 \clf_languagenumber
371 {\currentlanguage}
372 {\defaultlanguage\currentlanguage}
373 {\languageparameter\s!patterns}
374 {\languageparameter\s!goodies}
375 {\languageparameter\c!factor}
376 \relax
377 \normallanguage\csname\??languagenumbers\currentlanguage\endcsname}
378
379\let\lang_basics_synchronize_nop\zerocount
380
381\letcsname\??languagenumbers\endcsname\lang_basics_synchronize_nop
382
383\appendtoks
384 \letcsname\??languagenumbers\endcsname\lang_basics_synchronize_yes
385\to \everydump
386
387\def\lang_basics_synchronize
388 {\normallanguage\csname\??languagenumbers
389 \ifcsname\??languagenumbers\currentlanguage\endcsname
390 \currentlanguage
391 \fi
392 \endcsname
393 \relax
394 \expand\everylanguage
395 \relax}
396
397\newinteger\hyphenstate
398\newinteger\hyphenminoffset
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418\exhyphenchar 45
419
420
421
422
423\permanent \integerdef \completehyphenationcode \numexpr
424 \normalhyphenationcode
425 \automatichyphenationcode
426 \explicithyphenationcode
427 \syllablehyphenationcode
428 \uppercasehyphenationcode
429 \compoundhyphenationcode
430
431
432 \automaticpenaltyhyphenationcode
433 \explicitpenaltyhyphenationcode
434 \permitgluehyphenationcode
435 \permitallhyphenationcode
436 \permitmathreplacehyphenationcode
437 \forcehandlerhyphenationcode
438 \feedbackcompoundhyphenationcode
439 \ignoreboundshyphenationcode
440 \collapsehyphenationcode
441\relax
442
443\permanent \integerdef \partialhyphenationcode \numexpr
444 \ignoreboundshyphenationcode
445
446 \collapsehyphenationcode
447\relax
448
449\hccode"002D "002D
450\hccode"00B7 "00B7
451
452\permanent\protected\def\keephyphensequences
453 {\hccode"2010 \zerocount
454 \hccode"2013 \zerocount
455 \hccode"2014 \zerocount}
456
457\permanent\protected\def\collapsehyphensequences
458 {\hccode"2010 "2010\relax
459 \hccode"2013 "2013\relax
460 \hccode"2014 "2014\relax}
461
462\collapsehyphensequences
463
464
465
466\permanent\protected\def\dohyphens{\hyphenationmode\completehyphenationcode}
467\permanent\protected\def\nohyphens{\hyphenationmode\partialhyphenationcode}
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483\permanent\protected\def\dohyphencollapsing{\hyphenationmode\bitwiseflip\hyphenationmode \collapsehyphenationcode}
484\permanent\protected\def\nohyphencollapsing{\hyphenationmode\bitwiseflip\hyphenationmode\collapsehyphenationcode}
485
486\permanent\protected\def\doexplicithyphens{\hyphenationmode\bitwiseflip\hyphenationmode \explicithyphenationcode}
487\permanent\protected\def\noexplicithyphens{\hyphenationmode\bitwiseflip\hyphenationmode\explicithyphenationcode}
488
489\permanent\protected\def\usehyphensparameter#1
490 {\ifcstok{#1\c!hyphens}\v!no
491 \ifbitwiseand\hyphenationmode\collapsehyphenationcode
492 \nohyphens
493 \else
494 \nohyphens
495 \nohyphencollapsing
496 \fi
497 \fi}
498
499\dohyphens
500
501
502
503\permanent\protected\def\lesshyphens
504 {\advanceby\hyphenminoffset\plusone
505 \lang_basics_synchronize_min_max}
506
507\permanent\protected\def\morehyphens
508 {\ifcase\hyphenminoffset \else
509 \advanceby\hyphenminoffset\minusone
510 \fi
511 \lang_basics_synchronize_min_max}
512
513
514
515
516
517
518
519
520
521
522\protected\def\lang_basics_synchronize_min_max
523 {
524 \lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin \hyphenminoffset\relax
525 \righthyphenmin\numexpr0\languageparameter\s!righthyphenmin\hyphenminoffset\relax
526 \hyphenationmin\numexpr0\languageparameter\s!hyphenmin\relax
527
528 \prehyphenchar \languageparameter\s!righthyphenchar\relax
529 \posthyphenchar \languageparameter\s!lefthyphenchar \relax
530 \preexhyphenchar \languageparameter\s!explicitrighthyphenchar\relax
531 \postexhyphenchar\languageparameter\s!explicitlefthyphenchar \relax}
532
533\appendtoks
534 \lang_basics_synchronize_min_max
535\to \everylanguage
536
537\permanent\protected\def\unhyphenated
538 {\groupedcommand{\lefthyphenmin\maxdimen}\donothing}
539
540
541
542
543
544
545
546\mutable\lettonothing\currentlanguagesetups
547
548\appendtoks
549 \edef\currentlanguagesetups{\languageparameter\c!setups}
550 \ifempty\currentlanguagesetups \else
551 \setups[\currentlanguagesetups]
552 \fi
553\to \everylanguage
554
555
556
557\appendtoks
558 \usebidiparameter\languageparameter
559\to \everylanguage
560
561
562
563\appendtoks
564 \ifcstok{\languageparameter\c!spacing}\v!broad
565 \nonfrenchspacing
566 \else
567 \frenchspacing
568 \fi
569\to \everylanguage
570
571
572
573
574
575
576
577
578\permanent\protected\def\setuplanguages
579 {\setuplanguage[\s!default]}
580
581
582
583
584
585\appendtoks
586 \edef\p_language_font{\languageparameter\c!font}
587 \ifempty\p_language_font
588 \orelse\ifx\p_language_font\v!auto
589 \doaddfeature\currentlanguage
590 \else
591 \doaddfeature\p_language_font
592 \fi
593\to \everylanguage
594
595
596
597\def\lang_basics_switch_asked
598 {\ifcsname\??languagelinked\askedlanguage\endcsname
599 \edef\askedlanguage{\lastnamedcs}
600 \ifx\currentlanguage\askedlanguage \else
601 \setcurrentlanguage\currentmainlanguage\askedlanguage
602 \lang_basics_synchronize
603 \fi
604 \fi}
605
606\permanent\protected\def\uselanguageparameter#1
607 {\edef\askedlanguage{#1\c!language}
608 \ifempty\askedlanguage\else\lang_basics_switch_asked\fi}
609
610\permanent\protected\def\douselanguageparameter#1
611 {\edef\askedlanguage{#1}
612 \ifempty\askedlanguage\else\lang_basics_switch_asked\fi}
613
614\protected\def\lang_basics_set_current[#1]
615 {\edef\askedlanguage{#1}
616 \ifempty\askedlanguage\else\lang_basics_switch_asked\fi}
617
618\pushoverloadmode
619
620 \permanent\protected\def\language
621 {\doifelsenextoptionalcs\lang_basics_set_current\normallanguage}
622
623 \aliased\let\setlanguage\language
624
625 \aliased\let\patterns\gobbleoneargument
626
627\popoverloadmode
628
629\newinteger\mainlanguagenumber
630
631
632
633
634\permanent\protected\def\startlanguage
635 {\begingroup\language}
636
637\permanent\let\stoplanguage\endgroup
638
639\permanent\protected\def\mainlanguage[#1]
640 {\edef\askedlanguage{#1}
641 \ifempty\askedlanguage
642 \orelse\ifcsname\??languagelinked\askedlanguage\endcsname
643
644 \edef\askedlanguage{\lastnamedcs}
645 \ifx\currentlanguage\askedlanguage
646 \ifx\currentmainlanguage\askedlanguage \else
647 \setcurrentlanguage\askedlanguage\askedlanguage
648 \lang_basics_synchronize
649 \fi
650 \else
651 \setcurrentlanguage\askedlanguage\askedlanguage
652 \lang_basics_synchronize
653 \fi
654 \fi
655 \mainlanguagenumber\normallanguage}
656
657\appendtoks
658 \normallanguage\mainlanguagenumber
659\to \everybeforepagebody
660
661
662
663\permanent\def\splitsequence#1#2
664 {\ifcstok{#1}\v!no
665 #2
666 \orelse\ifcstok{#1}\v!yes
667 \languageparameter\c!limittext
668 \else
669 #1
670 \fi}
671
672\permanent\def\splitsymbol#1
673 {\splitsequence{#1}{\languageparameter\c!limittext}}
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\permanent\protected\def\nopatterns{\normallanguage\minusone}
784
785
786
787
788\setupcurrentlanguage[\s!en]
789
790\permanent\protected\def\initializemainlanguage
791 {\mainlanguage[\currentlanguage]
792 \showmessage\m!languages9\currentlanguage}
793
794
795
796\permanent\let\stopexceptions\relax
797
798\tolerant\permanent\protected\def\startexceptions[#1]#:#2\stopexceptions
799 {\begingroup
800 \edef\askedlanguage{\reallanguagetag{#1}}
801 \ifempty\askedlanguage
802 \let\askedlanguage\currentlanguage
803 \fi
804 \clf_setlanguageexceptions{\askedlanguage}{#2}
805 \endgroup}
806
807\permanent\let\stoppatterns\relax
808
809\tolerant\permanent\protected\def\startpatterns[#1]#:#2\stoppatterns
810 {\begingroup
811 \edef\askedlanguage{\reallanguagetag{#1}}
812 \ifempty\askedlanguage
813 \let\askedlanguage\currentlanguage
814 \fi
815 \clf_setlanguagepatterns{\askedlanguage}{#2}
816 \endgroup}
817
818
819\pushoverloadmode
820
821\permanent\protected\def\hyphenation{\clf_setlanguageexceptions{\currentlanguage}}
822\permanent\protected\def\patterns {\clf_setlanguagepatterns {\currentlanguage}}
823
824\popoverloadmode
825
826
827
828\permanent\protected\def\traceddiscretionary#1#
829 {\dontleavehmode\lang_basics_traced_discretionary{#1}}
830
831\protected\def\lang_basics_traced_discretionary#1#2#3#4
832 {\normaldiscretionary#1{\darkred#2}{\darkgreen#3}{\darkblue#4}}
833
834\def\lang_basics_trace_discretionary_yes{\enforced\let\discretionary\traceddiscretionary}
835\def\lang_basics_trace_discretionary_nop{\enforced\let\discretionary\normaldiscretionary}
836
837
838\installtextracker
839 {discretionaries}
840 {\lang_basics_trace_discretionary_yes}
841 {\lang_basics_trace_discretionary_nop}
842
843\permanent\protected\def\samplediscretionary
844 {\traceddiscretionary
845 {pre\clf_currentprehyphenchar}
846 {\clf_currentposthyphenchar post}
847 {replace}}
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862\immutable\integerdef\nokerningcode \numexpr\noleftkernglyphoptioncode \norightkernglyphoptioncode \relax
863\immutable\integerdef\noligaturingcode\numexpr\noleftligatureglyphoptioncode \norightligatureglyphoptioncode \relax
864\immutable\integerdef\noitalicscode \numexpr\noitaliccorrectionglyphoptioncode\nozeroitaliccorrectionglyphoptioncode\relax
865
866\permanent\protected\def\nokerning {\bitwiseflip\glyphoptions\nokerningcode}
867\permanent\protected\def\noligaturing {\bitwiseflip\glyphoptions\noligaturingcode}
868\permanent\protected\def\noitaliccorrection{\bitwiseflip\glyphoptions\noitalicscode}
869
870\permanent\protected\def\noleftkerning {\bitwiseflip\glyphoptions\noleftkernglyphoptioncode}
871\permanent\protected\def\noleftligaturing {\bitwiseflip\glyphoptions\noleftligatureglyphoptioncode}
872\permanent\protected\def\norightkerning {\bitwiseflip\glyphoptions\norightkernglyphoptioncode}
873\permanent\protected\def\norightligaturing {\bitwiseflip\glyphoptions\norightligatureglyphoptioncode}
874
875\bitwiseflip\glyphoptions\nozeroitaliccorrectionglyphoptioncode
876
877
878
879
880
881
882
883\permanent\let\stoplanguageoptions\relax
884
885\permanent\protected\def\startlanguageoptions
886 {\begingroup
887 \catcode\othercatcode
888 \lang_startlanguageoptions}
889
890\tolerant\def\lang_startlanguageoptions[#1]#:#2\stoplanguageoptions
891 {\edef\askedlanguage{\reallanguagetag{#1}}
892 \ifempty\askedlanguage
893 \let\askedlanguage\currentlanguage
894 \fi
895 \clf_setlanguageoptions{\askedlanguage}{#2}
896 \endgroup}
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914\protect \endinput
915 |