diff options
Diffstat (limited to 'Master/texmf-dist/tex/optex/base/hyphen-lan.opm')
-rw-r--r-- | Master/texmf-dist/tex/optex/base/hyphen-lan.opm | 245 |
1 files changed, 245 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/optex/base/hyphen-lan.opm b/Master/texmf-dist/tex/optex/base/hyphen-lan.opm new file mode 100644 index 00000000000..dad0b26657e --- /dev/null +++ b/Master/texmf-dist/tex/optex/base/hyphen-lan.opm @@ -0,0 +1,245 @@ +%% This is part of the 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 an 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 the 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 the 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 +\_def\enlang{\_enlang} +\_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> <hyph-file-spec> <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 <hyph-file-spec> <number> <long-lang> % 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` and + \^`\_uselang` first (in initialization state) and it runs + only \^`\_uselang` when it is called again (in processing state). + \_cod ----------------------------- + +\_def\_preplang #1 #2 #3 #4 #5 {% + \_ea\_chardef \_csname _#1Patt\_endcsname=#4 + \_sdef{_lan:#4}{#1}\_lowercase{\_sdef{_ulan:#2}}{#1}% + \_def\_next{\_ea\_noexpand\_csname _#1lang\_endcsname}% + \_ea\_edef \_csname _#1lang\_endcsname {% + \_noexpand\_loadpattrs #3 #4 #2 % loads patterns + \_gdef\_next{\_noexpand\_uselang{#1}\_csname _#1Patt\_endcsname #5}% re-defines itself + \_next % runs itself in processing state + } + \_addto\_langlist{ #1(#2)}% + \_sdef{#1lang\_ea}\_ea{\_csname _#1lang\_endcsname}% unprefixed \<isocode>lang +} + + \_doc ----------------------------- + \`\_loadpattrs` `<hyph-file-spec> <number> <long-lang>` + loads hyphenation patterns and hyphenation exceptions for given language + and registers them as `\language=<number>`. + + The <hyph-file-spec> is a part of full file name wich is read: + `hyph-<hyph-file-spec>.tex`. The patterns and hyphenation exceptions + are saved here in UTF-8 encoding. + The <hyph-file-spec> should be a list of individual <hyph-file-spec>'s + separated by commas, see the language Serbian below for an example. + \_cod ----------------------------- + +\_def\_loadpattrs#1 #2 #3 {% + \_wlog{Loading hyphenation #3: (#1) \_string\language=#2}% + \_begingroup\_setbox0=\_vbox{% we don't want spaces in horizontal mode + \_language=#2\_def\\{#3}% + \_let\patterns=\_patterns \_let\hyphenation=\_hyphenation \_def\message##1{}% + \_loadpattrsA #1,,% + }\_endgroup +} +\_def\_loadpattrsA #1,{\_ifx,#1,\_else + \_isfile {hyph-#1}\_iftrue \_opinput{hyph-#1}% + \_else \_opwarning{No hyph. patterns #1 for \\, missing package?}% + \_def\_opwarning##1{}\_fi + \_ea \_loadpattrsA \_fi +} + + \_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 by 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 en-us 100 23 +\_preplang engb UKenglish en-gb 101 23 +\_preplang it Italian it 102 22 +\_preplang ia Interlingua ia 103 22 +\_preplang id Indonesian id 104 22 + +\_preplang cs Czech cs 115 23 +\_preplang sk Slovak sk 116 23 +\_preplang de nGerman de-1996 121 22 +\_preplang fr French fr 122 22 +\_preplang pl Polish pl 123 22 +\_preplang cy Welsh cy 124 23 +\_preplang da Danish da 125 22 +\_preplang es Spanish es 126 22 +\_preplang sl Slovenian sl 128 22 +\_preplang fi Finnish fi 129 22 +\_preplang hu Hungarian hu 130 22 +\_preplang tr Turkish tr 131 22 +\_preplang et Estonian et 132 23 +\_preplang eu Basque eu 133 22 +\_preplang ga Irish ga 134 23 +\_preplang nb Bokmal nb 135 22 +\_preplang nn Nynorsk nn 136 22 +\_preplang nl Dutch nl 137 22 +\_preplang pt Portuguese pt 138 23 +\_preplang ro Romanian ro 139 22 +\_preplang hr Croatian hr 140 22 +\_preplang zh Pinyin zh-latn-pinyin 141 11 +\_preplang is Icelandic is 142 22 +\_preplang hsb Uppersorbian hsb 143 22 +\_preplang af Afrikaans af 144 12 +\_preplang gl Galician gl 145 22 +\_preplang kmr Kurmanji kmr 146 22 +\_preplang tk Turkmen tk 147 22 +\_preplang la Latin la 148 22 +\_preplang lac classicLatin la-x-classic 149 22 +\_preplang lal liturgicalLatin la-x-liturgic 150 22 +\_preplang elm monoGreek el-monoton 201 11 +\_preplang elp Greek el-polyton 202 11 +\_preplang grc ancientGreek grc 203 11 +\_preplang ca Catalan ca 204 22 +\_preplang cop Coptic cop 205 11 +\_preplang mn Mongolian mn-cyrl 206 22 +\_preplang sa Sanskrit sa 207 13 +\_preplang ru Russian ru 208 22 +\_preplang uk Ukrainian uk 209 22 +\_preplang hy Armenian hy 210 12 +\_preplang as Assamese as 211 11 +\_preplang hi Hindi hi 212 11 +\_preplang kn Kannada kn 213 11 +\_preplang lv Latvian lv 215 22 +\_preplang lt Lithuanian lt 216 22 +\_preplang ml Malayalam ml 217 11 +\_preplang mr Marathi mr 218 11 +\_preplang or Oriya or 219 11 +\_preplang pa Panjabi pa 220 11 +\_preplang ta Tamil ta 221 11 +\_preplang te Telugu te 222 11 + +\_preplang be Belarusian be 223 22 +\_preplang bg Bulgarian bg 224 22 +\_preplang bn Bengali bn 225 11 +\_preplang cu churchslavonic cu 226 12 +\_preplang deo oldGerman de-1901 227 22 +\_preplang gsw swissGerman de-ch-1901 228 22 +\_preplang eo Esperanto eo 229 22 +\_preplang fur Friulan fur 230 22 +\_preplang gu Gujarati gu 231 11 +\_preplang ka Georgian ka 232 12 +\_preplang mk Macedonian mk 233 22 +\_preplang oc Occitan oc 234 22 +\_preplang pi Pali pi 235 12 +\_preplang pms Piedmontese pms 236 22 +\_preplang rm Romansh rm 237 22 +\_preplang sr Serbian sh-cyrl,sh-latn 238 22 +\_preplang sv Swedish sv 239 22 +\_preplang th Thai th 240 23 +\_preplang ethi Ethiopic mul-ethi 241 11 + + \_doc ----------------------------- + The \`\langlist` includes names of all languages which are ready to load + and use their hyphenation patterns. This list is printed to the terminal and + to log at ini\TeX/ state here. It can be used when processing documents 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 just switching +hyphenation patterns. For example, you need to load a specific font with a +specific script used in the selected language, you can define 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 set language-specific phrases (like `\today`) +by this code. Another concept is used for such tasks. See the +section~\ref[langphrases] for more details. |