summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/optex/hyphen-lan.opm
blob: 94e87503c1c16fccc48fc6283e14d67e0891d4fd (plain)
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
%% This is part of OpTeX project, see http://petr.olsak.net/optex

\_codedecl \langlist {Initialization of hypenation patterns <2020-03-10>} % preloaded in format  

   \_doc -----------------------------
   The <iso-code> means a shortcut of language name (mostly by ISO 639-1).
   The following control sequences are used for language switching:
   \begitems
   * `\_lan:<number>` expands to `<iso-code>` of the language.
     The number is internal number of languages used as a value of
     `\language` register.
   * `\_ulan:<long-lang>` expands to `<iso-code>` too. This is transformation
     from long name of language (lowercase letters) to <iso-code>.
   * `\_<iso-code>Patt` (for example `\_csPatt`) is the language `<number>` declared by `\chardef`.
   * `\<iso-code>lang` 
     (for example \`\enlang`, \`\cslang`, \`\sklang`, \`\delang`, \`\pllang`) 
     is language selector.  It exists in two states
     \begitems
     * Initialization state: when `\<iso-code>lang` is used first then it
       must load the patterns into memory using Lua code. If it is done then 
       the `\<iso-code>lang` re-defines itself to processing state.
     * Processing state: it only sets `\language=\_<iso-code>Patt`, i.e it
       selects the hyphenation patterns. It does a little more
       language-dependent work, as mentioned below.
     \enditems
   * `\_langspecific:<isocode>` is processed by `\<iso-code>lang` and it
     should include language-specific macros declared by user or macro designer.
   \enditems
   The USenglish patters are preloaded first: 
   \_cod -----------------------------

\_chardef\_enPatt=0
\_def\_pattlist{\_enPatt=0}
\_def\_langlist{en(USenglish)}
\_sdef{_lan:0}{en}
\_sdef{_ulan:usenglish}{en}
\_def\enlang{\_uselang{en}\_enPatt23} % \lefthyph=2 \righthyph=3
\_sdef{_langspecific:en}{\_nonfrenchspacing}

\_lefthyphenmin=2 \_righthyphenmin=3 % disallow x- or -xx breaks
\_input hyphen  % en(USenglish) patterns from TeX82

   \_doc -----------------------------
   \`\preplang` `<iso-code> <long-lang> <number-cs> <number> <pre-hyph><post-hyph>`
   prepares the\nl `\<iso-code>lang` to its initialization state. Roughly
   speaking, it does:
   \begtt \catcode`\<=13
   \chardef\_<iso-code>Patt = <number>
   \def\_lan:<number> {<iso-code>}
   \def\_ulan:<long-lang> {<iso-code>}
   \def\_<iso-code>lang {%
      \_loadpattrs <long-lang> <number> % loads patterns using Lua code
      \gdef\_<iso-code>lang {\_uselang{<iso-code>}\_<iso-code>Patt <pre-hyph><post-hyph>}
      \_<iso-code>lang                  % runs itself in processing state
   }
   \def\<iso-code>lang {\_<iso-code>lang} % public version \<iso-code>lang
   \endtt
   You can see that `\<iso-code>lang` runs \`\_loadpattrs` `<long-lang> <iso-code>`
   in initialization state and \^`\_uselang` in processing state.
   \_cod -----------------------------

