Debian Codegraph @

texmf-dist/tex/optex/base/languages.opm

raw
1 %% This is part of the OpTeX project, see http://petr.olsak.net/optex
2
3 \_codedecl \_mtext {Languages <2026-05-17>} % preloaded in format
4
5 \_doc -----------------------------
6 Four words are generated by \OpTeX/ macros: \"Chapter",
7 \"Table", \"Figure" and \"Subject". These phrases are generated depending
8 on the current value of the `\language` register, if you use \`\_mtext``{<phrase-id>}`,
9 specially `\_mtext{chap}`, `\_mtext{t}`, `\_mtext{f}` or `\_mtext{subj}`.
10 If your macros generate more words then
11 you can define such words by `\sdef{_mt:<phrase-id>:<lang-tag>}` where
12 `<phrase-id>` is a label for the declared word and `<lang-tag>` is a language shortcut
13 declared by \~`\_preplang`.
14 \_cod -----------------------------
15
16 \_def\_mtext#1{\_trycs{_mt:#1:\_trycs{_lan:\_the\_language}{en}}
17 {\_csname _mt:#1:en\_endcsname}}
18
19 \_doc -----------------------------
20 We can declare such language-dependent words by
21 \begtt
22 \_sdef{_mt:chap:en}{Chapter} \_sdef{_mt:chap:cs}{Kapitola}
23 \_sdef{_mt:t:en}{Table} \_sdef{_mt:t:cs}{Tabulka}
24 \endtt
25 etc. but we use more \"compact" macro
26 \`\_langw` `<lang-tag> <chapter> <table> <figure> <subject>`
27 for declaring them.
28 \_cod -----------------------------
29
30 \_def \_langw #1 #2 #3 #4 #5 {%
31 \_sdef{_mt:chap:#1}{#2}\_sdef{_mt:t:#1}{#3}\_sdef{_mt:f:#1}{#4}%
32 \_sdef{_mt:subj:#1}{#5}%
33 }
34
35 \_doc -----------------------------
36 More phrases are auto-generated in bibliography references. They are declared by\nl
37 \`\_langb` `<lang-tag> {<and>} {<et-al>} {<ed>} {<cit>} {<vol>} {<no>} {<pp>} {<p>} {<ed>} {<eds>}`\nl
38 ` {<avail-from>} {<avali-to>} {<ba-thesis>} {<ma-thesis>} {<phd-thesis>}`.
39 It is used similar way as the \^`\_langw` above. Both these macros are used
40 in `lang-data.opm` file, see the end of section~\ref[langdecl].
41 \_cod -----------------------------
42
43 \_def\_langb#1 #2#3#4#5#6#7#8#9{\_def\_mbib##1##2{\_sdef{_mt:bib.##2:#1}{##1}}%
44 \_mbib{#2}{and}\_mbib{#3}{etal}\_mbib{#4}{edition}\_mbib{#5}{citedate}\_mbib{#6}{volume}%
45 \_mbib{#7}{number}\_mbib{#8}{prepages}\_mbib{#9}{postpages}\_langbA}
46 \_def\_langbA#1#2#3#4#5#6#7{\_mbib{#1}{editor}\_mbib{#2}{editors}\_mbib{#3}{available}%
47 \_mbib{#4}{availablealso}\_mbib{#5}{bachthesis}\_mbib{#6}{masthesis}\_mbib{#7}{phdthesis}}
48
49 \_doc -----------------------------
50 \`\today` macro needs auto-generated words for each name of the month.\nl
51 \`\_monthw` `<lang-tag> <January> <February> ... <December>` is used for
52 decaring them.\nl
53 The language-dependent format for printing date should be declared like
54 \begtt
55 \_sdef{_mt:today:en}{\_mtext{m\_the\_month} \_the\_day, \_the\_year}
56 \endtt
57 This example declares date format for English where <lang-tag> is `en`.
58 \_cod -----------------------------
59
60 \_def \_monthw #1 #2 #3 #4 #5 #6 #7 {%
61 \_sdef{_mt:m1:#1}{#2}\_sdef{_mt:m2:#1}{#3}\_sdef{_mt:m3:#1}{#4}%
62 \_sdef{_mt:m4:#1}{#5}\_sdef{_mt:m5:#1}{#6}\_sdef{_mt:m6:#1}{#7}%
63 \_monthwB #1
64 }
65 \_def \_monthwB #1 #2 #3 #4 #5 #6 #7 {%
66 \_sdef{_mt:m7:#1}{#2}\_sdef{_mt:m8:#1}{#3}\_sdef{_mt:m9:#1}{#4}%
67 \_sdef{_mt:m10:#1}{#5}\_sdef{_mt:m11:#1}{#6}\_sdef{_mt:m12:#1}{#7}%
68 }
69 \_def\_today{\_mtext{today}}
70 \_public \today ;
71
72 \_doc -----------------------------
73 Quotes should be tagged by `\"<text>"` and `\'<text>'` if `\<iso-code>quotes`
74 is declared at beginning of the document (for example `\enquotes`).
75 If not, then the control
76 sequences `\"` and `\'` are undefined. Remember, that they are used in
77 another meaning when the `\oldaccents` command is used.
78 The macros `\"` and `\'` are not defined as `\protected` because we need
79 their expansion when `\outlines` are created.
80 User can declare quotes by \^`\quoteschars``<clqq><crqq><clq><crq>`, where
81 `<clqq>...<crqq>` are normal quotes and `<clq>...<crq>` are alternative quotes.
82 or use \`\altquotes` to swap between the meaning of these two types of quotes.
83 \`\enquotes`, \`\csquotes`, \`\frquotes`, \`\dequotes`, \`\skquotes` are defined here.
84 Languages in general provide the \`\quotes` declaration macro. It declares the
85 quotation marks depending on the actual selected language. For example,
86 `\eslang \quotes` declares Spanish language including its quotation marks
87 used for `\"<text>"` and `\'<text>'`. The language-dependent quotation
88 marks should be declared by \`\_quotationmarks` `<lang-tag> {<clqq><crqq><clq><crq>}`
89 in the `lang-data.opm` file.
90 \_cod -----------------------------
91
92 \_def \_enquotes {\_quoteschars “”‘’}
93 \_def \_csquotes {\_quoteschars „“‚‘}
94 \_def \_frquotes {\_quoteschars \_flqq\_frqq\_flq\_frq}
95 \_let \_dequotes = \_csquotes
96 \_let \_skquotes = \_csquotes
97
98 \_def \_quotes {\_trycs{_qt:\_trycs{_lan:\_the\_language}{en}}{\_enquotes}}
99 \_def \_quotationmarks #1 #2{\_sdef{_qt:#1}{\_quoteschars #2}}
100
101 \_public \quotes \enquotes \csquotes \frquotes \dequotes \skquotes ;
102
103 \_doc -----------------------------
104 The \`\quoteschars``<lqq><rqq><lq><rq>` defines `\"` and `\"` as `\_qqA`
105 in normal mode and as expadable macros in outline mode.
106 We want to well process the common cases: \code{\\"`&`"} or \code{\\"`\{`"}.
107 This is the reason why the quotes parameter is read in verbatim mode and retokenized
108 again by `\scantextokens`. We want to allow to quote the quotes mark
109 itself by \code{\\"{`"`}"}. This is the reason why the sub-verbatim mode is
110 used when the first character is \code{\{} in the parameter.\nl
111 The `\"` is defined as `\_qqA\_qqB<lqq><rqq>` and `\'` as `\_qqA\_qqC<lq><rq>`.
112 The \`\_qqA``\_qqB<clqq><crqq>` runs \`\_qqB``<lqq><rqq><text>"`.\nl
113 The \`\_regquotes``\""<L><R>` does `\def\"#1"{<L>#1<R>}` for outlines but the `"`
114 separator is active (because `"` and `'` are active in \^`\pdfunidef`).
115 \_cod -----------------------------
116
117 \_def \_quoteschars #1#2#3#4{\_def\_altquotes{\_quoteschars#3#4#1#2}\_public\altquotes;%
118 \_protected\_def \"{\_qqA\_qqB#1#2}\_protected\_def \'{\_qqA\_qqC#3#4}%
119 \_regmacro{}{}{\_regquotes\""#1#2\_regquotes\''#3#4}}
120
121 \_def\_qqA#1#2#3{\_bgroup\_setverb \_catcode`\ =10
122 \_isnextchar\_bgroup{\_catcode`\{=1 \_catcode`\}=2 #1#2#3}{#1#2#3}}
123 \_def\_qqB#1#2#3"{\_egroup#1\_scantextokens{#3}#2}
124 \_def\_qqC#1#2#3'{\_egroup#1\_scantextokens{#3}#2}
125 \_def\_regquotes#1#2#3#4{\_bgroup \_lccode`~=`#2\_lowercase{\_egroup \_def#1##1~}{#3##1#4}}
126
127 \_doc -----------------------------
128 Sometimes should be usable to leave the markup `"such"` or `'such'` i.e.~without
129 the first backslash. Then you can make the characters `"` and `'` active
130 by the \`\activequotes` macro and leave quotes without the first backslash.
131 First, declare `\<iso-code>quotes`, then \^`\altquotes` (if needed) and finally
132 \^`\activequotes`.
133 \_cod -----------------------------
134
135 \_def\_activequotes{\_let\_actqq=\"\_adef"{\_actqq}\_let\_actq=\'\_adef'{\_actq}%
136 \_regmacro{}{}{\_adef"{\"}\_adef'{\'}}}
137
138 \_public \quoteschars \activequotes ;
139
140 \_endcode % -------------------------------------
141
142 2026-05-17 \frquotes redefined
143 2022-11-18 \"..." are not \long now
144 2022-02-19 \quotes, \_quotationmarks introduced
145 2022-02-04 \_langinput, words-lan.opm introduced
146 2021-05-23 \_monthw: bug fix
147 2021-01-21 more robust quotes in outlines
148 2020-12-05 bib phrases moved here
149 2020-04-29 Obrazek -> Abbildung: bug fixed
150 2020-03-15 introduced