1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23\writestatus{loading}{ConTeXt Language Macros Initialization}
24
25\registerctxluafile{langini}{}
26\registerctxluafile{langdef}{}
27\registerctxluafile{langcnt}{}
28
29\unprotect
30
31\ifdefined\nonfrenchspacing\else \let\nonfrenchspacing\relax \fi
32\ifdefined\frenchspacing \else \let\frenchspacing \relax \fi
33
34
35
36
37
38
39
40
41
42
43
44\normallanguage\zerocount \def\loadedlanguage{1}
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63\let\currentlanguage \empty
64\let\currentmainlanguage\empty
65
66
67
68
69
70
71
72\installcorenamespace{language}
73\installcorenamespace{languagelinked}
74
75\def\currentusedlanguage{\currentlanguage}
76
77\def\defaultlanguage#1
78 {\ifcsname\??language#1\s!default\endcsname
79 \expandafter\defaultlanguage\lastnamedcs
80 \else
81 #1
82 \fi}
83
84\def\languageparameter#1
85 {\ifcsname\??language\currentlanguage#1\endcsname
86 \lastnamedcs
87 \else\ifcsname\??language\currentlanguage\s!default\endcsname
88 \expandafter\specificlanguageparameter\lastnamedcs{#1}
89 \else\ifcsname\??language\s!default#1\endcsname
90 \lastnamedcs
91 \fi\fi\fi}
92
93\def\specificlanguageparameter#1#2
94 {\ifcsname\??language#1#2\endcsname
95 \lastnamedcs
96 \else\ifcsname\??language#1\s!default\endcsname
97 \expandafter\specificlanguageparameter\lastnamedcs{#2}
98 \else\ifcsname\??language\s!default#2\endcsname
99 \lastnamedcs
100 \fi\fi\fi}
101
102\def\mainlanguageparameter#1
103 {\ifcsname\??language\currentmainlanguage#1\endcsname
104 \lastnamedcs
105 \else\ifcsname\??language\currentmainlanguage\s!default\endcsname
106 \expandafter\specificlanguageparameter\lastnamedcs{#1}
107 \else\ifcsname\??language\s!default#1\endcsname
108 \lastnamedcs
109 \fi\fi\fi}
110
111\let\usedlanguageparameter\languageparameter
112
113\def\askedlanguageparameter#1
114 {\ifcsname\??language\currentusedlanguage#1\endcsname
115 \lastnamedcs
116 \else\ifcsname\??language\currentusedlanguage\s!default\endcsname
117 \expandafter\specificlanguageparameter\lastnamedcs{#1}
118 \else\ifcsname\??language\s!default#1\endcsname
119 \lastnamedcs
120 \fi\fi\fi}
121
122\unexpanded\def\setusedlanguage#1
123 {\edef\currentusedlanguage{\reallanguagetag{#1}}
124 \ifx\currentusedlanguage\empty
125 \let\currentusedlanguage \currentlanguage
126 \let\usedlanguageparameter\languageparameter
127 \else\ifx\currentusedlanguage\v!global
128 \let\currentusedlanguage \currentmainlanguage
129 \let\usedlanguageparameter\mainlanguageparameter
130 \else\ifx\currentusedlanguage\v!local
131 \let\currentusedlanguage \currentlanguage
132 \let\usedlanguageparameter\languageparameter
133 \else
134 \let\usedlanguageparameter\askedlanguageparameter
135 \fi\fi\fi}
136
137\unexpanded\def\setupcurrentlanguage[#1]
138 {\setcurrentlanguage\currentmainlanguage{#1}}
139
140\unexpanded\def\setcurrentlanguage#1#2
141 {\edef\xaskedlanguage{#1}
142 \ifx\xaskedlanguage\empty \else
143 \ifx\currentmainlanguage\empty\else\resetsystemmode{\systemmodeprefix\currentmainlanguage}\fi
144 \let\currentmainlanguage\xaskedlanguage
145 \setsystemmode{\systemmodeprefix\currentmainlanguage}
146 \fi
147 \edef\xaskedlanguage{#2}
148 \ifx\xaskedlanguage\empty \else
149 \ifx\currentlanguage\empty\else\resetsystemmode\currentlanguage\fi
150 \let\currentlanguage\xaskedlanguage
151 \setsystemmode\currentlanguage
152 \fi}
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\newtoks \everysetuplanguage
178
179\def\installedlanguages{\clf_installedlanguages}
180
181\unexpanded\def\doifelselanguage#1
182 {\ifcsname\??language#1\c!state\endcsname
183 \expandafter\firstoftwoarguments
184 \else
185 \expandafter\secondoftwoarguments
186 \fi}
187
188\let\doiflanguageelse\doifelselanguage
189
190\def\reallanguagetag#1
191 {\ifcsname\??languagelinked#1\endcsname\lastnamedcs\else#1\fi}
192
193
194
195\unexpanded\def\installlanguage
196 {\dodoubleargument\lang_basics_install}
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212\def\lang_basics_install[#1][#2]
213 {\ifcondition\validassignment{#2}
214 \doifelselanguage{#1}
215 {\getparameters[\??language#1][#2]}
216 {\setvalue{\??languagelinked#1}{#1}
217 \lang_basics_install_indeed{#1}{#1}
218 \getparameters[\??language#1][\c!state=\v!start,#2]}
219 \edef\currentsetuplanguage{#1}
220 \clf_definelanguage{#1}{\specificlanguageparameter{#1}\s!default}
221 \the\everysetuplanguage
222 \else
223 \setvalue{\??languagelinked#1}{#2}
224 \clf_setlanguagesynonym{#1}{#2}
225 \lang_basics_install_indeed{#1}{#2}
226 \fi}
227
228\def\lang_basics_install_indeed#1#2
229 {\ifcsname#1\endcsname\else\setuvalue{#1}{\lang_basics_set_current[#2]}\fi}
230
231
232
233
234
235\unexpanded\def\doifelsepatterns#1
236 {\begingroup
237 \lang_basics_set_current[#1]
238 \ifnum\normallanguage>\zerocount
239 \endgroup\expandafter\firstoftwoarguments
240 \else
241 \endgroup\expandafter\secondoftwoarguments
242 \fi}
243
244\let\doifpatternselse\doifelsepatterns
245
246
247
248
249
250
251
252
253
254
255\unexpanded\def\setuplanguage
256 {\dodoubleempty\lang_basics_setup}
257
258\ifdefined\lang_basics_synchronize \else
259 \let\lang_basics_synchronize\relax
260\fi
261
262\installmacrostack\currentlanguage
263
264\def\lang_basics_setup[#1][#2]
265 {\ifsecondargument
266 \push_macro_currentlanguage
267 \edef\currentsetuplanguage{\reallanguagetag{#1}}
268 \getparameters[\??language\currentsetuplanguage][#2]
269 \the\everysetuplanguage
270 \pop_macro_currentlanguage
271
272 \else
273 \let\currentsetuplanguage\currentlanguage
274 \getparameters[\??language\currentsetuplanguage][#1]
275 \the\everysetuplanguage
276 \fi
277 \lang_basics_synchronize}
278
279\appendtoks
280 \clf_unloadlanguage{\currentsetuplanguage}
281\to \everysetuplanguage
282
283\setuplanguage
284 [\s!default]
285 [\s!patterns=,
286 \s!lefthyphenmin=2,
287 \s!righthyphenmin=2,
288 \s!lefthyphenchar=1,
289 \s!righthyphenchar=45,
290 \s!explicitlefthyphenchar=\languageparameter\s!lefthyphenchar,
291 \s!explicitrighthyphenchar=\languageparameter\s!righthyphenchar,
292
293 \c!lefthyphen=,
294 \c!righthyphen=,
295 \c!hyphen=,
296 \c!spacing=\v!packed,
297 \c!compoundhyphen=\compoundhyphen,
298 \c!rightcompoundhyphen=\compoundhyphen,
299 \c!leftcompoundhyphen=,
300 \c!midsentence=,
301 \c!leftsentence=,
302 \c!rightsentence=,
303 \c!leftsubsentence=,
304 \c!rightsubsentence=,
305 \c!leftquote=\upperleftsinglesixquote,
306 \c!rightquote=\upperrightsingleninequote,
307 \c!leftquotation=\upperleftdoublesixquote,
308 \c!rightquotation=\upperrightdoubleninequote,
309 \c!leftspeech=\languageparameter\c!leftquotation,
310 \c!middlespeech=,
311 \c!rightspeech=\languageparameter\c!rightquotation,
312 \c!limittext=\unknown,
313 \c!time={h,:,m},
314 \c!date={\v!year,\ ,\v!month,\ ,\v!day},
315 \c!text=Ag,
316 \c!font=]
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335\def\currentdatespecification{\languageparameter\c!date}
336\def\currenttimespecification{\languageparameter\c!time}
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\newtoks \everylanguage
373
374\installcorenamespace{languagenumbers}
375
376\appendtoks
377
378
379 \expandafter\glet\csname\??languagenumbers\currentlanguage\endcsname\undefined
380\to \everysetuplanguage
381
382\def\lang_basics_synchronize_yes
383 {\zerocount
384 \global\expandafter\chardef\csname\??languagenumbers\currentlanguage\endcsname
385 \clf_languagenumber
386 {\currentlanguage}
387 {\defaultlanguage\currentlanguage}
388 {\languageparameter\s!patterns}
389 {\languageparameter\c!factor}
390 \relax
391 \normallanguage\csname\??languagenumbers\currentlanguage\endcsname}
392
393\let\lang_basics_synchronize_nop\zerocount
394
395\letvalue{\??languagenumbers}\lang_basics_synchronize_nop
396
397\appendtoks
398 \letvalue{\??languagenumbers}\lang_basics_synchronize_yes
399\to \everydump
400
401\def\lang_basics_synchronize
402 {\normallanguage\csname\??languagenumbers
403 \ifcsname\??languagenumbers\currentlanguage\endcsname
404 \currentlanguage
405 \fi
406 \endcsname
407 \relax
408 \the\everylanguage
409 \relax}
410
411\newcount\hyphenstate
412\newcount\hyphenminoffset
413
414\unexpanded\def\lesshyphens
415 {\advance\hyphenminoffset\plusone
416 \lang_basics_synchronize_min_max}
417
418\unexpanded\def\morehyphens
419 {\ifcase\hyphenminoffset \else
420 \advance\hyphenminoffset\minusone
421 \fi
422 \lang_basics_synchronize_min_max}
423
424\unexpanded\def\nohyphens
425 {\ifx\dohyphens\relax
426 \unexpanded\edef\dohyphens
427 {\hyphenminoffset\the\hyphenminoffset\relax
428 \lang_basics_synchronize_min_max}
429 \fi
430 \hyphenminoffset\plusthousand
431 \lang_basics_synchronize_min_max}
432
433\let\dohyphens\relax
434
435\unexpanded\def\usehyphensparameter#1
436 {\edef\p_hyphens{#1\c!hyphens}
437 \ifx\p_hyhens\v!no
438 \nohyphens
439 \fi}
440
441\unexpanded\def\lang_basics_synchronize_min_max
442 {
443 \lefthyphenmin \numexpr0\languageparameter\s!lefthyphenmin \hyphenminoffset\relax
444 \righthyphenmin\numexpr0\languageparameter\s!righthyphenmin\hyphenminoffset\relax
445 \hyphenationmin\numexpr0\languageparameter\s!hyphenmin\relax
446
447 \prehyphenchar \languageparameter\s!righthyphenchar\relax
448 \posthyphenchar \languageparameter\s!lefthyphenchar \relax
449 \preexhyphenchar \languageparameter\s!explicitrighthyphenchar\relax
450 \postexhyphenchar\languageparameter\s!explicitlefthyphenchar \relax}
451
452\appendtoks
453 \lang_basics_synchronize_min_max
454\to \everylanguage
455
456\unexpanded\def\unhyphenated
457 {\groupedcommand{\lefthyphenmin\maxdimen}\donothing}
458
459
460
461
462
463
464
465\appendtoks
466 \edef\currentlanguagesetups{\languageparameter\c!setups}
467 \ifx\currentlanguagesetups\empty \else
468 \setups[\currentlanguagesetups]
469 \fi
470\to \everylanguage
471
472
473
474\appendtoks
475 \usebidiparameter\languageparameter
476\to \everylanguage
477
478
479
480\appendtoks
481 \edef\p_spacing{\languageparameter\c!spacing}
482 \ifx\p_spacing\v!broad
483 \nonfrenchspacing
484 \else
485 \frenchspacing
486 \fi
487\to \everylanguage
488
489
490
491
492
493
494
495
496\unexpanded\def\setuplanguages
497 {\setuplanguage[\s!default]}
498
499
500
501
502
503\appendtoks
504 \edef\p_language_font{\languageparameter\c!font}
505 \ifx\p_language_font\empty\else
506 \ifx\p_language_font\v!auto
507 \doaddfeature\currentlanguage
508 \else
509 \doaddfeature\p_language_font
510 \fi
511 \fi
512\to \everylanguage
513
514
515
516\def\lang_basics_switch_asked
517 {\ifcsname\??languagelinked\askedlanguage\endcsname
518 \edef\askedlanguage{\lastnamedcs}
519 \ifx\currentlanguage\askedlanguage \else
520 \setcurrentlanguage\currentmainlanguage\askedlanguage
521 \lang_basics_synchronize
522 \fi
523 \fi}
524
525\unexpanded\def\uselanguageparameter#1
526 {\edef\askedlanguage{#1\c!language}
527 \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
528
529\unexpanded\def\douselanguageparameter#1
530 {\edef\askedlanguage{#1}
531 \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
532
533\unexpanded\def\lang_basics_set_current[#1]
534 {\edef\askedlanguage{#1}
535 \ifx\askedlanguage\empty\else\lang_basics_switch_asked\fi}
536
537\unexpanded\def\language
538 {\doifelsenextoptionalcs\lang_basics_set_current\normallanguage}
539
540\let\setlanguage\language
541
542\let\patterns\gobbleoneargument
543
544\newcount\mainlanguagenumber
545
546
547
548
549\unexpanded\def\startlanguage
550 {\begingroup\language}
551
552\let\stoplanguage\endgroup
553
554\unexpanded\def\mainlanguage[#1]
555 {\edef\askedlanguage{#1}
556 \ifx\askedlanguage\empty \else
557 \ifcsname\??languagelinked\askedlanguage\endcsname
558
559 \edef\askedlanguage{\lastnamedcs}
560 \ifx\currentlanguage\askedlanguage
561 \ifx\currentmainlanguage\askedlanguage \else
562 \setcurrentlanguage\askedlanguage\askedlanguage
563 \lang_basics_synchronize
564 \fi
565 \else
566 \setcurrentlanguage\askedlanguage\askedlanguage
567 \lang_basics_synchronize
568 \fi
569 \fi
570 \fi
571 \mainlanguagenumber\normallanguage}
572
573\appendtoks
574 \normallanguage\mainlanguagenumber
575\to \everybeforepagebody
576
577
578
579\def\splitsequence#1#2
580 {\doifelse{#1}\v!no{#2}{\doifelse{#1}\v!yes{\languageparameter\c!limittext}{#1}}}
581
582\def\splitsymbol#1
583 {\splitsequence{#1}{\languageparameter\c!limittext}}
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\unexpanded\def\nopatterns{\normallanguage\minusone}
694
695
696
697
698\setupcurrentlanguage[\s!en]
699
700\unexpanded\def\initializemainlanguage
701 {\mainlanguage[\currentlanguage]
702 \showmessage\m!languages9\currentlanguage}
703
704
705
706\let\stopexceptions\relax
707
708\unexpanded\def\startexceptions
709 {\dosingleempty\lang_basics_start_exceptions}
710
711\def\lang_basics_start_exceptions[#1]#2\stopexceptions
712 {\begingroup
713 \edef\askedlanguage{\reallanguagetag{#1}}
714 \ifx\askedlanguage\empty
715 \let\askedlanguage\currentlanguage
716 \fi
717 \clf_setlanguageexceptions{\askedlanguage}{#2}
718 \endgroup}
719
720\unexpanded\def\hyphenation
721 {\clf_setlanguageexceptions{\currentlanguage}}
722
723
724
725\uchyph 1
726\exhyphenchar 45
727
728
729
730\unexpanded\def\traceddiscretionary#1#
731 {\dontleavehmode\lang_basics_traced_discretionary{#1}}
732
733\unexpanded\def\lang_basics_traced_discretionary#1#2#3#4
734 {\normaldiscretionary#1{\darkred#2}{\darkgreen#3}{\darkblue#4}}
735
736\installtextracker
737 {discretionaries}
738 {\let\discretionary\traceddiscretionary}
739 {\let\discretionary\normaldiscretionary}
740
741\unexpanded\def\samplediscretionary
742 {\traceddiscretionary
743 {pre\clf_currentprehyphenchar}
744 {\clf_currentposthyphenchar post}
745 {replace}}
746
747\protect \endinput
748 |