\_def\_preplang #1 #2 #3#4 #5 {%
   \_chardef#3=#4
   \_sdef{_lan:#4}{#1}\_lowercase{\_sdef{_ulan:#2}}{#1}%  
   \_def\_next{\_ea\_noexpand\_csname _#1lang\_endcsname}
   \_ea\_edef \_csname _#1lang\_endcsname {%
      \_lowercase{\_noexpand\_loadpattrs #2} #4 % loads patterns
      \_gdef\_next{\_noexpand\_uselang{#1}#3#5}%  re-defines itself
      \_next                                   %  runs itself in processing state
   }
   \_addto\_langlist{ #1(#2)}%
   \_sdef{#1lang}{\_csname _#1lang\_endcsname}% unprefixed \<isocode>lang
}
\_def\_loadpattrs#1 #2 {%
   \_directlua{
      require("luatex-hyphen")
      luatexhyphen.loadlanguage("#1",#2)
   }%
}

   \_doc -----------------------------
   \`\_uselang``{<iso-code>}\_<iso-code>Patt <pre-hyph><post-hyph>`\nl 
   sets `\language`, `\lefthyphenmin`, `\righthyphenmin` and runs
   `\frenchspacing`. This default language-dependent settings
   should be re-declared by `\_langspecific:<iso-code>` which is run
   finally (it is `\relax` by default, only `\_langspecific:en` runs
   \^`\nonfrenchspacing`).
   \_cod -----------------------------

\_def\_uselang#1#2#3#4{\_language=#2\_lefthyphenmin=#3\_righthyphenmin=#4\_relax
   \_frenchspacing  % \nonfrenchspacing can be set in \cs{_langspecific:lan}
   \_cs{_langspecific:#1}%
}
   \_doc -----------------------------
   The \`\uselanguage` `{<long-lang>}` is defined here 
   (for compatibility with e-plain users).
   \_cod -----------------------------

\_def\_uselanguage#1{\_lowercase{\_cs{_\_cs{_ulan:#1}lang}}}
\_public \uselanguage ; 

   \_doc -----------------------------
   The numbers for languages are declared as fixed constants (no
   auto-generated). This concept is inspired from CSplain. 
   There are typical numbers of languages in CSplain: 5=Czech in IL2,
   15=Czech in T1 and 115=Czech in Unicode. We keep these constants
   but we load only Unicode patterns (greater than 100), of course.
   \_cod -----------------------------

\_preplang enus USenglishmax \_enusPatt 100 23
\_preplang engb UKenglish    \_engbPatt 101 23
\_preplang it   Italian      \_itPatt 102 22
\_preplang ia   Interlingua  \_iaPatt 103 22
\_preplang id   Indonesian   \_idPatt 104 22

\_preplang cs   Czech      \_csPatt 115 23
\_preplang sk   Slovak     \_skPatt 116 23
\_preplang de   nGerman    \_dePatt 121 22
\_preplang fr   French     \_frPatt 122 22
\_preplang pl   Polish     \_plPatt 123 22 
\_preplang cy   Welsh      \_cyPatt 124 23
\_preplang da   Danish     \_daPatt 125 22
\_preplang es   Spanish    \_esPatt 126 22
\_preplang sl   Slovenian  \_slPatt 128 22
\_preplang fi   Finnish    \_fiPatt 129 22
\_preplang hy   Hungarian  \_huPatt 130 22
\_preplang tr   Turkish    \_trPatt 131 22
\_preplang et   Estoniak   \_etPatt 132 23
\_preplang eu   Basque     \_euPatt 133 22
\_preplang ga   Irish      \_gaPatt 134 23
\_preplang nb   Bokmal     \_nbPatt 135 22
\_preplang nn   Nynorsk    \_nnPatt 136 22
\_preplang nl   Dutch      \_nlPatt 137 22
\_preplang pt   Portuguese \_ptPatt 138 23
\_preplang ro   Romanian   \_roPatt 139 22
\_preplang hr   Croatian   \_hrPatt 140 22
\_preplang zh   Pinyin     \_zhPatt 141 11
\_preplang is   Icelandic  \_isPatt 142 22
\_preplang hsb  Uppersorbian \_hsbPatt 143 22
\_preplang af   Afrikaans  \_afPatt 144 12
\_preplang gl   Galician   \_glPatt 145 22
\_preplang kmr  Kurmanji   \_kmrPatt 146 22
\_preplang tk   Turkmen    \_tkPatt 147 22
\_preplang la   Latin      \_laPatt 148 22
\_preplang lac  classicLatin \_lacPatt 149 22
\_preplang lal  liturgicalLatin \_lalPatt 150 22
\_preplang elm  monoGreek  \_elmPatt 201 11
\_preplang elp  Greek      \_elpPatt 202 11
\_preplang grc  ancientGreek \_grcPatt 203 11
\_preplang ca   Catalan    \_caPatt 204 22
\_preplang cop  Coptic     \_copPatt 205 11
\_preplang mn   Mongolian  \_mnPatt 206 22
\_preplang sa   Sanskrit   \_saPatt 207 13
\_preplang ru   Russian    \_ruPatt 208 22
\_preplang uk   Ukrainian  \_ukPatt 209 22
\_preplang hy   Armenian   \_hyPatt 210 12
\_preplang as   Assamese   \_asPatt 211 11
\_preplang hi   Hindi      \_hiPatt 212 11
\_preplang kn   Kannada    \_knPatt 213 11
\_preplang lv   Latvian    \_lvPatt 215 22
\_preplang lt   Lithuanian \_ltPatt 216 22
\_preplang ml   Malayalam  \_mlPatt 217 11
\_preplang mr   Marathi    \_mrPatt 218 11
\_preplang or   Oriya      \_orPatt 219 11
\_preplang pa   Panjabi    \_paPatt 220 11
\_preplang ta   Tamil      \_taPatt 221 11
\_preplang te   Telugu     \_tePatt 222 11

   \_doc -----------------------------
   The \`\langlist` includes names of all languages which are ready to load
   and use their hyphenation patterns. This list is printed to terminal and
   to log at ini\TeX/ state here. It can be used when processing document too.
   \_cod -----------------------------

\message{Language hyph.patterns ready to load: \_langlist.
   Use \string\<shortname>lang to initialize language,
   \string\cslang\space for example}

\_public \langlist ;

\_endcode % ---------------------------------------------


Maybe, you need to do more language specific actions than only to swich
hyphenation patterns. For example you need to load a specific font with a
specific script used in selected language, you can define a macros for
quotation marks depending on the language etc.

The example shows how to declare such language specific things.

\begtt
\def\langset #1 #2{\sdef{_langspecific:#1}{#2}}

\langset fr {... declare French quotation marks}
\langset de {... declare German quotation marks}
\langset gr {... switch to Greek fonts family}
... etc. 
\endtt

Note that you need not to set language specific phrases (like `\today`) 
by this code. Another concept is used for such tasks. See the 
section~\ref[langphrases] for more details.