Debian Codegraph @

texmf-dist/doc/generic/tracklang/tracklang-manual.tex

raw
1 % arara: lualatex
2 % arara: bib2gls: { group: on, options: [ "--replace-quotes" ] }
3 % arara: lualatex
4 % arara: bib2gls: { group: on, options: [ "--replace-quotes" ] } if found ("log", "Glossary entry `sym.")
5 % arara: lualatex
6 % arara: lualatex if found ("log", "Rerun to")
7
8 \documentclass[titlepage=false,oneside,
9 fontsize=12pt,captions=tableheading]{scrbook}
10
11 \usepackage
12 [
13 floats,
14 %debug=showwrgloss
15 ]
16 {nlctuserguide}
17
18 \usepackage{glossary-table}
19
20 \glsxtrnewgls{opt.envvar.}{\envvar}
21 \defsemanticcmd[style2]{\envvarfmt}{\texttt}{}
22 \defsemanticcmd[style1]{\langtagfmt}{\texttt}{}
23
24 \glsaddstoragekey{dialect}{}{\dialect}
25 \glsaddstoragekey{isotag}{}{\isotag}
26 \glsaddstoragekey{langtag}{}{\langtag}
27 \glsxtrprovidestoragekey{tags}{}{}
28 \glsxtrprovidestoragekey{region}{}{}
29 \glsaddstoragekey{numeric}{}{\numerictag}
30 \glsxtrprovidestoragekey{alpha3}{}{}
31 \glsxtrprovidestoragekey{postname}{}{}
32
33 \newcommand{\optisotag}[1]{\isotag{opt.#1}}
34 \newcommand{\iso}[1]{\glslink{opt.#1}{\optfmt{\optisotag{#1}}}}
35 \newcommand{\numericcode}[1]{\glslink{opt.#1}{\glsxtrusefield{opt.#1}{numeric}}}
36
37 \newcommand{\tklscript}[1]{\glslink{TrackLangScriptCode}{\csfmt{TrackLangScript#1}}}
38 \newcommand{\tklcaptions}[1]{\glslink{captionsdialect}{\csfmt{captions#1}}}
39 \newcommand{\tkldate}[1]{\glslink{datedialect}{\csfmt{date#1}}}
40
41 \newcommand{\ldf}[2]{%
42 \glslink{file.prefix-localeid.ldf}{\filefmt{#1\dhyphen #2.ldf}}}
43 \newcommand{\localefile}[1]{%
44 \glslink{file.prefix-localeid.ldf}{\filemetafmt{#1\dhyphen}{localeid}{.ldf}}}
45 \newcommand{\localemetafile}[1]{%
46 \glslink{file.prefix-localeid.ldf}{\filemetametafmt{}{#1}{\dhyphen}{localeid}{.ldf}}}
47 \newcommand{\localemetametafile}[2]{%
48 \glslink{file.prefix-localeid.ldf}{\filemetametafmt{}{#1}{\dhyphen}{#2}{.ldf}}}
49
50 \newcommand{\fnregion}{\fnsym*{2}}
51
52 \renewcommand{\filetag}[1]{}
53
54 \renewcommand{\nlctuserguidecustomentryaliases}{%
55 bcplangregion=index,
56 rootlang=index,
57 nonbcp=index,
58 isocode=index,
59 region=index,
60 script=index
61 }
62
63 \nlctuserguidegls[selection=all]
64 {
65 \def\genvvar#1#2{%
66 \glsbibwriteentry{option}{opt.envvar.#1}{%
67 \field{name}{\envvarfmt{#1}}\parent{idx.envvar}#2}}%
68 \gidxpl{envvar}{\field{text}{environment variable}}
69 % predefined language-region tags
70 % \gbcplangtag{xx}{XX}{dialect}{options}
71 \def\gbcplangtag#1#2#3#4{%
72 \glsbibwriteentry{bcplangregion}{opt.#1-#2}{%
73 \name{\optfmt{#1-#2}}%
74 \field{langtag}{#1}\field{region}{#2}%
75 \field{isotag}{#1-#2}%
76 \field{dialect}{#3}#4}%
77 }%
78 % \gbcplangtagwithvar{xx}{XX}{variant}{dialect}{options}
79 \def\gbcplangtagwithvar#1#2#3#4#5{%
80 \glsbibwriteentry{bcplangregion}{opt.#1-#2-#3}{%
81 \name{\optfmt{#1-#2-#3}}%
82 \field{langtag}{#1}\field{region}{#2}%
83 \field{isotag}{#1-#2-#3}%
84 \field{dialect}{#4}#5}%
85 }%
86 % predefined root language labels
87 % \grootlangtag{language}{iso tag}{options}
88 \def\grootlangtag#1#2#3{%
89 \glsbibwriteentry{rootlang}{opt.#1}{%
90 \name{\optfmt{#1}}%
91 \field{dialect}{#1}%
92 \field{langtag}{#2}%
93 \field{isotag}{#2}#3}%
94 \glsbibwriteentry{isocode}{opt.#2}{\name{\optfmt{#2}}\field{alias}{opt.#1}}%
95 }%
96 % \grootlangsametag{language}{options}
97 \def\grootlangsametag#1#2{%
98 \glsbibwriteentry{rootlang}{opt.#1}{%
99 \name{\optfmt{#1}}%
100 \field{dialect}{#1}%
101 \field{langtag}{#1}%
102 \field{isotag}{#1}#2}%
103 }%
104 % \grootlangtagwithreg{language}{lang}{region}{options}
105 \def\grootlangtagwithreg#1#2#3#4{%
106 \glsbibwriteentry{rootlang}{opt.#1}{%
107 \field{name}{\optfmt{#1}\fnregion}
108 \field{text}{\optfmt{#1}}
109 \field{region}{#3}
110 \field{dialect}{#1}%
111 \field{langtag}{#2}
112 \field{isotag}{#2-#3}#4}%
113 \glsbibwriteentry{isocode}{opt.#2}{\name{\optfmt{#2}}\field{alias}{opt.#1}}%
114 }
115 % predefined non-iso dialects
116 % \gdialecttag{dialect}{tag}{options}
117 \def\gdialecttag#1#2#3{%
118 \glsbibwriteentry{nonbcp}{opt.#1}{%
119 \name{\optfmt{#1}}%
120 \field{dialect}{#1}%
121 \field{isotag}{\optisotag{#2}}%
122 \field{tags}{\optfmt{\optisotag{#2}}}#3}%
123 }%
124 % \gdialecttagsuppl{dialect}{tag}{suppl}{options}
125 \def\gdialecttagsuppl#1#2#3#4{%
126 \glsbibwriteentry{nonbcp}{opt.#1}{%
127 \name{\optfmt{#1}}%
128 \field{dialect}{#1}%
129 \field{isotag}{\optisotag{#2}-#3}%
130 \field{tags}{\optfmt{\optisotag{#2}-#3}}#4}%
131 }%
132 % \gdialecttagwithmap{dialect}{tag}{mapped}{options}
133 \def\gdialecttagwithmap#1#2#3#4{%
134 \glsbibwriteentry{nonbcp}{opt.#1}{%
135 \field{dialect}{#1}%
136 \field{isotag}{\optisotag{#2}}%
137 \field{tags}{\optfmt{\optisotag{#2}} / \optfmt{#3}}#4}%
138 }%
139 % \gdialecttagsupplwithmap{dialect}{tag}{suppl}{mapped}{options}
140 \def\gdialecttagsupplwithmap#1#2#3#4#5{%
141 \glsbibwriteentry{nonbcp}{opt.#1}{%
142 \name{\optfmt{#1}}%
143 \field{dialect}{#1}%
144 \field{isotag}{\optisotag{#2}-#3}%
145 \field{tags}{\optfmt{\optisotag{#2}-#3} / \opt{#4}}#5}%
146 }%
147 % \gdialecttagwithreg{dialect}{lang}{region}{options}
148 \def\gdialecttagwithreg#1#2#3#4{%
149 \glsbibwriteentry{nonbcp}{opt.#1}{%
150 \field{name}{\optfmt{#1}\fnregion }
151 \field{text}{\optfmt{#1}}
152 \field{region}{#3}
153 \field{dialect}{#1}%
154 \field{isotag}{\langtag{opt.#2}-#3}%
155 \field{tags}{\optfmt{\langtag{opt.#2}-#3}}#4
156 }%
157 }%
158 % \gdialecttagwithmapandreg{dialect}{tag}{region}{mapped}{options}
159 \def\gdialecttagwithmapandreg#1#2#3#4#5{%
160 \glsbibwriteentry{nonbcp}{opt.#1}{%
161 \field{name}{\optfmt{#1}\fnregion }
162 \field{text}{\optfmt{#1}}
163 \field{region}{#3}
164 \field{dialect}{#1}%
165 \field{isotag}{\optisotag{#2}-#3}%
166 \field{tags}{\optfmt{\langtag{opt.#2}-#3} / \opt{#4}}#5}%
167 }%
168 % \gregion{numeric}{2-alpha}{3-alpha}{options}
169 \def\gregion#1#2#3#4{%
170 \glsbibwriteentry{region}{opt.#2}{%
171 \field{name}{\optfmt{#2}}
172 \field{numeric}{#1}\field{alpha3}{#3}
173 #4}%
174 }%
175 % \gscript{alpha}{numeric}{name}{direction}{parent}{options}
176 \def\gscript#1#2#3#4#5#6{%
177 \glsbibwriteentry{script}{opt.#1}{%
178 \field{name}{\optfmt{#1}}
179 \field{numeric}{#2}\field{user2}{#4}\field{description}{#3}
180 #6}%
181 }%
182 % COMMANDS
183 % \AnyTrackedLanguages
184 \gcmd{Any\-Track\-ed\-Lan\-guages}
185 {
186 \providedby{\file{tracklang.tex} v1.0+}
187 \syntax{\margm{true}\margm{false}}
188 \desc{expands to \meta{true} if there are any tracked languages,
189 otherwise expands to \meta{false}}
190 }
191 % \IfTrackedLanguage
192 \gcmd{If\-Track\-ed\-Lan\-guage}
193 {
194 \providedby{\file{tracklang.tex} v1.0+}
195 \syntax{\margm{language-label}\margm{true}\margm{false}}
196 \desc{does \meta{true} if the language identified by
197 \meta{language-label} has been tracked,
198 otherwise does \meta{false}}
199 }
200 % \IfTrackedDialect
201 \gcmd{If\-Track\-ed\-Di\-alect}
202 {
203 \providedby{\file{tracklang.tex} v1.0+}
204 \syntax{\margm{dialect-label}\margm{true}\margm{false}}
205 \desc{does \meta{true} if the dialect identified by
206 \meta{dialect-label} has been tracked,
207 otherwise does \meta{false}}
208 }
209 % \AnyTrackedRegions
210 \gcmd{Any\-Track\-ed\-Regions}
211 {
212 \providedby{\file{tracklang.tex} v1.6.3+}
213 \syntax{\margm{true}\margm{false}}
214 \desc{expands to \meta{true} if there are any tracked regions,
215 otherwise expands to \meta{false}}
216 }
217 % \IfTrackedLanguageFileExists
218 \gcmd{If\-Track\-ed\-Lan\-guage\-File\-Exists}
219 {
220 \providedby{\file{tracklang.tex} v1.0+}
221 \syntax{\margm{dialect}\margm{prefix}\margm{suffix}\margm{true
222 code}\margm{false code}}
223 \desc{does \code{\gls{SetCurrentTrackedDialect}\margm{dialect}}
224 and if the dialect is recognised, then determines if the file
225 \filefmt{\meta{prefix}\meta{tag}\meta{suffix}} exists. If it does,
226 \gls{CurrentTrackedTag} is set to \meta{tag} and \meta{true} is
227 done, otherwise \meta{false} is done}
228 }
229 % \IfTrackedLanguageFileExistsOmitDialectLabel
230 \gcmd{If\-Track\-ed\-Lan\-guage\-File\-Exists\-Omit\-Dialect\-Label}
231 {
232 \providedby{\file{tracklang.tex} v1.6.3+}
233 \syntax{\margm{dialect}\margm{prefix}\margm{suffix}\margm{true
234 code}\margm{false code}}
235 \desc{as \gls{IfTrackedLanguageFileExists} but skips the dialect
236 label check. Note that if the dialect label happens to be the same
237 as the root label, it will still be checked but at the end instead
238 of near the start}
239 }
240 % \IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion
241 \gcmd{If\-Track\-ed\-Lan\-guage\-File\-Exists\-Omit\-Dialect\-Label\-Omit\-Only\-Region}
242 {
243 \providedby{\file{tracklang.tex} v1.6.3+}
244 \syntax{\margm{dialect}\margm{prefix}\margm{suffix}\margm{true
245 code}\margm{false code}}
246 \desc{as \gls{IfTrackedLanguageFileExists} but skips the dialect
247 label check and just the region code check. Note that if the
248 dialect label happens to be the same as the root label, it will
249 still be checked but at the end instead of near the start}
250 }
251 % \IfTrackedLanguageFileExistsOmitOnlyRegion
252 \gcmd{If\-Track\-ed\-Lan\-guage\-File\-Exists\-Omit\-Only\-Region}
253 {
254 \providedby{\file{tracklang.tex} v1.6.3+}
255 \syntax{\margm{dialect}\margm{prefix}\margm{suffix}\margm{true
256 code}\margm{false code}}
257 \desc{as \gls{IfTrackedLanguageFileExists} but skips the solo
258 region code check}
259 }
260 % \CurrentTrackedTag
261 \gcmd{Current\-Track\-ed\-Tag}
262 {
263 \providedby{\file{tracklang.tex} v1.0+}
264 \desc{expands to the current tracked tag}
265 }
266 % \ifTrackLangShowWarnings
267 \gcond{if\-Track\-Lang\-Show\-Warnings}
268 {
269 \initval{\cmd{iftrue}}
270 \providedby{\file{tracklang.tex} v1.3+}
271 \desc{conditional that indicates whether or not to show warnings}
272 }
273 % \TrackLangShowWarningsfalse
274 \gcmd{Track\-Lang\-Show\-Warnings\-false}
275 {
276 \providedby{\file{tracklang.tex} v1.3+}
277 \desc{sets \gls{ifTrackLangShowWarnings} to false}
278 }
279 % \TrackLangShowWarningstrue
280 \gcmd{Track\-Lang\-Show\-Warnings\-true}
281 {
282 \providedby{\file{tracklang.tex} v1.3+}
283 \desc{sets \gls{ifTrackLangShowWarnings} to true}
284 }
285 % \ifTrackLangShowInfo
286 \gcond{if\-Track\-Lang\-Show\-Info}
287 {
288 \initval{\cmd{iftrue}}
289 \providedby{\file{tracklang.tex} v1.3+}
290 \desc{conditional that indicates whether or not to show
291 information messages}
292 }
293 % \ifTrackLangShowVerbose
294 \gcond{if\-Track\-Lang\-Show\-Verbose}
295 {
296 \initval{\cmd{iffalse}}
297 \providedby{\file{tracklang.tex} v1.4+}
298 \desc{conditional that indicates whether or not to show
299 verbose messages}
300 }
301 % \TrackLangQueryEnv
302 \gcmd{Track\-Lang\-Query\-Env}
303 {
304 \providedby{\file{tracklang.tex} v1.3+}
305 \desc{attempts to obtain locale information from the
306 \envvar{LCALL} environment variable via the \idx{shellescape}
307 or, with \LuaTeX, \gls{directlua}}
308 }
309 % \TrackLangQueryOtherEnv
310 \gcmd{Track\-Lang\-Query\-Other\-Env}
311 {
312 \providedby{\file{tracklang.tex} v1.3+}
313 \syntax{\margm{env-name}}
314 \desc{attempts to obtain locale information from the
315 \envvar{LCALL} environment variable and then by the
316 \meta{env-name} environment variable via the \idx{shellescape}
317 or, with \LuaTeX, \gls{directlua}}
318 }
319 % \TrackLangParseFromEnv
320 \gcmd{Track\-Lang\-Parse\-From\-Env}
321 {
322 \providedby{\file{tracklang.tex} v1.3+}
323 \desc{attempts to obtain locale information from the
324 expansion of \gls{TrackLangEnv}}
325 }
326 % \TrackLangEnv
327 \gcmd{Track\-Lang\-Env}
328 {
329 \note{user defined}
330 \desc{may be defined using the same format as \envvar{LCALL}
331 before using \gls{TrackLangParseFromEnv} to skip the environment
332 variable query}
333 }
334 % \TrackLangEnvLang
335 \gcmd{Track\-Lang\-Env\-Lang}
336 {
337 \providedby{\file{tracklang.tex} v1.3+}
338 \desc{set by \gls{TrackLangParseFromEnv} to the language code}
339 }
340 % \TrackLangEnvTerritory
341 \gcmd{Track\-Lang\-Env\-Territory}
342 {
343 \providedby{\file{tracklang.tex} v1.3+}
344 \desc{set by \gls{TrackLangParseFromEnv} to the \idx{territory}}
345 }
346 % \TrackLangEnvCodeSet
347 \gcmd{Track\-Lang\-Env\-Code\-Set}
348 {
349 \providedby{\file{tracklang.tex} v1.3+}
350 \desc{set by \gls{TrackLangParseFromEnv} to the \idx{code-set}}
351 }
352 % \TrackLangEnvModifier
353 \gcmd{Track\-Lang\-Env\-Modifier}
354 {
355 \providedby{\file{tracklang.tex} v1.3+}
356 \desc{set by \gls{TrackLangParseFromEnv} to the \idx{modifier}}
357 }
358 % \ForEachTrackedLanguage
359 \gcmd{For\-Each\-Track\-ed\-Lan\-guage}
360 {
361 \providedby{\file{tracklang.tex} v1.0+}
362 \syntax{\margm{cs}\margm{body}}
363 \desc{iterates through the list of tracked languages. On each
364 iteration \meta{cs} is set to the language tag and \meta{body} is
365 performed}
366 }
367 % \ForEachTrackedDialect
368 \gcmd{For\-Each\-Track\-ed\-Di\-alect}
369 {
370 \providedby{\file{tracklang.tex} v1.0+}
371 \syntax{\margm{cs}\margm{body}}
372 \desc{iterates through the list of tracked dialects. On each
373 iteration \meta{cs} is set to the dialect tag and \meta{body} is
374 performed}
375 }
376 % \ForEachTrackedRegion
377 \gcmd{For\-Each\-Track\-ed\-Region}
378 {
379 \providedby{\file{tracklang.tex} v1.0+}
380 \syntax{\margm{cs}\margm{body}}
381 \desc{iterates through the list of tracked regions. On each
382 iteration \meta{cs} is set to the region code and \meta{body} is
383 performed}
384 }
385 % \TrackLangNewLanguage
386 \gcmd{Track\-Lang\-New\-Lan\-guage}
387 {
388 \providedby{\file{tracklang.tex} v1.3+}
389 \syntax{\margm{language label}\margm{639-1 code}\margm{639-2 (T)}%
390 \margm{639-2 (B)}\margm{639-3}\margm{3166-1}\margm{default script}}
391 \desc{identifies a new language that may be tracked. Apart from
392 \meta{language label}, the other arguments may be empty if
393 the information is unavailable}
394 }
395 % \TrackLangIfKnownLang
396 \gcmd{Track\-Lang\-If\-Known\-Lang}
397 {
398 \providedby{\file{tracklang.tex} v1.3+}
399 \syntax{\margm{language}\margm{true}\margm{false}}
400 \desc{does \meta{true} if \meta{language} is known
401 (but not necessarily tracked), otherwise does \meta{false}}
402 }
403 % \TrackLangIfKnownIsoTwoLetterLang
404 \gcmd{Track\-Lang\-If\-Known\-Iso\-Two\-Letter\-Lang}
405 {
406 \providedby{\file{tracklang.tex} v1.3+}
407 \syntax{\margm{language}\margm{true}\margm{false}}
408 \desc{does \meta{true} if \meta{language} has an \idxn{639-1} code
409 (but is not necessarily tracked), otherwise does \meta{false}}
410 }
411 % \TrackLangGetKnownIsoTwoLetterLang
412 \gcmd{Track\-Lang\-Get\-Known\-Iso\-Two\-Letter\-Lang}
413 {
414 \providedby{\file{tracklang.tex} v1.3+}
415 \syntax{\margm{language}}
416 \desc{expands to the \idxn{639-1} language code associated with
417 \meta{language}}
418 }
419 % \TrackLangIfKnownIsoThreeLetterLang
420 \gcmd{Track\-Lang\-If\-Known\-Iso\-Three\-Letter\-Lang}
421 {
422 \providedby{\file{tracklang.tex} v1.3+}
423 \syntax{\margm{language}\margm{true}\margm{false}}
424 \desc{does \meta{true} if \meta{language} has an \idxn{639-2} code
425 (but is not necessarily tracked), otherwise does \meta{false}}
426 }
427 % \TrackLangGetKnownIsoThreeLetterLang
428 \gcmd{Track\-Lang\-Get\-Known\-Iso\-Three\-Letter\-Lang}
429 {
430 \providedby{\file{tracklang.tex} v1.3+}
431 \syntax{\margm{language}}
432 \desc{expands to the \idxn{639-2} language code associated with
433 \meta{language}}
434 }
435 % \TrackLangIfKnownIsoThreeLetterLangB
436 \gcmd{Track\-Lang\-If\-Known\-Iso\-Three\-Letter\-LangB}
437 {
438 \providedby{\file{tracklang.tex} v1.3+}
439 \syntax{\margm{language}\margm{true}\margm{false}}
440 \desc{does \meta{true} if \meta{language} has an \idxn{639-2B} code
441 (but is not necessarily tracked), otherwise does \meta{false}}
442 }
443 % \TrackLangGetKnownIsoThreeLetterLangB
444 \gcmd{Track\-Lang\-Get\-Known\-Iso\-Three\-Letter\-LangB}
445 {
446 \providedby{\file{tracklang.tex} v1.3+}
447 \syntax{\margm{language}}
448 \desc{expands to the \idxn{639-2B} language code associated with
449 \meta{language}}
450 }
451 % \IfTrackedLanguageHasIsoCode
452 \gcmd{If\-Track\-ed\-Lan\-guage\-Has\-Iso\-Code}
453 {
454 \providedby{\file{tracklang.tex} v1.0+}
455 \syntax{\margm{code type}\margm{label}\margm{true}\margm{false}}
456 \desc{does \meta{true} if the given language or dialect has a
457 corresponding \idx{ISO} code of the given type, otherwise does
458 \meta{false}}
459 }
460 % \IfTrackedIsoCode
461 \gcmd{If\-Track\-ed\-Iso\-Code}
462 {
463 \providedby{\file{tracklang.tex} v1.0+}
464 \syntax{\margm{code type}\margm{code}\margm{true}\margm{false}}
465 \desc{does \meta{true} if the given \idx{ISO} code has been defined
466 otherwise does \meta{false}}
467 }
468 % \TrackLangIfKnownLangFromIso
469 \gcmd{Track\-Lang\-If\-Known\-Lang\-From\-Iso}
470 {
471 \providedby{\file{tracklang.tex} v1.3+}
472 \syntax{\margm{ISO code}\margm{true}\margm{false}}
473 \desc{does \meta{true} if the given language code (\idx{639-1} or
474 \idx{639-2} or \idx{639-3}) is
475 recognised (but not necessarily tracked), otherwise does \meta{false}}
476 }
477 % \TrackLangGetKnownLangFromIso
478 \gcmd{Track\-Lang\-Get\-Known\-Lang\-From\-Iso}
479 {
480 \providedby{\file{tracklang.tex} v1.3+}
481 \syntax{\margm{ISO code}}
482 \desc{expands to the root language label from the
483 given \idx{ISO} code (\idx{639-1} or \idx{639-2} or \idx{639-3})}
484 }
485 % \TrackLangIfHasKnownCountry
486 \gcmd{Track\-Lang\-If\-Has\-Known\-Coun\-try}
487 {
488 \providedby{\file{tracklang.tex} v1.3+}
489 \syntax{\margm{language}\margm{true}\margm{false}}
490 \desc{does \meta{true} if the given language has an \idxn{3166-1}
491 country code (but is not necessarily tracked), otherwise does \meta{false}}
492 }
493 % \TrackLangGetKnownCountry
494 \gcmd{Track\-Lang\-Get\-Known\-Coun\-try}
495 {
496 \providedby{\file{tracklang.tex} v1.3+}
497 \syntax{\margm{language}}
498 \desc{expands to the \idxn{3166-1} country code for the given language}
499 }
500 % \TrackLangGetDefaultScript
501 \gcmd{Track\-Lang\-Get\-Default\-Script}
502 {
503 \providedby{\file{tracklang.tex} v1.3+}
504 \syntax{\margm{language}}
505 \desc{expands to the default script for the given language}
506 }
507 % \TrackLangIfHasDefaultScript
508 \gcmd{Track\-Lang\-If\-Has\-Default\-Script}
509 {
510 \providedby{\file{tracklang.tex} v1.3+}
511 \syntax{\margm{language}\margm{true}\margm{false}}
512 \desc{does \meta{true} if the given language has a default
513 script (but is not necessarily tracked), otherwise does \meta{false}}
514 }
515 % \AddTrackedDialect
516 \gcmd{Add\-Track\-ed\-Di\-alect}
517 {
518 \providedby{\file{tracklang.tex} v1.0+}
519 \syntax{\margm{dialect label}\margm{root language label}}
520 \desc{tracks a dialect. This command defines
521 \gls{TrackLangLastTrackedDialect} to provide a convenient way to
522 reference the last dialect to be tracked}
523 }
524 % \AddTrackedLanguage
525 \gcmd{Add\-Track\-ed\-Lan\-guage}
526 {
527 \providedby{\file{tracklang.tex} v1.0+}
528 \syntax{\margm{root language label}}
529 \desc{shortcut for \code{\gls{AddTrackedDialect}\margm{root language
530 label}\margm{root language label}}}
531 }
532 % \AddTrackedIsoLanguage
533 \gcmd{Add\-Track\-ed\-Iso\-Lan\-guage}
534 {
535 \providedby{\file{tracklang.tex} v1.0+}
536 \syntax{\margm{code type}\margm{code}\margm{language}}
537 \desc{adds a mapping between the given \idx{ISO} code and language name}
538 }
539 % \TrackedLanguageFromIsoCode
540 \gcmd{Tracked\-Lan\-guage\-From\-Iso\-Code}
541 {
542 \providedby{\file{tracklang.tex} v1.0+}
543 \syntax{\margm{code type}\margm{code}}
544 \desc{expands to a comma-separated list of language or
545 dialect labels associated with the given code}
546 }
547 % \TrackedIsoCodeFromLanguage
548 \gcmd{Track\-ed\-Iso\-Code\-From\-Lan\-guage}
549 {
550 \providedby{\file{tracklang.tex} v1.0+}
551 \syntax{\margm{code type}\margm{label}}
552 \desc{expands to the code associated with the given language or
553 dialect identified by \meta{label}}
554 }
555 % \TrackedLanguageFromDialect
556 \gcmd{Track\-ed\-Lan\-guage\-From\-Di\-alect}
557 {
558 \providedby{\file{tracklang.tex} v1.0+}
559 \syntax{\margm{dialect}}
560 \desc{expands to the language from the given dialect}
561 }
562 % \TrackedDialectsFromLanguage
563 \gcmd{Tracked\-Di\-alects\-From\-Lan\-guage}
564 {
565 \providedby{\file{tracklang.tex} v1.0+}
566 \syntax{\margm{root language label}}
567 \desc{expands to a comma-separated list of the tracked dialects with the given language}
568 }
569 % \TwoLetterIsoCountryCode
570 \gcmd{Two\-Letter\-Iso\-Coun\-try\-Code}
571 {
572 \providedby{\file{tracklang.tex} v1.0+}
573 \desc{expands to \idx{3166-1} (should not be redefined)}
574 }
575 % \TwoLetterIsoLanguageCode
576 \gcmd{Two\-Letter\-Iso\-Lan\-guage\-Code}
577 {
578 \providedby{\file{tracklang.tex} v1.0+}
579 \desc{expands to \idx{639-1} (should not be redefined)}
580 }
581 % \ThreeLetterIsoLanguageCode
582 \gcmd{Three\-Letter\-Iso\-Lan\-guage\-Code}
583 {
584 \providedby{\file{tracklang.tex} v1.0+}
585 \desc{expands to \idx{639-2} (should not be redefined)}
586 }
587 % \ThreeLetterExtIsoLanguageCode
588 \gcmd{Three\-Letter\-Ext\-Iso\-Lan\-guage\-Code}
589 {
590 \providedby{\file{tracklang.tex} v1.3+}
591 \desc{expands to \idx{639-3} (should not be redefined)}
592 }
593 % \SetTrackedDialectModifier
594 \gcmd{Set\-Track\-ed\-Di\-alect\-Mod\-i\-fier}
595 {
596 \providedby{\file{tracklang.tex} v1.3+}
597 \syntax{\margm{dialect}\margm{value}}
598 \desc{sets the modifier for the given \meta{dialect} to
599 \meta{value}}
600 }
601 % \GetTrackedDialectModifier
602 \gcmd{Get\-Track\-ed\-Di\-alect\-Mod\-i\-fier}
603 {
604 \providedby{\file{tracklang.tex} v1.3+}
605 \syntax{\margm{dialect}}
606 \desc{expands to the modifier for the given dialect}
607 }
608 % \IfHasTrackedDialectModifier
609 \gcmd{If\-Has\-Track\-ed\-Di\-alect\-Mod\-i\-fier}
610 {
611 \providedby{\file{tracklang.tex} v1.3+}
612 \syntax{\margm{dialect}\margm{true}\margm{false}}
613 \desc{expands to \meta{true} if there's a modifier for the given
614 dialect, otherwise expands to \meta{false}}
615 }
616 % \SetTrackedDialectScript
617 \gcmd{Set\-Track\-ed\-Di\-alect\-Script}
618 {
619 \providedby{\file{tracklang.tex} v1.3+}
620 \syntax{\margm{dialect}\margm{value}}
621 \desc{sets the script for \meta{dialect} to \meta{value}}
622 }
623 % \GetTrackedDialectScript
624 \gcmd{Get\-Track\-ed\-Di\-alect\-Script}
625 {
626 \providedby{\file{tracklang.tex} v1.3+}
627 \syntax{\margm{dialect}}
628 \desc{expands to the script for \meta{dialect}}
629 }
630 % \IfHasTrackedDialectScript
631 \gcmd{If\-Has\-Track\-ed\-Di\-alect\-Script}
632 {
633 \providedby{\file{tracklang.tex} v1.3+}
634 \syntax{\margm{dialect}\margm{true}\margm{false}}
635 \desc{expands to \meta{true} if there's a script for
636 \meta{dialect}, otherwise expands to \meta{false}}
637 }
638 % \IfTrackedDialectIsScriptCs
639 \gcmd{If\-Track\-ed\-Di\-alect\-Is\-Script\-Cs}
640 {
641 \providedby{\file{tracklang.tex} v1.3+}
642 \syntax{\margm{dialect}\margm{cs}\margm{true}\margm{false}}
643 \desc{if the given tracked dialect has an associated script and that
644 script code matches the replacement text for the control sequence
645 \meta{cs} then do \meta{true} otherwise to \meta{false}. If the
646 tracked dialect doesn't have an associated script then the default
647 script for the root language is tested}
648 }
649 % \SetTrackedDialectVariant
650 \gcmd{Set\-Track\-ed\-Di\-alect\-Vari\-ant}
651 {
652 \providedby{\file{tracklang.tex} v1.3+}
653 \syntax{\margm{dialect}\margm{value}}
654 \desc{sets the modifier for \meta{dialect} to \meta{value}}
655 }
656 % \GetTrackedDialectVariant
657 \gcmd{Get\-Track\-ed\-Di\-alect\-Vari\-ant}
658 {
659 \providedby{\file{tracklang.tex} v1.3+}
660 \syntax{\margm{dialect}}
661 \desc{expands to the modifier for \meta{dialect}}
662 }
663 % \IfHasTrackedDialectVariant
664 \gcmd{If\-Has\-Track\-ed\-Di\-alect\-Vari\-ant}
665 {
666 \providedby{\file{tracklang.tex} v1.3+}
667 \syntax{\margm{dialect}\margm{true}\margm{false}}
668 \desc{expands to \meta{true} if there's a modifier for
669 \meta{dialect}, otherwise expands to \meta{false}}
670 }
671 % \SetTrackedDialectSubLang
672 \gcmd{Set\-Track\-ed\-Di\-alect\-Sub\-Lang}
673 {
674 \providedby{\file{tracklang.tex} v1.3+}
675 \syntax{\margm{dialect}\margm{value}}
676 \desc{sets the sub-language for \meta{dialect} to \meta{value}}
677 }
678 % \GetTrackedDialectSubLang
679 \gcmd{Get\-Track\-ed\-Di\-alect\-Sub\-Lang}
680 {
681 \providedby{\file{tracklang.tex} v1.3+}
682 \syntax{\margm{dialect}}
683 \desc{expands to the sub-language for \meta{dialect}}
684 }
685 % \IfHasTrackedDialectSubLang
686 \gcmd{If\-Has\-Track\-ed\-Di\-alect\-Sub\-Lang}
687 {
688 \providedby{\file{tracklang.tex} v1.3+}
689 \syntax{\margm{dialect}\margm{true}\margm{false}}
690 \desc{expands to \meta{true} if there's a sub-language for
691 \meta{dialect}, otherwise expands to \meta{false}}
692 }
693 % \SetTrackedDialectAdditional
694 \gcmd{Set\-Track\-ed\-Di\-alect\-Ad\-di\-tional}
695 {
696 \providedby{\file{tracklang.tex} v1.3+}
697 \syntax{\margm{dialect}\margm{value}}
698 \desc{sets the extra information for \meta{dialect} to \meta{value}}
699 }
700 % \GetTrackedDialectAdditional
701 \gcmd{Get\-Track\-ed\-Di\-alect\-Ad\-di\-tional}
702 {
703 \providedby{\file{tracklang.tex} v1.3+}
704 \syntax{\margm{dialect}}
705 \desc{expands to the extra information for \meta{dialect}}
706 }
707 % \IfHasTrackedDialectAdditional
708 \gcmd{If\-Has\-Track\-ed\-Di\-alect\-Ad\-di\-tional}
709 {
710 \providedby{\file{tracklang.tex} v1.3+}
711 \syntax{\margm{dialect}\margm{true}\margm{false}}
712 \desc{expands to \meta{true} if there's extra information for
713 \meta{dialect}, otherwise expands to \meta{false}}
714 }
715 % \GetTrackedLanguageTag
716 \gcmd{Get\-Track\-ed\-Lan\-guage\-Tag}
717 {
718 \providedby{\file{tracklang.tex} v1.3+}
719 \syntax{\margm{dialect}}
720 \desc{gets the language tag for \meta{dialect}}
721 }
722 % \SetCurrentTrackedDialect
723 \gcmd{Set\-Current\-Track\-ed\-Di\-alect}
724 {
725 \providedby{\file{tracklang.tex} v1.3+}
726 \syntax{\margm{dialect}}
727 \desc{sets the current tracked dialect}
728 }
729 % \CurrentTrackedDialect
730 \gcmd{Current\-Track\-ed\-Dialect}
731 {
732 \providedby{\file{tracklang.tex} v1.3+}
733 \desc{defined by \gls{SetCurrentTrackedDialect} to the
734 dialect label, which may be the supplied \meta{dialect} label
735 or the mapped label or, if \meta{dialect} is a root language label,
736 the last tracked dialect for the given root language}
737 }
738 % \CurrentTrackedLanguage
739 \gcmd{Current\-Track\-ed\-Language}
740 {
741 \providedby{\file{tracklang.tex} v1.3+}
742 \desc{defined by \gls{SetCurrentTrackedDialect} to the
743 associated root language label}
744 }
745 % \CurrentTrackedDialectModifier
746 \gcmd{Current\-Track\-ed\-Di\-alect\-Modifier}
747 {
748 \providedby{\file{tracklang.tex} v1.3+}
749 \desc{defined by \gls{SetCurrentTrackedDialect} to the
750 associated modifier (may be empty)}
751 }
752 % \CurrentTrackedDialectVariant
753 \gcmd{Current\-Track\-ed\-Di\-alect\-Variant}
754 {
755 \providedby{\file{tracklang.tex} v1.3+}
756 \desc{defined by \gls{SetCurrentTrackedDialect} to the
757 associated variant (may be empty)}
758 }
759 % \CurrentTrackedDialectScript
760 \gcmd{Current\-Track\-ed\-Di\-alect\-Script}
761 {
762 \providedby{\file{tracklang.tex} v1.3+}
763 \desc{defined by \gls{SetCurrentTrackedDialect} to the
764 script associated with the dialect, or to the default script for the language}
765 }
766 % \CurrentTrackedDialectSubLang
767 \gcmd{Current\-Track\-ed\-Di\-alect\-Sub\-Lang}
768 {
769 \providedby{\file{tracklang.tex} v1.3+}
770 \desc{defined by \gls{SetCurrentTrackedDialect} to the sub
771 language associated with the dialect (may be empty)}
772 }
773 % \CurrentTrackedDialectAdditional
774 \gcmd{Current\-Track\-ed\-Di\-alect\-Ad\-di\-tional}
775 {
776 \providedby{\file{tracklang.tex} v1.3+}
777 \desc{defined by \gls{SetCurrentTrackedDialect} to the
778 additional part associated with the dialect (may be empty)}
779 }
780 % \CurrentTrackedLanguageTag
781 \gcmd{Current\-Track\-ed\-Lan\-guage\-Tag}
782 {
783 \providedby{\file{tracklang.tex} v1.3+}
784 \desc{defined by \gls{SetCurrentTrackedDialect} to the language
785 tag that identifies the dialect or \iso{undetermined} if no match}
786 }
787 % \CurrentTrackedRegion
788 \gcmd{Current\-Track\-ed\-Region}
789 {
790 \providedby{\file{tracklang.tex} v1.3+}
791 \desc{defined by \gls{SetCurrentTrackedDialect} to the
792 \idxn{3166-1} region code associated with the dialect (may be empty)}
793 }
794 % \CurrentTrackedIsoCode
795 \gcmd{Current\-Track\-ed\-Iso\-Code}
796 {
797 \providedby{\file{tracklang.tex} v1.3+}
798 \desc{defined by \gls{SetCurrentTrackedDialect} to the
799 \idxn{639-1} or \idx{639-2} or \idx{639-3} language code (may be empty)}
800 }
801 % \AddTrackedLanguageIsoCodes
802 \gcmd{Add\-Track\-ed\-Lan\-guage\-Iso\-Codes}
803 {
804 \providedby{\file{tracklang.tex} v1.3+}
805 \syntax{\margm{root language label}}
806 \desc{adds the \idxn{639-1}, \idx{639-2} and \idx{639-3} codes, which must have
807 previously been declared using \gls{TrackLangNewLanguage}}
808 }
809 % \AddTrackedCountryIsoCode
810 \gcmd{Add\-Track\-ed\-Coun\-try\-Iso\-Code}
811 {
812 \providedby{\file{tracklang.tex} v1.3+}
813 \syntax{\margm{language}}
814 \desc{adds the \idxn{3166-1} code}
815 }
816 % \GetTrackedDialectFromLanguageTag
817 \gcmd{Get\-Track\-ed\-Di\-alect\-From\-Lan\-guage\-Tag}
818 {
819 \providedby{\file{tracklang.tex} v1.3+}
820 \syntax{\margm{tag}\margm{cs}}
821 \desc{finds the tracked dialect that matches the given language
822 tag and stores the dialect label in \meta{cs}. If no match found,
823 \meta{cs} will be empty}
824 }
825 % \TrackedDialectClosestSubMatch
826 \gcmd{Track\-ed\-Dialect\-Closest\-Sub\-Match}
827 {
828 \providedby{\file{tracklang.tex} v1.3.6+}
829 \desc{defined by \gls{GetTrackedDialectFromLanguageTag} to the
830 closest match}
831 }
832 % \TrackPredefinedDialect
833 \gcmd{Track\-Pre\-de\-fined\-Di\-alect}
834 {
835 \providedby{\file{tracklang.tex} v1.0+}
836 \syntax{\margm{dialect label}}
837 \desc{tracks a predefined language or dialect}
838 }
839 % \TrackLangIfAlphaNumericChar
840 \gcmd{Track\-Lang\-If\-Alpha\-Numeric\-Char}
841 {
842 \providedby{\file{tracklang.tex} v1.3+}
843 \syntax{\margm{tag}\margm{true}\margm{false}}
844 \desc{does \meta{true} if the argument is a single alphanumeric character
845 otherwise does \meta{false}}
846 }
847 % \TrackLangIfLanguageTag
848 \gcmd{Track\-Lang\-If\-Lan\-guage\-Tag}
849 {
850 \providedby{\file{tracklang.tex} v1.3+}
851 \syntax{\margm{tag}\margm{true}\margm{false}}
852 \desc{does \meta{true} if the argument is a language tag
853 otherwise does \meta{false}}
854 }
855 % \TrackLangIfRegionTag
856 \gcmd{Track\-Lang\-If\-Region\-Tag}
857 {
858 \providedby{\file{tracklang.tex} v1.3+}
859 \syntax{\margm{tag}\margm{true}\margm{false}}
860 \desc{does \meta{true} if the argument is a region tag
861 otherwise does \meta{false}}
862 }
863 % \TrackLangIfScriptTag
864 \gcmd{Track\-Lang\-If\-Script\-Tag}
865 {
866 \providedby{\file{tracklang.tex} v1.3+}
867 \syntax{\margm{tag}\margm{true}\margm{false}}
868 \desc{does \meta{true} if the argument is a script tag
869 otherwise does \meta{false}}
870 }
871 % \TrackLangIfVariantTag
872 \gcmd{Track\-Lang\-If\-Vari\-ant\-Tag}
873 {
874 \providedby{\file{tracklang.tex} v1.3+}
875 \syntax{\margm{tag}\margm{true}\margm{false}}
876 \desc{does \meta{true} if the argument is a variant tag
877 otherwise does \meta{false}}
878 }
879 % \TrackLanguageTag
880 \gcmd{Track\-Lan\-guage\-Tag}
881 {
882 \providedby{\file{tracklang.tex} v1.3+}
883 \syntax{\margm{tag}}
884 \desc{parse \meta{tag}, which should be a regular, well-formed
885 RFC 5646 language tag (not an irregular grandfather tag) and
886 track the dialect. Note that the tag must start with a language
887 identifier and can't simply be a region code}
888 }
889 % \TrackIfKnownLanguage
890 \gcmd{Track\-If\-Known\-Lan\-guage}
891 {
892 \providedby{\file{tracklang.tex} v1.3.9+}
893 \syntax{\margm{tag}\margm{success code}\margm{fail code}}
894 \desc{as \gls{TrackLanguageTag} but does \meta{fail code}
895 if the tag doesn't contain a valid language code. If successful, does
896 \meta{success code} after tracking the language}
897 }
898 % \TrackLangAddExtraRegionFile
899 \gcmd{Track\-Lang\-Add\-Extra\-Region\-File}
900 {
901 \providedby{\file{tracklang.tex} v1.4+}
902 \syntax{\margm{file}}
903 \desc{adds \meta{file} to the list of extra region code files that should
904 be input by \file{tracklang-region-codes.tex}}
905 }
906 % \TrackLangAddExtraScriptFile
907 \gcmd{Track\-Lang\-Add\-Extra\-Script\-File}
908 {
909 \providedby{\file{tracklang.tex} v1.4+}
910 \syntax{\margm{file}}
911 \desc{adds \meta{file} to the list of files that should
912 be input by \file{tracklang-scripts.tex}}
913 }
914 % \TrackLangFromEnv
915 \gcmd{Track\-Lang\-From\-Env}
916 {
917 \providedby{\file{tracklang.tex} v1.3+}
918 \desc{queries environment variable if \gls{TrackLangEnv} not
919 already set, parses \gls{TrackLangEnv} if it has been set, and
920 adds the dialect if it's recognised}
921 }
922 % \TrackLocale
923 \gcmd{Track\-Locale}
924 {
925 \providedby{\file{tracklang.tex} v1.3+}
926 \syntax{\margm{locale}}
927 \desc{tracks the dialect identified by the given \meta{locale}, which
928 may either be a predefined language\slash dialect or in the same format as
929 \gls{TrackLangEnv}}
930 }
931 % \TrackLangProvidePredefinedLanguage
932 \gcmd{Track\-Lang\-Provide\-Pre\-de\-fined\-Lan\-guage}
933 {
934 \providedby{\file{tracklang.tex} v1.4+}
935 \syntax{\margm{language label}}
936 \desc{sets up a language label for use with \gls{TrackPredefinedDialect}}
937 }
938 % \TrackLangDeclareLanguageOption
939 \gcmd{Track\-Lang\-Declare\-Lan\-guage\-Op\-tion}
940 {
941 \providedby{\file{tracklang.tex} v1.3+}
942 \syntax{\margm{language name}\margm{639-1 code}\margm{639-2 (T)}\margm{639-2
943 (B)}\margm{639-3}\margm{3166-1}\margm{default script}}
944 \desc{defines a new root language that's declared as an option}
945 }
946 % \TrackLangProvidePredefinedDialect
947 \gcmd{Track\-Lang\-Provide\-Pre\-de\-fined\-Di\-alect}
948 {
949 \providedby{\file{tracklang.tex} v1.4+}
950 \syntax{\margm{dialect label}\margm{root
951 language label}\margm{3166-1 code}\margm{modifier}\margm{variant}\margm{map}\margm{script}}
952 \desc{defines a predefined dialect label that can be used
953 by \gls{TrackPredefinedDialect}}
954 }
955 % \TrackLangDeclareDialectOption
956 \gcmd{Track\-Lang\-Declare\-Di\-alect\-Op\-tion}
957 {
958 \providedby{\file{tracklang.tex} v1.3+}
959 \syntax{\margm{dialect}\margm{root
960 language}\margm{3166-1
961 code}\margm{modifier}\margm{variant}\margm{map}\margm{script}}
962 \desc{defines a predefined dialect label that can be used
963 by \gls{TrackPredefinedDialect}}
964 }
965 % \TrackLangProvidesResource
966 \gcmd{Track\-Lang\-Provides\-Resource}
967 {
968 \providedby{\file{tracklang.tex} v1.3+}
969 \syntax{\margm{tag}\oargm{version info}}
970 \desc{analogous to \gls{ProvidesFile}}
971 }
972 % \TrackLangEncodingName
973 \gcmd{Track\-Lang\-Encoding\-Name}
974 {
975 \providedby{\file{tracklang.tex} v1.6.1+}
976 \desc{expands to \gls{inputencodingname} if it has been defined
977 or \code{utf8} otherwise}
978 }
979 % \TrackLangAddToHook
980 \gcmd{Track\-Lang\-Add\-To\-Hook}
981 {
982 \providedby{\file{tracklang.tex} v1.3+}
983 \syntax{\margm{code}\margm{type}}
984 \desc{for use within resource files, this can be used to add
985 \meta{code} to the appropriate hook}
986 }
987 % \TrackLangAddToCaptions
988 \gcmd{Track\-Lang\-Add\-To\-Captions}
989 {
990 \providedby{\file{tracklang.tex} v1.3+}
991 \syntax{\margm{code}}
992 \desc{a shortcut that just does
993 \code{\gls{TrackLangAddToHook}\margm{code}\marg{captions}}}
994 }
995 % \TrackLangRedefHook
996 \gcmd{Track\-Lang\-Re\-def\-Hook}
997 {
998 \providedby{\file{tracklang.tex} v1.4+}
999 \syntax{\margm{code}\margm{type}}
1000 \desc{similar to \gls{TrackLangAddToHook} but redefines the hook
1001 rather than appending to it}
1002 }
1003 % \TrackLangRequireResource
1004 \gcmd{Track\-Lang\-Require\-Resource}
1005 {
1006 \providedby{\file{tracklang.tex} v1.3+}
1007 \syntax{\margm{tag}}
1008 \desc{loads the appropriate \ext{ldf} file if it hasn't already
1009 been loaded}
1010 }
1011 % \TrackLangRequireResourceOrDo
1012 \gcmd{Track\-Lang\-Require\-Resource\-Or\-Do}
1013 {
1014 \providedby{\file{tracklang.tex} v1.3+}
1015 \syntax{\margm{tag}\margm{code1}\margm{code2}}
1016 \desc{as \gls{TrackLangRequireResource} but does \meta{code1}
1017 if the file is now loaded or \meta{code2}
1018 if the file has already been loaded}
1019 }
1020 % \TrackLangRequestResource
1021 \gcmd{Track\-Lang\-Request\-Resource}
1022 {
1023 \providedby{\file{tracklang.tex} v1.3+}
1024 \syntax{\margm{tag}\margm{not found code}}
1025 \desc{as \gls{TrackLangRequireResource} but does \meta{not found code}
1026 if the file doesn't exist}
1027 }
1028 % \TrackLangRequireDialect
1029 \gcmd{Track\-Lang\-Require\-Di\-alect}
1030 {
1031 \providedby{\file{tracklang.tex} v1.3+}
1032 \syntax{\oargm{load code}\margm{pkgname}\margm{dialect}}
1033 \desc{loads the dialect for the given package using
1034 \gls{IfTrackedLanguageFileExists}}
1035 }
1036 % \TrackLangRequireDialectOmitDialectLabel
1037 \gcmd{Track\-Lang\-Require\-Di\-alect\-Omit\-Di\-alect\-Label}
1038 {
1039 \providedby{\file{tracklang.tex} v1.3+}
1040 \syntax{\oargm{load code}\margm{pkgname}\margm{dialect}}
1041 \desc{loads the dialect for the given package using
1042 \gls{IfTrackedLanguageFileExistsOmitDialectLabel}}
1043 }
1044 % \TrackLangRequireDialectOmitDialectLabelOmitOnlyRegion
1045 \gcmd{Track\-Lang\-Require\-Di\-alect\-Omit\-Di\-alect\-Label\-Omit\-Only\-Region}
1046 {
1047 \providedby{\file{tracklang.tex} v1.3+}
1048 \syntax{\oargm{load code}\margm{pkgname}\margm{dialect}}
1049 \desc{loads the dialect for the given package using
1050 \gls{IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion}}
1051 }
1052 % \TrackLangRequireDialectOmitOnlyRegion
1053 \gcmd{Track\-Lang\-Require\-Di\-alect\-Omit\-Only\-Region}
1054 {
1055 \providedby{\file{tracklang.tex} v1.3+}
1056 \syntax{\oargm{load code}\margm{pkgname}\margm{dialect}}
1057 \desc{loads the dialect for the given package using
1058 \gls{IfTrackedLanguageFileExistsOmitOnlyRegion}}
1059 }
1060 % \TrackLangRequireDialectPrefix
1061 \gcmd{Track\-Lang\-Require\-Di\-alect\-Prefix}
1062 {
1063 \providedby{\file{tracklang.tex} v1.3+}
1064 \desc{defined by \gls{TrackLangRequireDialect}}
1065 }
1066 % \SetTrackedDialectLabelMap
1067 \gcmd{Set\-Track\-ed\-Di\-alect\-Label\-Map}
1068 {
1069 \providedby{\file{tracklang.tex} v1.3+}
1070 \syntax{\margm{tracklang-label}\margm{hook-label}}
1071 \desc{defines a mapping between a \sty{tracklang} dialect label
1072 and the corresponding dialect label used by a language hook, such as
1073 \gls{captionsdialect}}
1074 }
1075 % \TrackLangLastTrackedDialect
1076 \gcmd{Track\-Lang\-Last\-Track\-ed\-Dialect}
1077 {
1078 \providedby{\file{tracklang.tex} v1.3+}
1079 \desc{expands to the label of the last tracked dialect}
1080 }
1081 % COMMANDS: INTERNAL
1082 % \@tracklang@declareoption
1083 \gcmd{@track\-lang\-@\-declare\-option}
1084 {
1085 \providedby{\sty{tracklang} v1.1+}
1086 \syntax{\margm{dialect}}
1087 \desc{provided by \file{tracklang.sty} to declare \meta{dialect}
1088 as a package option that tracks \meta{dialect}. Provided by
1089 \file{tracklang.tex}, if not already defined, to ignore its argument}
1090 }
1091 % \@tracklang@for
1092 \gcmd{@track\-lang\-@\-for}
1093 {
1094 \providedby{\file{tracklang.tex} v1.0+}
1095 \syntax{\meta{cs}:=\meta{list}\cmd{do}\margm{body}}
1096 \desc{as \LaTeX's \gls{@for}}
1097 }
1098 % \@tracklang@prelangpkgcheck@hook
1099 \gcmd{@track\-lang\-@\-pre\-lang\-pkg\-check\-@\-hook}
1100 {
1101 \desc{if defined before \file{tracklang.sty} v1.3.8+ is loaded, this
1102 command will be done after package options have been processed but
1103 before the check for language packages, such as \sty{babel} and
1104 \sty{polyglossia}}
1105 }
1106 % COMMANDS: tracklang-region-codes.tex
1107 % \TrackLangAlphaIIToNumericRegion
1108 \gcmd{Track\-Lang\-Alpha\-II\-To\-Numeric\-Region}
1109 {
1110 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1111 \syntax{\margm{alpha-2 code}}
1112 \desc{expands to the numeric code corresponding to the given
1113 alpha-2 code}
1114 }
1115 % \TrackLangNumericToAlphaIIRegion
1116 \gcmd{Track\-Lang\-Numeric\-To\-Alpha\-II\-Region}
1117 {
1118 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1119 \syntax{\margm{numeric code}}
1120 \desc{expands to the alpha-2 code corresponding to the given
1121 numeric code}
1122 }
1123 % \TrackLangIfKnownAlphaIIRegion
1124 \gcmd{Track\-Lang\-If\-Known\-Alpha\-II\-Region}
1125 {
1126 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1127 \syntax{\margm{alpha-2 code}\margm{true}\margm{false}}
1128 \desc{expands to \meta{true} if there's a known mapping for the
1129 given alpha-2 \idx{region} code, otherwise expands to \meta{false}}
1130 }
1131 % \TrackLangIfKnownNumericRegion
1132 \gcmd{Track\-Lang\-If\-Known\-Numeric\-Region}
1133 {
1134 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1135 \syntax{\margm{numeric code}\margm{true}\margm{false}}
1136 \desc{expands to \meta{true} if there's a known mapping for the
1137 given numeric \idx{region} code, otherwise expands to \meta{false}}
1138 }
1139 % \TrackLangAlphaIIIToNumericRegion
1140 \gcmd{Track\-Lang\-Alpha\-III\-To\-Numeric\-Region}
1141 {
1142 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1143 \syntax{\margm{alpha-3 code}}
1144 \desc{expands to the numeric code corresponding to the given
1145 alpha-3 code}
1146 }
1147 % \TrackLangNumericToAlphaIIIRegion
1148 \gcmd{Track\-Lang\-Numeric\-To\-Alpha\-III\-Region}
1149 {
1150 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1151 \syntax{\margm{numeric code}}
1152 \desc{expands to the alpha-3 code corresponding to the given
1153 numeric code}
1154 }
1155 % \TrackLangIfKnownAlphaIIIRegion
1156 \gcmd{Track\-Lang\-If\-Known\-Alpha\-III\-Region}
1157 {
1158 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1159 \syntax{\margm{alpha-3 code}\margm{true}\margm{false}}
1160 \desc{expands to \meta{true} if there's a known mapping for the
1161 given \meta{alpha-3 code}, otherwise expands to \meta{false}}
1162 }
1163 % \TrackLangRegionMap
1164 \gcmd{Track\-Lang\-Region\-Map}
1165 {
1166 \providedby{\file{tracklang-region-codes.tex} v1.3+}
1167 \syntax{\margm{numeric}\margm{alpha-2}\margm{alpha-3}}
1168 \desc{establishes a mapping between a numeric \idx{region} code
1169 and alpha-2 and alpha-3 codes}
1170 }
1171 % COMMANDS: tracklang-scripts.tex
1172 % \TrackLangScriptMap
1173 \gcmd{Track\-Lang\-Script\-Map}
1174 {
1175 \providedby{\file{tracklang-scripts.tex} v1.3+}
1176 \syntax{\margm{letter code}\margm{numeric code}\margm{script name}\margm{direction}\margm{parent script}}
1177 \desc{defines a mapping between an alpha code and a numeric code}
1178 }
1179 % \TrackLangScriptAlphaToNumeric
1180 \gcmd{Track\-Lang\-Script\-Alpha\-To\-Numeric}
1181 {
1182 \providedby{\file{tracklang-scripts.tex} v1.3+}
1183 \syntax{\margm{alpha code}}
1184 \desc{expands to the numeric script code corresponding to the given alpha code}
1185 }
1186 % \TrackLangScriptIfKnownAlpha
1187 \gcmd{Track\-Lang\-Script\-If\-Known\-Alpha}
1188 {
1189 \providedby{\file{tracklang-scripts.tex} v1.3+}
1190 \syntax{\margm{alpha code}\margm{true}\margm{false}}
1191 \desc{expands to \meta{true} if there's a known mapping for the
1192 given alpha script code otherwise expands to \meta{false}}
1193 }
1194 % \TrackLangScriptNumericToAlpha
1195 \gcmd{Track\-Lang\-Script\-Numeric\-To\-Alpha}
1196 {
1197 \providedby{\file{tracklang-scripts.tex} v1.3+}
1198 \syntax{\margm{numeric code}}
1199 \desc{expands to the alpha script code corresponding to the
1200 given numeric code}
1201 }
1202 % \TrackLangScriptIfKnownNumeric
1203 \gcmd{Track\-Lang\-Script\-If\-Known\-Numeric}
1204 {
1205 \providedby{\file{tracklang-scripts.tex} v1.3+}
1206 \syntax{\margm{numeric code}\margm{true}\margm{false}}
1207 \desc{expands to \meta{true} if there's a known mapping for the
1208 given numeric script code otherwise expands to \meta{false}}
1209 }
1210 % \TrackLangScriptAlphaToName
1211 \gcmd{Track\-Lang\-Script\-Alpha\-To\-Name}
1212 {
1213 \providedby{\file{tracklang-scripts.tex} v1.3+}
1214 \syntax{\margm{alpha code}}
1215 \desc{expands to the name associated with the given alpha script
1216 code}
1217 }
1218 % \TrackLangScriptAlphaToDir
1219 \gcmd{Track\-Lang\-Script\-Alpha\-To\-Dir}
1220 {
1221 \providedby{\file{tracklang-scripts.tex} v1.3+}
1222 \syntax{\margm{alpha code}}
1223 \desc{expands to the direction associated with the given alpha script
1224 code}
1225 }
1226 % \TrackLangScriptSetParent
1227 \gcmd{Track\-Lang\-Script\-Set\-Parent}
1228 {
1229 \providedby{\file{tracklang-scripts.tex} v1.3+}
1230 \syntax{\margm{alpha code}\margm{parent alpha code}}
1231 \desc{sets the parent for the given alpha script code}
1232 }
1233 % \TrackLangScriptGetParent
1234 \gcmd{Track\-Lang\-Script\-Get\-Parent}
1235 {
1236 \providedby{\file{tracklang-scripts.tex} v1.3+}
1237 \syntax{\margm{alpha code}}
1238 \desc{expands to the parent of the given alpha script code}
1239 }
1240 % \TrackLangScriptIfHasParent
1241 \gcmd{Track\-Lang\-Script\-If\-Has\-Parent}
1242 {
1243 \providedby{\file{tracklang-scripts.tex} v1.3+}
1244 \syntax{\margm{alpha code}\margm{true}\margm{false}}
1245 \desc{expands to \meta{true} if the given alpha script code has
1246 a parent otherwise expands to \meta{false}}
1247 }
1248 % \TrackLangScript<Code>
1249 \gcmdmeta{Track\-Lang\-Script}{Code}{}
1250 {
1251 \providedby{\file{tracklang-scripts.tex} v1.3+}
1252 \desc{set by \gls{TrackLangScriptMap} to the associated alpha code \meta{Code}}
1253 }
1254 % PACKAGE OPTIONS:
1255 \gstyopt{verbose}
1256 {
1257 \providedby{\sty{tracklang} v1.6.3+}
1258 \desc{switches on verbose setting}
1259 }
1260 \gstyopt{noverbose}
1261 {
1262 \providedby{\sty{tracklang} v1.6.3+}
1263 \desc{switches off verbose setting (default)}
1264 }
1265 \gstyopt{warn}
1266 {
1267 \providedby{\sty{tracklang} v1.6.5+}
1268 \desc{switches on warning setting (default)}
1269 }
1270 \gstyopt{nowarn}
1271 {
1272 \providedby{\sty{tracklang} v1.6.5+}
1273 \desc{switches off warning setting}
1274 }
1275 \gstyopt{isotag}
1276 {
1277 \name{\styoptfmt{\meta{bcp-tag}}}
1278 \desc{Any tag listed in \tableref{tab:bcp47opts} may be used
1279 as a package option}
1280 }
1281 \gstyopt{dialect}
1282 {
1283 \name{\styoptfmt{\meta{dialect}}}
1284 \desc{Any dialect label listed in \tableref{tab:bcp47opts} may be used
1285 as a package option}
1286 }
1287 % FILES
1288 \gfile{track\-lang.tex}{}% tracklang.tex
1289 \gfile{track\-lang.sty}% tracklang.sty
1290 {\field{alias}{pkg.tracklang}}%
1291 \gfile{track\-lang\dhyphen scripts.sty}% tracklang-scripts.sty
1292 {\field{alias}{pkg.tracklang-scripts}}%
1293 \gfile{tracklang\dhyphen region\dhyphen codes.tex}{}% tracklang-region-codes.tex
1294 \gfile{tracklang\dhyphen scripts.tex}{}% tracklang-scripts.tex
1295 \gfile{tex\-os\-query.tex}{}% texosquery.tex
1296 \gfile{tex\-os\-query.cfg}{}% texosquery.cfg
1297 \gfilemetameta{}{prefix}{\dhyphen}{localeid}{.ldf}{} % <prefix>-<localeid>.ldf
1298 % FILE EXTENSIONS
1299 \gext{tex}{}% .tex
1300 \gext{ldf}{}% .ldf
1301 \gext{log}{}% .log
1302 % PACKAGES
1303 \gpkg{track\-lang}{\common}% tracklang
1304 \gpkg{track\-lang\dhyphen scripts}{}% tracklang-scripts
1305 \gpkg{tex\-os\-query}{}% texosquery
1306 \gpkg{poly\-glossia}{}% polyglossia.sty
1307 \gpkg{babel}{}% babel.sty
1308 \gpkg{translator}{}% translator.sty
1309 \gpkg{shell\-esc}{}% shellesc.sty
1310 \gpkg{ngerman}{}% ngerman.sty
1311 \gpkg{german}{}% german.sty
1312 \gpkg{glossaries}{}% glossaries.sty
1313 \gpkg{etool\-box}{}% etoolbox.sty
1314 \gpkg{date\-time2}{}% datetime2.sty
1315 \gpkg{input\-enc}{}% inputenc.sty
1316 % Example packages
1317 \gfile{animals.sty}{}% animals.sty
1318 \gfile{regions.sty}{}% regions.sty
1319 \gfile{alien.sty}{}% alien.sty
1320 \gpkg{alien}{\field{alias}{file.alien.sty}}
1321 % environment variables
1322 \genvvar{LC\dsb ALL}{}% LC_ALL
1323 \genvvar{LANG}{}% LANG
1324 \genvvar{LC\dsb MONETARY}{}% LC_MONETARY
1325 % TERMS
1326 \gterm{shellescape}
1327 {
1328 \name{shell escape}
1329 \desc{\TeX\ has the ability to run \idx{cli} applications while
1330 it's typesetting a document. Whilst this is a convenient way
1331 of using tools to help build the document, it's a security
1332 risk. To help protect users from arbitrary\dash and
1333 potentially dangerous\dash code from begin executed, \TeX\ has
1334 a restricted mode, where only trusted applications are allowed to
1335 run. This is usually the default mode, but your \TeX\
1336 installation may be set up so that the shell escape is disabled by
1337 default. The unrestricted mode allows you to run any
1338 application from the shell escape. Take care about
1339 enabling this option. If you receive a document or package
1340 from an untrusted source, first run \TeX\ with the shell escape
1341 disabled or in restricted mode and search the \ext+{log} file for
1342 \qt{runsystem} before using the unrestricted mode. Note that
1343 \LuaLaTeX\ additionally requires the \sty{shellesc} package}
1344 }
1345 \gtermacr{cli}{CLI}{command-line interface}%
1346 {%
1347 \desc{an application that doesn't have a graphical user
1348 interface. That is, an application that doesn't have any windows,
1349 buttons or menus and can be run in
1350 \dickimawhref{latex/novices/html/terminal.html}{a command
1351 prompt or terminal}}%
1352 }%
1353 % INDEX ONLY
1354 % COMMANDS - GENERAL
1355 \gcmd{input\-encoding\-name}{}% \inputencodingname
1356 \gcmd{Input\-If\-File\-Exists}{}% \InputIfFileExists
1357 \gcmd{direct\-lua}{}% \directlua
1358 \gcmd{Locale\-For\-Each}{}% \LocaleForEach
1359 \gcmd{babel\-provide}{}% \babelprovide
1360 \gcmd{bbl\-@\-loaded}{}% \bbl@loaded
1361 \gcmd{select\-language}{}% \selectlanguage
1362 \gcmd{input}{}% \input
1363 \gcmd{Require\-Package}{}% \RequirePackage
1364 \gcmd{Declare\-Option}{}% \DeclareOption
1365 \gcmdmeta{captions}{dialect}{}{}% \captions<dialect>
1366 \gcmdmeta{date}{dialect}{}{}% \date<dialect>
1367 \gcmd{Provides\-File}{}% \ProvidesFile
1368 \gcmd{xpg\-@\-bcp\-@\-loaded}{}% \xpg@bcp@loaded
1369 \gcmd{xpg\-@\-loaded}{}% \xpg@loaded
1370 \gcmd{trans\-@\-languages}{}% \trans@languages
1371 \gcmd{lan\-guage\-name}{}% \languagename
1372 \gcmd{TeX\-OS\-Query\-Lang\-Tag}{}% \TeXOSQueryLangTag
1373 \gcmd{TeX\-OS\-Query\-Locale}{}% \TeXOSQueryLocale
1374 \gcmd{@for}{}
1375 \gcmd{@nil}{}
1376 \gcmd{At\-Begin\-Doc\-u\-ment}{}% \AtBeginDocument
1377 % APPLICATIONS
1378 \gapp{tex\-os\-query}{}% texosquery
1379 \gapp{kpse\-which}{}% kpsewhich
1380 \gapp{etex}{}% etex
1381 \gapp{tex}{}% tex
1382 \gapp{pdflatex}{}% pdflatex
1383 % PUNCTUATION
1384 \gpunc{atletter}% @ as a letter
1385 {\name{\code{@} (catcode 11)}\field{text}{\code{@}}}%
1386 \gpunc{atmod}% @ separates modifier
1387 {\name{\code{@} (modifier)}\field{text}{\code{@}}}%
1388 \gpunc{hyphensep}% - in tag
1389 {\name{\code{-} (separator)}\field{text}{\code{-}}}%
1390 \gpunc{underscoresep}% _ in tag
1391 {\name{\code{\_} (separator)}\field{text}{\code{\_}}}%
1392 \gpunc{dotsep}% . separates code-set
1393 {\name{\code{.}\ (code-set)}\field{text}{\code{.}}}%
1394 \gpunc{dollarenv}% ${ENV VAR}
1395 {\name{\code{\$} (environment variable)}\field{text}{\code{\$}}}
1396 \gpunc{escbsl}% \\
1397 {\name{\code{\glsbackslash\glsbackslash} (escaped backslash)}
1398 \field{text}{\code{\glsbackslash\glsbackslash}}
1399 }
1400 % INDEX ONLY TERMS
1401 \gidx{code-set}{}
1402 \gidx{modifier}{}
1403 \gidx{variant}{}
1404 \gidx{territory}{}
1405 \gidx{region}{\field{alias}{idx.territory}}
1406 \gidx{script}{}
1407 \gidx{BCP47}{\name{BCP~47}}
1408 % ISO CODES
1409 \gidx{639-1}{\name{ISO \mbox{639-1}}\field{text}{\mbox{639-1}}}
1410 \gidx{639-2}{\name{ISO \mbox{639-2}}\field{text}{\mbox{639-2}}}
1411 \gidx{639-2B}{\parent{idx.639-2}%
1412 \name{ISO \mbox{639-2} (B)}%
1413 \field{text}{\mbox{639-2} (B)}}
1414 \gidx{639-2T}{\parent{idx.639-2}%
1415 \name{ISO \mbox{639-2} (T)}%
1416 \field{text}{\mbox{639-2} (T)}}
1417 \gidx{639-3}{\name{ISO \mbox{639-3}}\field{text}{\mbox{639-3}}}
1418 \gidx{3166-1}{\name{ISO \mbox{3166-1}}\field{text}{\mbox{3166-1}}}
1419 \gidx{15924}{\name{ISO 15924}\field{text}{15924}}
1420 % ABBREVIATIONS
1421 \gacr{ISO}{ISO}{International Organization for Standardization}{\common}
1422 \gacr{POSIX}{POSIX}{Portable Operating System Interface}{}
1423 % SWITCHES
1424 \glongswitchpunc{shell\dhyphen escape}{}
1425 % PREDEFINED LANGUAGE-REGION TAGS
1426 \gbcplangtag{en}{US}{american}{}
1427 \gbcplangtag{en}{GB}{british}{}
1428 \gbcplangtag{en}{AU}{australian}{}
1429 \gbcplangtag{en}{NZ}{newzealand}{}
1430 \gbcplangtag{en}{CA}{canadian}{}
1431 \gbcplangtag{fr}{CA}{canadien}{}
1432 \gbcplangtag{fr}{BE}{belgique}{}
1433 \gbcplangtag{pt}{BR}{brazilian}{}
1434 \gbcplangtag{it}{HR}{istriacountyitalian}{}
1435 \gbcplangtag{nl}{BE}{flemish}{}
1436 \gbcplangtag{fr}{FR}{france}{}
1437 \gbcplangtag{de}{DE}{ngermanDE}{}
1438 \gbcplangtag{de}{BE}{belgiangerman}{}
1439 \gbcplangtag{en}{GG}{guernseyenglish}{}
1440 \gbcplangtag{fr}{GG}{guernseyfrench}{}
1441 \gbcplangtag{it}{IT}{italy}{}
1442 \gbcplangtag{mt}{MT}{maltamaltese}{}
1443 \gbcplangtag{en}{MT}{maltaenglish}{}
1444 \gbcplangtag{en}{IM}{isleofmanenglish}{}
1445 \gbcplangtag{en}{JE}{jerseyenglish}{}
1446 \gbcplangtag{fr}{JE}{jerseyfrench}{}
1447 \gbcplangtag{nl}{NL}{netherlands}{}
1448 \gbcplangtag{pt}{PT}{portugal}{}
1449 \gbcplangtag{it}{SM}{sanmarino}{}
1450 \gbcplangtag{sl}{SI}{slovenia}{}
1451 \gbcplangtag{it}{SI}{sloveneistriaitalian}{}
1452 \gbcplangtag{es}{ES}{spainspanish}{}
1453 \gbcplangtag{es}{AR}{argentinespanish}{}
1454 \gbcplangtag{es}{BO}{bolivianspanish}{}
1455 \gbcplangtag{es}{CL}{chilianspanish}{}
1456 \gbcplangtag{es}{CO}{columbianspanish}{}
1457 \gbcplangtag{es}{CR}{costaricanspanish}{}
1458 \gbcplangtag{es}{CU}{cubanspanish}{}
1459 \gbcplangtag{es}{DO}{dominicanspanish}{}
1460 \gbcplangtag{es}{EC}{ecudorianspanish}{}
1461 \gbcplangtag{es}{SV}{elsalvadorspanish}{}
1462 \gbcplangtag{es}{GT}{guatemalanspanish}{}
1463 \gbcplangtag{es}{HN}{honduranspanish}{}
1464 \gbcplangtag{es}{MX}{mexicanspanish}{}
1465 \gbcplangtag{es}{NI}{nicaraguanspanish}{}
1466 \gbcplangtag{es}{PA}{panamaspanish}{}
1467 \gbcplangtag{es}{PY}{paraguayspanish}{}
1468 \gbcplangtag{es}{PE}{peruvianspanish}{}
1469 \gbcplangtag{es}{PR}{puertoricospanish}{}
1470 \gbcplangtag{es}{UY}{uruguayspanish}{}
1471 \gbcplangtag{es}{VE}{venezuelanspanish}{}
1472 \gbcplangtag{de}{CH}{nswissgerman}{}
1473 \gbcplangtag{fr}{CH}{swissfrench}{}
1474 \gbcplangtag{it}{CH}{swissitalian}{}
1475 \gbcplangtag{rm}{CH}{swissromansh}{}
1476 \gbcplangtag{it}{VA}{vatican}{}
1477 \gbcplangtag{ga}{IE}{IEirish}{}
1478 \gbcplangtag{ga}{GB}{GBirish}{}
1479 \gbcplangtag{en}{IE}{IEenglish}{}
1480 \gbcplangtagwithvar{de}{AT}{1996}{naustrian}{}
1481 \gbcplangtagwithvar{de}{AT}{1901}{oldaustrian}{}
1482 \gbcplangtag{de}{AT}{naustrian}{}
1483 \gbcplangtag{id}{IN}{bahasa}{}
1484 \gbcplangtag{ms}{MY}{malay}{}
1485 \gbcplangtag{hr}{HR}{croatia}{}
1486 \gbcplangtagwithvar{de}{DE}{1901}{oldgermanDE}{}
1487 \gbcplangtagwithvar{de}{DE}{1996}{ngermanDE}{}
1488 \gbcplangtagwithvar{de}{CH}{1996}{nswissgerman}{}
1489 \gbcplangtagwithvar{de}{CH}{1901}{oldswissgerman}{}
1490 \gbcplangtag{hu}{HU}{hungarian}{}
1491 \gbcplangtag{gd}{GB}{GBscottish}{}
1492 \gbcplangtag{cy}{GB}{GBwelsh}{}
1493 % PREDEFINED ROOT LANGUAGE TAGS
1494 \grootlangtag{abkhaz}{ab}{}
1495 \grootlangtag{afar}{aa}{}
1496 \grootlangtag{afrikaans}{af}{}
1497 \grootlangtag{akan}{ak}{}
1498 \grootlangtag{albanian}{sq}{}
1499 \grootlangtagwithreg{amharic}{am}{ET}{}
1500 \grootlangtag{anglosaxon}{ang}{}
1501 \grootlangtag{apache}{apa}{}
1502 \grootlangtag{arabic}{ar}{}
1503 \grootlangtagwithreg{aragonese}{an}{ES}{}
1504 \grootlangtag{armenian}{hy}{}
1505 \grootlangtag{assamese}{as}{}
1506 \grootlangtag{asturian}{ast}{}
1507 \grootlangtag{avaric}{av}{}
1508 \grootlangtag{avestan}{ae}{}
1509 \grootlangtag{aymara}{ay}{}
1510 \grootlangtag{azerbaijani}{az}{}
1511 \grootlangtagwithreg{bahasai}{id}{IN}{}
1512 \grootlangtagwithreg{bahasam}{ms}{MY}{}
1513 \grootlangtagwithreg{bambara}{bm}{ML}{}
1514 \grootlangtag{bashkir}{ba}{}
1515 \grootlangtag{basque}{eu}{}
1516 \grootlangtag{belarusian}{be}{}
1517 \grootlangtag{bengali}{bn}{}
1518 \grootlangtag{berber}{ber}{}
1519 \grootlangtag{bihari}{bh}{}
1520 \grootlangtagwithreg{bislama}{bi}{VU}{}
1521 \grootlangtagwithreg{bokmal}{nb}{NO}{}
1522 \grootlangtag{bosnian}{bs}{}
1523 \grootlangtagwithreg{breton}{br}{FR}{}
1524 \grootlangtag{bulgarian}{bg}{}
1525 \grootlangtag{burmese}{my}{}
1526 \grootlangtag{catalan}{ca}{}
1527 \grootlangtag{chamorro}{ch}{}
1528 \grootlangtag{chechen}{ce}{}
1529 \grootlangtag{chichewa}{ny}{}
1530 \grootlangtag{chinese}{zh}{}
1531 \grootlangtag{churchslavonic}{cu}{}
1532 \grootlangtagwithreg{chuvash}{cv}{RU}{}
1533 \grootlangtag{coptic}{cop}{}
1534 \grootlangtagwithreg{cornish}{kw}{GB}{}
1535 \grootlangtag{corsican}{co}{}
1536 \grootlangtag{cree}{cr}{}
1537 \grootlangtag{croatian}{hr}{}
1538 \grootlangtag{czech}{cs}{}
1539 \grootlangtag{danish}{da}{}
1540 \grootlangtagwithreg{divehi}{dv}{MV}{}
1541 \grootlangtag{dutch}{nl}{}
1542 \grootlangtagwithreg{dzongkha}{dz}{BT}{}
1543 \grootlangtagwithreg{easternpunjabi}{pa}{IN}{}
1544 \grootlangtag{english}{en}{}
1545 \grootlangtag{esperanto}{eo}{}
1546 \grootlangtag{estonian}{et}{}
1547 \grootlangtag{ewe}{ee}{}
1548 \grootlangtag{faroese}{fo}{}
1549 \grootlangtag{farsi}{fa}{}
1550 \grootlangtagwithreg{fijian}{fj}{FJ}{}
1551 \grootlangtag{finnish}{fi}{}
1552 \grootlangtag{french}{fr}{}
1553 \grootlangtagwithreg{friulan}{fur}{IT}{}
1554 \grootlangtag{fula}{ff}{}
1555 \grootlangtag{galician}{gl}{}
1556 \grootlangtagwithreg{ganda}{lg}{UG}{}
1557 \grootlangtag{georgian}{ka}{}
1558 \grootlangtag{german}{de}{}
1559 \grootlangtag{greek}{el}{}
1560 \grootlangtag{guarani}{gn}{}
1561 \grootlangtag{gujarati}{gu}{}
1562 \grootlangtagwithreg{haitian}{ht}{HT}{}
1563 \grootlangtag{hausa}{ha}{}
1564 \grootlangtag{hebrew}{he}{}
1565 \grootlangtag{herero}{hz}{}
1566 \grootlangtag{hindi}{hi}{}
1567 \grootlangtagwithreg{hirimotu}{ho}{PG}{}
1568 \grootlangtagwithreg{icelandic}{is}{IS}{}
1569 \grootlangtag{ido}{io}{}
1570 \grootlangtag{igbo}{ig}{}
1571 \grootlangtag{interlingua}{ia}{}
1572 \grootlangtag{interlingue}{ie}{}
1573 \grootlangtag{inuktitut}{iu}{}
1574 \grootlangtag{inupiaq}{ik}{}
1575 \grootlangtag{irish}{ga}{}
1576 \grootlangtag{italian}{it}{}
1577 \grootlangtag{japanese}{ja}{}
1578 \grootlangtag{javanese}{jv}{}
1579 \grootlangtag{kalaallisut}{kl}{}
1580 \grootlangtagwithreg{kannada}{kn}{IN}{}
1581 \grootlangtag{kanuri}{kr}{}
1582 \grootlangtagwithreg{kashmiri}{ks}{IN}{}
1583 \grootlangtag{kazakh}{kk}{}
1584 \grootlangtag{khmer}{km}{}
1585 \grootlangtag{kikuyu}{ki}{}
1586 \grootlangtag{kinyarwanda}{rw}{}
1587 \grootlangtag{kirundi}{rn}{}
1588 \grootlangtagwithreg{komi}{kv}{RU}{}
1589 \grootlangtag{kongo}{kg}{}
1590 \grootlangtag{korean}{ko}{}
1591 \grootlangtag{kurdish}{ku}{}
1592 \grootlangtag{kwanyama}{kj}{}
1593 \grootlangtag{kyrgyz}{ky}{}
1594 \grootlangtag{lao}{lo}{}
1595 \grootlangtag{latin}{la}{}
1596 \grootlangtag{latvian}{lv}{}
1597 \grootlangtag{limburgish}{li}{}
1598 \grootlangtag{lingala}{ln}{}
1599 \grootlangtag{lithuanian}{lt}{}
1600 \grootlangtagwithreg{lsorbian}{dsb}{DE}{}
1601 \grootlangtagwithreg{lubakatanga}{lu}{CD}{}
1602 \grootlangtag{luxembourgish}{lb}{}
1603 \grootlangtag{macedonian}{mk}{}
1604 \grootlangtag{magyar}{hu}{}
1605 \grootlangtag{malagasy}{mg}{}
1606 \grootlangtagwithreg{malayalam}{ml}{IN}{}
1607 \grootlangtag{maltese}{mt}{}
1608 \grootlangtagwithreg{manx}{gv}{IM}{}
1609 \grootlangtagwithreg{maori}{mi}{NZ}{}
1610 \grootlangtagwithreg{marathi}{mr}{IN}{}
1611 \grootlangtagwithreg{marshallese}{mh}{MH}{}
1612 \grootlangtag{mongolian}{mn}{}
1613 \grootlangtagwithreg{nauruan}{na}{NR}{}
1614 \grootlangtagwithreg{navajo}{nv}{US}{}
1615 \grootlangtag{ndonga}{ng}{}
1616 \grootlangtag{nepali}{ne}{}
1617 \grootlangtag{nko}{nqo}{}
1618 \grootlangtag{northernndebele}{nd}{}
1619 \grootlangtagwithreg{nynorsk}{nn}{NO}{}
1620 \grootlangtag{norsk}{no}{}
1621 \grootlangtag{northernsotho}{nso}{}
1622 \grootlangtagwithreg{nuosu}{ii}{CN}{}
1623 \grootlangtag{occitan}{oc}{}
1624 \grootlangtag{ojibwe}{oj}{}
1625 \grootlangtag{oromo}{om}{}
1626 \grootlangtag{oriya}{or}{}
1627 \grootlangtag{ossetian}{os}{}
1628 \grootlangtag{pali}{pi}{}
1629 \grootlangtag{pashto}{ps}{}
1630 \grootlangtagwithreg{piedmontese}{pms}{IT}{}
1631 \grootlangtag{polish}{pl}{}
1632 \grootlangtag{portuges}{pt}{}
1633 \grootlangtag{quechua}{qu}{}
1634 \grootlangtag{romanian}{ro}{}
1635 \grootlangtagwithreg{romansh}{rm}{CH}{}
1636 \grootlangtag{russian}{ru}{}
1637 \grootlangtag{samin}{se}{}
1638 \grootlangtag{sanskrit}{sa}{}
1639 \grootlangtag{samoan}{sm}{}
1640 \grootlangtag{sango}{sg}{}
1641 \grootlangtagwithreg{sardinian}{sc}{IT}{}
1642 \grootlangtag{scots}{sco}{}
1643 \grootlangtag{scottish}{gd}{}
1644 \grootlangtag{serbian}{sr}{}
1645 \grootlangtag{shona}{sn}{}
1646 \grootlangtag{sindhi}{sd}{}
1647 \grootlangtagwithreg{sinhalese}{si}{LK}{}
1648 \grootlangtag{slovak}{sk}{}
1649 \grootlangtag{slovene}{sl}{}
1650 \grootlangtag{somali}{so}{}
1651 \grootlangtagwithreg{southernndebele}{nr}{ZA}{}
1652 \grootlangtag{southernsotho}{st}{}
1653 \grootlangtag{spanish}{es}{}
1654 \grootlangtag{sudanese}{su}{}
1655 \grootlangtag{swahili}{sw}{}
1656 \grootlangtag{swati}{ss}{}
1657 \grootlangtag{swedish}{sv}{}
1658 \grootlangtag{syriac}{syr}{}
1659 \grootlangtagwithreg{tagalog}{tl}{PH}{}
1660 \grootlangtagwithreg{tahitian}{ty}{PF}{}
1661 \grootlangsametag{tai}{}
1662 \grootlangtag{tajik}{tg}{}
1663 \grootlangtag{tamil}{ta}{}
1664 \grootlangtag{tatar}{tt}{}
1665 \grootlangtagwithreg{telugu}{te}{IN}{}
1666 \grootlangtagwithreg{thai}{th}{TH}{}
1667 \grootlangtag{tibetan}{bo}{}
1668 \grootlangtag{tigrinya}{ti}{}
1669 \grootlangtagwithreg{tonga}{to}{TO}{}
1670 \grootlangtag{tsonga}{ts}{}
1671 \grootlangtag{tswana}{tn}{}
1672 \grootlangtag{turkish}{tr}{}
1673 \grootlangtag{turkmen}{tk}{}
1674 \grootlangtagwithreg{twi}{tw}{GH}{}
1675 \grootlangtagwithreg{ukrainian}{uk}{UA}{}
1676 \grootlangtag{undetermined}{und}{}
1677 \grootlangtag{urdu}{ur}{}
1678 \grootlangtagwithreg{usorbian}{hsb}{DE}{}
1679 \grootlangtagwithreg{uyghur}{ug}{CN}{}
1680 \grootlangtag{uzbek}{uz}{}
1681 \grootlangtagwithreg{venda}{ve}{ZA}{}
1682 \grootlangtag{vietnamese}{vi}{}
1683 \grootlangtag{volapuk}{vo}{}
1684 \grootlangtag{walloon}{wa}{}
1685 \grootlangtag{welsh}{cy}{}
1686 \grootlangtagwithreg{westernfrisian}{fy}{NL}{}
1687 \grootlangtag{wolof}{wo}{}
1688 \grootlangtag{xhosa}{xh}{}
1689 \grootlangtag{yiddish}{yi}{}
1690 \grootlangtag{yoruba}{yo}{}
1691 \grootlangtagwithreg{zhuang}{za}{CN}{}
1692 \grootlangtag{zulu}{zu}{}
1693 % PREDEFINED NON-BCP47 DIALECTS
1694 \gdialecttag{acadian}{french}{}
1695 \gdialecttagwithreg{american}{english}{US}{}
1696 \gdialecttagwithreg{australian}{english}{AU}{}
1697 \gdialecttagwithreg{austrian}{german}{AT}{}
1698 \gdialecttagwithreg{naustrian}{german}{AT-1996}{}
1699 \gdialecttagwithreg{bahasa}{bahasai}{IN}{}
1700 \gdialecttagwithreg{brazil}{portuges}{BR}{}
1701 \gdialecttagwithreg{brazilian}{portuges}{BR}{}
1702 \gdialecttagwithreg{british}{english}{GB}{}
1703 \gdialecttagwithreg{canadian}{english}{CA}{}
1704 \gdialecttagwithreg{canadien}{french}{CA}{}
1705 \gdialecttagwithreg{croatia}{croatian}{HR}{}
1706 \gdialecttagwithreg{istriacountycroatian}{croatian}{HR}{}
1707 \gdialecttagwithreg{istriacountyitalian}{italian}{HR}{}
1708 \gdialecttagwithreg{netherlands}{dutch}{NL}{}
1709 \gdialecttag{persian}{farsi}{}
1710 \gdialecttagwithreg{flemish}{dutch}{BE}{}
1711 \gdialecttag{francais}{french}{}
1712 \gdialecttag{frenchb}{french}{}
1713 \gdialecttagwithreg{france}{french}{FR}{}
1714 \gdialecttagwithreg{belgique}{french}{BE}{}
1715 \gdialecttagwithreg{belgiangerman}{german}{BE}{}
1716 \gdialecttagwithmapandreg{nbelgiangerman}{german}{BE-1996}{ngerman}{}
1717 \gdialecttagwithreg{friulian}{friulan}{IT}{}
1718 \gdialecttagwithreg{friulano}{friulan}{IT}{}
1719 \gdialecttagwithreg{furlan}{friulan}{IT}{}
1720 \gdialecttag{kurmanji}{kurdish}{}
1721 \gdialecttag{galicien}{galician}{}
1722 \gdialecttag{deutsch}{german}{}
1723 \gdialecttagsuppl{ngerman}{german}{1996}{}
1724 \gdialecttagsupplwithmap{ngermanb}{german}{1996}{ngerman}{}
1725 \gdialecttag{germanb}{german}{}
1726 \gdialecttagwithmapandreg{ngermanDE}{german}{DE-1996}{ngerman}{}
1727 \gdialecttagwithreg{germanDE}{german}{DE}{}
1728 \gdialecttagwithreg{oldgermanDE}{german}{DE-1901}{}
1729 \gdialecttagwithmapandreg{oldaustrian}{german}{AT-1901}{austrian}{}
1730 \gdialecttagwithmapandreg{german-at}{german}{AT}{naustrian}{}
1731 \gdialecttagwithmapandreg{german-austria}{german}{AT}{naustrian}{}
1732 \gdialecttagwithmapandreg{german-austria-1901}{german}{AT}{austrian}{}
1733 \gdialecttagwithmapandreg{german-at-1901}{german}{AT}{austrian}{}
1734 \gdialecttagwithmapandreg{german-germany}{german}{DE}{ngerman}{}
1735 \gdialecttagwithmapandreg{german-de}{german}{DE}{ngerman}{}
1736 \gdialecttagwithreg{german-germany-1901}{german}{DE}{}
1737 \gdialecttagwithreg{german-de-1901}{german}{DE}{}
1738 % swissgeman -> no "r" in babel's captions hook name
1739 \gdialecttagwithmapandreg{german-switzerland}{german}{CH}{nswissgeman}{}
1740 \gdialecttagwithmapandreg{german-ch}{german}{CH}{nswissgeman}{}
1741 \gdialecttagwithmapandreg{german-switzerland-1901}{german}{CH}{swissgeman}{}
1742 \gdialecttagwithmapandreg{german-ch-1901}{german}{CH}{swissgeman}{}
1743 \gdialecttagwithreg{hungarian}{magyar}{HU}{}
1744 \gdialecttagwithreg{indon}{bahasai}{IN}{}
1745 \gdialecttagwithreg{indonesian}{bahasai}{IN}{}
1746 \gdialecttag{gaeilge}{irish}{}
1747 \gdialecttagwithreg{IEirish}{irish}{IE}{}
1748 \gdialecttagwithreg{GBirish}{irish}{GB}{}
1749 \gdialecttagwithmapandreg{IEenglish}{english}{IE}{british}{}
1750 \gdialecttagwithreg{italy}{italian}{IT}{}
1751 \gdialecttagwithreg{vatican}{italian}{VA}{}
1752 \gdialecttagwithreg{sanmarino}{italian}{SM}{}
1753 \gdialecttagwithreg{sloveneistriaitalian}{italian}{SI}{}
1754 \gdialecttagwithmapandreg{jerseyenglish}{english}{JE}{british}{}
1755 \gdialecttagwithreg{jerseyfrench}{french}{JE}{}
1756 \gdialecttagwithmapandreg{guernseyenglish}{english}{GG}{british}{}
1757 \gdialecttagwithreg{guernseyfrench}{french}{GG}{}
1758 \gdialecttag{latein}{latin}{}
1759 \gdialecttagwithreg{lowersorbian}{lsorbian}{DE}{}
1760 \gdialecttagwithreg{malay}{bahasam}{MY}{}
1761 \gdialecttagwithreg{meyalu}{bahasam}{MY}{}
1762 \gdialecttagwithreg{maltamaltese}{maltese}{MT}{}
1763 \gdialecttagwithmapandreg{maltaenglish}{english}{MT}{british}{}
1764 \gdialecttagwithreg{newzealand}{english}{NZ}{}
1765 \gdialecttagwithmapandreg{isleofmanenglish}{english}{IM}{british}{}
1766 \gdialecttagwithreg{norwegian}{norsk}{NO}{}
1767 \gdialecttagwithreg{piemonteis}{piedmontese}{IT}{}
1768 \gdialecttag{polutonikogreek}{greek}{}
1769 \gdialecttag{polutoniko}{greek}{}
1770 \gdialecttag{portuguese}{portuges}{}
1771 \gdialecttagwithreg{portugal}{portuges}{PT}{}
1772 \gdialecttag{romansch}{romansh}{}
1773 \gdialecttag{rumantsch}{romansh}{}
1774 \gdialecttag{romanche}{romansh}{}
1775 \gdialecttag{russianb}{russian}{}
1776 \gdialecttag{gaelic}{scottish}{}
1777 \gdialecttagwithreg{GBscottish}{scottish}{GB}{}
1778 \gdialecttagsuppl{serbianc}{serbian}{Cyrl}{}
1779 \gdialecttagsuppl{serbianl}{serbian}{Latn}{}
1780 \gdialecttag{slovenian}{slovene}{}
1781 \gdialecttagwithmapandreg{slovenia}{slovene}{SI}{slovenian}{}
1782 \gdialecttagwithmapandreg{sloveneistriaslovenian}{slovene}{SI}{slovenian}{}
1783 \gdialecttagwithreg{spainspanish}{spanish}{ES}{}
1784 \gdialecttagwithreg{argentinespanish}{spanish}{AR}{}
1785 \gdialecttagwithreg{bolivianspanish}{spanish}{BO}{}
1786 \gdialecttagwithreg{chilianspanish}{spanish}{CL}{}
1787 \gdialecttagwithreg{columbianspanish}{spanish}{CO}{}
1788 \gdialecttagwithreg{costaricanspanish}{spanish}{CR}{}
1789 \gdialecttagwithreg{cubanspanish}{spanish}{CU}{}
1790 \gdialecttagwithreg{dominicanspanish}{spanish}{DO}{}
1791 \gdialecttagwithreg{ecudorianspanish}{spanish}{EC}{}
1792 \gdialecttagwithreg{elsalvadorspanish}{spanish}{SV}{}
1793 \gdialecttagwithreg{guatemalanspanish}{spanish}{GT}{}
1794 \gdialecttagwithreg{honduranspanish}{spanish}{HN}{}
1795 \gdialecttagwithreg{mexicanspanish}{spanish}{MX}{}
1796 \gdialecttagwithreg{nicaraguanspanish}{spanish}{NI}{}
1797 \gdialecttagwithreg{panamaspanish}{spanish}{PA}{}
1798 \gdialecttagwithreg{paraguayspanish}{spanish}{PY}{}
1799 \gdialecttagwithreg{peruvianspanish}{spanish}{PE}{}
1800 \gdialecttagwithreg{puertoricospanish}{spanish}{PR}{}
1801 \gdialecttagwithreg{uruguayspanish}{spanish}{UY}{}
1802 \gdialecttagwithreg{venezuelanspanish}{spanish}{VE}{}
1803 % swissgeman -> no "r" in babel's captions hook name
1804 \gdialecttagwithmapandreg{swissgerman}{german}{CH}{swissgeman}{}
1805 \gdialecttagwithmapandreg{nswissgerman}{german}{CH-1996}{nswissgeman}{}
1806 \gdialecttagwithmapandreg{oldswissgerman}{german}{CH-1901}{swissgeman}{}
1807 % supporting "r"-less spellings
1808 \gdialecttagwithreg{nswissgeman}{german}{CH-1996}{\field{postname}{[sic]}}
1809 \gdialecttagwithreg{swissgeman}{german}{CH-1901}{\field{postname}{[sic]}}
1810 \gdialecttagwithreg{swissfrench}{french}{CH}{}
1811 \gdialecttagwithreg{swissitalian}{italian}{CH}{}
1812 \gdialecttagwithreg{swissromansh}{romansh}{CH}{}
1813 \gdialecttagwithreg{UKenglish}{english}{GB}{}
1814 \gdialecttagwithreg{ukraineb}{ukrainian}{UA}{}
1815 \gdialecttagwithreg{ukraine}{ukrainian}{UA}{}
1816 \gdialecttagwithreg{uppersorbian}{usorbian}{DE}{}
1817 \gdialecttagwithreg{USenglish}{english}{US}{}
1818 \gdialecttag{valencian}{catalan}{}
1819 \gdialecttag{valencien}{catalan}{}
1820 \gdialecttag{cymraeg}{welsh}{}
1821 \gdialecttagwithreg{GBwelsh}{welsh}{GB}{}
1822 \gdialecttag{nil}{undetermined}{}
1823 % PREDEFINED REGIONS
1824 \gregion{004}{AF}{AFG}{}%
1825 \gregion{248}{AX}{ALA}{}%
1826 \gregion{008}{AL}{ALB}{}%
1827 \gregion{012}{DZ}{DZA}{}%
1828 \gregion{016}{AS}{ASM}{}%
1829 \gregion{020}{AD}{AND}{}%
1830 \gregion{024}{AO}{AGO}{}%
1831 \gregion{660}{AI}{AIA}{}%
1832 \gregion{010}{AQ}{ATA}{}%
1833 \gregion{028}{AG}{ATG}{}%
1834 \gregion{032}{AR}{ARG}{}%
1835 \gregion{051}{AM}{ARM}{}%
1836 \gregion{533}{AW}{ABW}{}%
1837 \gregion{036}{AU}{AUS}{}%
1838 \gregion{040}{AT}{AUT}{}%
1839 \gregion{031}{AZ}{AZE}{}%
1840 \gregion{044}{BS}{BHS}{}%
1841 \gregion{048}{BH}{BHR}{}%
1842 \gregion{050}{BD}{BGD}{}%
1843 \gregion{052}{BB}{BRB}{}%
1844 \gregion{112}{BY}{BLR}{}%
1845 \gregion{056}{BE}{BEL}{}%
1846 \gregion{084}{BZ}{BLZ}{}%
1847 \gregion{204}{BJ}{BEN}{}%
1848 \gregion{060}{BM}{BMU}{}%
1849 \gregion{064}{BT}{BTN}{}%
1850 \gregion{068}{BO}{BOL}{}%
1851 \gregion{535}{BQ}{BES}{}%
1852 \gregion{070}{BA}{BIH}{}%
1853 \gregion{072}{BW}{BWA}{}%
1854 \gregion{074}{BV}{BVT}{}%
1855 \gregion{076}{BR}{BRA}{}%
1856 \gregion{086}{IO}{IOT}{}%
1857 \gregion{096}{BN}{BRN}{}%
1858 \gregion{100}{BG}{BGR}{}%
1859 \gregion{854}{BF}{BFA}{}%
1860 \gregion{108}{BI}{BDI}{}%
1861 \gregion{132}{CV}{CPV}{}%
1862 \gregion{116}{KH}{KHM}{}%
1863 \gregion{120}{CM}{CMR}{}%
1864 \gregion{124}{CA}{CAN}{}%
1865 \gregion{136}{KY}{CYM}{}%
1866 \gregion{140}{CF}{CAF}{}%
1867 \gregion{148}{TD}{TCD}{}%
1868 \gregion{152}{CL}{CHL}{}%
1869 \gregion{156}{CN}{CHN}{}%
1870 \gregion{162}{CX}{CXR}{}%
1871 \gregion{166}{CC}{CCK}{}%
1872 \gregion{170}{CO}{COL}{}%
1873 \gregion{174}{KM}{COM}{}%
1874 \gregion{180}{CD}{COD}{}%
1875 \gregion{178}{CG}{COG}{}%
1876 \gregion{184}{CK}{COK}{}%
1877 \gregion{188}{CR}{CRI}{}%
1878 \gregion{384}{CI}{CIV}{}%
1879 \gregion{191}{HR}{HRV}{}%
1880 \gregion{192}{CU}{CUB}{}%
1881 \gregion{531}{CW}{CUW}{}%
1882 \gregion{196}{CY}{CYP}{}%
1883 \gregion{203}{CZ}{CZE}{}%
1884 \gregion{208}{DK}{DNK}{}%
1885 \gregion{262}{DJ}{DJI}{}%
1886 \gregion{212}{DM}{DMA}{}%
1887 \gregion{214}{DO}{DOM}{}%
1888 \gregion{218}{EC}{ECU}{}%
1889 \gregion{818}{EG}{EGY}{}%
1890 \gregion{222}{SV}{SLV}{}%
1891 \gregion{226}{GQ}{GNQ}{}%
1892 \gregion{232}{ER}{ERI}{}%
1893 \gregion{233}{EE}{EST}{}%
1894 \gregion{231}{ET}{ETH}{}%
1895 \gregion{238}{FK}{FLK}{}%
1896 \gregion{234}{FO}{FRO}{}%
1897 \gregion{242}{FJ}{FJI}{}%
1898 \gregion{246}{FI}{FIN}{}%
1899 \gregion{250}{FR}{FRA}{}%
1900 \gregion{254}{GF}{GUF}{}%
1901 \gregion{258}{PF}{PYF}{}%
1902 \gregion{260}{TF}{ATF}{}%
1903 \gregion{266}{GA}{GAB}{}%
1904 \gregion{270}{GM}{GMB}{}%
1905 \gregion{268}{GE}{GEO}{}%
1906 \gregion{276}{DE}{DEU}{}%
1907 \gregion{288}{GH}{GHA}{}%
1908 \gregion{292}{GI}{GIB}{}%
1909 \gregion{300}{GR}{GRC}{}%
1910 \gregion{304}{GL}{GRL}{}%
1911 \gregion{308}{GD}{GRD}{}%
1912 \gregion{312}{GP}{GLP}{}%
1913 \gregion{316}{GU}{GUM}{}%
1914 \gregion{320}{GT}{GTM}{}%
1915 \gregion{831}{GG}{GGY}{}%
1916 \gregion{324}{GN}{GIN}{}%
1917 \gregion{624}{GW}{GNB}{}%
1918 \gregion{328}{GY}{GUY}{}%
1919 \gregion{332}{HT}{HTI}{}%
1920 \gregion{334}{HM}{HMD}{}%
1921 \gregion{336}{VA}{VAT}{}%
1922 \gregion{340}{HN}{HND}{}%
1923 \gregion{344}{HK}{HKG}{}%
1924 \gregion{348}{HU}{HUN}{}%
1925 \gregion{352}{IS}{ISL}{}%
1926 \gregion{356}{IN}{IND}{}%
1927 \gregion{360}{ID}{IDN}{}%
1928 \gregion{364}{IR}{IRN}{}%
1929 \gregion{368}{IQ}{IRQ}{}%
1930 \gregion{372}{IE}{IRL}{}%
1931 \gregion{833}{IM}{IMN}{}%
1932 \gregion{376}{IL}{ISR}{}%
1933 \gregion{380}{IT}{ITA}{}%
1934 \gregion{388}{JM}{JAM}{}%
1935 \gregion{392}{JP}{JPN}{}%
1936 \gregion{832}{JE}{JEY}{}%
1937 \gregion{400}{JO}{JOR}{}%
1938 \gregion{398}{KZ}{KAZ}{}%
1939 \gregion{404}{KE}{KEN}{}%
1940 \gregion{296}{KI}{KIR}{}%
1941 \gregion{408}{KP}{PRK}{}%
1942 \gregion{410}{KR}{KOR}{}%
1943 \gregion{414}{KW}{KWT}{}%
1944 \gregion{417}{KG}{KGZ}{}%
1945 \gregion{418}{LA}{LAO}{}%
1946 \gregion{428}{LV}{LVA}{}%
1947 \gregion{422}{LB}{LBN}{}%
1948 \gregion{426}{LS}{LSO}{}%
1949 \gregion{430}{LR}{LBR}{}%
1950 \gregion{434}{LY}{LBY}{}%
1951 \gregion{438}{LI}{LIE}{}%
1952 \gregion{440}{LT}{LTU}{}%
1953 \gregion{442}{LU}{LUX}{}%
1954 \gregion{446}{MO}{MAC}{}%
1955 \gregion{807}{MK}{MKD}{}%
1956 \gregion{450}{MG}{MDG}{}%
1957 \gregion{454}{MW}{MWI}{}%
1958 \gregion{458}{MY}{MYS}{}%
1959 \gregion{462}{MV}{MDV}{}%
1960 \gregion{466}{ML}{MLI}{}%
1961 \gregion{470}{MT}{MLT}{}%
1962 \gregion{584}{MH}{MHL}{}%
1963 \gregion{474}{MQ}{MTQ}{}%
1964 \gregion{478}{MR}{MRT}{}%
1965 \gregion{480}{MU}{MUS}{}%
1966 \gregion{175}{YT}{MYT}{}%
1967 \gregion{484}{MX}{MEX}{}%
1968 \gregion{583}{FM}{FSM}{}%
1969 \gregion{498}{MD}{MDA}{}%
1970 \gregion{492}{MC}{MCO}{}%
1971 \gregion{496}{MN}{MNG}{}%
1972 \gregion{499}{ME}{MNE}{}%
1973 \gregion{500}{MS}{MSR}{}%
1974 \gregion{504}{MA}{MAR}{}%
1975 \gregion{508}{MZ}{MOZ}{}%
1976 \gregion{104}{MM}{MMR}{}%
1977 \gregion{516}{NA}{NAM}{}%
1978 \gregion{520}{NR}{NRU}{}%
1979 \gregion{524}{NP}{NPL}{}%
1980 \gregion{528}{NL}{NLD}{}%
1981 \gregion{540}{NC}{NCL}{}%
1982 \gregion{554}{NZ}{NZL}{}%
1983 \gregion{558}{NI}{NIC}{}%
1984 \gregion{562}{NE}{NER}{}%
1985 \gregion{566}{NG}{NGA}{}%
1986 \gregion{570}{NU}{NIU}{}%
1987 \gregion{574}{NF}{NFK}{}%
1988 \gregion{580}{MP}{MNP}{}%
1989 \gregion{578}{NO}{NOR}{}%
1990 \gregion{512}{OM}{OMN}{}%
1991 \gregion{586}{PK}{PAK}{}%
1992 \gregion{585}{PW}{PLW}{}%
1993 \gregion{275}{PS}{PSE}{}%
1994 \gregion{591}{PA}{PAN}{}%
1995 \gregion{598}{PG}{PNG}{}%
1996 \gregion{600}{PY}{PRY}{}%
1997 \gregion{604}{PE}{PER}{}%
1998 \gregion{608}{PH}{PHL}{}%
1999 \gregion{612}{PN}{PCN}{}%
2000 \gregion{616}{PL}{POL}{}%
2001 \gregion{620}{PT}{PRT}{}%
2002 \gregion{630}{PR}{PRI}{}%
2003 \gregion{634}{QA}{QAT}{}%
2004 \gregion{638}{RE}{REU}{}%
2005 \gregion{642}{RO}{ROU}{}%
2006 \gregion{643}{RU}{RUS}{}%
2007 \gregion{646}{RW}{RWA}{}%
2008 \gregion{652}{BL}{BLM}{}%
2009 \gregion{654}{SH}{SHN}{}%
2010 \gregion{659}{KN}{KNA}{}%
2011 \gregion{662}{LC}{LCA}{}%
2012 \gregion{663}{MF}{MAF}{}%
2013 \gregion{666}{PM}{SPM}{}%
2014 \gregion{670}{VC}{VCT}{}%
2015 \gregion{882}{WS}{WSM}{}%
2016 \gregion{674}{SM}{SMR}{}%
2017 \gregion{678}{ST}{STP}{}%
2018 \gregion{682}{SA}{SAU}{}%
2019 \gregion{686}{SN}{SEN}{}%
2020 \gregion{688}{RS}{SRB}{}%
2021 \gregion{690}{SC}{SYC}{}%
2022 \gregion{694}{SL}{SLE}{}%
2023 \gregion{702}{SG}{SGP}{}%
2024 \gregion{534}{SX}{SXM}{}%
2025 \gregion{703}{SK}{SVK}{}%
2026 \gregion{705}{SI}{SVN}{}%
2027 \gregion{090}{SB}{SLB}{}%
2028 \gregion{706}{SO}{SOM}{}%
2029 \gregion{710}{ZA}{ZAF}{}%
2030 \gregion{239}{GS}{SGS}{}%
2031 \gregion{728}{SS}{SSD}{}%
2032 \gregion{724}{ES}{ESP}{}%
2033 \gregion{144}{LK}{LKA}{}%
2034 \gregion{729}{SD}{SDN}{}%
2035 \gregion{740}{SR}{SUR}{}%
2036 \gregion{744}{SJ}{SJM}{}%
2037 \gregion{748}{SZ}{SWZ}{}%
2038 \gregion{752}{SE}{SWE}{}%
2039 \gregion{756}{CH}{CHE}{}%
2040 \gregion{760}{SY}{SYR}{}%
2041 \gregion{158}{TW}{TWN}{}%
2042 \gregion{762}{TJ}{TJK}{}%
2043 \gregion{834}{TZ}{TZA}{}%
2044 \gregion{764}{TH}{THA}{}%
2045 \gregion{626}{TL}{TLS}{}%
2046 \gregion{768}{TG}{TGO}{}%
2047 \gregion{772}{TK}{TKL}{}%
2048 \gregion{776}{TO}{TON}{}%
2049 \gregion{780}{TT}{TTO}{}%
2050 \gregion{788}{TN}{TUN}{}%
2051 \gregion{792}{TR}{TUR}{}%
2052 \gregion{795}{TM}{TKM}{}%
2053 \gregion{796}{TC}{TCA}{}%
2054 \gregion{798}{TV}{TUV}{}%
2055 \gregion{800}{UG}{UGA}{}%
2056 \gregion{804}{UA}{UKR}{}%
2057 \gregion{784}{AE}{ARE}{}%
2058 \gregion{826}{GB}{GBR}{}%
2059 \gregion{581}{UM}{UMI}{}%
2060 \gregion{840}{US}{USA}{}%
2061 \gregion{858}{UY}{URY}{}%
2062 \gregion{860}{UZ}{UZB}{}%
2063 \gregion{548}{VU}{VUT}{}%
2064 \gregion{862}{VE}{VEN}{}%
2065 \gregion{704}{VN}{VNM}{}%
2066 \gregion{092}{VG}{VGB}{}%
2067 \gregion{850}{VI}{VIR}{}%
2068 \gregion{876}{WF}{WLF}{}%
2069 \gregion{732}{EH}{ESH}{}%
2070 \gregion{887}{YE}{YEM}{}%
2071 \gregion{894}{ZM}{ZMB}{}%
2072 \gregion{716}{ZW}{ZWE}{}%
2073 % PREDEFINED SCRIPTS
2074 \gscript{Adlm}{166}{Adlam}{RL}{}{}
2075 \gscript{Afak}{439}{Afaka}{varies}{}{}
2076 \gscript{Aghb}{239}{Caucasian Albanian}{LR}{}{}
2077 \gscript{Ahom}{338}{Ahom, Tai Ahom}{LR}{}{}
2078 \gscript{Arab}{160}{Arabic}{RL}{}{}
2079 \gscript{Aran}{161}{Arabic (Nastaliq variant)}{RL}{}{}
2080 \gscript{Armi}{124}{Imperial Aramaic}{RL}{}{}
2081 \gscript{Armn}{230}{Armenian}{LR}{}{}
2082 \gscript{Avst}{134}{Avestan}{RL}{}{}
2083 \gscript{Bali}{360}{Balinese}{LR}{}{}
2084 \gscript{Bamu}{435}{Bamum}{LR}{}{}
2085 \gscript{Bass}{259}{Bassa Vah}{LR}{}{}
2086 \gscript{Batk}{365}{Batak}{LR}{}{}
2087 \gscript{Beng}{334}{Bhaiksuki}{LR}{}{}
2088 \gscript{Blis}{550}{Blissymbols}{varies}{}{}
2089 \gscript{Bopo}{285}{Bopomofo}{LR}{}{}
2090 \gscript{Brah}{300}{Brahmi}{LR}{}{}
2091 \gscript{Brai}{570}{Braille}{LR}{}{}
2092 \gscript{Bugi}{367}{Buginese}{LR}{}{}
2093 \gscript{Buhd}{372}{Buhid}{LR}{}{}
2094 \gscript{Cakm}{349}{Chakma}{LR}{}{}
2095 \gscript{Cans}{440}{Unified Canadian Aboriginal Syllabics}{LR}{}{}
2096 \gscript{Cari}{201}{Carian}{LR}{}{}
2097 \gscript{Cham}{358}{Cham}{LR}{}{}
2098 \gscript{Cher}{445}{Cherokee}{LR}{}{}
2099 \gscript{Cirt}{291}{Cirth}{varies}{}{}
2100 \gscript{Copt}{204}{Coptic}{LR}{}{}
2101 \gscript{Cprt}{403}{Cypriot}{RL}{}{}
2102 \gscript{Cyrl}{220}{Cyrillic}{LR}{}{}
2103 \gscript{Cyrs}{221}{Cyrillic (Old Church Slavonic variant)}{varies}{}{}
2104 \gscript{Deva}{315}{Devanagari (Nagari)}{LR}{}{}
2105 \gscript{Dsrt}{250}{Deseret (Mormon)}{LR}{}{}
2106 \gscript{Dupl}{755}{Duployan shorthand, Duployan stenography}{LR}{}{}
2107 \gscript{Egyd}{070}{Egyptian demotic}{RL}{}{}
2108 \gscript{Egyh}{060}{Egyptian hieratic}{RL}{}{}
2109 \gscript{Egyp}{050}{Egyptian hieroglyphs}{LR}{}{}
2110 \gscript{Elba}{226}{Elbasan}{LR}{}{}
2111 \gscript{Ethi}{430}{Ethiopic (Ge'ez)}{LR}{}{}
2112 \gscript{Geok}{241}{Khutsuri (Asomtavruli and Nuskhuri)}{LR}{}{}
2113 \gscript{Geor}{240}{Georgian (Mkhedruli)}{LR}{}{}
2114 \gscript{Glag}{225}{Glagolitic}{LR}{}{}
2115 \gscript{Goth}{206}{Gothic}{LR}{}{}
2116 \gscript{Gran}{343}{Grantha}{LR}{}{}
2117 \gscript{Grek}{200}{Greek}{LR}{}{}
2118 \gscript{Gujr}{320}{Gujarati}{LR}{}{}
2119 \gscript{Guru}{310}{Gurmukhi}{LR}{}{}
2120 \gscript{Hanb}{503}{Han with Bopomofo (alias for Han + Bopomofo)}{LR}{}{}
2121 \gscript{Hang}{286}{Hangul}{LR}{}{}
2122 \gscript{Hani}{500}{Han (Hanzi, Kanji, Hanja)}{LR}{}{}
2123 \gscript{Hano}{371}{Hanunoo}{LR}{}{}
2124 \gscript{Hans}{501}{Han (Simplified variant)}{varies}{}{}
2125 \gscript{Hant}{502}{Han (Traditional variant)}{varies}{}{}
2126 \gscript{Hatr}{127}{Hatran}{RL}{}{}
2127 \gscript{Hebr}{125}{Hebrew}{RL}{}{}
2128 \gscript{Hira}{410}{Hiragana}{LR}{}{}
2129 \gscript{Hluw}{080}{Anatolian Hieroglyphs (Luwian Hieroglyphs, Hittite Hieroglyphs)}{LR}{}{}
2130 \gscript{Hmng}{450}{Pahawh Hmong}{LR}{}{}
2131 \gscript{Hrkt}{412}{Japanese syllabaries (alias for Hiragana + Katakana)}{varies}{}{}
2132 \gscript{Hung}{176}{Old Hungarian (Hungarian Runic)}{RL}{}{}
2133 \gscript{Inds}{610}{Indus (Harappan)}{RL}{}{}
2134 \gscript{Ital}{210}{Old Italic (Etruscan, Oscan, etc.)}{LR}{}{}
2135 \gscript{Jamo}{284}{Jamo (alias for Jamo subset of Hangul)}{LR}{}{}
2136 \gscript{Java}{361}{Javanese}{LR}{}{}
2137 \gscript{Jpan}{413}{Japanese (alias for Han + Hiragana + Katakana)}{varies}{}{}
2138 \gscript{Jurc}{510}{Jurchen}{LR}{}{}
2139 \gscript{Kali}{357}{Kayah Li}{LR}{}{}
2140 \gscript{Kana}{411}{Katakana}{LR}{}{}
2141 \gscript{Khar}{305}{Kharoshthi}{RL}{}{}
2142 \gscript{Khmr}{355}{Khmer}{LR}{}{}
2143 \gscript{Khoj}{322}{Khojki}{LR}{}{}
2144 \gscript{Kitl}{505}{Khitan large script}{LR}{}{}
2145 \gscript{Kits}{288}{Khitan small script}{TB}{}{}
2146 \gscript{Knda}{345}{Kannada}{LR}{}{}
2147 \gscript{Kore}{287}{Korean (alias for Hangul + Han)}{LR}{}{}
2148 \gscript{Kpel}{436}{Kpelle}{LR}{}{}
2149 \gscript{Kthi}{317}{Kaithi}{LR}{}{}
2150 \gscript{Lana}{351}{Tai Tham (Lanna)}{LR}{}{}
2151 \gscript{Laoo}{356}{Lao}{LR}{}{}
2152 \gscript{Latf}{217}{Latin (Fraktur variant)}{varies}{}{}
2153 \gscript{Latg}{216}{Latin (Gaelic variant)}{LR}{}{}
2154 \gscript{Latn}{215}{Latin}{LR}{}{}
2155 \gscript{Leke}{364}{Leke}{LR}{}{}
2156 \gscript{Lepc}{335}{Lepcha}{LR}{}{}
2157 \gscript{Limb}{336}{Limbu}{LR}{}{}
2158 \gscript{Lina}{400}{Linear A}{LR}{}{}
2159 \gscript{Linb}{401}{Linear B}{LR}{}{}
2160 \gscript{Lisu}{399}{Lisu (Fraser)}{LR}{}{}
2161 \gscript{Loma}{437}{Loma}{LR}{}{}
2162 \gscript{Lyci}{202}{Lycian}{LR}{}{}
2163 \gscript{Lydi}{116}{Lydian}{RL}{}{}
2164 \gscript{Mahj}{314}{Mahajani}{LR}{}{}
2165 \gscript{Mand}{140}{Mandaic, Mandaean}{RL}{}{}
2166 \gscript{Mani}{139}{Manichaean}{RL}{}{}
2167 \gscript{Marc}{332}{Marchen}{LR}{}{}
2168 \gscript{Maya}{090}{Mayan hieroglyphs}{varies}{}{}
2169 \gscript{Mend}{438}{Mende Kikakui}{RL}{}{}
2170 \gscript{Merc}{101}{Meroitic Cursive}{RL}{}{}
2171 \gscript{Mero}{100}{Meroitic Hieroglyphs}{RL}{}{}
2172 \gscript{Mlym}{347}{Malayalam}{LR}{}{}
2173 \gscript{Modi}{324}{Modi}{LR}{}{}
2174 \gscript{Mong}{145}{Mongolian}{TB}{}{}
2175 \gscript{Moon}{218}{Moon (Moon code, Moon script, Moon type)}{varies}{}{}
2176 \gscript{Mroo}{199}{Mro, Mru}{LR}{}{}
2177 \gscript{Mtei}{337}{Meitei Mayek (Meithei, Meetei)}{LR}{}{}
2178 \gscript{Mult}{323}{Multani}{LR}{}{}
2179 \gscript{Mymr}{350}{Myanmar (Burmese)}{LR}{}{}
2180 \gscript{Narb}{106}{Old North Arabian (Ancient North Arabian)}{RL}{}{}
2181 \gscript{Nbat}{159}{Nabataean}{RL}{}{}
2182 \gscript{Newa}{333}{Newa, Newar, Newari}{LR}{}{}
2183 \gscript{Nkgb}{420}{Nakhi Geba}{LR}{}{}
2184 \gscript{Nkoo}{165}{N'Ko}{RL}{}{}
2185 \gscript{Nshu}{499}{Nushu}{LR}{}{}
2186 \gscript{Ogam}{212}{Ogham}{varies}{}{}
2187 \gscript{Olck}{261}{Ol Chiki}{LR}{}{}
2188 \gscript{Orkh}{175}{Old Turkic, Orkhon Runic}{RL}{}{}
2189 \gscript{Orya}{327}{Oriya}{LR}{}{}
2190 \gscript{Osge}{219}{Osage}{LR}{}{}
2191 \gscript{Osma}{260}{Osmanya}{LR}{}{}
2192 \gscript{Palm}{126}{Palmyrene}{RL}{}{}
2193 \gscript{Pauc}{263}{Pau Cin Hau}{LR}{}{}
2194 \gscript{Perm}{227}{Old Permic}{LR}{}{}
2195 \gscript{Phag}{331}{Phags-pa}{TB}{}{}
2196 \gscript{Phli}{131}{Inscriptional Pahlavi}{RL}{}{}
2197 \gscript{Phlp}{132}{Psalter Pahlavi}{RL}{}{}
2198 \gscript{Phlv}{133}{Book Pahlavi}{RL}{}{}
2199 \gscript{Phnx}{115}{Phoenician}{RL}{}{}
2200 \gscript{Piqd}{293}{Klingon (KLI plqaD)}{LR}{}{}
2201 \gscript{Plrd}{282}{Miao (Pollard)}{LR}{}{}
2202 \gscript{Prti}{130}{Inscriptional Parthian}{RL}{}{}
2203 \gscript{Qaaa}{900}{Reserved for private use (start)}{varies}{}{}
2204 \gscript{Qaai}{908}{Private use}{varies}{}{}
2205 \gscript{Qabx}{949}{Reserved for private use (end)}{varies}{}{}
2206 \gscript{Rjng}{363}{Rejang (Redjang, Kaganga)}{LR}{}{}
2207 \gscript{Roro}{620}{Rongorongo}{varies}{}{}
2208 \gscript{Runr}{211}{Runic}{LR}{}{}
2209 \gscript{Samr}{123}{Samaritan}{RL}{}{}
2210 \gscript{Sara}{292}{Sarati}{varies}{}{}
2211 \gscript{Sarb}{105}{Old South Arabian}{RL}{}{}
2212 \gscript{Saur}{344}{Saurashtra}{LR}{}{}
2213 \gscript{Sgnw}{095}{SignWriting}{TB}{}{}
2214 \gscript{Shaw}{281}{Shavian (Shaw)}{LR}{}{}
2215 \gscript{Shrd}{319}{Sharada}{LR}{}{}
2216 \gscript{Sidd}{302}{Siddham}{LR}{}{}
2217 \gscript{Sind}{318}{Khudawadi, Sindhi}{LR}{}{}
2218 \gscript{Sinh}{348}{Sinhala}{LR}{}{}
2219 \gscript{Sora}{398}{Sora Sompeng}{LR}{}{}
2220 \gscript{Sund}{362}{Sundanese}{LR}{}{}
2221 \gscript{Sylo}{316}{Syloti Nagri}{LR}{}{}
2222 \gscript{Syrc}{135}{Syriac}{RL}{}{}
2223 \gscript{Syre}{138}{Syriac (Estrangelo variant)}{RL}{}{}
2224 \gscript{Syrj}{137}{Syriac (Western variant)}{RL}{}{}
2225 \gscript{Syrn}{136}{Syriac (Eastern variant)}{RL}{}{}
2226 \gscript{Tagb}{373}{Tagbanwa}{LR}{}{}
2227 \gscript{Takr}{321}{Takri}{LR}{}{}
2228 \gscript{Tale}{353}{Tai Le}{LR}{}{}
2229 \gscript{Talu}{354}{New Tai Lue}{LR}{}{}
2230 \gscript{Taml}{346}{Tamil}{LR}{}{}
2231 \gscript{Tang}{520}{Tangut}{LR}{}{}
2232 \gscript{Tavt}{359}{Tai Viet}{LR}{}{}
2233 \gscript{Telu}{340}{Telugu}{LR}{}{}
2234 \gscript{Teng}{290}{Tengwar}{LR}{}{}
2235 \gscript{Tfng}{120}{Tifinagh (Berber)}{LR}{}{}
2236 \gscript{Tglg}{370}{Tagalog (Baybayin, Alibata)}{LR}{}{}
2237 \gscript{Thaa}{170}{Thaana}{RL}{}{}
2238 \gscript{Thai}{352}{Thai}{LR}{}{}
2239 \gscript{Tibt}{330}{Tibetan}{LR}{}{}
2240 \gscript{Tirh}{326}{Tirhuta}{LR}{}{}
2241 \gscript{Ugar}{040}{Ugaritic}{LR}{}{}
2242 \gscript{Vaii}{470}{Vai}{LR}{}{}
2243 \gscript{Visp}{280}{Visible Speech}{LR}{}{}
2244 \gscript{Wara}{262}{Warang Citi (Varang Kshiti)}{LR}{}{}
2245 \gscript{Wole}{480}{Woleai}{RL}{}{}
2246 \gscript{Xpeo}{030}{Old Persian}{LR}{}{}
2247 \gscript{Xsux}{020}{Cuneiform, Sumero-Akkadian}{LR}{}{}
2248 \gscript{Yiii}{460}{Yi}{LR}{}{}
2249 \gscript{Zinh}{994}{Inherited script}{inherited}{}{}
2250 \gscript{Zmth}{995}{Mathematical notation}{LR}{}{}
2251 \gscript{Zsym}{996}{Symbols}{varies}{}{}
2252 \gscript{Zsye}{993}{Symbols (emoji variant)}{varies}{}{}
2253 \gscript{Zxxx}{997}{Unwritten documents}{varies}{}{}
2254 \gscript{Zyyy}{998}{Undetermined script}{varies}{}{}
2255 \gscript{Zzzz}{999}{Uncoded script}{varies}{}{}
2256 }
2257
2258 \title{tracklang.sty v1.6.8:
2259 tracking language options}
2260 \author{Nicola L.C. Talbot\\[10pt]
2261 Dickimaw Books\\
2262 \href{https://www.dickimaw-books.com/}{\nolinkurl{dickimaw-books.com}}}
2263 \date{2026-05-24
2264 }
2265
2266 \newcommand{\refoptstables}{\tablesref{tab:bcp47opts,tab:rootlangopts,tab:nonbcp47opts}}
2267
2268 \begin{document}
2269 \maketitle
2270
2271 \htmlavailable
2272
2273 \begin{abstract}
2274 The \sty+{tracklang} package is provided for package developers
2275 who want a simple interface to find out which languages the user has
2276 requested through packages such as \sty{babel} and
2277 \sty{polyglossia}. \emph{This package doesn't provide any
2278 translations.}
2279 Its purpose is simply to track which languages have been requested by the
2280 user. Generic \TeX\ code is in \file{tracklang.tex} for
2281 non-\LaTeX\ users.
2282
2283 If the \idx{shellescape} is enabled or \gls{directlua} is available,
2284 this package may also be used to query the \envvar{LCALL}
2285 or \envvar{LANG} environment variable (see
2286 \sectionref{sec:langsty}). Windows users, who don't have the locale
2287 stored in environment variables, can use \app{texosquery}
2288 in combination with \sty{tracklang}. (Similarly if \envvar{LCALL}
2289 or \envvar{LANG} don't contain sufficient information.) In order to
2290 use \app{texosquery} through the restricted \idx{shellescape}, you must
2291 have at least Java~8 and set up \file{texosquery.cfg}
2292 appropriately. (See the \app{texosquery} manual for further details.)
2293 \end{abstract}
2294
2295 The fundamental aim of this generic package is to be able to
2296 effectively say:
2297 \begin{quote}
2298 The user (that is, the \emph{document} author) wants to use
2299 dialects \langtagfmt{xx-XX}, \langtagfmt{yy-YY-Scrp}, etc in their
2300 document. Any packages used by their document that provide
2301 multilingual or region-dependent support should do whatever is
2302 required to activate the settings for those languages and regions
2303 (or warn the user that there's no support).
2304 \end{quote}
2305 Naturally, this is only of use if the locale-sensitive packages use
2306 \sty{tracklang} to pick up this information, which is entirely up
2307 to the package authors, but at the moment there's no standard method
2308 for packages to detect the required language and region. The aim of
2309 \sty{tracklang} is to provide that method. In particular, the
2310 emphasis is on using \idx{BCP47} tags with \idx+{ISO} language and region codes rather than
2311 hard-coding the various language labels used by different language
2312 packages.
2313
2314 Related articles:
2315 \tugboat{Localisation of \TeX\ documents: \styfmt{tracklang}.}
2316 {2016}{37}{3}{http://www.tug.org/TUGboat/tb37-3/tb117talbot.pdf},
2317 \dickimawhref{latex/tracklang}{Localisation with \filefmt{tracklang.tex}},
2318 and \faqspkg{tracklang}.
2319
2320 \frontmatter
2321 \tableofcontents
2322 \listoftables
2323
2324 \mainmatter
2325 \part{User Guide}
2326
2327 \chapter{Introduction}
2328 \label{sec:intro}
2329
2330 When I'm developing a package that provides multilingual support
2331 (for example, \sty{glossaries}) it's cumbersome trying to work out
2332 if the user has requested translations for fixed text. This usually
2333 involves checking if \sty{babel} or \sty{translator} or
2334 \sty{polyglossia} has been loaded and, if so, what language settings
2335 have been used. The result can be a tangled mass of conditional
2336 code. The alternative is to tell users to add the language as
2337 a~document class option, which they may or may not want to do, or to
2338 tell them to supply the language settings to every package they load
2339 that provides multilingual support, which users are even less likely
2340 to want to do.
2341
2342 The \sty{tracklang} package tries to neaten this up by working out
2343 as much of this information as possible for you and providing a
2344 command that iterates through the loaded languages. This way, you
2345 can just iterate through the list of tracked languages and, for each
2346 language, either define the translations or warn the user that
2347 there's no translation for that language.
2348
2349 As from version 1.6.4, \sty{tracklang} now checks for
2350 \sty{babel}['s] \gls{LocaleForEach} and, if defined, will
2351 use that command to iterate over all languages that have currently
2352 been loaded either via package option or using \gls{babelprovide}.
2353 Note that \qt{lazy loading} a language via \gls{selectlanguage}
2354 in the document is too late for \sty{tracklang} to detect.
2355
2356 If \sty{polyglossia} is loaded, \sty{tracklang} will check if
2357 \gls{xpg@bcp@loaded} is defined and, if so, will iterate over that
2358 list. Older versions of \sty{babel} and \sty{polyglossia} that lack
2359 these convenient commands are much harder for \sty{tracklang} to
2360 work with.
2361
2362 The \sty{tracklang} package works fairly well with
2363 \sty{translator} but will additionally assume the root language was
2364 also requested when a dialect is specified. So, for example,
2365 \begin{codebox}
2366 \cmd{usepackage}[\opt{british}]\marg{translator}
2367 \cmd{usepackage}\marg{tracklang}
2368 \end{codebox}
2369 is equivalent to
2370 \begin{compactcodebox}
2371 \cmd{usepackage}[\opt{british}]\marg{translator}
2372 \cmd{usepackage}[\opt{english},\opt{british}]\marg{tracklang}
2373 \end{compactcodebox}
2374 This means that \gls{ForEachTrackedDialect} will iterate
2375 through the list \qt{\opt{english}\dcomma\opt{british}} instead of just
2376 \qt{\opt{british}}, which can result in some redundancy.
2377
2378 If any document class or package options are passed to
2379 \sty{tracklang}, then \sty{tracklang} won't bother checking
2380 for known language packages. So, if the above example is changed to:
2381 \begin{codebox}
2382 \cmd{documentclass}[\opt{british}]\marg{article}
2383 \cmd{usepackage}\marg{translator}
2384 \cmd{usepackage}\marg{tracklang}
2385 \end{codebox}
2386 then the dialect list will just consist of \qt{\opt{british}} rather than
2387 \qt{\opt{english},\opt{british}}. This does, however, mean that if the user mixes
2388 class and package options, only the class options will be detected.
2389 For example:
2390 \begin{codebox}
2391 \cmd{documentclass}[\opt{british}]\marg{article}
2392 \cmd{usepackage}[\opt{french}]\marg{babel}
2393 \cmd{usepackage}\marg{tracklang}
2394 \end{codebox}
2395 In this case, only the \opt{british} option will be detected. The user
2396 can therefore use the document class option (or \sty{tracklang}
2397 package option) to override the dialect and set the country code
2398 (where provided). For example:
2399 \begin{codebox}
2400 \cmd{documentclass}[\opt{es-MX}]\marg{article}
2401 \cmd{usepackage}[\opt{spanish}]\marg{babel}
2402 \cmd{usepackage}\marg{tracklang}
2403 \end{codebox}
2404 This sets the dialect to \opt{mexicanspanish} and the root language to
2405 \opt{spanish}.
2406
2407 Predefined dialects are listed in \refoptstables. These may be
2408 passed in the document class options or
2409 used in \gls{TrackPredefinedDialect}, as illustrated above.
2410
2411 \begin{information}
2412 Version 1.6.8 introduced \opt{de-DE-1901}, \opt{de-AT-1901} and
2413 \opt{de-CH-1901}. The options \opt{de-DE}, \opt{de-AT} and
2414 \opt{de-CH} were made synonymous to \opt{de-DE-1996},
2415 \opt{de-AT-1996} and \opt{de-CH-1996}, respectively.
2416 The label used in the \sty{babel} captions hooks for \opt{de-CH-1996}
2417 and \opt{de-CH-1901} seem to be
2418 \optfmt{nswissgeman} and \optfmt{swissgeman} (no \qt{r}).
2419 So this is what's used for the target mapping label.
2420 \end{information}
2421
2422 \Sectionref{sec:summary} provides brief examples of use for those
2423 who want a general overview before reading the more detailed
2424 sections.
2425 \Sectionref{sec:generic} describes generic commands for
2426 identifying the document languages.
2427 \Sectionref{sec:user} is for package writers who want to
2428 add multilingual support to their package and need to know which
2429 settings the user has requested through language packages like
2430 \sty{babel}. \Sectionref{sec:langsty} is for
2431 developers of language definition packages who want to help other
2432 package writers to detect what languages have been requested.
2433
2434 \printunsrttable
2435 [
2436 type=index,
2437 block-style=name-other,
2438 other=dialect,
2439 toctitle={Predefined BCP~47 Language-Region Dialects},
2440 title={Predefined Language-Region Dialects. (\idx{BCP47} tag or
2441 \styfmt{tracklang} dialect label may be used as a
2442 package option or with \gls{TrackPredefinedDialect})},
2443 label={tab:bcp47opts},
2444 postamble={Other combinations need to be set with \gls{TrackLocale}
2445 or \gls{TrackLanguageTag}},
2446 init={%
2447 \renewcommand{\glstableNameTarget}[1]{\inlineglsdef[optdef]{##1}}%
2448 \let\glstableOtherFmt\optfmt
2449 \renewcommand{\glstablenameheader}{Tag}%
2450 \renewcommand{\glstableotherheader}{\styfmt{tracklang} Dialect Label}%
2451 \renewcommand{\glstableiffilter}[3]{\glsifcategory{##1}{bcplangregion}{##3}{##2}}%
2452 }
2453 ]
2454
2455 \printunsrttable
2456 [
2457 type=index,
2458 header=false,rules=false,blocksep={},clearpage,
2459 block-style=name,blocks=3,
2460 other=isotag,
2461 toctitle={Predefined Root Languages},
2462 title={Predefined Root Languages. (\fnregion Has an associated
2463 territory.) The corresponding tag obtained with
2464 \code{\gls{GetTrackedLanguageTag}\margm{dialect}} is shown in
2465 parentheses},
2466 label={tab:rootlangopts},
2467 init={\let\glstableOtherFmt\optfmt
2468 \renewcommand{\glstableNameTarget}[1]{\inlineglsdef[optdef]{##1}}%
2469 \renewcommand{\glstableiffilter}[3]{\glsifcategory{##1}{rootlang}{##3}{##2}}%
2470 }
2471 ]
2472
2473 \printunsrttable
2474 [
2475 type=index,
2476 block-style=name,rules=false,header=false,blocksep={},clearpage,
2477 other=tags,par=ragged,
2478 toctitle={Predefined Dialects Labels},
2479 title={Predefined Dialects Labels. (\fnregion Has an
2480 associated territory.) The corresponding
2481 language tag obtained with
2482 \code{\gls{GetTrackedLanguageTag}\margm{dialect}}
2483 is shown in parentheses. If the dialect has a corresponding mapping
2484 for the closest matching non-root language \gls{captionsdialect} or
2485 \gls{datedialect}, this is also included after the tag following a
2486 slash (matching \sty{babel}['s] spelling for Swiss German
2487 \gls{captionsdialect}).},
2488 label={tab:nonbcp47opts},
2489 init={%
2490 \renewcommand{\glstableiffilter}[3]{\glsifcategory{##1}{nonbcp}{##3}{##2}}%
2491 \renewcommand{\glstableNameTarget}[1]{%
2492 \inlineglsdef[optdef]{##1}%
2493 \glsxtrifhasfield{postname}{##1}{\space \glscurrentfieldvalue}{}%
2494 }%
2495 }
2496 ]
2497
2498 \chapter{Summary of Use}
2499 \label{sec:summary}
2500
2501 There are three levels of use:
2502 \begin{enumerate}
2503 \item document level (code used by document authors);
2504
2505 \item locale-sensitive package level
2506 (code for package authors who need to
2507 know what languages or locale the document is
2508 using, such as \sty{glossaries} to translate commands like
2509 \cmd{descriptionname} or \sty{datetime2} to provide localised
2510 formats or time zone information);
2511
2512 \item language set-up level (code for packages that set up
2513 the document languages, such as \sty{babel} or \sty{polyglossia}).
2514 \end{enumerate}
2515
2516 \section{Document Level}
2517 \label{sec:summary-doc}
2518
2519 Document level use can be divided into generic \TeX\ use
2520 (\sectionref{sec:tex}) and \LaTeX-specific use (\sectionref{sec:latex}).
2521
2522 \subsection{Generic \texorpdfstring{\TeX}{TeX}}
2523 \label{sec:tex}
2524
2525 This section is for generic \TeX\ use. The \sty+{tracklang} files are
2526 loaded with \gls{input}. See \sectionref{sec:latex} for \LaTeX\ use.
2527
2528 A Unix-like user wants the locale information picked up from the
2529 locale environment variable (the \ext+{tex} extension may be omitted):
2530 \begin{codebox*}
2531 \gls{input} \file{tracklang.tex} \comment{v1.3}
2532 \gls{TrackLangFromEnv}
2533 \comment{load packages that use tracklang for localisation}
2534 \end{codebox*}
2535
2536 A Windows user wants the locale information picked up from the
2537 operating system (again the \ext{tex} extension may be omitted):
2538 \begin{codebox*}
2539 \gls{input} \file{texosquery.tex}
2540 \gls{input} \file{tracklang.tex} \comment{v1.3}
2541 \gls{TrackLangFromEnv}
2542 \comment{load packages that use tracklang for localisation}
2543 \end{codebox*}
2544 Or (\sty{texosquery} v1.2)
2545 \begin{codebox*}
2546 \gls{input} \file{texosquery.tex} \comment{v1.2}
2547 \gls{input} \file{tracklang.tex} \comment{v1.3}
2548 \codepar
2549 \gls{TeXOSQueryLangTag}\marg{\cmd{langtag}}
2550 \gls{TrackLanguageTag}\marg{\cmd{langtag}}
2551 \comment{load packages that use tracklang for localisation}
2552 \end{codebox*}
2553 A Unix-like user who may or may not have \app{texosquery} setup to run in the
2554 \idx{shellescape}:
2555 \begin{codebox*}
2556 \gls{input} \file{texosquery.tex}
2557 \gls{input} \file{tracklang.tex} \comment{v1.3}
2558 \codepar
2559 \cmd{ifdefined}\gls{TeXOSQueryLangTag}
2560 \gls{TeXOSQueryLangTag}\marg{\cmd{langtag}}
2561 \gls{TrackLanguageTag}\marg{\cmd{langtag}}
2562 \cmd{else}
2563 \gls{TrackLangFromEnv}
2564 \cmd{fi}
2565 \comment{load packages that use tracklang for localisation}
2566 \end{codebox*}
2567
2568 A user is writing in Italy in Armenian with a Latin
2569 \idx{script} (\opt{Latn}) and the arevela \idx{variant}:
2570 \begin{codebox*}
2571 \gls{input} \file{tracklang.tex} \comment{v1.3}
2572 \gls{TrackLanguageTag}\marg{hy-Latn-IT-arevela}
2573 \comment{load packages that use tracklang for localisation}
2574 \end{codebox*}
2575
2576 A user is writing in English in the UK:
2577 \begin{codebox*}
2578 \gls{input} \file{tracklang.tex}
2579 \gls{TrackPredefinedDialect}\marg{british}
2580 \comment{load packages that use tracklang for localisation}
2581 \end{codebox*}
2582
2583 Find out information about the current language (supplied
2584 in \gls{languagename}):
2585 \begin{codebox*}
2586 \gls{SetCurrentTrackedDialect}\marg{\gls{languagename}}
2587 Dialect label: \gls{CurrentTrackedDialect}.
2588 Language label: \gls{CurrentTrackedLanguage}.
2589 ISO 639 language Code: \gls{CurrentTrackedIsoCode}.
2590 ISO 3166-1 Region Code: \gls{CurrentTrackedRegion}.
2591 Modifier: \gls{CurrentTrackedDialectModifier}.
2592 Variant: \gls{CurrentTrackedDialectVariant}.
2593 Script: \gls{CurrentTrackedDialectScript}.
2594 Sub-Lang: \gls{CurrentTrackedDialectSubLang}.
2595 Additional: \gls{CurrentTrackedDialectAdditional}.
2596 BCP 47 Language Tag: \gls{CurrentTrackedLanguageTag}.
2597 \end{codebox*}
2598 Additional information about the \idx{script} can be obtained by
2599 also loading \sty{tracklang-scripts}:
2600 \begin{codebox*}
2601 \gls{input} \file{tracklang-scripts.tex}
2602 \end{codebox*}
2603 The name, numeric code and direction can now be obtained:
2604 \begin{codebox*}
2605 Name: \gls{TrackLangScriptAlphaToName}\marg{\gls{CurrentTrackedDialectScript}}.
2606 Numeric:
2607 \gls{TrackLangScriptAlphaToNumeric}\marg{\gls{CurrentTrackedDialectScript}}.
2608 Direction:
2609 \gls{TrackLangScriptAlphaToDir}\marg{\gls{CurrentTrackedDialectScript}}.
2610 \end{codebox*}
2611 Test for a specific \idx{script} (in this case \opt{Latn}):
2612 \begin{codebox*}
2613 Latin?
2614 \cmd{ifx}\gls{CurrentTrackedDialectScript}\tklscript{Latn}
2615 Yes
2616 \cmd{else}
2617 No
2618 \cmd{fi}
2619 \end{codebox*}
2620
2621 \subsection{\texorpdfstring{\LaTeX}{LaTeX}}
2622 \label{sec:latex}
2623
2624 This section is for \LaTeX\ use. See \sectionref{sec:tex} for generic \TeX\ use.
2625
2626 With newer versions of \sty{polyglossia}, where \gls{xpg@bcp@loaded}
2627 is defined, you just need to make sure the languages are set before
2628 \sty{tracklang} is loaded:
2629 \begin{codebox*}
2630 \cmd{documentclass}\marg{article}
2631 \cmd{usepackage}\marg{polyglossia}
2632 \cmd{setmainlanguage}[variant=uk]\marg{english}
2633 \comment{load packages that use tracklang for localisation}
2634 \end{codebox*}
2635 For older versions of \sty{polyglossia} where the regional
2636 information is required, use recognised class options:
2637 \begin{codebox*}
2638 \cmd{documentclass}[\opt{en-GB}]\marg{article}
2639 \cmd{usepackage}\marg{polyglossia}
2640 \cmd{setmainlanguage}[variant=uk]\marg{english}
2641 \comment{load packages that use tracklang for localisation}
2642 \end{codebox*}
2643
2644 For \sty{babel} users where the supplied \sty{babel} dialect
2645 label is sufficient, and is passed either through the document class
2646 or package options, there's no need to do anything special:
2647 \begin{codebox*}
2648 \cmd{documentclass}[\opt{british},\opt{canadien}]\marg{article}
2649 \cmd{usepackage}[T1]\marg{fontenc}
2650 \cmd{usepackage}\marg{babel}
2651 \comment{load packages that use tracklang for localisation}
2652 \end{codebox*}
2653 With \sty{tracklang} v1.6.4+ there is now a check for
2654 \gls{LocaleForEach}, which allows \sty{tracklang} to pick up locales
2655 set with \gls{babelprovide}. For example:
2656 \begin{codebox*}
2657 \cmd{documentclass}\marg{article}
2658 \cmd{usepackage}[T1]\marg{fontenc}
2659 \cmd{usepackage}\oarg{british}\marg{babel}
2660 \gls{babelprovide}\marg{canadianfrench}
2661 \comment{load packages that use tracklang for localisation}
2662 \end{codebox*}
2663
2664 If the region is important but there's no \sty{babel} dialect that
2665 represents it, there are several options.
2666 The first method is to use the class options recognised by \sty{tracklang}
2667 and the root language labels when loading \sty{babel}:
2668 \begin{codebox*}
2669 \cmd{documentclass}[\opt{en-IE},\opt{ga-IE}]\marg{article}
2670 \cmd{usepackage}[english,irish]\marg{babel}
2671 \comment{load packages that use tracklang for localisation}
2672 \end{codebox*}
2673
2674 Another method with \sty{babel} is to use \gls{TrackLanguageTag} and map the new
2675 dialect label to the nearest matching \gls{captionsdialect}:
2676 \begin{codebox*}
2677 \cmd{documentclass}\marg{article}
2678 \codepar
2679 \cmd{usepackage}\marg{tracklang}\comment{v1.3}
2680 \gls{TrackLanguageTag}\marg{\opt{en-MT}}
2681 \gls{SetTrackedDialectLabelMap}
2682 \marg{\gls{TrackLangLastTrackedDialect}}\marg{\opt{UKenglish}}
2683 \codepar
2684 \cmd{usepackage}[UKenglish]\marg{babel}
2685 \comment{load packages that use tracklang for localisation}
2686 \end{codebox*}
2687 This ensures that the \tklcaptions{UKenglish} hook is detected
2688 by the localisation packages. This mapping isn't needed
2689 for \sty{polyglossia} as the caption hooks use the root language
2690 label. This mapping also isn't needed if \opt{british} is used
2691 instead of \opt{UKenglish} since the \opt{en-MT}
2692 (\opt{maltaenglish})
2693 predefined dialect automatically sets up a mapping to
2694 \opt{british}. (The default mappings are shown in
2695 \tableref{tab:nonbcp47opts}.)
2696
2697 \section{Locale-Sensitive Packages}
2698 \label{sec:summary-localepkg}
2699
2700 Let's suppose you are developing a package called
2701 \filefmt{mypackage.sty} or \filefmt{mypackage.tex} and you want
2702 to find out what languages the document author has requested. (See also:
2703 \dickimawhref{latex/tracklang/otherpkg.shtml}{Using
2704 \filefmt{tracklang.tex} in Packages with Localisation Features}.)
2705
2706 Generic \TeX\ use (the \ext{tex} extension may be omitted):
2707 \begin{codebox*}
2708 \gls{input} \file{tracklang.tex}
2709 \end{codebox*}
2710 (Most of the commands used in this section require at least
2711 \sty{tracklang} version 1.3 but 1.4 is better if you want to
2712 include the \idx{script} tag in the \ext+{ldf} files.)
2713 Note that \file{tracklang.tex} has a check to determine if
2714 it's already been loaded, so you don't need to worry about that.
2715
2716 \LaTeX\ use:
2717 \begin{codebox*}
2718 \gls{RequirePackage}\marg{tracklang}[2019/11/30]\comment{at least v1.4}
2719 \end{codebox*}
2720 This will picked up any language options supplied in the document
2721 class options and will also detect if \sty{babel} or
2722 \sty{polyglossia} have been loaded.
2723
2724 (\LaTeX) If you want to allow the user to set the locale in the
2725 package options:
2726 \begin{codebox*}
2727 \gls{DeclareOption}*\marg{\gls{TrackLanguageTag}\marg{\cmd{CurrentOption}}}
2728 \end{codebox*}
2729 This means the user can do, say,
2730 \begin{codebox}
2731 \cmd{usepackage}[hy-Latn-IT-arevela]\marg{mypackage}
2732 \end{codebox}
2733 With at least version 1.4, it's better to use \gls{TrackIfKnownLanguage}:
2734 \begin{codebox}
2735 \gls{DeclareOption}*\marg{\comment{}
2736 \gls{TrackIfKnownLanguage}\marg{\cmd{CurrentOption}}\comment{}
2737 \marg{\comment{successful}
2738 \cmd{PackageInfo}\marg{mypackage}\marg{Tracking language `\cmd{CurrentOption}'}\comment{}
2739 }\comment{}
2740 \marg{\comment{failed}
2741 \cmd{PackageError}\marg{mypackage}\comment{}
2742 \marg{Unknown language specification `\cmd{CurrentOption}'}\comment{}
2743 \marg{You need to supply either a known dialect label
2744 or a valid language tag}\comment{}
2745 }\comment{}
2746 }
2747 \end{codebox}
2748
2749 \begin{information}
2750 The rest of the example package in this section uses generic code.
2751 If you are using \LaTeX, it's better to replace \cmd{def} and
2752 \cmd{ifx} with more appropriate \LaTeX\ commands.
2753 \end{information}
2754
2755 If you want to fetch the locale information from the operating
2756 system when the user hasn't requested a language:
2757 \begin{codebox*}
2758 \gls{AnyTrackedLanguages}
2759 \marg{}
2760 \marg{\comment{fetch locale information from the operating system}
2761 \cmd{ifdefined}\gls{TeXOSQueryLangTag}
2762 \comment{texosquery v1.2 available}
2763 \gls{TeXOSQueryLangTag}\marg{\cmd{langtag}}
2764 \gls{TrackLanguageTag}\marg{\cmd{langtag}}
2765 \cmd{else}
2766 \comment{texosquery v1.2 not available}
2767 \gls{TrackLangFromEnv}
2768 \cmd{fi}
2769 }
2770 \end{codebox*}
2771
2772 Set up the defaults if necessary:
2773 \begin{codebox}
2774 \cmd{def}\cmd{fooname}\marg{Foo}
2775 \cmd{def}\cmd{barname}\marg{Bar}
2776 \end{codebox}
2777
2778 Now load the resource files:
2779 \begin{codebox*}
2780 \gls{AnyTrackedLanguages}
2781 \marg{\comment{}
2782 \gls{ForEachTrackedDialect}\marg{\cmd{thisdialect}}\marg{\comment{}
2783 \gls{TrackLangRequireDialect}\marg{mypackage}\marg{\cmd{thisdialect}}\comment{}
2784 }\comment{}
2785 }
2786 \marg{}\comment{no tracked languages, default already set up}
2787 \end{codebox*}
2788
2789 Each resource file has the naming scheme \file{prefix-localeid.ldf}\glsadd{ext.ldf}.
2790 In this example, the \meta{prefix} is \filefmt{mypackage}. The
2791 \meta{localeid} part may be the language or dialect label (for
2792 example, \opt{english} or \opt{british}) or a combination of the
2793 \idx{ISO} language and region codes (for example, \opt{en-GB} or
2794 \iso{english} or \optfmt{GB}). As from version 1.4, \meta{localeid}
2795 may also include the \idx{script} or \idx{variant}. (See the definition of
2796 \gls{IfTrackedLanguageFileExists} \pref{pg:filesearch} for further
2797 details.)
2798
2799 The simplest scheme is to use the root language label (not the
2800 dialect label) for the base language settings and use the \idx+{ISO}
2801 codes for regional support.
2802
2803 For example, the file \ldf{mypackage}{english}:
2804 \begin{codebox*}
2805 \comment{identify this file:}
2806 \gls{TrackLangProvidesResource}\marg{english}[2016/10/06 v1.0]
2807 \codepar
2808 \gls{TrackLangAddToCaptions}\marg{\comment{}
2809 \cmd{def}\cmd{fooname}\marg{Foo}\comment{}
2810 \cmd{def}\cmd{barname}\marg{Bar}\comment{}
2811 }
2812 \end{codebox*}
2813 This sets up appropriate the \gls{captionsdialect} hook (if it's
2814 found). For other hooks, such as \gls{datedialect}, use
2815 \gls{TrackLangAddToHook} or \gls{TrackLangRedefHook} instead.
2816
2817 With pre-v1.4 versions of \sty{tracklang}, the \idx{script} isn't included
2818 in the file search. If it's needed then either require at least v1.4
2819 or have a base \ext{ldf} file that tries to load a version for the
2820 particular \idx{script} (which can be accessed with
2821 \gls{CurrentTrackedDialectScript}).
2822 Here's an example for a language with different writing systems.
2823 The resource file for Serbian \ldf{mypackage}{serbian}:
2824 \begin{codebox*}
2825 \comment{identify file:}
2826 \gls{TrackLangProvidesResource}\marg{serbian}[2016/10/06 v1.0]
2827 \codepar
2828 \gls{TrackLangRequestResource}\marg{serbian-\gls{CurrentTrackedDialectScript}}
2829 \marg{}\comment{file not found, do something sensible here}
2830 \end{codebox*}
2831 The file \ldf{mypackage}{serbian-Latn} sets up
2832 the Latin \idx{script} (\opt{Latn}):
2833 \begin{codebox*}
2834 \gls{TrackLangProvidesResource}\marg{serbian-Latn}[2016/10/06 v1.0]
2835 \codepar
2836 \gls{TrackLangAddToCaptions}\marg{\comment{}
2837 \cmd{def}\cmd{fooname}\marg{...}\comment{provide appropriate Latin translations}
2838 \cmd{def}\cmd{barname}\marg{...}\comment{}
2839 }
2840 \end{codebox*}
2841 The file \ldf{mypackage}{serbian-Cyrl} sets up
2842 the Cyrillic \idx{script} (\opt{Cyrl}):
2843 \begin{codebox*}
2844 \gls{TrackLangProvidesResource}\marg{serbian-Cyrl}[2016/10/06 v1.0]
2845 \codepar
2846 \gls{TrackLangAddToCaptions}\marg{\comment{}
2847 \cmd{def}\cmd{fooname}\marg{...}\comment{provide appropriate Cyrillic translations}
2848 \cmd{def}\cmd{barname}\marg{...}\comment{}
2849 }
2850 \end{codebox*}
2851 With v1.4+ you just need \ldf{mypackage}{sr-Latn} and
2852 \ldf{mypackage}{sr-Cyrl} for the regionless versions.
2853
2854 \section{Language Packages}
2855 \label{sec:summary-langpkg}
2856
2857 Let's suppose now you're the developer of a package that
2858 sets up the language, hyphenation patterns and so on.
2859 It would be really helpful to the locale-sensitive packages
2860 in \sectionref{sec:summary-localepkg} to know what languages
2861 the document author has requested. You can use the
2862 \sty{tracklang} package to identify this information
2863 by tracking the requested localisation, so that other packages
2864 can have a consistent way of querying it. (See also:
2865 \dickimawhref{latex/tracklang/langpkg.shtml}{Integrating
2866 \filefmt{tracklang.tex} into Language Packages}.)
2867
2868 Generic use:
2869 \begin{codebox}
2870 \gls{input} tracklang
2871 \end{codebox}
2872 Alternative \LaTeX\ use:
2873 \begin{codebox}
2874 \gls{RequirePackage}\marg{tracklang}[2019/11/30]\comment{v1.4}
2875 \end{codebox}
2876 Unlike \gls{input}, \gls{RequirePackage} will allow \sty{tracklang}
2877 to pick up the document class options, but using \gls{RequirePackage}
2878 will also trigger the tests for known language packages.
2879 (If you want to find out if \sty{tracklang} has already been
2880 loaded and locales have already been tracked, you can use the
2881 same code as in the previous section.)
2882
2883 When a user requests a particular language through your package,
2884 the simplest way of letting \sty{tracklang} know about it
2885 is to use \gls{TrackPredefinedDialect} or \gls{TrackLanguageTag}.
2886 For example, if the user requests \opt{british}, that's a
2887 predefined dialect so you can just do:
2888 \begin{codebox}
2889 \gls{TrackPredefinedDialect}\marg{\opt{british}}
2890 \end{codebox}
2891 Alternatively
2892 \begin{codebox}
2893 \gls{TrackLanguageTag}\marg{\opt{en-GB}}
2894 \end{codebox}
2895 If your package uses caption hooks, then you can set up
2896 a mapping between \sty{tracklang}'s internal dialect label
2897 and your caption label. For example, let's suppose the
2898 closest match to English used in Malta (\opt{en-MT}) is the
2899 dialect \opt{UKenglish} (for example, the date format is
2900 similar between GB and MT):
2901 \begin{codebox}
2902 \gls{TrackLanguageTag}\marg{\opt{en-MT}}
2903 \gls{SetTrackedDialectLabelMap}\marg{\gls{TrackLangLastTrackedDialect}}\marg{\opt{UKenglish}}
2904 \cmd{def}\tklcaptions{UKenglish}\marg{\comment{}
2905 \cmd{def}\cmd{contentsname}\marg{Contents}\comment{}
2906 \comment{...}
2907 }
2908 \end{codebox}
2909 (The predefined \opt{maltaenglish} option provided by
2910 \sty{tracklang} automatically sets the mapping to
2911 \opt{british}, but the above method will change that mapping
2912 to \opt{UKenglish}.)
2913
2914 This now means that \gls{TrackLangAddToHook} and \gls{TrackLangRedefHook} commands can
2915 find your language hooks. You don't need the map if your dialect
2916 label is the same as \sty{tracklang}'s root language label
2917 for that locale. For example:
2918 \begin{codebox}
2919 \gls{TrackLanguageTag}\marg{\opt{en-MT}}
2920 \cmd{def}\tklcaptions{english}\marg{\comment{}
2921 \cmd{def}\cmd{contentsname}\marg{Contents}\comment{}
2922 \comment{...}
2923 }
2924 \end{codebox}
2925
2926 When the user switches language through commands like
2927 \gls{selectlanguage} it would be useful to also use
2928 \code{\gls{SetCurrentTrackedDialect}\margm{dialect}} to make it easier
2929 for the document author or locale-sensitive packages to pick
2930 up the current locale. The \meta{dialect} argument may be
2931 \sty{tracklang}'s internal dialect label or the dialect
2932 label you assigned with \gls{SetTrackedDialectLabelMap}. It
2933 may also be the root language label, in which case
2934 \sty{tracklang} will search for the last dialect to be
2935 tracked with that language. For example:
2936 \begin{codebox}
2937 \cmd{def}\gls{selectlanguage}\#1\marg{\comment{}
2938 \gls{SetCurrentTrackedDialect}\marg{\#1}\comment{}
2939 \comment{set up hyphenation patterns etc}
2940 }
2941 \end{codebox}
2942 See the example in \sectionref{sec:summary-doc} or the example in
2943 \dickimawhref{latex/tracklang/langpkg.shtml}{Integrating
2944 \filefmt{tracklang.tex} into Language Packages}.
2945
2946 \chapter{Generic Use}
2947 \label{sec:generic}
2948
2949 For plain \TeX\ you can input \file{tracklang.tex}:
2950 \begin{codebox}
2951 \gls{input} tracklang
2952 \end{codebox}
2953 or for \TeX\ formats that have an argument form for \gls{input}:
2954 \begin{codebox}
2955 \gls{input}\marg{tracklang}
2956 \end{codebox}
2957 As from version 1.3, you don't need to change the category
2958 code of \idx{atletter} before loading \file{tracklang.tex}
2959 as it will automatically be changed to 11 and switched
2960 back at the end (if required).
2961
2962 The \LaTeX\ package \file{tracklang.sty}
2963 inputs the generic \TeX\ code in \file{tracklang.tex}, but before
2964 it does so it defines
2965 \cmddef{@tracklang@declareoption}
2966 to
2967 \begin{compactcodebox*}
2968 \gls{DeclareOption}\margm{dialect}\marg{\gls{TrackPredefinedDialect}\margm{dialect}}
2969 \end{compactcodebox*}
2970 If \gls{@tracklang@declareoption} isn't defined when
2971 \file{tracklang.tex} is input, it will be defined to ignore its
2972 argument.
2973
2974 This means that all the predefined languages and dialects
2975 (\refoptstables) automatically become package options, so
2976 the \file{tracklang.sty} package can pick up document class
2977 options and add them to \sty{tracklang}'s internal list of tracked
2978 document languages.
2979
2980 As from version 1.6.3, the \LaTeX\ package also has options
2981 \inlineoptdef{verbose} and \inlineoptdef{noverbose} to switch on and
2982 off verbose mode. As from version 1.6.5, there are also
2983 \inlineoptdef{warn} and \inlineoptdef{nowarn} settings to switch on
2984 (default) and off warnings. This means that these options can be
2985 picked up if they are used as document class options or passed to
2986 \sty{tracklang} before it's first loaded.
2987
2988 If you're not using \LaTeX, package options aren't available
2989 although you can redefine
2990 \gls{@tracklang@declareoption}
2991 to use something analogous to \gls{DeclareOption}, if appropriate.
2992 Otherwise, the document languages need
2993 to be explicitly identified (using any of the following commands)
2994 so that \sty{tracklang} knows about them.
2995
2996 \cmddef{TrackPredefinedDialect}
2997 This will add the predefined dialect and its associated \idx{ISO} codes to the list
2998 of tracked document languages. The \meta{dialect label} may be any
2999 of those listed in \refoptstables.
3000
3001 For example:
3002 \begin{codebox}
3003 \gls{input} tracklang
3004 \gls{TrackPredefinedDialect}\marg{\opt{british}}
3005 \end{codebox}
3006 is the Plain \TeX\ alternative to:
3007 \begin{codebox}
3008 \cmd{documentclass}[\opt{british}]\marg{article}
3009 \cmd{usepackage}\marg{tracklang}
3010 \end{codebox}
3011
3012 Note that it's impractical to define every possible language
3013 and region combination as it would significantly slow the
3014 time taken to load \sty{tracklang} so, after version~1.3,
3015 I don't intend adding any new predefined dialects. As from version
3016 1.3, if you want to track a dialect that's not predefined by
3017 \sty{tracklang}, then you can use:
3018 \cmddef{TrackLocale}
3019 If \meta{locale} is a recognised dialect, this is equivalent to
3020 using \gls{TrackPredefinedDialect}, otherwise \meta{locale}
3021 needs to be in one the following formats:
3022 \begin{itemize}
3023 \item \meta{\idx{ISO} lang}
3024 \item \meta{\idx{ISO} lang}\idx{atmod}\meta{modifier}
3025 \item \meta{\idx{ISO} lang}\idx{hyphensep}\meta{\idx{ISO} country}
3026 \item \meta{\idx{ISO} lang}\idx{hyphensep}\meta{\idx{ISO} country}\idx{atmod}\meta{modifier}
3027 \end{itemize}
3028 where \meta{\idx{ISO} lang} is the \idxn{639-1} or \idx{639-2} code identifying
3029 the language (lower case), \meta{\idx{ISO} country} is the \idx{3166-1}
3030 \idx{ISO} code identifying the \idx{territory} (upper case) and
3031 \meta{modifier} is the \idx{modifier} or \idx{variant}. The hyphen
3032 (\idx{hyphensep}) may be replaced by an underscore character
3033 (\idx{underscoresep}). \Idx{code-set} information in the
3034 form \code{\idx{dotsep}\meta{codeset}} may optionally appear before the
3035 \idx{modifier}. For example,
3036 \code{de\idx{hyphensep}DE\idx{dotsep}utf8\idx{atmod}new} (\idx{modifier} is
3037 \optfmt{new}) or \code{en\idx{hyphensep}GB\idx{dotsep}utf8} (\idx{modifier} is missing).
3038 The \idx{code-set} will be ignored if present, but it won't interfere
3039 with the parsing.
3040
3041 For example:
3042 \begin{codebox}
3043 \gls{TrackLocale}\marg{de\idx{hyphensep}NA\idx{atmod}new}
3044 \end{codebox}
3045 indicates German in Namibia using the new spelling.
3046
3047 \begin{important}
3048 If a language has different \idxn{639-2T} and \idx{639-2B} codes, then
3049 the \qt{T} form should be used. (So for the above example,
3050 \code{deu} may be used instead of \code{de}, but \code{ger}
3051 won't be recognised.)
3052 \end{important}
3053
3054 Alternatively, you can use
3055 \cmddef{TrackLanguageTag}
3056 where \meta{tag} is a regular, well-formed \idx{BCP47} language tag or a recognised dialect
3057 label. (Irregular grandfather tags aren't recognised.)
3058 Note that the tag must start with a language
3059 identifier and can't simply be a region code (use \qt{und} if the
3060 language is unknown).
3061 This command will fully expand \meta{tag}.
3062 A warning is issued if the tag is empty.
3063
3064 If you want to first check that \meta{tag} includes a valid language
3065 code, then you can instead use:
3066 \cmddef{TrackIfKnownLanguage}
3067 This will only track \meta{tag} (and then do \meta{success code}) if
3068 \meta{tag} starts with a valid language code (or is a predefined
3069 dialect) otherwise it will do \meta{fail code}. Both
3070 \gls{TrackLanguageTag} and \gls{TrackIfKnownLanguage} will check if
3071 \meta{tag} is a predefined option. (This saves parsing the tag if
3072 it's recognised.)
3073
3074 For example:
3075 \begin{codebox}
3076 \gls{TrackLanguageTag}\marg{hy-Latn-IT-arevela}
3077 Latn-ME: \gls{TrackIfKnownLanguage}\marg{Latn-ME}\marg{success}\marg{fail}.
3078 brazilian: \gls{TrackIfKnownLanguage}\marg{brazilian}\marg{success}\marg{fail}.
3079 \end{codebox}
3080 This will track \optfmt{hy-Latn-IT-arevela} and \opt{brazilian}
3081 (\optfmt{pt-BR}) but not \optfmt{Latn-ME} (because it doesn't contain a
3082 valid language code) even though it's a valid \idx{script} and country
3083 code. The above is just for illustrative purposes. Typically the
3084 language tracking isn't performed within the document text.
3085
3086 The \sty{datetime2} package assumes that any unknown package option is a
3087 language identifier. It could simply do:
3088 \begin{compactcodebox}
3089 \gls{TrackLanguageTag}\marg{\cmd{CurrentOption}}
3090 \end{compactcodebox}
3091 but users can make mistakes sometimes and this won't provide any
3092 helpful information if they, for example, misspelt a package option
3093 or forgot the \qt{\meta{key}=} part of a \keyval\
3094 setting. Instead (as from v1.5.5) \sty{datetime2} now does:
3095 \begin{compactcodebox}
3096 \gls{TrackIfKnownLanguage}\marg{\cmd{CurrentOption}}
3097 \marg{...}\comment{known language}
3098 \marg{\cmd{PackageError}\marg{...}\marg{...}\marg{...}}
3099 \end{compactcodebox}
3100 This will now give the user some guidance.
3101
3102 If \meta{tag} contains a sub-language tag, this will be set
3103 as the \idx{639-3} code for the \emph{dialect} label. Note that this is
3104 different to the root language codes which are set using the
3105 language label. For example:
3106 \begin{codebox}
3107 \gls{TrackLanguageTag}\marg{zh-cmn-Hans-CN}
3108 \end{codebox}
3109 creates a new dialect with the label \code{zh\-cmn\-Hans\-CN}.
3110 The root language \opt{chinese} has the \idx{639-1} code
3111 \optfmt{zh} and the dialect \code{zh\-cmn\-Hans\-CN} has the
3112 \idxn{639-3} code \optfmt{cmn}.
3113 \begin{codebox}
3114 ISO 639-1: \gls{TrackedIsoCodeFromLanguage}\marg{639-1}\marg{chinese}.
3115 ISO 639-3: \gls{TrackedIsoCodeFromLanguage}\marg{639-3}\marg{zhcmnHansCN}.
3116 \end{codebox}
3117
3118 Version 1.2 of \sty{texosquery} provides the command \gls{TeXOSQueryLangTag},
3119 which may be used to fetch the operating system's regional
3120 information as a language tag. These commands can be used as
3121 follows:
3122 \begin{codebox}
3123 \gls{input} tracklang \comment{v1.3}
3124 \gls{input} texosquery \comment{v1.2}
3125 \codepar
3126 \gls{TeXOSQueryLangTag}\marg{\cmd{langtag}}
3127 \gls{TrackLanguageTag}\marg{\cmd{langtag}}
3128 \end{codebox}
3129 (If the \idx{shellescape} is disabled, \cmd{langtag} will be empty, which
3130 will trigger a~warning but no errors.)
3131
3132 Some of the predefined root language options listed
3133 in \tableref{tab:rootlangopts} have an associated region
3134 (denoted by \fnregion).
3135 If \gls{TrackLocale} is used with just the language \idx{ISO} code,
3136 no region is tracked for that language. For example
3137 \begin{codebox}
3138 \gls{TrackLocale}\marg{\opt{manx}}
3139 \end{codebox}
3140 will track the \optfmt{IM} (Isle of Man) \idxn{3166-1} code but
3141 \begin{codebox}
3142 \gls{TrackLocale}\marg{gv}
3143 \end{codebox}
3144 won't track the region.
3145 Similarly for \gls{TrackLanguageTag}.
3146
3147 (New to version 1.3.)
3148 There's a similar command to \gls{TrackLocale} that doesn't take an argument:
3149 \cmddef{TrackLangFromEnv}
3150 If the \idx{shellescape} has been enabled or \gls{directlua} is
3151 available, this will try to get the language information from the
3152 system environment variables \envvar{LCALL} or \envvar{LANG} and, if
3153 successful, track that.
3154
3155 Since \sty{tracklang} is neither able to look up the \idx{POSIX} locale
3156 tables nor interpret file locales, if the result is \code{C} or
3157 \code{POSIX} or starts with a forward slash \code{/} then
3158 the locale value is treated as empty.
3159
3160 \begin{important}
3161 Not all operating systems use environment variables for
3162 the system locale information. For example, Windows stores the
3163 locale information in the registry. In which case, consider
3164 using \sty{texosquery}.
3165 \end{important}
3166
3167 If the operating system locale can't be obtained from environment variables, then
3168 \sty{tracklang} will use \gls{TeXOSQueryLocale} as a fallback if
3169 \sty{texosquery} has been loaded. Since \sty{texosquery} requires
3170 both the \idx{shellescape} and the Java runtime environment,
3171 \sty{tracklang} doesn't automatically load it.
3172
3173 Plain \TeX\ example:
3174 \begin{codebox}
3175 \gls{input} texosquery
3176 \gls{input} tracklang
3177 \gls{TrackLangFromEnv}
3178 \end{codebox}
3179 Document build:
3180 \begin{terminal}
3181 \app{etex} \switch{shell-escape} \meta{filename}
3182 \end{terminal}
3183
3184 \LaTeX\ example:
3185 \begin{codebox}
3186 \cmd{usepackage}\marg{texosquery}
3187 \cmd{usepackage}\marg{tracklang}
3188 \gls{TrackLangFromEnv}
3189 \end{codebox}
3190 Document build:
3191 \begin{terminal}
3192 \app{pdflatex} \switch{shell-escape} \meta{filename}
3193 \end{terminal}
3194
3195 If the locale can't be determined, there will be warning messages.
3196 These can be suppressed using
3197 \cmddef{TrackLangShowWarningsfalse}
3198 or switched back on again using
3199 \cmddef{TrackLangShowWarningstrue}
3200
3201 For example, I have the environment variable \envvar{LANG} set to
3202 \code{en\idx{underscoresep}GB\idx{dotsep}utf8} on my Linux system so instead of
3203 \begin{codebox}
3204 \gls{TrackPredefinedDialect}\marg{\opt{british}}
3205 \end{codebox}
3206 I can use
3207 \begin{codebox}
3208 \gls{TrackLangFromEnv}
3209 \end{codebox}
3210
3211 With \LaTeX\ documents I can do
3212 \begin{codebox}
3213 \cmd{documentclass}\marg{article}
3214 \cmd{usepackage}\marg{tracklang}
3215 \gls{TrackLangFromEnv}
3216 \end{codebox}
3217 However, this only helps subsequently loaded packages that
3218 use \sty{tracklang} to determine the required regional
3219 settings. For example:
3220 \begin{codebox}
3221 \cmd{documentclass}\marg{article}
3222 \cmd{usepackage}\marg{tracklang}
3223 \gls{TrackLangFromEnv}
3224 \cmd{usepackage}[useregional]\marg{datetime2}
3225 \end{codebox}
3226 In my case, with the \envvar{LANG} environment variable set to
3227 \code{en\idx{underscoresep}GB\idx{dotsep}utf8} and the
3228 \idx{shellescape} enabled, this automatically switches on the
3229 \opt{en-GB} date style.
3230 Naturally this doesn't help locale-sensitive packages that don't use
3231 \sty{tracklang}.
3232
3233 The \gls{TrackLangFromEnv} command also incidentally sets
3234 \gls{TrackLangEnv}
3235 to the value of the environment variable or empty if the
3236 query was unsuccessful (for example, the \idx{shellescape} is
3237 unavailable).
3238
3239 If the command:
3240 \cmddef{TrackLangEnv}
3241 is already defined before \gls{TrackLangFromEnv} is used, then the
3242 environment variable won't be queried and the value of
3243 \gls{TrackLangEnv} will be parsed instead.
3244
3245 \begin{important}
3246 The parser which splits the locale string into
3247 its component parts first tries splitting on the underscore
3248 \idx{underscoresep} with its usual category code~8, then tries splitting
3249 on a hyphen \idx{hyphensep} with category code~12, and then tries
3250 splitting on the underscore \idx{underscoresep} with category code~12.
3251 \end{important}
3252
3253 For example:
3254 \begin{codebox}
3255 \cmd{def}\gls{TrackLangEnv}\marg{en-GB}
3256 \gls{TrackLangFromEnv}
3257 \end{codebox}
3258 This doesn't perform a \idx{shellescape} since \gls{TrackLangEnv}
3259 is already defined. In this case, you may just as well use:
3260 \begin{codebox}
3261 \gls{TrackLocale}\marg{en-GB}
3262 \end{codebox}
3263 (unless you happen to additionally require the component
3264 commands that are set by \gls{TrackLangFromEnv}, see below.)
3265
3266 If the \idx{shellescape} is unavailable
3267 (for example, your \TeX\ installation prohibits it), you
3268 can set this value when you invoke \TeX. For example,
3269 if the document file is called \filefmt{myDoc.tex} (and it's
3270 in Plain \TeX):
3271 \begin{terminal}
3272 \app{tex} "\idx{escbsl}def\idx{escbsl}\glscsname{TrackLangEnv}\marg{\idx{dollarenv}\envvar{LANG}}\idx{escbsl}\glscsname{input} myDoc"
3273 \end{terminal}
3274
3275 The \gls{TrackLangFromEnv} command also happens to store the
3276 component parts of the environment variable value in the
3277 following commands. (These aren't provided by \gls{TrackLocale}.)
3278 If the information is unavailable, the relevant commands will be set
3279 to empty.
3280
3281 The language code is stored in:
3282 \cmddef{TrackLangEnvLang}
3283
3284 The \idx{territory} (if present) is stored in:
3285 \cmddef{TrackLangEnvTerritory}
3286
3287 The \idx{code-set} (if present) is stored in:
3288 \cmddef{TrackLangEnvCodeSet}
3289
3290 The \idx{modifier} (if present) is stored in:
3291 \cmddef{TrackLangEnvModifier}
3292
3293 If you want to query the language environment, but don't
3294 want to track the result, you can just use:
3295 \cmddef{TrackLangQueryEnv}
3296 This only tries to fetch the value of the
3297 language environment variable (and use \sty{texosquery} as
3298 a fallback, if it has been loaded). It doesn't try to parse the
3299 result. The result is stored in \gls{TrackLangEnv} (empty if
3300 unsuccessful). Unlike \gls{TrackLangFromEnv}, this doesn't check if
3301 \gls{TrackLangEnv} already exists. A warning will occur if the shell
3302 escape is unavailable. For systems that store the locale information in
3303 environment variables, this is more efficient than using
3304 \sty{texosquery}'s \gls{TeXOSQueryLocale} command (which is what's
3305 used as the fallback).
3306
3307 The above queries \envvar{LCALL} and, if that is unsuccessful,
3308 then queries \envvar{LANG} (before optionally falling back on
3309 \sty{texosquery}). If you want another environment
3310 variable tried after \envvar{LCALL} and before \envvar{LANG},
3311 you can instead use:
3312 \cmddef{TrackLangQueryOtherEnv}
3313 For example, to also query \envvar{LCMONETARY}:
3314 \begin{codebox}
3315 \gls{TrackLangQueryOtherEnv}\marg{\envvar{LCMONETARY}}
3316 \end{codebox}
3317
3318 Since this sets \gls{TrackLangEnv}, you can use it before
3319 \gls{TrackLangFromEnv}. For example:
3320 \begin{codebox}
3321 \gls{TrackLangQueryOtherEnv}\marg{\envvar{LCMONETARY}}
3322 \gls{TrackLangFromEnv}
3323 \end{codebox}
3324 Remember that if you only want to do the \idx{shellescape} if
3325 \gls{TrackLangEnv} hasn't already been defined, you can test for this
3326 first:
3327 \begin{codebox}
3328 \cmd{ifdefined}\gls{TrackLangEnv}
3329 \cmd{else}
3330 \gls{TrackLangQueryOtherEnv}\marg{\envvar{LCMONETARY}}
3331 \cmd{fi}
3332 \gls{TrackLangFromEnv}
3333 \end{codebox}
3334
3335 It's also possible to just parse the value of \gls{TrackLangEnv}
3336 without tracking the result using:
3337 \cmddef{TrackLangParseFromEnv}
3338 This is like \gls{TrackLangFromEnv} but assumes that
3339 \gls{TrackLangEnv} has already been set and doesn't track the
3340 result. The component parts are stored as for \gls{TrackLangFromEnv}.
3341
3342 Example (Plain \TeX):
3343 \begin{codebox}
3344 \gls{input} tracklang
3345 \codepar
3346 \cmd{def}\gls{TrackLangEnv}\marg{fr\idx{hyphensep}BE\idx{dotsep}utf8\idx{atmod}euro}
3347 \codepar
3348 \gls{TrackLangParseFromEnv}
3349 \codepar
3350 Language: \gls{TrackLangEnvLang}.
3351 Territory: \gls{TrackLangEnvTerritory}.
3352 Codeset: \gls{TrackLangEnvCodeSet}.
3353 Modifier: \gls{TrackLangEnvModifier}.
3354 Any tracked languages? \gls{AnyTrackedLanguages}\marg{Yes}\marg{No}.
3355 \end{codebox}
3356 This produces:
3357 \begin{resultbox}
3358 Language: fr. Territory: BE. Codeset: utf8. Modifier: euro.
3359 Any tracked languages? No.
3360 \end{resultbox}
3361
3362 Compare this with:
3363 \begin{codebox}
3364 \gls{input} tracklang
3365 \codepar
3366 \cmd{def}\gls{TrackLangEnv}\marg{fr\idx{hyphensep}BE\idx{dotsep}utf8\idx{atmod}euro}
3367 \codepar
3368 \gls{TrackLangFromEnv}
3369 \codepar
3370 Language: \gls{TrackLangEnvLang}.
3371 Territory: \gls{TrackLangEnvTerritory}.
3372 Codeset: \gls{TrackLangEnvCodeSet}.
3373 Modifier: \gls{TrackLangEnvModifier}.
3374 Any tracked languages? \gls{AnyTrackedLanguages}\marg{Yes}\marg{No}.
3375 Tracked dialect(s):\comment{}
3376 \gls{ForEachTrackedDialect}\marg{\cmd{thisdialect}}\marg{\cmd{space}\cmd{thisdialect}}.
3377 \end{codebox}
3378 This produces:
3379
3380 \begin{resultbox}
3381 Language: fr. Territory: BE. Codeset: utf8. Modifier: euro.
3382 Any tracked languages? Yes.
3383 Tracked dialect(s): belgique.
3384 \end{resultbox}
3385
3386 If \gls{TrackLangFromEnv} doesn't recognise the given language and
3387 territory combination, it will define a new dialect and add that.
3388
3389 For example, \sty{tracklang} doesn't recognise \code{en-BE}, so
3390 the sample document below defines a new dialect labelled
3391 \code{enBEeuro}:
3392 \begin{codebox}
3393 \gls{input} tracklang
3394 \codepar
3395 \cmd{def}\gls{TrackLangEnv}\marg{en\idx{hyphensep}BE\idx{dotsep}utf8\idx{atmod}euro}
3396 \codepar
3397 \gls{TrackLangFromEnv}
3398 \codepar
3399 Language: \gls{TrackLangEnvLang}.
3400 Territory: \gls{TrackLangEnvTerritory}.
3401 Codeset: \gls{TrackLangEnvCodeSet}.
3402 Modifier: \gls{TrackLangEnvModifier}.
3403 Any tracked languages? \gls{AnyTrackedLanguages}\marg{Yes}\marg{No}.
3404 Tracked dialect(s):\comment{}
3405 \gls{ForEachTrackedDialect}\marg{\cmd{thisdialect}}\marg{\cmd{space}\cmd{thisdialect}}.
3406 \end{codebox}
3407 This now produces:
3408 \begin{resultbox}
3409 Language: en. Territory: BE. Codeset: utf8. Modifier: euro.
3410 Any tracked languages? Yes.
3411 Tracked dialect(s): enBEeuro.
3412 \end{resultbox}
3413
3414 \chapter{Supplementary Packages}
3415 \label{sec:supplpkgs}
3416
3417 In addition to the main \file{tracklang.tex} file and
3418 \file{tracklang.sty} \LaTeX\ wrapper, the \sty{tracklang} package
3419 also provides supplementary files for region and script mappings.
3420
3421 \filedef{tracklang-region-codes.tex}
3422 This file is only loaded if a mapping is required between numeric
3423 and alphabetic \idx{region} codes. If \gls{TrackLanguageTag}
3424 encounters a numeric \idx{region} code, it will automatically input
3425 \file{tracklang-region-codes.tex}, if it hasn't already been input.
3426 This file provides the following commands.
3427
3428 \cmddef{TrackLangAlphaIIToNumericRegion}
3429 Expands to the numeric code corresponding to the given alpha-2 code or
3430 empty if no mapping has been supplied.
3431
3432 \cmddef{TrackLangNumericToAlphaIIRegion}
3433 Expands to the alpha-2 code corresponding to the given numeric code or
3434 empty if no mapping has been supplied.
3435
3436 \cmddef{TrackLangIfKnownAlphaIIRegion}
3437 Expands to \meta{true} if there's an alpha-2 to numeric \idx{region}
3438 code mapping, otherwise expands to \meta{false}.
3439
3440 \cmddef{TrackLangIfKnownNumericRegion}
3441 Expands to \meta{true} if there's a numeric to alpha-2 \idx{region}
3442 code mapping, otherwise expands to \meta{false}.
3443
3444 \cmddef{TrackLangAlphaIIIToNumericRegion}
3445 Expands to the numeric code corresponding to the given alpha-3 code or
3446 empty if no mapping has been supplied.
3447
3448 \cmddef{TrackLangNumericToAlphaIIIRegion}
3449 Expands to the alpha-3 code corresponding to the given numeric code or
3450 empty if no mapping has been supplied.
3451
3452 \cmddef{TrackLangIfKnownAlphaIIIRegion}
3453 Expands to \meta{true} if there's an alpha-3 to numeric \idx{region}
3454 code mapping, otherwise expands to \meta{false}.
3455
3456 Mappings are established with:
3457 \cmddef{TrackLangRegionMap}
3458 Predefined mappings are listed in \tableref{tab:regionmappings}.
3459
3460 When \file{tracklang-region-codes.tex} is input, it can load
3461 additional files that provide supplementary mappings.
3462
3463 \cmddef{TrackLangAddExtraRegionFile}
3464 This command adds the supplied \meta{file} to the list of extra
3465 region code files that should be input by
3466 \file{tracklang-region-codes.tex}, unless
3467 \file{tracklang-region-codes.tex} has already been input, in which
3468 case \meta{file} will be input straight away.
3469
3470 \filedef{tracklang-scripts.tex}
3471 The \sty{tracklang-scripts} package provides information about
3472 \idxn{15924} scripts. The file isn't automatically loaded. If
3473 you want to use any of the commands provided in it you need to input
3474 it.
3475
3476 Plain \TeX:
3477 \begin{codebox}
3478 \gls{input} tracklang-scripts
3479 \end{codebox}
3480 There's a simple wrapper package \file{tracklang-scripts.sty} for
3481 \LaTeX\ users:
3482 \begin{codebox}
3483 \cmd{usepackage}\marg{tracklang-scripts}
3484 \end{codebox}
3485
3486 \cmddef{TrackLangScriptMap}
3487 Defines a mapping. The first argument is the four letter alpha code,
3488 such as \opt{Latn} or \opt{Cyrl}. The second argument is the numeric
3489 code. The third argument is the script's name, for example
3490 \qt{Imperial Aramaic}. The fourth argument is the direction, which
3491 may be one of: \optfmt{LR} (left-to-right), \optfmt{RL} (right-to-left),
3492 \optfmt{TB} (top-to-bottom), \optfmt{varies} or \optfmt{inherited}.
3493 The \meta{parent} argument is for the parent writing system, which
3494 may be left blank (currently unsupported).
3495
3496 This command defines:
3497 \cmddef{TrackLangScriptCode}
3498 which expands to \meta{Code} for use with \gls{IfTrackedDialectIsScriptCs}.
3499
3500 See \tableref{tab:scriptmappings} for a summary of all the mappings
3501 that are provided by the file \file{tracklang-scripts.tex}.
3502
3503 \cmddef{TrackLangScriptAlphaToNumeric}
3504 Expands to the numeric code corresponding to the given alpha code or
3505 empty if no mapping.
3506
3507 \cmddef{TrackLangScriptIfKnownAlpha}
3508 Expands to \meta{true} if there is a known alpha to numeric mapping
3509 or \meta{false} otherwise.
3510
3511 \cmddef{TrackLangScriptNumericToAlpha}
3512 Expands to the alpha code corresponding to the given numeric code or
3513 empty if no mapping.
3514
3515 \cmddef{TrackLangScriptIfKnownNumeric}
3516 Expands to \meta{true} if there is a known numeric to alpha mapping
3517 or \meta{false} otherwise.
3518
3519 \cmddef{TrackLangScriptAlphaToName}
3520 Expands to the name corresponding to the given alpha code or
3521 empty if no mapping.
3522
3523 \cmddef{TrackLangScriptAlphaToDir}
3524 Expands to the direction corresponding to the given alpha code or
3525 empty if no mapping.
3526
3527 \cmddef{TrackLangScriptSetParent}
3528 Sets the parent for the given alpha code.
3529
3530 \cmddef{TrackLangScriptGetParent}
3531 Expands to the parent for the given alpha code or empty if no
3532 mapping.
3533
3534 \cmddef{TrackLangScriptIfHasParent}
3535 Expands to \meta{true} if the given alpha code has a parent
3536 or to \meta{false} otherwise. Note that if a parent is explicitly
3537 set to empty with \gls{TrackLangScriptSetParent} then it will be
3538 considered defined, but if the \meta{parent} argument was empty in
3539 \gls{TrackLangScriptMap}, then it will be undefined.
3540
3541 \cmddef{TrackLangAddExtraScriptFile}
3542 This command adds \meta{file} to the list of extra script files that should
3543 be input by \file{tracklang-scripts.tex}, unless
3544 \file{tracklang-scripts.tex} has already been input, in which
3545 case \meta{file} will be input straight away.
3546
3547
3548 \chapter{Detecting the User's Requested Languages}
3549 \label{sec:user}
3550
3551 The \sty{tracklang} package tries to track the loaded languages and
3552 the option names used to identify those languages. For want of a better
3553 term, the language option names are referred to as dialects even if
3554 they're only a synonym for the language rather than an actual
3555 dialect. For example, if the user
3556 has requested \opt{british}, the \emph{root language} label is
3557 \opt{english} and the dialect is \opt{british}, whereas if the
3558 user requested \opt{UKenglish}, the root language label is
3559 \opt{english} and the dialect is \opt{UKenglish}. The
3560 exceptions to this are the \sty{tracklang} package options that have been
3561 specified in the form \meta{iso lang}-\meta{iso country} (listed
3562 in \tableref{tab:rootlangopts}). For
3563 example, the package option \iso{british} behaves as though the
3564 user requested the package option \opt{british}.
3565
3566 If \gls{TrackLocale} or \gls{TrackLangFromEnv} are used and the locale
3567 isn't recognised a new dialect is created with the label formed from
3568 the \idx{ISO} codes (and \idx{modifier}, if present).
3569 Similarly for \gls{TrackLanguageTag} a new
3570 dialect is created with a label that's essentially the language tag
3571 without the hyphen separators. For example,
3572 \begin{codebox}
3573 \gls{TrackLocale}\marg{xx\idx{hyphensep}YY}
3574 \end{codebox}
3575 will add a new dialect with the label \code{xxYY},
3576 \begin{codebox}
3577 \gls{TrackLocale}\marg{xx\idx{hyphensep}YY\idx{atmod}mod}
3578 \end{codebox}
3579 will add a new dialect with the label \code{xxYYmod} and
3580 \begin{codebox}
3581 \gls{TrackLanguageTag}\marg{xx-Latn-YY}
3582 \end{codebox}
3583 will add a new dialect with the label \code{xxLatnYY}.
3584
3585 \begin{important}
3586 If \gls{TrackLocale} or \gls{TrackLangFromEnv} find a \idx{modifier}, the
3587 value will be sanitized to allow it to be used as a label. If the
3588 modifier is set explicitly using \gls{SetTrackedDialectModifier},
3589 no sanitization is performed.
3590 \end{important}
3591
3592 In addition to the root language label and the dialect identifier,
3593 many of the language options also have corresponding \idx{ISO} codes. In
3594 most cases there is an \idxn{639-1} or an \idxn{639-2} code (or both), and in some
3595 cases there is an \idxn{3166-1} code identifying the dialect \idx{region}.
3596 Where a language has different \idxn{639-2T} and \idx{639-2B} codes,
3597 the \qt{T} version is assumed.
3598
3599 When the \file{tracklang.sty} \LaTeX\ package is loaded, it first attempts to find the
3600 language options through the package options supplied to
3601 \sty{tracklang}. This means that any languages that have been
3602 supplied in the document class options should get identified
3603 (provided that the document class has used the standard option
3604 declaration mechanism). If no languages have been supplied in this
3605 way, \file{tracklang.sty} then attempts to identify language settings in
3606 the following order:
3607 \begin{enumerate}
3608 \item if \gls{LocaleForEach} is defined (\sty{babel}),
3609 \sty{tracklang} will use it to iterate over each dialect label
3610 and fetch the associated \idx{BCP47} tag;
3611
3612 \item if \gls{bbl@loaded} is defined (\sty{babel}), \sty{tracklang}
3613 will iterate over each label in that command definition;
3614
3615 \item if \gls{trans@languages} is defined (\sty{translator}),
3616 \sty{tracklang} will iterate over each label in that command
3617 definition;
3618
3619 \item if \sty{ngerman} has been loaded, the \opt{ngerman} dialect
3620 will be tracked;
3621
3622 \item if \sty{german} has been loaded, the \opt{german} root
3623 language will be tracked;
3624
3625 \item if \sty{polyglossia} has been loaded:
3626
3627 \begin{enumerate}
3628 \item if \gls{xpg@bcp@loaded} has been defined, \sty{tracklang}
3629 will iterate over the \idx{BCP47} tags in that command definition;
3630
3631 \item if \gls{xpg@loaded} has been defined, \sty{tracklang} will
3632 iterate over each language label in that command definition;
3633
3634 \item \sty{tracklang} will iterate over all \sty{tracklang} options
3635 and test if the root language has been loaded.
3636 \end{enumerate}
3637
3638 \end{enumerate}
3639 The check for \sty{ngerman}\slash\sty{german} is retained
3640 for backward-compatibility. Note that the old \sty{ngerman}
3641 and \sty{german} language options are now discouraged.
3642
3643 Each identified language and dialect is added to the \emph{tracked
3644 language} and \emph{tracked dialect} lists. Note that the tracked
3645 language and tracked dialect are labels rather than proper nouns.
3646 If a~dialect label is identical to its root language label, the
3647 label will appear in both lists.
3648
3649 You can check whether or not any languages have been detected using:
3650 \cmddef{AnyTrackedLanguages}
3651 This will do \meta{true} if one or more languages have been
3652 tracked otherwise it will do \meta{false}. (Each detected
3653 dialect will automatically have the root language label added
3654 to the tracked language list, if it's not already present.)
3655
3656 You can check whether or not any regions have been detected using:
3657 \cmddef{AnyTrackedRegions}
3658 This will do \meta{true} if one or more regions have been
3659 tracked otherwise it will do \meta{false}.
3660
3661 If you want to find out if any of the tracked dialects
3662 matches a particular language tag, you can use:
3663 \cmddef{GetTrackedDialectFromLanguageTag}
3664 If successful, the supplied control sequence \meta{cs} is set to the
3665 dialect label, otherwise \meta{cs} is set to empty. The test is for an exact
3666 match on the root language, \idx{script}, sub-language, \idx{variant} and
3667 \idx{region}. The control sequence \meta{cs} will be empty if none of the
3668 tracked dialects matches all five of those elements. (If the script
3669 isn't given explicitly, the default for that language is assumed.)
3670 In the event that \meta{cs} is empty, you can now (as from v1.3.6)
3671 get the closest match with:
3672 \cmddef{TrackedDialectClosestSubMatch}
3673 (which is set by \gls{GetTrackedDialectFromLanguageTag}).
3674 This will be empty if no tracked dialects match on the root
3675 language or if there's a tracked dialect label that exactly matches
3676 the label formed by concatenating the language code, sub-language,
3677 \idx{script}, \idx{region}, \idx{modifier} and \idx{variant}.
3678
3679 For example (Plain \TeX):
3680 \begin{codebox}
3681 \gls{input} tracklang
3682 \gls{TrackLanguageTag}\marg{en-826}
3683 Has en-Latn-GB been tracked?
3684 \gls{GetTrackedDialectFromLanguageTag}\marg{en-Latn-GB}\marg{\cmd{thisdialect}}\comment{}
3685 \cmd{ifx}\cmd{thisdialect}\cmd{empty}
3686 No!
3687 \cmd{else}
3688 Yes! Dialect label: \cmd{thisdialect}.
3689 \cmd{fi}
3690 \cmd{bye}
3691 \end{codebox}
3692 This matches because the \idx{territory} code \numericcode{GB} is recognised as
3693 equivalent to the code \opt{GB}, and the default \idx{script} for
3694 \opt{english} is \opt{Latn}. In this case, the dialect
3695 label is \opt{british}. Note that this doesn't require
3696 the use of \gls{TrackLanguageTag} to track the dialect.
3697 It also works if the dialect has been tracked using other commands,
3698 such as \gls{TrackLocale}.
3699
3700 Here's an example that doesn't have an exact match, but does have a
3701 partial match:
3702 \begin{codebox}
3703 \gls{input} tracklang
3704 \gls{TrackLanguageTag}\marg{de-CH-1996}
3705 Has de-DE-1996 been tracked?
3706 \gls{GetTrackedDialectFromLanguageTag}\marg{de-DE-1996}\marg{\cmd{thisdialect}}\comment{}
3707 \cmd{ifx}\cmd{thisdialect}\cmd{empty}
3708 No!
3709 \cmd{ifx}\gls{TrackedDialectClosestSubMatch}\cmd{empty}
3710 No match on root language.
3711 \cmd{else}
3712 Closest match: \gls{TrackedDialectClosestSubMatch}.
3713 \cmd{fi}
3714 \cmd{else}
3715 Yes! Dialect label: \cmd{thisdialect}.
3716 \cmd{fi}
3717 \cmd{bye}
3718 \end{codebox}
3719 In this case the result is:
3720 \begin{resultbox}
3721 Has de-DE-1996 been tracked? No! Closest match: nswissgerman.
3722 \end{resultbox}
3723
3724 You can iterate through each tracked dialect using:
3725 \cmddef{ForEachTrackedDialect}
3726 At the start of each iteration, this sets the control sequence
3727 \meta{cs} to the tracked dialect and does \meta{body}.
3728
3729 You can iterate through each tracked language using:
3730 \cmddef{ForEachTrackedLanguage}
3731 At the start of each iteration, this sets the control sequence \meta{cs} to the
3732 tracked language and does \meta{body}.
3733
3734 You can iterate through each tracked region using:
3735 \cmddef{ForEachTrackedRegion}
3736
3737 The above for-loops use the same internal mechanism as \LaTeX's
3738 \gls{@for} loop. Since this isn't defined by \TeX, a similar command
3739 (\inlineglsdef{@tracklang@for}) will be defined that works in the same way.
3740
3741 The provided control sequence \meta{cs} is updated at the
3742 start of each iteration to the current element. The loop is
3743 terminated when this control sequence is set to \gls{@nil}. This
3744 special control sequence should never been used as it's just a
3745 marker and isn't actually defined. If you get an error message
3746 stating that \gls{@nil} is undefined, then it's most likely due to a
3747 loop control sequence being used outside the loop. This can occur if
3748 the loop contains code that isn't expanded until later. For example,
3749 if the loop code includes \gls{AtBeginDocument}, you need to ensure
3750 that the loop control sequence is expanded before being added to the
3751 hook.
3752
3753 You can test if a root language has been detected using:
3754 \cmddef{IfTrackedLanguage}
3755 where \meta{language-label} is the language label. If
3756 true, this does \meta{true} otherwise it does \meta{false}.
3757
3758 You can test if a particular dialect has been detected using:
3759 \cmddef{IfTrackedDialect}
3760 where \meta{dialect-label} is the dialect label. If the root
3761 language was explicitly specified, then it will also be detected as
3762 a dialect.
3763
3764 For example:
3765 \begin{codebox}
3766 \cmd{documentclass}[\opt{british},\opt{dutch}]\marg{article}
3767 \codepar
3768 \cmd{usepackage}\marg{tracklang}
3769 \codepar
3770 \cbeg{document}
3771 ``english'' \gls{IfTrackedDialect}\marg{english}\marg{has}\marg{hasn't} been specified.
3772 \codepar
3773 ``british'' \gls{IfTrackedDialect}\marg{british}\marg{has}\marg{hasn't} been specified.
3774 \codepar
3775 ``flemish'' \gls{IfTrackedDialect}\marg{flemish}\marg{has}\marg{hasn't} been specified.
3776 \codepar
3777 ``dutch'' \gls{IfTrackedDialect}\marg{dutch}\marg{has}\marg{hasn't} been specified.
3778 \codepar
3779 ``english'' or an English variant
3780 \gls{IfTrackedLanguage}\marg{english}\marg{has}\marg{hasn't} been specified.
3781 \cend{document}
3782 \end{codebox}
3783 This produces:
3784 \begin{resultbox}
3785 ``english'' hasn't been specified.
3786
3787 ``british'' has been specified.
3788
3789 ``flemish'' hasn't been specified.
3790
3791 ``dutch'' has been specified.
3792
3793 ``english'' or an English variant has been specified.
3794 \end{resultbox}
3795
3796 You can find the root language label for a given tracked dialect
3797 using:
3798 \cmddef{TrackedLanguageFromDialect}
3799 If \meta{dialect} hasn't been defined this does nothing otherwise it
3800 expands to the root language label.
3801
3802 You can find the tracked dialects from a given root language
3803 using:
3804 \cmddef{TrackedDialectsFromLanguage}
3805 This will expand to a~comma-separated list of dialect labels
3806 if the root language label has been defined, otherwise it
3807 does nothing.
3808
3809 You can test if a language or dialect has a corresponding \idx+{ISO} code using:
3810 \cmddef{IfTrackedLanguageHasIsoCode}
3811 where \meta{code type} is the type of \idx{ISO} code (for example,
3812 \idx{639-1} for root languages or \idx{3166-1} for regional
3813 dialects), and \meta{label} is the language or dialect label.
3814 Note that the \idx{639-3} may be set for the dialect
3815 rather than root language for sub-languages parsed using
3816 \gls{TrackLanguageTag}.
3817
3818 Alternatively, you can test if a particular \idx{ISO} code has been
3819 defined using:
3820 \cmddef{IfTrackedIsoCode}
3821 where \meta{code type} is again the type of \idx{ISO} code (for example,
3822 \idx{639-1} or \idx{3166-1}), and \meta{code} is the
3823 particular code (for example, \opt{en} for \idxn{639-1} or
3824 \opt{GB} for \idxn{3166-1}).
3825
3826 You can fetch the language (or dialect) label associated with a
3827 given \idx{ISO} code using:
3828 \cmddef{TrackedLanguageFromIsoCode}
3829 This does nothing if the given \meta{code} for the given \idx{ISO}
3830 \meta{code type} has not been defined, otherwise it expands
3831 a~comma-separated list of language or dialect labels.
3832
3833 You can fetch the \idx{ISO} code for a given code type using:
3834 \cmddef{TrackedIsoCodeFromLanguage}
3835 where \meta{label} is the language or dialect label and \meta{code
3836 type} is the \idx{ISO} code type (for example, \idx{639-1} or
3837 \idx{3166-1}). Unlike \gls{TrackedLanguageFromIsoCode}, this
3838 command only expands to a single label rather than a~comma-separated
3839 list.
3840
3841 The above commands do nothing in the event of an unknown code or
3842 code type,
3843 so if you accidentally get the wrong code type, you won't get an error.
3844 If you're unsure of the code type, you can use the following commands:
3845 \cmddef{TwoLetterIsoCountryCode}
3846 This expands to \idx{3166-1} and is used for the two-letter country codes.
3847
3848 \cmddef{TwoLetterIsoLanguageCode}
3849 This expands to \idx{639-1} and is used for the two-letter root language codes.
3850
3851 \cmddef{ThreeLetterIsoLanguageCode}
3852 This expands to \idx{639-2} and is used for the three-letter root language
3853 codes.
3854
3855 \cmddef{ThreeLetterExtIsoLanguageCode}
3856 This expands to \idx{639-3}. This code is only used for a root language if
3857 there's no \idx{639-1} or \idx{639-2} code. It may also be used for a
3858 dialect if a sub-language part has been set in the language
3859 tag parsed by \gls{TrackLanguageTag}.
3860
3861 The \cmd{Get\ldots} commands below are designed to be expandable.
3862 If the supplied \meta{dialect} is unrecognised they expand to empty.
3863 Remember that the dialect must first be identified as a tracked
3864 language for it to be recognised.
3865
3866 As from v1.3, the language tag for a given dialect can be obtained
3867 using:
3868 \cmddef{GetTrackedLanguageTag}
3869 where \meta{dialect} is the label identifying the dialect.
3870 Uses the \opt{und} (undetermined) code for unknown languages.
3871
3872 As from v1.3, each tracked dialect may also have an associated
3873 modifier, which can be fetched using:
3874 \cmddef{GetTrackedDialectModifier}
3875 where \meta{dialect} is the label identifying the dialect.
3876 This value is typically obtained by parsing a \idx{POSIX} locale identifier
3877 with \gls{TrackLocale} or \gls{TrackLangFromEnv} but may be set explicitly.
3878 (See \sectionref{sec:langsty} for setting this value. Likewise for
3879 the following commands.)
3880
3881 You can test if a dialect has an associated \idx{modifier} using:
3882 \cmddef{IfHasTrackedDialectModifier}
3883 If the dialect has an associated \idx{modifier} this does \meta{true}
3884 otherwise it does \meta{false}.
3885
3886 For example:
3887 \begin{codebox}
3888 \cmd{documentclass}[\opt{british}\dcomma\opt{francais}\dcomma\opt{american}\dcomma\opt{canadian}\dcomma\opt{canadien}\dcomma\opt{dutch}]\marg{article}
3889 \codepar
3890 \cmd{usepackage}\marg{tracklang}
3891 \codepar
3892 \cbeg{document}
3893 Languages:
3894 \gls{ForEachTrackedLanguage}\marg{\cmd{ThisLanguage}}\marg{\cmd{ThisLanguage}\cmd{space}
3895 (ISO \gls{TwoLetterIsoLanguageCode}:
3896 ``\gls{TrackedIsoCodeFromLanguage}
3897 \marg{\gls{TwoLetterIsoLanguageCode}}\marg{\cmd{ThisLanguage}}''). }
3898 \codepar
3899 Dialects:
3900 \gls{ForEachTrackedDialect}\marg{\cmd{ThisDialect}}\marg{\cmd{ThisDialect}\cmd{space}
3901 (\gls{IfTrackedLanguageHasIsoCode}
3902 \marg{\gls{TwoLetterIsoCountryCode}}\marg{\cmd{ThisDialect}}\comment{}
3903 \marg{ISO \gls{TwoLetterIsoCountryCode}:
3904 ``\gls{TrackedIsoCodeFromLanguage}
3905 \marg{\gls{TwoLetterIsoCountryCode}}\marg{\cmd{ThisDialect}}''}%
3906 \marg{no specific region};
3907 root: \gls{TrackedLanguageFromDialect}\marg{\cmd{ThisDialect}}). }
3908 \codepar
3909 Language for ISO \gls{TwoLetterIsoCountryCode}\cmd{ }``GB'':
3910 \gls{TrackedLanguageFromIsoCode}
3911 \marg{\gls{TwoLetterIsoCountryCode}}\marg{GB}.
3912 \codepar
3913 Language for ISO \gls{TwoLetterIsoCountryCode}\cmd{ }``CA'':
3914 \gls{TrackedLanguageFromIsoCode}
3915 \marg{\gls{TwoLetterIsoCountryCode}}\marg{CA}.
3916 \codepar
3917 Country ISO \gls{TwoLetterIsoCountryCode}\cmd{ }code for ``canadian'':
3918 \gls{TrackedIsoCodeFromLanguage}
3919 \marg{\gls{TwoLetterIsoCountryCode}}\marg{canadian}.
3920 \cend{document}
3921 \end{codebox}
3922 This produces:
3923 \begin{resultbox}
3924 Languages: english (ISO 639-1: ``en''). french (ISO 639-1: ``fr'').
3925 dutch (ISO 639-1: ``nl'').
3926
3927 Dialects: american (ISO 3166-1: ``US''; root: english).
3928 british (ISO 3166-1: ``GB''; root: english).
3929 canadian (ISO 3166-1: ``CA''; root: english).
3930 canadien (ISO 3166-1: ``CA''; root: french).
3931 dutch (no specific region; root: dutch).
3932 francais (no specific region; root: french).
3933
3934 Language for ISO 3166-1 ``GB'': british.
3935
3936 Language for ISO 3166-1 ``CA'': canadian,canadien.
3937
3938 Country ISO 3166-1 code for ``canadian'': CA.
3939 \end{resultbox}
3940
3941 As from v1.3, each tracked dialect may also have an associated
3942 variant, which can be fetched using:
3943 \cmddef{GetTrackedDialectVariant}
3944 where \meta{dialect} is the label identifying the dialect.
3945 This value is typically obtained by parsing a language tag
3946 with \gls{TrackLanguageTag} but may be set explicitly.
3947
3948 You can test if a dialect has an associated variant using:
3949 \cmddef{IfHasTrackedDialectVariant}
3950
3951 As from v1.3, each tracked dialect may also have an associated
3952 script, which can be fetched using:
3953 \cmddef{GetTrackedDialectScript}
3954 where \meta{dialect} is the label identifying the dialect.
3955
3956 You can test if a dialect has an associated script using:
3957 \cmddef{IfHasTrackedDialectScript}
3958 If the dialect has an associated script this does \meta{true}
3959 otherwise it does \meta{false}. This information is provided
3960 for language packages that need to know what script is required,
3961 but there's no guarantee that the script will actually be set
3962 in the document. Similarly for all the other attributes described
3963 here.
3964
3965 Note that the script should be a recognised four-letter \idxn{15924}
3966 code, such as \opt{Latn} or \opt{Cyrl}. If a~dialect
3967 doesn't have an associated script then the default for the root
3968 language should be assumed. For example, \opt{Latn} for English dialects or
3969 \opt{Cyrl} for Russian dialects. The default script for
3970 known languages can be obtained using:
3971 \cmddef{TrackLangGetDefaultScript}
3972 Most root languages have a default script, but there
3973 are a few without one as it may depend on region, politics
3974 or ideology.
3975
3976 There's a convenient expandable command for testing the script:
3977 \cmddef{IfTrackedDialectIsScriptCs}
3978 This tests if the given tracked dialect has an associated script and
3979 compares the value with the replacement text of \meta{cs}.
3980 If the dialect hasn't been explicitly assigned a script,
3981 then test is performed against the default script for the root
3982 language.
3983
3984 The supplementary package \sty{tracklang-scripts} provides some
3985 additional commands relating to writing systems, including commands
3986 in the form \gls{TrackLangScriptCode} where
3987 \meta{Code} is the \idxn{15924} four-letter code. If the dialect
3988 doesn't have an associated script, \meta{false} is done.
3989 This package isn't
3990 loaded automatically, so you'll need to explicitly load it. The
3991 generic code is in \file{tracklang-scripts.tex}:
3992 \begin{codebox}
3993 \gls{input} tracklang-scripts
3994 \end{codebox}
3995 There's a convenient \LaTeX\ wrapper \file{tracklang-scripts.sty}:
3996 \begin{codebox}
3997 \cmd{usepackage}\marg{tracklang-scripts}
3998 \end{codebox}
3999 See \sectionref{sec:supplpkgs} for further details of
4000 that package.
4001
4002 For example, the following defines a command to check if
4003 the given dialect should use a Latin \idx{script}:
4004 \begin{codebox}
4005 \gls{input} tracklang-scripts
4006 \cmd{def}\cmd{islatin}\#1\#2\#3\marg{\comment{}
4007 \gls{IfTrackedDialectIsScriptCs}\marg{\#1}\marg{\tklscript{Latn}}\marg{\#2}\marg{\#3}\comment{}
4008 }
4009 \end{codebox}
4010
4011 \begin{important}
4012 Note that the \idx{script} value doesn't mean that the document is
4013 actually using that script. It means that this is the user's
4014 \emph{desired} script, but whether that \idx{script} is actually set relies
4015 on the appropriate settings in the relevant language package (such
4016 as \sty{polyglossia}['s] \optfmt{script} key).
4017 \end{important}
4018
4019 As from v1.3, each tracked dialect may also have a sub-language
4020 identifier (for example, \optfmt{arevela}), which can be fetched
4021 using:
4022 \cmddef{GetTrackedDialectSubLang}
4023 where \meta{dialect} is the label identifying the dialect.
4024
4025 You can test if a dialect has an associated sub-tag using:
4026 \cmddef{IfHasTrackedDialectSubLang}
4027 If the dialect has an associated sub-tag this does \meta{true}
4028 otherwise it does \meta{false}.
4029
4030 As from v1.3, each tracked dialect may also have additional
4031 information, which can be fetched using:
4032 \cmddef{GetTrackedDialectAdditional}
4033 where \meta{dialect} is the label identifying the dialect.
4034
4035 You can test if a dialect has additional information using:
4036 \cmddef{IfHasTrackedDialectAdditional}
4037 If the dialect has additional information this does \meta{true}
4038 otherwise it does \meta{false}.
4039
4040 Most packages that implement multilingual support have a~set of
4041 language definition files for each supported language or dialect.
4042 It may be that only the root language is needed, if there are no
4043 variations between that language's dialect (for the purposes of that
4044 package), or it may be that separate definition files are required
4045 for each dialect. However it can be awkward trying to map the
4046 requested dialect or language label to the file name. Should, say,
4047 the file containing the French code be called
4048 \filemetametafmt{}{prefix}{\dhyphen french\dhyphen }{suffix}{} or
4049 \filemetametafmt{}{prefix}{\dhyphen frenchb\dhyphen }{suffix}{} or
4050 \filemetametafmt{}{prefix}{\dhyphen francais\dhyphen}{suffix}{}?
4051 Should, say, the file containing the British English code be called
4052 \filemetametafmt{}{prefix}{\dhyphen british\dhyphen }{suffix}{} or
4053 \filemetametafmt{}{prefix}{\dhyphen UKenglish\dhyphen }{suffix}{}?
4054 If you want to modularise the language support for your package so
4055 that each language module has a different maintainer will the
4056 maintainers know what tag to use for their language?
4057
4058 \label{pg:filesearch}To help with this, \sty{tracklang} provides:
4059 \cmddef{IfTrackedLanguageFileExists}
4060 This attempts to find the file called
4061 \meta{prefix}\meta{localeid}\meta{suffix} where \meta{localeid} is determined
4062 from \meta{dialect} (see below). If the file is found then
4063 \cmddef{CurrentTrackedTag}
4064 is set to \meta{localeid} and \meta{true code} is done, otherwise
4065 \meta{false code} is done. If this command
4066 is empty, then the dialect hasn't been detected. If the dialect
4067 has been detected, but no file can be found, then
4068 \gls{CurrentTrackedTag} is set to the final attempt at determining
4069 \meta{localeid}.
4070
4071 Sometimes the dialect label can cause a problem, especially if it
4072 happens to be identical to the root label. The solo region code
4073 check may also be problematic, so the following analoguous commands are
4074 also provided.
4075
4076 \cmddef{IfTrackedLanguageFileExistsOmitDialectLabel}
4077 As \gls{IfTrackedLanguageFileExists} but omits the test for the
4078 dialect label. Note that if the dialect label happens to be
4079 identical to the root language label, it will still be checked, but
4080 at the very end instead of near the start.
4081
4082 \cmddef{IfTrackedLanguageFileExistsOmitOnlyRegion}
4083 As \gls{IfTrackedLanguageFileExists} but omits the test for just the
4084 region code.
4085
4086 \cmddef{IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion}
4087 Combination of the above two commands.
4088 As \gls{IfTrackedLanguageFileExists} but omits the tests for the
4089 dialect label and for just the region code.
4090
4091 There's a convenient shortcut command new to version 1.3:
4092 \cmddef{TrackLangRequireDialect}
4093 which uses \gls{IfTrackedLanguageFileExists} to input the resource
4094 file if found. The prefix is given by \meta{pkgname}\code{-} and
4095 the suffix is \code{.\ext+{ldf}}. A warning is issued if no resource file
4096 is found. Note that while it makes sense for \meta{pkgname}
4097 to be the same as the base name of the package that uses these
4098 resource files, they don't have to be the same. This command
4099 additionally defines:
4100 \cmddef{TrackLangRequireDialectPrefix}
4101 to \meta{pkgname}, which allows the prefix to be picked up by
4102 resource file commands, such as \gls{TrackLangProvidesResource}
4103 and \gls{TrackLangRequireResource}. (See below.)
4104
4105 There are analogous commands
4106 \cmddef{TrackLangRequireDialectOmitDialectLabel}
4107 As above, but uses \gls{IfTrackedLanguageFileExistsOmitDialectLabel}.
4108
4109 \cmddef{TrackLangRequireDialectOmitDialectLabelOmitOnlyRegion}
4110 As above, but uses
4111 \gls{IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion}.
4112
4113 \cmddef{TrackLangRequireDialectOmitOnlyRegion}
4114 As above, but uses
4115 \gls{IfTrackedLanguageFileExistsOmitOnlyRegion}.
4116
4117 The optional argument \meta{load code} is the code that actually
4118 inputs the required file. This defaults to
4119 \begin{codebox}
4120 \gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}
4121 \end{codebox}
4122
4123 The \gls{IfTrackedLanguageFileExists} command sets up the current
4124 tracked dialect with:
4125 \begin{compactcodebox*}
4126 \gls{SetCurrentTrackedDialect}\margm{dialect}
4127 \end{compactcodebox*}
4128 which enables the following commands that may be used within
4129 \meta{true code} or \meta{false code}:
4130 \cmddef{CurrentTrackedDialect}
4131 Expands to the dialect label.
4132
4133 \cmddef{CurrentTrackedLanguage}
4134 If the dialect hasn't been detected, this command will be empty,
4135 otherwise it will expand to the root language label (which may
4136 be the same as the dialect label).
4137
4138 \cmddef{CurrentTrackedRegion}
4139 If the dialect hasn't been detected, this command will be empty.
4140 If the dialect has been assigned an \idxn{3166-1} code,
4141 \gls{CurrentTrackedRegion} will expand to that code, otherwise it
4142 will be empty.
4143
4144 \cmddef{CurrentTrackedIsoCode}
4145 If the dialect hasn't been detected, this command will be empty.
4146 Otherwise it may be empty or it may expand to the
4147 \idxn{639-1} or \idxn{639-2} or \idxn{639-3} code.
4148
4149 \cmddef{CurrentTrackedDialectModifier}
4150 The dialect's modifier or empty if not set. (This is set but not
4151 used in the set of possible \meta{localeid} values.)
4152
4153 \cmddef{CurrentTrackedDialectVariant}
4154 The dialect's variant or empty if not set.
4155
4156 \cmddef{CurrentTrackedDialectSubLang}
4157 The dialect's sub-language code or empty if not set.
4158
4159 \cmddef{CurrentTrackedDialectAdditional}
4160 The dialect's additional information or empty if not set.
4161
4162 \cmddef{CurrentTrackedLanguageTag}
4163 The dialect's language tag. Take care not to confuse this
4164 with \gls{CurrentTrackedTag}.
4165
4166 \cmddef{CurrentTrackedDialectScript}
4167 The dialect's script. If the dialect doesn't have the script set,
4168 the default script for the language is used instead.
4169
4170 \gls{IfTrackedLanguageFileExists} behaves as follows:
4171 \begin{itemize}
4172 \item If no dialect with the given label has been
4173 detected, the condition evaluates to \emph{false} and
4174 \gls{CurrentTrackedTag} is empty.
4175
4176 \item If a dialect with the given label has been detected, then:
4177 \begin{itemize}
4178 \item For each possible \meta{localeid} in an ordered set of tags determined by
4179 the dialect label (see below), the first file matching
4180 \meta{prefix}\meta{localeid}\meta{suffix} that's found on
4181 \TeX's path results in the condition evaluating to \emph{true} and
4182 \gls{CurrentTrackedTag} is set to the current \meta{localeid} in the
4183 set. The rest of the set of possible values of \meta{localeid} is skipped.
4184
4185 \item If no file matching \meta{prefix}\meta{localeid}\meta{suffix} is
4186 found on \TeX's path, then the condition evaluates to \emph{false}
4187 and \gls{CurrentTrackedTag} is set to the final \meta{localeid} in the
4188 set (the language label).
4189 \end{itemize}
4190 \end{itemize}
4191
4192 The ordered set of possible values of \meta{localeid} is determined from
4193 the given dialect.
4194 \begin{important}
4195 The ordering has changed in version 1.4, which now also includes the
4196 \idx{script} and \idx{variant}. This new ordering should typically make the more
4197 common combinations closer to the start of the search.
4198 \end{important}
4199 The possible values of \meta{localeid} are listed below in the order of priority used
4200 by \gls{IfTrackedLanguageFileExists}. Note that the set may contain
4201 repetitions (for example, if the dialect label is the same as the
4202 root language label). If an item contains an element that hasn't
4203 been set (such as the \idxn{639-3} code or a sub-language
4204 \meta{sublang} or \idx{variant}) then
4205 that item is skipped.
4206 \begin{enumerate}
4207 \item \meta{localeid} is just the value of \gls{CurrentTrackedLanguageTag}.
4208
4209 \item \meta{localeid} is just the dialect label.
4210 This step is omitted with \gls{IfTrackedLanguageFileExistsOmitDialectLabel}
4211 and \gls{IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion}.
4212
4213 \item \meta{localeid} is
4214 \meta{ISO~639-1}\code{-}\meta{sublang}\code{-}\meta{script}\code{-}\meta{region}.
4215
4216 \item \meta{localeid} is
4217 \meta{ISO~639-1}\code{-}\meta{script}\code{-}\meta{region}.
4218
4219 \item \meta{localeid} is
4220 \meta{ISO~639-1}\code{-}\meta{sublang}\code{-}\meta{region} (if there's no script or if
4221 the script is the default for the given language).
4222 \meta{ISO~639-1}\code{-}\meta{region} (if there's no script or if
4223 the script is the default for the given language).
4224
4225 \item \meta{localeid} is
4226 \meta{ISO~639-1}\code{-}\meta{sublang}\code{-}\meta{script}.
4227
4228 \item \meta{localeid} is
4229 \meta{ISO~639-1}\code{-}\meta{script}.
4230
4231 \item \meta{localeid} is \meta{ISO~639-1}\code{-}\meta{sublang}.
4232
4233 \item \meta{localeid} is just \meta{ISO~639-1}.
4234
4235 \item \meta{localeid} is
4236 \meta{ISO~639-2}\code{-}\meta{sublang}\code{-}\meta{script}\code{-}\meta{region}.
4237
4238 \item \meta{localeid} is
4239 \meta{ISO~639-2}\code{-}\meta{script}\code{-}\meta{region}.
4240
4241 \item \meta{localeid} is
4242 \meta{ISO~639-2}\code{-}\meta{sublang}\code{-}\code{region} (if there's no script or if
4243 the script is the default for the given language).
4244 \meta{ISO~639-2}\code{-}\meta{region} (if there's no script or if
4245 the script is the default for the given language).
4246
4247 \item \meta{localeid} is
4248 \meta{ISO~639-2}\code{-}\meta{sublang}\code{-}\meta{script}.
4249
4250 \item \meta{localeid} is
4251 \meta{ISO~639-2}\code{-}\meta{script}.
4252
4253 \item \meta{localeid} is \meta{ISO~639-2}\code{-}\meta{sublang}.
4254 \item \meta{localeid} is just \meta{ISO~639-2}.
4255
4256 \item \meta{localeid} is
4257 \meta{ISO~639-3}\code{-}\meta{sublang}\code{-}\meta{script}\code{-}\meta{region}.
4258
4259 \item \meta{localeid} is
4260 \meta{ISO~639-3}\code{-}\meta{script}\code{-}\meta{region}.
4261
4262 \item \meta{localeid} is
4263 \meta{ISO~639-3}\code{-}\meta{sublang}\code{-}\meta{region} (if there's no script or if
4264 the script is the default for the given language).
4265 \meta{ISO~639-3}\code{-}\meta{region} (if there's no script or if
4266 the script is the default for the given language).
4267
4268 \item \meta{localeid} is
4269 \meta{ISO~639-3}\code{-}\meta{sublang}\code{-}\meta{script}.
4270
4271 \item \meta{localeid} is
4272 \meta{ISO~639-3}\code{-}\meta{script}.
4273
4274 \item \meta{localeid} is \meta{ISO~639-3}\code{-}\meta{sublang}.
4275
4276 \item \meta{localeid} is just \meta{ISO~639-3}.
4277
4278 \item \meta{localeid} is just \meta{region}.
4279 This step is omitted with
4280 \gls{IfTrackedLanguageFileExistsOmitOnlyRegion}
4281 and \gls{IfTrackedLanguageFileExistsOmitDialectLabelOmitOnlyRegion}.
4282
4283 \item \meta{localeid} is
4284 \meta{ISO~639-1}\code{-}\meta{sublang}\code{-}\meta{variant}
4285 or \meta{ISO~639-1}\code{-}\meta{variant} if \meta{sublang} is missing.
4286
4287 \item \meta{localeid} is
4288 \meta{ISO~639-2}\code{-}\meta{sublang}\code{-}\meta{variant}
4289 or \meta{ISO~639-2}\code{-}\meta{variant} if \meta{sublang} is missing.
4290
4291 \item \meta{localeid} is
4292 \meta{ISO~639-3}\code{-}\meta{sublang}\code{-}\meta{variant}
4293 or \meta{ISO~639-3}\code{-}\meta{variant} if \meta{sublang} is missing.
4294
4295 \item \meta{localeid} is just the value of \gls{CurrentTrackedLanguage}
4296 (the root language label).
4297 \end{enumerate}
4298
4299 For example (pre v1.3):
4300 \begin{codebox}[fontupper=\small\ttfamily]
4301 \gls{AnyTrackedLanguages}
4302 \marg{\comment{}
4303 \gls{ForEachTrackedDialect}\marg{\cmd{ThisDialect}}\comment{}
4304 \marg{\comment{}
4305 \comment{try to load the language file for this dialect}
4306 \gls{IfTrackedLanguageFileExists}\marg{\cmd{ThisDialect}}\comment{}
4307 \marg{mypackage-}\comment{file prefix}
4308 \marg{.ldf}\comment{file suffix}
4309 \marg{\gls{input} mypackage-\gls{CurrentTrackedTag}.ldf}\comment{file found}
4310 \marg{\comment{file not found}
4311 \cmd{PackageWarning}\marg{mypackage}
4312 \marg{No support for language `\cmd{ThisDialect}'}\comment{}
4313 }\comment{}
4314 }\comment{}
4315 }
4316 \marg{\comment{no languages detected so use defaults}
4317 }
4318 \end{codebox}
4319 With version 1.3 onwards, this can be written more concisely as:
4320 \begin{codebox}[fontupper=\small\ttfamily]
4321 \gls{AnyTrackedLanguages}
4322 \marg{\comment{}
4323 \gls{ForEachTrackedDialect}\marg{\cmd{ThisDialect}}\comment{}
4324 \marg{\comment{}
4325 \comment{try to load the language file for this dialect}
4326 \gls{TrackLangRequireDialect}\marg{mypackage}\marg{\cmd{ThisDialect}}\comment{}
4327 }\comment{}
4328 }
4329 \marg{\comment{no languages detected so use defaults}
4330 }
4331 \end{codebox}
4332 which additionally enables the \sty{tracklang} version 1.3 commands described below,
4333 such as \gls{TrackLangRequireResource}.
4334
4335 \plabel{pg.britishfilesearch}%
4336 If, for example, \cmd{ThisDialect} is \opt{british}, then the file search will
4337 be in the order:
4338 \begin{enumerate}
4339 \item \ldf{mypackage}{en-GB} (language tag)
4340 \item \ldf{mypackage}{british} (dialect label)
4341
4342 \item \ldf{mypackage}{en-Latn-GB} (\idx{639-1} language code,
4343 \idx{script}, \idx{region})
4344 \item \ldf{mypackage}{en-GB} (\idx{639-1} language code,
4345 \idx{region})
4346 \item \ldf{mypackage}{en-Latn} (\idx{639-1} language code,
4347 \idx{script})
4348 \item \ldf{mypackage}{en} (\idx{639-1} language code)
4349
4350 \item \ldf{mypackage}{eng-Latn-GB} (\idx{639-2} language
4351 code, \idx{script}, \idx{region})
4352 \item \ldf{mypackage}{eng-GB} (\idx{639-2} language code,
4353 \idx{region})
4354 \item \ldf{mypackage}{eng-Latn} (\idx{639-2} language code,
4355 \idx{script})
4356 \item \ldf{mypackage}{eng} (\idx{639-2} language code)
4357
4358 \item \ldf{mypackage}{GB} (\idx{region})
4359 \item \ldf{mypackage}{english} (language label)
4360 \end{enumerate}
4361
4362 If, for example, \cmd{ThisDialect} is \opt{naustrian}, then the file search will
4363 be in the order:
4364 \begin{enumerate}
4365 \item \ldf{mypackage}{de-AT-1996} (language tag)
4366 \item \ldf{mypackage}{naustrian} (dialect label)
4367
4368 \item \ldf{mypackage}{de-Latn-AT} (\idx{639-1} language code,
4369 \idx{script}, \idx{region})
4370 \item \ldf{mypackage}{de-AT} (\idx{639-1} language code,
4371 \idx{region})
4372 \item \ldf{mypackage}{de-Latn} (\idx{639-1} language code,
4373 \idx{script})
4374 \item \ldf{mypackage}{de} (\idx{639-1} language code)
4375
4376 \item \ldf{mypackage}{deu-Latn-AT} (\idx{639-2} language
4377 code, \idx{script}, \idx{region})
4378 \item \ldf{mypackage}{deu-AT} (\idx{639-2} language code,
4379 \idx{region})
4380 \item \ldf{mypackage}{deu-Latn} (\idx{639-2} language code,
4381 \idx{script})
4382 \item \ldf{mypackage}{deu} (\idx{639-2} language code)
4383
4384 \item \ldf{mypackage}{AT} (\idx{region})
4385
4386 \item \ldf{mypackage}{de-1996} (\idx{639-1} language code,
4387 \idx{variant})
4388 \item \ldf{mypackage}{deu-1996} (\idx{639-2} language code,
4389 \idx{variant})
4390
4391 \item \ldf{mypackage}{german} (language label)
4392 \end{enumerate}
4393
4394 If, for example, \cmd{ThisDialect} is \opt{francais}, then the file search will
4395 be in the order:
4396 \begin{enumerate}
4397 \item \ldf{mypackage}{fr} (language tag)
4398 \item \ldf{mypackage}{francais} (dialect label)
4399 \item \ldf{mypackage}{fr-Latn} (\idx{639-1} language code,
4400 \idx{script})
4401 \item \ldf{mypackage}{fr} (\idx{639-1} language code)
4402 \item \ldf{mypackage}{fra-Latn} (\idx{639-2} language code,
4403 \idx{script})
4404 \item \ldf{mypackage}{fra} (\idx{639-2} language code)
4405 \item \ldf{mypackage}{french} (language)
4406 \end{enumerate}
4407 This is because the predefined \opt{francais} option has no
4408 region assigned to it. Be careful if the dialect label is the actual
4409 root language. For example, if \cmd{ThisDialect} is \opt{french},
4410 then the file search will be in the order:
4411 \begin{enumerate}
4412 \item \ldf{mypackage}{fr} (language tag)
4413 \item \ldf{mypackage}{french} (dialect label)
4414 \item \ldf{mypackage}{fr-Latn} (\idx{639-1} language code,
4415 \idx{script})
4416 \item \ldf{mypackage}{fr} (\idx{639-1} language code)
4417 \item \ldf{mypackage}{fra-Latn} (\idx{639-2} language code,
4418 \idx{script})
4419 \item \ldf{mypackage}{fra} (\idx{639-2} language code)
4420 \item \ldf{mypackage}{french} (language)
4421 \end{enumerate}
4422 Note that the last try will always fail in this case since if the
4423 file exists, it will be found on the second try.
4424
4425 If the dialect label is identical to the root language label then it
4426 means that all associated information is the default
4427 for that language. For example, in the above case of \opt{french},
4428 the script is \opt{Latn} and the region is unspecified. The root
4429 language label can therefore be used as the fallback in the event of
4430 no other match but for the specific case where the dialect is
4431 identical to the root language then all unnecessary file name checks
4432 can be skipped.
4433
4434 If you're only providing support for the root languages (pre v1.3):
4435 \begin{codebox}[fontupper=\small\ttfamily]
4436 \gls{AnyTrackedLanguages}
4437 \marg{\comment{}
4438 \gls{ForEachTrackedLanguage}\marg{\cmd{ThisLanguage}}\comment{}
4439 \marg{\comment{try to load the language file for this root language}
4440 \gls{IfTrackedLanguageFileExists}\marg{\cmd{ThisLanguage}}\comment{}
4441 \marg{mypackage-}\comment{file prefix}
4442 \marg{.ldf}\comment{file suffix}
4443 \marg{\gls{input} mypackage-\gls{CurrentTrackedTag}.ldf}\comment{file found}
4444 \marg{\comment{file not found}
4445 \cmd{PackageWarning}\marg{mypackage}\marg{No support for language
4446 `\cmd{ThisLanguage}'}\comment{}
4447 }\comment{}
4448 }\comment{}
4449 }
4450 \marg{\comment{no languages detected so use defaults}
4451 }
4452 \end{codebox}
4453 With version 1.3 onwards, this can be written more concisely as:
4454 \begin{codebox}[fontupper=\small\ttfamily]
4455 \gls{AnyTrackedLanguages}
4456 \marg{\comment{}
4457 \gls{ForEachTrackedLanguage}\marg{\cmd{ThisLanguage}}\comment{}
4458 \marg{\comment{try to load the language file for this root language}
4459 \gls{TrackLangRequireDialect}\marg{mypackage}\marg{\cmd{ThisLanguage}}\comment{}
4460 }\comment{}
4461 }
4462 \marg{\comment{no languages detected so use defaults}
4463 }
4464 \end{codebox}
4465 which additionally enables the commands described below.
4466 Note that in this case, if more than one dialect for the same
4467 language has been tracked, only the hooks for the last dialect for
4468 that language will be adjusted, so it's usually best to iterate over
4469 the dialects.
4470
4471 The following \cmd{TrackLang\ldots Resource\ldots} commands may
4472 only be used in resource files that are loaded using
4473 \gls{TrackLangRequireDialect}. An error will occur if the file is
4474 input through some other method.
4475
4476 Within the resource file \localemetafile{pkgname},
4477 you can identify the file using (new to version 1.3):
4478 \cmddef{TrackLangProvidesResource}
4479 where \meta{tag} is the locale identifier.
4480
4481 If \gls{ProvidesFile} is defined (through the \LaTeX\ kernel) this is
4482 used, otherwise a simplified generic alternative is used that's
4483 suitable for other \TeX\ formats.
4484
4485 The resource file can load another resource file
4486 \localemetametafile{pkgname}{tag},
4487 using (new to version 1.3):
4488 \cmddef{TrackLangRequireResource}
4489 For example, the dialect file \ldf{foo}{en-GB} might need to
4490 load the root language resource file \ldf{foo}{english}:
4491 \begin{codebox}
4492 \comment{(In file \ldf{foo}{en-GB})}
4493 \comment{Declare this regional file:}
4494 \gls{TrackLangProvidesResource}\marg{en-GB}
4495 \comment{load root language file \ldf{foo}{english}:}
4496 \gls{TrackLangRequireResource}\marg{english}
4497 \end{codebox}
4498 If \ldf{foo}{english} is also identified with
4499 \gls{TrackLangProvidesResource}, this will ensure that it's only
4500 loaded once.
4501
4502 It may be that you want to load a file depending on the input
4503 encoding. The \sty{inputenc} package defines
4504 \gls{inputencodingname}, but this is only used with \pdfLaTeX. To
4505 avoid repeated tests to determine whether or not \gls{inputencodingname}
4506 has been defined, you can use:
4507 \cmddef{TrackLangEncodingName}
4508 This will expand to \code{utf8} if \gls{inputencodingname} hasn't
4509 been defined (or has been set to \csfmt{relax}), otherwise it will
4510 expand to \gls{inputencodingname}.
4511 For example:
4512 \begin{codebox*}
4513 \gls{InputIfFileExists}\marg{foo-\gls{TrackLangEncodingName}.ldf}
4514 \marg{\comment{support available for the document encoding}
4515 }
4516 \marg{\comment{no support for the document encoding}
4517 }
4518 \end{codebox*}
4519
4520 If you require the resource file and want to perform
4521 \meta{code1} if it's loaded at this point or \meta{code2} if it's
4522 already been loaded then you can use:
4523 \cmddef{TrackLangRequireResourceOrDo}
4524
4525 If you want to load a resource file if it exists (without an
4526 error if it doesn't exist), then you can use
4527 \cmddef{TrackLangRequestResource}
4528 If the file doesn't exist, \meta{not found code} is done.
4529
4530 \begin{important}
4531 Note that these \cmd{\ldots Resource\ldots} commands are only
4532 permitted within the resource files. They are internally enabled
4533 through \gls{TrackLangRequireDialect}.
4534 \end{important}
4535
4536 The above restriction on the resource files loaded through
4537 \gls{TrackLangRequireDialect}, and the fact that it internally uses
4538 \gls{IfTrackedLanguageFileExists}, means that commands like
4539 \gls{CurrentTrackedLanguage} or \gls{CurrentTrackedDialect} may be
4540 used in those files. This means that the name of the captions hook
4541 can be obtained through them. (Remember that the file
4542 \ldf{foo}{en-GB} might have been loaded with, say, the
4543 \opt{british} dialect or with the synonymous \opt{UKenglish}
4544 dialect or with a dialect label that doesn't have a corresponding
4545 caption hook, such as \optfmt{enGBLatn}.)
4546
4547 The \sty{polyglossia} package has language caption hooks in the form
4548 \tklcaptions{\meta{language}} (where \meta{language} is the root language
4549 label) whereas \sty{babel} has dialect captions hooks
4550 in the form \gls{captionsdialect} (where \meta{dialect} is the
4551 dialect label). This leads to a rather
4552 cumbersome set of conditionals:
4553 \begin{compactcodebox}
4554 \cmd{ifcsundef}\marg{captions\gls{CurrentTrackedLanguage}}
4555 \marg{\comment{}
4556 \cmd{ifcsundef}\marg{captions\gls{CurrentTrackedDialect}}\comment{}
4557 \marg{}\comment{}
4558 \marg{\comment{}
4559 \cmd{csgappto}\marg{captions\gls{CurrentTrackedDialect}}\marg{\comment{}
4560 \comment{code to append to hook}
4561 }\comment{}
4562 }\comment{}
4563 }\comment{}
4564 \marg{\comment{}
4565 \cmd{csgappto}\marg{captions\gls{CurrentTrackedLanguage}}\marg{\comment{}
4566 \comment{code to append to hook}
4567 }\comment{}
4568 }
4569 \comment{do code now to initialise}
4570 \end{compactcodebox}
4571 Note that the above has been simplified through the use of
4572 \sty{etoolbox} commands, which isn't suitable for generic use.
4573 It also doesn't query the mapping from \sty{tracklang}['s] dialect
4574 label to the closest matching \sty{babel} dialect label.
4575
4576 Instead, \sty{tracklang} provides a command
4577 to perform this set of conditionals using generic code:
4578 \cmddef{TrackLangAddToHook}
4579 where \meta{code} is the code to append to the \meta{type} hook.
4580 This always performs \meta{code} after testing for the hook in case
4581 the hook is undefined or has already been called (for example, \sty{ngerman} uses
4582 \tklcaptions{ngerman} when the package is loaded, not at the start of
4583 the document).
4584
4585 Note that this command is enabled through
4586 \gls{TrackLangRequireDialect} so should only be used inside resource
4587 files.
4588
4589 Since \optfmt{captions} is a commonly used hook type, there's
4590 a~shortcut command provided:
4591 \cmddef{TrackLangAddToCaptions}
4592 This is equivalent to
4593 \begin{compactcodebox}
4594 \gls{TrackLangAddToHook}\margm{code}\marg{captions}
4595 \end{compactcodebox}
4596
4597 There may be some hooks, such as \gls{datedialect}, that need
4598 redefining rather than appending to, so there's an
4599 analogous command:
4600 \cmddef{TrackLangRedefHook}
4601 which will redefined the hook to do \meta{code}.
4602
4603 Note that no expansion is performed on \meta{code} when appending or
4604 redefining a hook.
4605
4606 \section{Examples}
4607 \label{sec:examples}
4608
4609 The examples in this section illustrate the above commands.
4610
4611 \subsection{\filefmt{animals.sty}}
4612 \label{sec:animals}
4613
4614 This example is for a trivial package called \file{animals.sty}
4615 that defines three textual commands: \cmd{catname}, \cmd{dogname}
4616 and \cmd{ladybirdname}. The default values are: \qt{cat}, \qt{dog} and
4617 \qt{bishy-barney-bee}.\footnote{Thass Broad Norfolk, my bewties
4618 \code{:-P}}
4619 The supported languages are defined in files
4620 \localefile{animals}.
4621
4622 Here's the code for \file{animals.sty}:
4623 \begin{codebox}[fontupper=\small\ttfamily]
4624 \comment{Example package animals.sty}
4625 \cmd{NeedsTeXFormat}\marg{LaTeX2e}
4626 \cmd{ProvidesPackage}\marg{animals}
4627 \codepar
4628 \cmd{RequirePackage}\marg{tracklang}[2019/11/30]\comment{v1.4}
4629 \codepar
4630 \comment{Any undeclared options are language settings:}
4631 \codepar
4632 \cmd{DeclareOption}*\marg{\comment{}
4633 \gls{TrackIfKnownLanguage}\marg{\cmd{CurrentOption}}\comment{}
4634 \marg{\comment{successful}
4635 \cmd{PackageInfo}\marg{animals}\marg{Tracking language `\cmd{CurrentOption}'}\comment{}
4636 }\comment{}
4637 \marg{\comment{failed}
4638 \cmd{PackageError}\marg{animals}\comment{}
4639 \marg{Unknown language specification `\cmd{CurrentOption}'}\comment{}
4640 \marg{You need to supply either a known dialect label
4641 or a valid language tag}\comment{}
4642 }\comment{}
4643 }
4644 \codepar
4645 \cmd{ProcessOptions}*
4646 \codepar
4647 \comment{Default definitions}
4648 \cmd{newcommand}\cmd{catname}\marg{cat}
4649 \cmd{newcommand}\cmd{dogname}\marg{dog}
4650 \cmd{newcommand}\cmd{ladybirdname}\marg{bishy-barney-bee}
4651 \codepar
4652 \gls{AnyTrackedLanguages}
4653 \marg{\comment{}
4654 \gls{ForEachTrackedDialect}\marg{\cmd{this@dialect}}\marg{\comment{}
4655 \gls{TrackLangRequireDialect}\marg{animals}\marg{\cmd{this@dialect}}\comment{}
4656 }\comment{}
4657 }
4658 \marg{\comment{no tracked languages, default already set up}
4659 }
4660 \codepar
4661 \cmd{endinput}
4662 \end{codebox}
4663 Here's a Plain \TeX\ version that picks up the language from the
4664 locale environment variable:
4665 \begin{codebox}[fontupper=\small\ttfamily]
4666 \gls{input} tracklang
4667 \codepar
4668 \gls{TrackLangFromEnv}
4669 \codepar
4670 \comment{Default definitions}
4671 \cmd{def}\cmd{catname}\marg{cat}
4672 \cmd{def}\cmd{dogname}\marg{dog}
4673 \cmd{def}\cmd{ladybirdname}\marg{bishy-barney-bee}
4674 \codepar
4675 \gls{AnyTrackedLanguages}
4676 \marg{\comment{}
4677 \gls{ForEachTrackedDialect}\marg{\cmd{thisdialect}}\marg{\comment{}
4678 \gls{TrackLangRequireDialect}\marg{animals}\marg{\cmd{thisdialect}}\comment{}
4679 }\comment{}
4680 }
4681 \marg{\comment{no tracked languages, default already set up}
4682 }
4683 \end{codebox}
4684 In the event that a user or supplementary package for some
4685 reason wants to load a resource
4686 file for a language that hasn't been tracked, it might be worth
4687 providing a command for this purpose:
4688 \begin{codebox}
4689 \cmd{newcommand}*\marg{\cmd{RequireAnimalsDialect}}[1]\marg{\comment{}
4690 \gls{TrackLangRequireDialect}\marg{animals}\marg{\#1}\comment{}
4691 }
4692 \end{codebox}
4693 The loop can then be changed to:
4694 \begin{codebox}
4695 \gls{ForEachTrackedDialect}\marg{\cmd{this@dialect}}\marg{\comment{}
4696 \cmd{RequireAnimalsDialect}\cmd{this@dialect}
4697 }\comment{}
4698 \end{codebox}
4699
4700 The \ldf{animals}{english} file valid for both the Plain \TeX\
4701 and \LaTeX\ formats contains:
4702 \begin{codebox}
4703 \gls{TrackLangProvidesResource}\marg{english}
4704 \codepar
4705 \cmd{def}\cmd{englishanimals}\marg{\comment{}
4706 \cmd{def}\cmd{catname}\marg{cat}\comment{}
4707 \cmd{def}\cmd{dogname}\marg{dog}\comment{}
4708 \cmd{def}\cmd{ladybirdname}\marg{bishy-barney-bee}\comment{}
4709 }
4710 \codepar
4711 \gls{TrackLangAddToCaptions}\marg{\cmd{englishanimals}}
4712 \end{codebox}
4713 The \ldf{animals}{en-GB} file contains:
4714 \begin{codebox}
4715 \gls{TrackLangProvidesResource}\marg{en-GB}
4716 \gls{TrackLangRequireResource}\marg{english}
4717 \codepar
4718 \cmd{def}\cmd{enGBanimals}\marg{\comment{}
4719 \cmd{englishanimals}
4720 \cmd{def}\cmd{ladybirdname}\marg{ladybird}\comment{}
4721 }
4722 \gls{TrackLangAddToCaptions}\marg{\cmd{enGBanimals}}
4723 \end{codebox}
4724 The \ldf{animals}{en-US} file contains:
4725 \begin{codebox}
4726 \gls{TrackLangProvidesResource}\marg{en-US}
4727 \gls{TrackLangRequireResource}\marg{english}
4728 \codepar
4729 \cmd{def}\cmd{enUSanimals}\marg{\comment{}
4730 \cmd{englishanimals}
4731 \cmd{def}\cmd{ladybirdname}\marg{ladybug}\comment{}
4732 }
4733 \gls{TrackLangAddToCaptions}\marg{\cmd{enUSanimals}}
4734 \end{codebox}
4735 Here's a German version in the file \ldf{animals}{german}:
4736 \begin{codebox}
4737 \gls{TrackLangProvidesResource}\marg{german}
4738 \codepar
4739 \cmd{def}\cmd{germananimals}\marg{\comment{}
4740 \cmd{def}\cmd{catname}\marg{Katze}\comment{}
4741 \cmd{def}\cmd{dogname}\marg{Hund}\comment{}
4742 \cmd{def}\cmd{ladybirdname}\marg{Marienk\cmd{"}afer}\comment{}
4743 }
4744 \codepar
4745 \gls{TrackLangAddToCaptions}\marg{\cmd{germananimals}}
4746 \end{codebox}
4747
4748 This means that if \sty{babel} or \sty{polyglossia} are loaded, the
4749 redefinitions are automatically performed whenever the language is
4750 changed, but if there's no caption mechanism the user can switch
4751 the fixed names using the \cmd{\ldots animals} commands.
4752
4753 Here's an example \LaTeX\ document that doesn't have any caption
4754 hooks:
4755 \begin{codebox}
4756 \cmd{documentclass}[\opt{english},\opt{german}]\marg{article}
4757 \codepar
4758 \cmd{usepackage}\marg{animals}
4759 \codepar
4760 \cbeg{document}
4761 \cmd{englishanimals}
4762 \codepar
4763 \cmd{catname}.
4764 \cmd{dogname}.
4765 \cmd{ladybirdname}.
4766 \codepar
4767 \cmd{germananimals}
4768 \codepar
4769 \cmd{catname}.
4770 \cmd{dogname}.
4771 \cmd{ladybirdname}.
4772 \cend{document}
4773 \end{codebox}
4774 Here's a \sty{babel} example document:
4775 \begin{codebox}
4776 \cmd{documentclass}[\opt{american},\opt{german},\opt{british}]\marg{article}
4777 \codepar
4778 \cmd{usepackage}\marg{babel}
4779 \cmd{usepackage}\marg{animals}
4780 \codepar
4781 \cbeg{document}
4782 \cmd{selectlanguage}\marg{american}
4783 \codepar
4784 \cmd{catname}.
4785 \cmd{dogname}.
4786 \cmd{ladybirdname}.
4787 \codepar
4788 \cmd{selectlanguage}\marg{german}
4789 \codepar
4790 \cmd{catname}.
4791 \cmd{dogname}.
4792 \cmd{ladybirdname}.
4793 \codepar
4794 \cmd{selectlanguage}\marg{british}
4795 \codepar
4796 \cmd{catname}.
4797 \cmd{dogname}.
4798 \cmd{ladybirdname}.
4799 \cend{document}
4800 \end{codebox}
4801
4802 There is some redundancy with the above resource files. Consider the
4803 \sty{babel} example above. The \opt{american} dialect is the
4804 first option, so in that case \ldf{animals}{en-US} is loaded
4805 followed by \ldf{animals}{english}. This means that the
4806 \tklcaptions{american} hook now includes
4807 \begin{codebox}
4808 \cmd{englishanimals}
4809 \cmd{enUSanimals}
4810 \end{codebox}
4811 Since \cmd{enUSanimals} includes \cmd{englishanimals}, there is
4812 redundant code. However, when the \opt{british} dialect is
4813 processed, this loads the file \ldf{animals}{en-GB} but not
4814 the file \ldf{animals}{english} (since it's already been loaded). This
4815 means that \tklcaptions{british} contains \cmd{enGBanimals} but not
4816 \cmd{englishanimals}.
4817
4818 If this redundancy is an issue (for example, there are so many
4819 redefinitions needed that it significantly slows the document build
4820 process), then it can be addressed with the following modifications.
4821 The \ldf{animals}{en-GB} file is now:
4822 \begin{codebox}
4823 \gls{TrackLangProvidesResource}\marg{en-GB}
4824 \codepar
4825 \cmd{def}\cmd{enGBanimals}\marg{\comment{}
4826 \cmd{englishanimals}
4827 \cmd{def}\cmd{ladybirdname}\marg{ladybird}\comment{}
4828 }
4829 \codepar
4830 \gls{TrackLangRequireResourceOrDo}\marg{english}\comment{}
4831 \marg{
4832 \gls{TrackLangAddToCaptions}\marg{\comment{}
4833 \cmd{def}\cmd{ladybirdname}\marg{ladybird}\comment{}
4834 }\comment{}
4835 }
4836 \marg{
4837 \gls{TrackLangAddToCaptions}\marg{\cmd{enGBanimals}}
4838 }
4839 \end{codebox}
4840 The \ldf{animals}{en-US} file is now:
4841 \begin{codebox}
4842 \gls{TrackLangProvidesResource}\marg{en-US}
4843 \codepar
4844 \cmd{providecommand}*\marg{\cmd{enUSanimals}}\marg{\comment{}
4845 \cmd{englishanimals}
4846 \cmd{renewcommand}*\marg{\cmd{ladybirdname}}\marg{ladybug}\comment{}
4847 }
4848 \codepar
4849 \gls{TrackLangRequireResourceOrDo}\marg{english}
4850 \marg{
4851 \gls{TrackLangAddToCaptions}\marg{\comment{}
4852 \cmd{renewcommand}*\marg{\cmd{ladybirdname}}\marg{ladybird}\comment{}
4853 }\comment{}
4854 }
4855 \marg{
4856 \gls{TrackLangAddToCaptions}\marg{\cmd{enUSanimals}}
4857 }
4858 \end{codebox}
4859 This means that the document that has the dialects listed in the
4860 order \opt{american}, \opt{british} now has
4861 \begin{codebox}
4862 \cmd{englishanimals}
4863 \cmd{def}\cmd{ladybirdname}\marg{ladybird}
4864 \end{codebox}
4865 in the \tklcaptions{british} hook and just \cmd{enUSanimals} in the
4866 \tklcaptions{american} hook, which has removed most of the redundancy.
4867
4868 Note that \sty{polyglossia} has a \tklcaptions{english} hook but not
4869 \tklcaptions{american} or \tklcaptions{british}, so this code doesn't
4870 allow for switching between variants of the same language with
4871 \sty{polyglossia}.
4872
4873 \subsection{\filefmt{regions.sty}}
4874 \label{sec:regions}
4875
4876 \glsadd{file.regions.sty}%
4877 \phyperref{Earlier}{pg.britishfilesearch}, I~mentioned the search order for
4878 \gls{IfTrackedLanguageFileExists} where if, for example, the dialect
4879 is \opt{british}, the file search (v1.4+) will be:
4880 \begin{enumerate}
4881 \item \ldf{mypackage}{en-GB} (language tag)
4882 \item \ldf{mypackage}{british} (dialect label)
4883
4884 \item \ldf{mypackage}{en-Latn-GB} (\idx{639-1} language code,
4885 \idx{script}, \idx{region})
4886 \item \ldf{mypackage}{en-GB} (\idx{639-1} language code,
4887 \idx{region})
4888 \item \ldf{mypackage}{en-Latn} (\idx{639-1} language code,
4889 \idx{script})
4890 \item \ldf{mypackage}{en} (\idx{639-1} language code)
4891
4892 \item \ldf{mypackage}{eng-Latn-GB} (\idx{639-2} language
4893 code, \idx{script}, \idx{region})
4894 \item \ldf{mypackage}{eng-GB} (\idx{639-2} language code,
4895 \idx{region})
4896 \item \ldf{mypackage}{eng-Latn} (\idx{639-2} language code,
4897 \idx{script})
4898 \item \ldf{mypackage}{eng} (\idx{639-2} language code)
4899
4900 \item \ldf{mypackage}{GB} (\idx{region})
4901 \item \ldf{mypackage}{english} (language label)
4902 \end{enumerate}
4903 You may have wondered why
4904 \ldf{mypackage}{GB} is included in the search given that some
4905 countries have multiple official languages, which means that the country code on its
4906 own may not indicate the language.
4907
4908 The reason for including just the country code as the \meta{localeid} in the
4909 file search is to allow for region rather than language dependent
4910 settings. For example, suppose I~want to write a package that needs
4911 to know whether to use imperial or metric measurements in the
4912 document, but I also want to provide multilingual support. The
4913 language alone won't tell me whether to use imperial or metric (for
4914 example, the US uses imperial and the UK uses metric for most
4915 product attributes). I could provide \ext+{ldf} files for every
4916 language and region combination, but this would result in a lot
4917 redundancy.
4918
4919 \gls{TrackLangRequireDialect} has an optional argument for adjusting
4920 the way the resource files are loaded. Suppose I have
4921 \localefile{regions} resource files, then
4922 \begin{codebox}
4923 \gls{TrackLangRequireDialect}\marg{regions}\marg{\cmd{this@dialect}}
4924 \end{codebox}
4925 loads the resource file for the dialect given by \cmd{this@dialect}
4926 using:
4927 \begin{compactcodebox}
4928 \gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}
4929 \end{compactcodebox}
4930 I can use the optional argument to also load the resource file for the
4931 root language as well:
4932 \begin{codebox}[fontupper=\small\ttfamily]
4933 \comment{custom file loader for regions.sty}
4934 \cmd{newcommand}*\marg{\cmd{RequireRegionsDialect}}[1]\marg{\comment{}
4935 \gls{TrackLangRequireDialect}
4936 \oarg{\gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}\comment{}
4937 \gls{TrackLangRequireResource}
4938 \marg{\gls{CurrentTrackedLanguage}}\comment{}
4939 }\comment{}
4940 \marg{regions}\marg{\#1}\comment{}
4941 }
4942 \end{codebox}
4943 Now the dialect \opt{british} can load both
4944 \ldf{regions}{GB} and \ldf{regions}{english}.
4945
4946 The example package (\file{regions.sty}) below illustrates this.
4947 \begin{codebox}[fontupper=\small\ttfamily]
4948 \comment{Example package regions.sty}
4949 \cmd{NeedsTeXFormat}\marg{LaTeX2e}
4950 \cmd{ProvidesPackage}\marg{regions}
4951 \codepar
4952 \gls{RequirePackage}\marg{tracklang}[2016/10/07]\comment{v1.3+}
4953 \codepar
4954 \cmd{DeclareOption}*\marg{\gls{TrackLanguageTag}\marg{\cmd{CurrentOption}}}
4955 \cmd{ProcessOptions}*
4956 \codepar
4957 \cmd{newcommand}*\marg{\cmd{weightunit}}\marg{kg}
4958 \cmd{newcommand}*\marg{\cmd{lengthunit}}\marg{mm}
4959 \cmd{newcommand}*\marg{\cmd{currencyunit}}\marg{EUR}
4960 \codepar
4961 \cmd{newcommand}*\marg{\cmd{unitname}}\marg{units}
4962 \codepar
4963 \cmd{newcommand}*\marg{\cmd{RequireRegionsDialect}}[1]\marg{\comment{}
4964 \gls{TrackLangRequireDialect}
4965 \oarg{\gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}\comment{}
4966 \gls{TrackLangRequireResource}
4967 \marg{\gls{CurrentTrackedLanguage}}\comment{}
4968 }\comment{}
4969 \marg{regions}\marg{\#1}\comment{}
4970 }
4971 \codepar
4972 \gls{AnyTrackedLanguages}
4973 \marg{\comment{}
4974 \gls{ForEachTrackedDialect}\marg{\cmd{this@dialect}}\marg{\comment{}
4975 \cmd{RequireRegionsDialect}\cmd{this@dialect}
4976 }\comment{}
4977 }
4978 \marg{\comment{no tracked languages, default already set up}
4979 }
4980 \codepar
4981 \cmd{endinput}
4982 \end{codebox}
4983 There are separate \ext{ldf} files for region and language.
4984 First are the regions.
4985
4986 \begin{itemize}
4987 \item \ldf{regions}{BE} (Belgium):
4988 \begin{codebox}
4989 \gls{TrackLangProvidesResource}\marg{BE}
4990 \codepar
4991 \cmd{providecommand}*\marg{\cmd{BEunits}}\marg{\comment{}
4992 \cmd{renewcommand}*\marg{\cmd{weightunit}}\marg{kg}\comment{}
4993 \cmd{renewcommand}*\marg{\cmd{lengthunit}}\marg{mm}\comment{}
4994 \cmd{renewcommand}*\marg{\cmd{currencyunit}}\marg{EUR}\comment{}
4995 }
4996 \codepar
4997 \gls{TrackLangAddToCaptions}\marg{\cmd{BEunits}}
4998 \end{codebox}
4999
5000 \item \ldf{regions}{CA} (Canada):
5001 \begin{codebox}
5002 \gls{TrackLangProvidesResource}\marg{CA}
5003 \codepar
5004 \cmd{providecommand}*\marg{\cmd{CAunits}}\marg{\comment{}
5005 \cmd{renewcommand}*\marg{\cmd{weightunit}}\marg{kg}\comment{}
5006 \cmd{renewcommand}*\marg{\cmd{lengthunit}}\marg{mm}\comment{}
5007 \cmd{renewcommand}*\marg{\cmd{currencyunit}}\marg{CAD}\comment{}
5008 }
5009 \codepar
5010 \gls{TrackLangAddToCaptions}\marg{\cmd{CAunits}}
5011 \end{codebox}
5012
5013 \item \ldf{regions}{GB} (Great Britain):
5014 \begin{codebox}
5015 \gls{TrackLangProvidesResource}\marg{GB}
5016 \codepar
5017 \cmd{providecommand}*\marg{\cmd{GBunits}}\marg{\comment{}
5018 \cmd{renewcommand}*\marg{\cmd{weightunit}}\marg{kg}\comment{}
5019 \cmd{renewcommand}*\marg{\cmd{lengthunit}}\marg{mm}\comment{}
5020 \cmd{renewcommand}*\marg{\cmd{currencyunit}}\marg{GBP}\comment{}
5021 }
5022 \codepar
5023 \gls{TrackLangAddToCaptions}\marg{\cmd{GBunits}}
5024 \end{codebox}
5025
5026 \item \ldf{regions}{US} (USA):
5027 \begin{codebox}
5028 \gls{TrackLangProvidesResource}\marg{US}
5029 \codepar
5030 \cmd{providecommand}*\marg{\cmd{USunits}}\marg{\comment{}
5031 \cmd{renewcommand}*\marg{\cmd{weightunit}}\marg{lb}\comment{}
5032 \cmd{renewcommand}*\marg{\cmd{lengthunit}}\marg{in}\comment{}
5033 \cmd{renewcommand}*\marg{\cmd{currencyunit}}\marg{USD}\comment{}
5034 }
5035 \codepar
5036 \gls{TrackLangAddToCaptions}\marg{\cmd{USunits}}
5037 \end{codebox}
5038 \end{itemize}
5039 Now the language files:
5040
5041 \begin{itemize}
5042 \item \ldf{regions}{dutch}:
5043 \begin{codebox}
5044 \gls{TrackLangProvidesResource}\marg{dutch}
5045 \codepar
5046 \cmd{providecommand}*\marg{\cmd{dutchnames}}\marg{\comment{}
5047 \cmd{renewcommand}*\marg{\cmd{unitname}}\marg{meeteenheden}\comment{}
5048 }
5049 \codepar
5050 \gls{TrackLangAddToCaptions}\marg{\cmd{dutchnames}}
5051 \end{codebox}
5052
5053 \item \ldf{regions}{english}:
5054 \begin{codebox}
5055 \gls{TrackLangProvidesResource}\marg{english}
5056 \codepar
5057 \cmd{providecommand}*\marg{\cmd{englishnames}}\marg{\comment{}
5058 \cmd{renewcommand}*\marg{\cmd{unitname}}\marg{units}\comment{}
5059 }
5060 \codepar
5061 \gls{TrackLangAddToCaptions}\marg{\cmd{englishnames}}
5062 \end{codebox}
5063
5064 \item \ldf{regions}{french}:
5065 \begin{codebox}
5066 \cmd{TrackLangProvidesResource}\marg{french}
5067 \codepar
5068 \cmd{providecommand}*\marg{\cmd{frenchnames}}\marg{\comment{}
5069 \cmd{renewcommand}*\marg{\cmd{unitname}}\marg{unit\cmd{'}es}\comment{}
5070 }
5071 \codepar
5072 \gls{TrackLangAddToCaptions}\marg{\cmd{frenchnames}}
5073 \end{codebox}
5074
5075 \item \ldf{regions}{german}:
5076 \begin{codebox}
5077 \gls{TrackLangProvidesResource}\marg{french}
5078 \codepar
5079 \cmd{providecommand}*\marg{\cmd{germannames}}\marg{\comment{}
5080 \cmd{renewcommand}*\marg{\cmd{unitname}}\marg{Ma\cmd{ss} einheiten}\comment{}
5081 }
5082 \codepar
5083 \gls{TrackLangAddToCaptions}\marg{\cmd{germannames}}
5084 \end{codebox}
5085 \end{itemize}
5086
5087 Here's an example document that uses this package:
5088 \begin{codebox}
5089 \cmd{documentclass}[\opt{canadien}]\marg{article}
5090 \codepar
5091 \cmd{usepackage}\marg{regions}
5092 \codepar
5093 \cbeg{document}
5094 \codepar
5095 \cmd{unitname}: \cmd{weightunit}, \cmd{lengthunit}, \cmd{currencyunit}.
5096 \codepar
5097 \cend{document}
5098 \end{codebox}
5099
5100 This works because the \meta{localeid} search looks for the
5101 country code before the root language label. However, this will fail if
5102 the dialect label is the same as a root language label that has an
5103 associated territory, marked with \fnregion\ in
5104 \tableref{tab:rootlangopts}, as then it will be picked up before the
5105 country code.
5106
5107 In the above example,
5108 \ldf{regions}{CA} is matched rather than
5109 \ldf{regions}{french}, so \ldf{regions}{CA} is loaded by
5110 \begin{compactcodebox}
5111 \gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}
5112 \end{compactcodebox}
5113 After this, the language file \ldf{regions}{french} is then loaded:
5114 \begin{compactcodebox}
5115 \gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedLanguage}}
5116 \end{compactcodebox}
5117
5118 This assumes that there's a country code \ext{ldf} file
5119 available. This example needs a little modification to use default
5120 units in case the region is missing:
5121 \begin{codebox}[fontupper=\small\ttfamily]
5122 \comment{Modified example package regions.sty}
5123 \cmd{NeedsTeXFormat}\marg{LaTeX2e}
5124 \cmd{ProvidesPackage}\marg{regions}
5125 \codepar
5126 \comment{Pass all options to \file{tracklang.sty}:}
5127 \cmd{DeclareOption}*\marg{\cmd{PassOptionsToPackage}\marg{\cmd{CurrentOption}}\marg{tracklang}}
5128 \cmd{ProcessOptions}*
5129 \codepar
5130 \gls{RequirePackage}\marg{tracklang}
5131 \codepar
5132 \cmd{newcommand}*\marg{\cmd{weightunit}}\marg{kg}
5133 \cmd{newcommand}*\marg{\cmd{lengthunit}}\marg{mm}
5134 \cmd{newcommand}*\marg{\cmd{currencyunit}}\marg{EUR}
5135 \codepar
5136 \cmd{newcommand}*\marg{\cmd{unitname}}\marg{units}
5137 \codepar
5138 \cmd{newcommand}*\marg{\cmd{defaultunits}}\marg{\comment{}
5139 \cmd{renewcommand}*\marg{\cmd{weightunit}}\marg{kg}\comment{}
5140 \cmd{renewcommand}*\marg{\cmd{lengthunit}}\marg{mm}\comment{}
5141 \cmd{renewcommand}*\marg{\cmd{currencyunit}}\marg{EUR}\comment{}
5142 }
5143 \codepar
5144 \cmd{newcommand}*\marg{\cmd{RequireRegionsDialect}}[1]\marg{\comment{}
5145 \gls{TrackLangRequireDialect}
5146 \oarg{\gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}\comment{}
5147 \cmd{ifx}\gls{CurrentTrackedTag}\gls{CurrentTrackedLanguage}
5148 \gls{TrackLangAddToCaptions}\marg{\cmd{defaultunits}}\comment{}
5149 \cmd{else}
5150 \gls{TrackLangRequireResource}
5151 \marg{\gls{CurrentTrackedLanguage}}\comment{}
5152 \cmd{fi}
5153 }\comment{}
5154 \marg{regions}\marg{\#1}\comment{}
5155 }
5156 \codepar
5157 \gls{AnyTrackedLanguages}
5158 \marg{\comment{}
5159 \gls{ForEachTrackedDialect}\marg{\cmd{this@dialect}}{\comment{}
5160 \cmd{RequireRegionsDialect}\cmd{this@dialect}
5161 }\comment{}
5162 }
5163 \marg{\comment{no tracked languages, default already set up}
5164 }
5165 \codepar
5166 \cmd{endinput}
5167 \end{codebox}
5168 Note that we still have a problem for dialect labels that are
5169 identical to root language labels with an associated territory (such
5170 as \opt{manx}). This case can be checked with the following
5171 adjustment:
5172 \begin{codebox}[fontupper=\small\ttfamily]
5173 \cmd{newcommand}*\marg{\cmd{RequireRegionsDialect}}[1]\marg{\comment{}
5174 \gls{TrackLangRequireDialect}
5175 \oarg{\gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}\comment{}
5176 \cmd{ifx}\gls{CurrentTrackedTag}\gls{CurrentTrackedLanguage}
5177 \cmd{ifx}\gls{CurrentTrackedRegion}\cmd{empty}
5178 \gls{TrackLangAddToCaptions}\marg{\cmd{defaultunits}}\comment{}
5179 \cmd{else}
5180 \gls{TrackLangRequireResource}
5181 \marg{\gls{CurrentTrackedRegion}}\comment{}
5182 \cmd{fi}
5183 \cmd{else}
5184 \gls{TrackLangRequireResource}
5185 \marg{\gls{CurrentTrackedLanguage}}\comment{}
5186 \cmd{fi}
5187 }\comment{}
5188 \marg{regions}\marg{\#1}\comment{}
5189 }
5190 \end{codebox}
5191 In the case where both the dialect and root language label are
5192 \opt{manx} with the resource files \ldf{regions}{manx}
5193 and \ldf{regions}{IM}, then \gls{CurrentTrackedTag} will be
5194 \opt{manx} (the dialect label) so \ldf{regions}{manx} will
5195 be loaded with:
5196 \begin{compactcodebox}
5197 \gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedTag}}
5198 \end{compactcodebox}
5199 In this case \gls{CurrentTrackedRegion} is \code{IM} (that is, it's
5200 not empty) so then \ldf{regions}{IM} will be loaded with:
5201 \begin{compactcodebox}
5202 \gls{TrackLangRequireResource}\marg{\gls{CurrentTrackedRegion}}
5203 \end{compactcodebox}
5204
5205 Here's another document that sets up dialects with
5206 \sty{tracklang} labels that aren't recognised by \sty{babel}.
5207 This means that there's no corresponding \gls{captionsdialect} hook
5208 for either the dialect label or the root language label,
5209 so mappings need to be defined from the \sty{tracklang} dialect
5210 label to the matching \sty{babel} dialect label.
5211
5212 \begin{information}
5213 The \opt{ngerman} option is now discouraged with \sty{babel}. However, the caption
5214 hook \tklcaptions{ngerman} is still provided by \sty{babel}, so
5215 that's the target for the mapping.
5216 \end{information}
5217
5218 \begin{codebox}[fontupper=\small\ttfamily]
5219 \cmd{documentclass}\marg{article}
5220 \codepar
5221 \cmd{usepackage}\marg{tracklang}
5222 \codepar
5223 \gls{TrackLanguageTag}\marg{de-US-1996}
5224 \gls{SetTrackedDialectLabelMap}
5225 \marg{\gls{TrackLangLastTrackedDialect}}\marg{ngerman}
5226 \codepar
5227 \gls{TrackLanguageTag}\marg{en-MT}
5228 \gls{SetTrackedDialectLabelMap}
5229 \marg{\gls{TrackLangLastTrackedDialect}}\marg{UKenglish}
5230 \codepar
5231 \cmd{usepackage}[main=ngerman,UKenglish]\marg{babel}
5232 \cmd{usepackage}\marg{regions}
5233 \codepar
5234 \cbeg{document}
5235 \gls{selectlanguage}\marg{ngerman}
5236 \codepar
5237 \cmd{unitname}: \cmd{weightunit}, \cmd{lengthunit}, \cmd{currencyunit}.
5238 \codepar
5239 \gls{selectlanguage}\marg{UKenglish}
5240 \codepar
5241 \cmd{unitname}: \cmd{weightunit}, \cmd{lengthunit}, \cmd{currencyunit}.
5242 \codepar
5243 \cend{document}
5244 \end{codebox}
5245 This produces:
5246 \begin{resultbox}
5247 Ma\ss einheiten: lb, in, USD.
5248
5249 units: kg, mm, EUR.
5250 \end{resultbox}
5251 Compare this with:
5252 \begin{codebox}
5253 \cmd{documentclass}\marg{article}
5254 \codepar
5255 \cmd{usepackage}[main=ngerman,UKenglish]\marg{babel}
5256 \cmd{usepackage}\marg{regions}
5257 \codepar
5258 \cbeg{document}
5259 \gls{selectlanguage}\marg{ngerman}
5260 \codepar
5261 \cmd{unitname}: \cmd{weightunit}, \cmd{lengthunit}, \cmd{currencyunit}.
5262 \codepar
5263 \gls{selectlanguage}\marg{UKenglish}
5264 \codepar
5265 \cmd{unitname}: \cmd{weightunit}, \cmd{lengthunit}, \cmd{currencyunit}.
5266 \codepar
5267 \cend{document}
5268 \end{codebox}
5269 which produces:
5270 \begin{resultbox}
5271 Ma\ss einheiten: kg, mm, EUR.
5272
5273 units: kg, mm, GBP.
5274 \end{resultbox}
5275
5276 Note that these mappings aren't needed if \sty{babel}
5277 is loaded with the root language labels instead. For example:
5278 \begin{codebox}[fontupper=\small\ttfamily]
5279 \cmd{documentclass}\marg{article}
5280 \codepar
5281 \cmd{usepackage}\marg{tracklang}
5282 \codepar
5283 \gls{TrackLanguageTag}\marg{de-US-1996}
5284 \gls{SetTrackedDialectLabelMap}
5285 \marg{\gls{TrackLangLastTrackedDialect}}\marg{ngerman}
5286 \codepar
5287 \gls{TrackLanguageTag}\marg{en-MT}
5288 \codepar
5289 \cmd{usepackage}[main=ngerman,english]\marg{babel}
5290 \cmd{usepackage}\marg{regions}
5291 \codepar
5292 \cbeg{document}
5293 \gls{selectlanguage}\marg{ngerman}
5294 \codepar
5295 \cmd{unitname}: \cmd{weightunit}, \cmd{lengthunit}, \cmd{currencyunit}.
5296 \codepar
5297 \gls{selectlanguage}\marg{english}
5298 \codepar
5299 \cmd{unitname}: \cmd{weightunit}, \cmd{lengthunit}, \cmd{currencyunit}.
5300 \codepar
5301 \cend{document}
5302 \end{codebox}
5303 No mapping is required for the \opt{en-MT} locale as
5304 it can pick up \tklcaptions{english} when \gls{TrackLangAddToHook}
5305 (used by \gls{TrackLangAddToCaptions})
5306 queries the root language label after failing to find the
5307 language hook from the dialect label.
5308
5309 Some of the predefined \sty{tracklang} dialects come with
5310 a mapping to the closest matching \sty{babel} dialect label.
5311 For example, the option \opt{ngermanDE} listed in
5312 \tableref{tab:nonbcp47opts} automatically provides a mapping
5313 to \opt{ngerman}. Since a \sty{tracklang} dialect label
5314 can only map to one \sty{babel} label, this can be problematic
5315 for synonymous labels such as
5316 \opt{british}\slash\opt{UKenglish} or
5317 \opt{american}\slash\opt{USenglish}. The default mappings used
5318 by \sty{tracklang} are shown in \tableref{tab:nonbcp47opts}.
5319
5320 \chapter{Adding Support for Language Tracking}
5321 \label{sec:langsty}
5322
5323 If you are writing a package that \emph{sets up} the document languages (rather
5324 than a package that provides multilingual support if the user has
5325 already loaded a language package) then you can load \sty{tracklang}
5326 and use the commands below to help other packages track your
5327 provided languages. (See also:
5328 \dickimawhref{latex/tracklang/langpkg.shtml}{Integrating
5329 \filefmt{tracklang.tex} into Language Packages}.)
5330
5331 The \sty{tracklang} package can be loaded using
5332 \begin{codebox}
5333 \gls{input} tracklang
5334 \end{codebox}
5335 or (\LaTeX\ only)
5336 \begin{codebox}
5337 \gls{RequirePackage}\marg{tracklang}
5338 \end{codebox}
5339
5340 When using \LaTeX, there's a difference between the two.
5341 The first case prevents \sty{tracklang} from picking up
5342 the document class options but skips the check for known
5343 language packages. This check is redundant since your package is
5344 the language package, so you need to decide whether or
5345 not to allow the user to set up the localisation information
5346 through the document class options.
5347
5348 There's a hook that, if defined, is performed by
5349 \file{tracklang.sty} after the package options have been loaded but
5350 before known language packages are checked:
5351 \cmddef{@tracklang@prelangpkgcheck@hook}
5352
5353 If you prefer \gls{RequirePackage} over \gls{input} but you want to make
5354 \file{tracklang.sty} skip the check for known
5355 language packages then (as from v1.3.8) define the pre-language
5356 package check hook as follows:
5357 \begin{codebox}
5358 \cmd{providecommand}\gls{@tracklang@prelangpkgcheck@hook}\marg{\cmd{endinput}}
5359 \gls{RequirePackage}\marg{tracklang}[2019/10/06]\comment{v1.3.8+}
5360 \end{codebox}
5361 This will still pick up languages supplied through the
5362 document class options.
5363
5364 If you just use \gls{input}, there's a test at the start of
5365 \file{tracklang.tex} to determine if it's already been loaded, so
5366 you don't need to worry if the document has already input it.
5367
5368 To integrate \sty{tracklang} into your language package, you need
5369 to consider the following steps:
5370 \begin{enumerate}
5371 \item Does \sty{tracklang} define your supported \idxn{15924} language
5372 scripts in the \file{tracklang-scripts.tex} file?
5373
5374 If yes, then skip this step. Otherwise create a file with the
5375 relevant \gls{TrackLangScriptMap} command for each unknown script and identify
5376 this new file with \gls{TrackLangAddExtraScriptFile} (see
5377 \sectionref{sec:newscripts}). This usually
5378 won't be necessary unless you have a custom script or a child script
5379 (a script that's a sub-category of another script).
5380
5381 \item Does \sty{tracklang} recognise the root language?
5382
5383 If yes, then skip this step.
5384
5385 If your package is setting up a language that \sty{tracklang}
5386 doesn't recognise then you will need to define the root language
5387 using \gls{TrackLangNewLanguage} (see \sectionref{sec:newlanguages}).
5388
5389 This usually won't be the case as \sty{tracklang} should support all
5390 languages that have an official \idxn{639-1} alpha-2 code.
5391
5392 If you simply have a different label from \sty{tracklang}
5393 identifying the root language, then you can just set up your label
5394 as a dialect using \gls{TrackLangProvidePredefinedDialect}.
5395
5396 \item Does \sty{tracklang} define the relevant \idxn{3166-1} region codes
5397 in the \file{tracklang-region-codes.tex} file?
5398
5399 If yes, then skip this step. Otherwise create a file with the
5400 relevant \gls{TrackLangRegionMap} command for each new region and
5401 identify this new file with \gls{TrackLangAddExtraRegionFile} (see
5402 \sectionref{sec:newregions}). This usually won't be necessary as
5403 \sty{tracklang} should recognise all countries that have an alpha-2
5404 region code, but you may require it if you need a broader region,
5405 such as EU.
5406
5407 \item Do you want to define some convenient dialect labels that can
5408 be used with \gls{TrackPredefinedDialect}?
5409
5410 If no, then skip this step. Otherwise you can use
5411 \gls{TrackLangProvidePredefinedLanguage} for root languages
5412 and \gls{TrackLangProvidePredefinedDialect} for dialects with
5413 additional information, such as a region, sub-language or script
5414 (see \sectionref{sec:definelabels}).
5415
5416 \item In your language initialisation code, add the \sty{tracklang}
5417 code to track the particular dialect (for example, use
5418 \gls{TrackPredefinedDialect} for recognised dialect labels or
5419 use the \csmetafmt{AddTracked}{Xxx}{} set of commands). See
5420 \sectionref{sec:initnewlang}.
5421
5422 \item In your language selection code (such as \gls{selectlanguage}), add
5423 \gls{SetCurrentTrackedDialect}\margm{label} to allow the document
5424 author to easily query the current localisation settings (such as
5425 the region). See \sectionref{sec:selectlanguage}.
5426 \end{enumerate}
5427
5428 \section{Initialising a New Language or Dialect}
5429 \label{sec:initnewlang}
5430
5431 When the user requests a particular dialect through your language
5432 package, you can notify \sty{tracklang} of this choice using
5433 \begin{compactcodebox*}
5434 \gls{TrackPredefinedDialect}\margm{dialect label}
5435 \end{compactcodebox*}
5436 provided the dialect label is recognised by \sty{tracklang} (all those
5437 listed in \refoptstables).
5438
5439 If there's no matching dialect predefined by \sty{tracklang}, you
5440 can just use \gls{TrackLocale} or \gls{TrackLanguageTag}
5441 (described in \sectionref{sec:generic})
5442 with the appropriate \idx{ISO} codes \emph{if you're not providing caption
5443 hooks}.
5444
5445 If you are providing a captions hook mechanism
5446 in the form \gls{captionsdialect}, then if \meta{dialect}
5447 doesn't match the corresponding \sty{tracklang} dialect label,
5448 you can provide a mapping using
5449 \gls{SetTrackedDialectLabelMap}, described below.
5450
5451 \section{Switching Language or Dialect}
5452 \label{sec:selectlanguage}
5453
5454 When the document author switches to a different language or
5455 dialect, the current localisation information can be set with:
5456 \cmddef{SetCurrentTrackedDialect}
5457 where \meta{dialect} may the \sty{tracklang} dialect label,
5458 or the mapped label previously set through \gls{SetTrackedDialectLabelMap},
5459 described below, or the language label (in which case the
5460 last dialect to be tracked with that root language will
5461 be assumed).
5462
5463 This will make the following commands available which may be
5464 of use to other packages:
5465 \begin{itemize}
5466 \item\gls{CurrentTrackedDialect} The dialect label recognised
5467 by \sty{tracklang} (which may not be the same as \meta{dialect}).
5468
5469 \item\gls{CurrentTrackedLanguage}
5470 The root language label used by \sty{tracklang}.
5471
5472 \item\gls{CurrentTrackedDialectModifier} The dialect modifier.
5473
5474 \item\gls{CurrentTrackedDialectVariant} The dialect variant.
5475
5476 \item\gls{CurrentTrackedDialectScript} The dialect script.
5477 Note that if \sty{tracklang-scripts} is also loaded, this allows the
5478 script direction to be accessed using
5479 \begin{codebox}
5480 \gls{TrackLangScriptAlphaToDir}
5481 \marg{\gls{CurrentTrackedDialectScript}}
5482 \end{codebox}
5483 See \sectionref{sec:supplpkgs} for further details.
5484
5485 \item\gls{CurrentTrackedDialectSubLang} The dialect sub-language
5486 code.
5487
5488 \item\gls{GetTrackedDialectAdditional} The dialect's additional
5489 information.
5490
5491 \item\gls{CurrentTrackedIsoCode} The dialect's root language
5492 \idx{ISO} code. (The first found in the sequence \idx{639-1},
5493 \idx{639-2}, \idx{639-3}.)
5494
5495 \item\gls{CurrentTrackedRegion} The dialect's \idxn{3166-1} region
5496 code.
5497
5498 \item\gls{CurrentTrackedLanguageTag} The dialect's language tag.
5499
5500 \end{itemize}
5501 (Without this automated use of \gls{SetCurrentTrackedDialect},
5502 the same information can be picked up using commands
5503 like \gls{GetTrackedDialectScript}, but that's less convenient,
5504 especially if \gls{languagename} needs to be converted
5505 to \meta{dialect}. See the accompanying sample file
5506 \filefmt{sample-setlang.tex} for an example.)
5507
5508 \section{Defining New Scripts}
5509 \label{sec:newscripts}
5510
5511 The \file{tracklang-scripts.tex} file isn't automatically loaded,
5512 but if it is then, as from v1.4, it contains a hook at the end of
5513 the file that can be used to load additional files that define
5514 supplementary scripts. This entails creating a file called, say,
5515 \filefmt{mypackage-scripts.tex} that contains:
5516 \begin{compactcodebox*}
5517 \gls{TrackLangScriptMap}\margm{alpha code}\margm{numeric code}\margm{name}\margm{direction}\margm{parent script}
5518 \end{compactcodebox*}
5519 The first argument \meta{alpha code} is the four-letter ISO~15924 code (such as
5520 \opt{Latn}), the second argument is the numeric code (such as
5521 215), the third argument \meta{name} is the name of the script (such
5522 as \optfmt{Latin}), the fourth argument is the direction (such as
5523 \optfmt{LR} for left-to-right) and the final argument is the parent
5524 script (leave blank if there's no parent). Note that this command will override any previous
5525 mapping for those codes. No check is performed to determine if they
5526 have already been defined.
5527
5528 The supplementary file should be identified with:
5529 \begin{compactcodebox*}
5530 \gls{TrackLangAddExtraScriptFile}\margm{filename}
5531 \end{compactcodebox*}
5532
5533 Additional information can be found in \sectionref{sec:supplpkgs}.
5534
5535 \section{Defining New Regions}
5536 \label{sec:newregions}
5537
5538 The \file{tracklang-region-codes.tex} file isn't automatically loaded,
5539 but if it is then, as from v1.4, it contains a hook at the end of
5540 the file that can be used to load additional files that define
5541 supplementary regions. This entails creating a file called, say,
5542 \filefmt{mypackage-regions.tex} that contains:
5543 \begin{compactcodebox*}
5544 \gls{TrackLangRegionMap}\margm{numeric code}\margm{alpha-2
5545 code}\margm{alpha-3 code}
5546 \end{compactcodebox*}
5547 where the first argument is the numeric region code (such as 826),
5548 the second argument is the alpha-2 region code (such as \code{GB})
5549 and the third argument is the alpha-3 region code (such as
5550 \code{GBR}). Note that this command will override any previous
5551 mapping for those codes. No check is performed to determine if they
5552 have already been defined.
5553
5554 The supplementary file should be identified with:
5555 \begin{compactcodebox*}
5556 \gls{TrackLangAddExtraRegionFile}\margm{filename}
5557 \end{compactcodebox*}
5558
5559 Additional information can be found in \sectionref{sec:supplpkgs}.
5560
5561 \section{Defining a New Language}
5562 \label{sec:newlanguages}
5563
5564 (New to version 1.3.)
5565 If the root language isn't recognised by \sty{tracklang}
5566 (not listed in \tableref{tab:rootlangopts}), then
5567 it can be defined (but not tracked at this point) using:
5568 \cmddef{TrackLangNewLanguage}
5569 where \meta{language label} is the root language label,
5570 \meta{639-1 code} is the \idxn{639-1} code for that language (may be
5571 empty if there isn't one), \meta{639-2 (T)} is the \idxn{639-2T}
5572 code for that language (may be empty if there isn't one),
5573 \meta{639-2 (B)} is the \idxn{639-2B} code for that language (may be
5574 empty if it's the same as \meta{639-2 (T)}), \meta{639-3} is the
5575 \idxn{639-3} code for that language (empty if the same as the
5576 \idx{639-2} code), \meta{3166-1} is the territory \idxn{3166-1} code for
5577 languages that are only spoken in one territory (should be empty if
5578 the language is spoken in multiple territories), and \meta{default
5579 script} is the default script (empty if disputed or varies according
5580 to region).
5581
5582 You can then track this language using:
5583 \cmddef{AddTrackedDialect}
5584 for dialects (where \meta{dialect label} is the dialect label and
5585 \meta{root language label} is the root language label) or, if
5586 no regional variant is needed, you can instead use:
5587 \cmddef{AddTrackedLanguage}
5588 This is equivalent to
5589 \begin{compactcodebox}
5590 \gls{AddTrackedDialect}\margm{root language label}\margm{root language label}
5591 \end{compactcodebox}
5592 Note that \gls{AddTrackedDialect} defines:
5593 \cmddef{TrackLangLastTrackedDialect}
5594 to the dialect label, which makes it easier to reference the last
5595 dialect to be tracked.
5596
5597 \section{Defining New \styfmt{tracklang} Labels}
5598 \label{sec:definelabels}
5599
5600 A dialect label may be predefined with associated information that
5601 allows that particular combination to be easily tracked with
5602 \gls{TrackPredefinedDialect}. In the case of a dialect label that
5603 only requires the information provided in \gls{TrackLangNewLanguage}
5604 you can use:
5605 \cmddef{TrackLangProvidePredefinedLanguage}
5606 where \meta{language label} corresponds to the language label used in
5607 \gls{TrackLangNewLanguage}. This allows
5608 \begin{compactcodebox*}
5609 \gls{TrackPredefinedDialect}\margm{label}
5610 \end{compactcodebox*}
5611 to not only track the root language but also the associated ISO codes.
5612
5613 If the dialect label doesn't match the root language label then use:
5614 \cmddef{TrackLangProvidePredefinedDialect}
5615 where \meta{dialect label} is the new \sty{tracklang} dialect label,
5616 \marg{root language label} is the \sty{tracklang} root language label,
5617 \meta{region} is the \idxn{3166-1} region code (may be empty),
5618 \meta{modifier} is the \idx{modifier} (may be empty), \meta{variant}
5619 is the \idx{variant} information (may be empty), \meta{map} is your
5620 package's language label that corresponds to the \sty{tracklang}
5621 dialect label supplied in the first argument (may be empty if
5622 identical), and \meta{script} is the \idxn{15924} alpha-4 script code
5623 (may be empty if it's the same as the default script for the root
5624 language).
5625
5626 For compatibility with pre version 1.3,
5627 if the dialect isn't predefined by
5628 \sty{tracklang}, then you can use:
5629 \begin{compactcodebox*}
5630 \gls{AddTrackedDialect}\margm{dialect}\margm{root language label}
5631 \end{compactcodebox*}
5632 where \meta{root language label} is the label for the dialect's root
5633 language (\tableref{tab:rootlangopts}) and \meta{dialect} matches
5634 the captions hook. If the dialect is already in the tracked dialect
5635 list, it won't be added again. If the root language is already in
5636 the tracked language list, it won't be added again. As from version
5637 1.3 this additionally defines
5638 \gls{TrackLangLastTrackedDialect}
5639 to \meta{dialect} for convenient reference if required.
5640 Note that \gls{AddTrackedDialect} is internally used by commands like
5641 \gls{TrackPredefinedDialect}, \gls{TrackLocale} and
5642 \gls{TrackLanguageTag}.
5643
5644 \begin{information}
5645 The \opt{ngerman} option is now discouraged with \sty{babel}. However, the caption
5646 hook \tklcaptions{ngerman} is still provided by \sty{babel}, so
5647 that's the target for the mapping.
5648 \end{information}
5649
5650 (New to version 1.3.) Many of the \sty{tracklang} dialect
5651 labels don't have a corresponding match in various language packages. For
5652 example, \sty{tracklang} provides \opt{ngermanDE} but the
5653 closest match in \sty{babel} is \opt{ngerman}. This means that
5654 the caption hook \tklcaptions{ngerman} can't be accessed
5655 through:
5656 \begin{compactcodebox}
5657 \cmd{csname} captions\gls{CurrentTrackedDialect}\cmd{endcsname}
5658 \end{compactcodebox}
5659 in the resource files. In this case, a mapping may be defined
5660 between the \sty{tracklang} dialect label and the closest
5661 matching label used by the language hooks. This is done through
5662 \cmddef{SetTrackedDialectLabelMap}
5663 where \meta{tracklang-label} is the \sty{tracklang} label and
5664 \meta{hook-label} is the language hook label. For example:
5665 \begin{compactcodebox*}[fontupper=\small\ttfamily]
5666 \gls{TrackLanguageTag}\marg{de-AR-1996}
5667 \gls{SetTrackedDialectLabelMap}
5668 \marg{\gls{TrackLangLastTrackedDialect}}\marg{ngerman}
5669 \end{compactcodebox*}
5670 Since \gls{TrackLanguageTag} internally uses \gls{AddTrackedDialect}
5671 the dialect label created by \sty{tracklang} can be accessed
5672 using \gls{TrackLangLastTrackedDialect}. This means that
5673 \gls{TrackLangAddToCaptions} can now find the \tklcaptions{ngerman}
5674 hook even though the \sty{tracklang} dialect label isn't \opt{ngerman}.
5675
5676 (New to version 1.3.)
5677 If the root language label is recognised by \sty{tracklang}, you
5678 can add the associated \idx{ISO} codes using:
5679 \cmddef{AddTrackedLanguageIsoCodes}
5680
5681 As from v1.3, you can also provide a modifier for a given
5682 dialect using:
5683 \cmddef{SetTrackedDialectModifier}
5684 where \meta{dialect} is the dialect label and \meta{value}
5685 is the modifier value. For example:
5686 \begin{compactcodebox*}
5687 \gls{AddTrackedDialect}\marg{oldgerman}\marg{\opt{german}}
5688 \gls{AddTrackedLanguageIsoCodes}\marg{german}
5689 \gls{SetTrackedDialectModifier}\marg{oldgerman}\marg{old}
5690 \end{compactcodebox*}
5691
5692 Note that no sanitization is performed on \meta{value} when the
5693 modifier is set explicitly through \gls{SetTrackedDialectModifier},
5694 since it's assumed that any package that specifically sets the
5695 modifier in this way is using a sensible labelling system. If the
5696 modifier is obtained through commands like \gls{TrackLocale}, then
5697 the modifier is sanitized as the value may have been obtained from
5698 the operating system and there's no guarantee that it won't contain
5699 problematic characters.
5700
5701 The \idx{modifier} is typically obtained by parsing locale information in
5702 \idx{POSIX} format.
5703 \begin{compactcodebox*}
5704 \meta{language}[\idx{underscoresep}\meta{territory}][\idx{dotsep}\meta{codeset}][\idx{atmod}\meta{modifier}]
5705 \end{compactcodebox*}
5706 whereas the \idx{variant} is typically obtained by parsing the language
5707 tag.
5708
5709 The information provided in the commands below (such as the script)
5710 are typically obtained by parsing the language tag. For example,
5711 with Serbian in the Latin alphabet the modifier would be \optfmt{latin}
5712 whereas the script would be \opt{Latn}:
5713 \begin{codebox*}
5714 \gls{AddTrackedDialect}\marg{serbianlatin}\marg{\opt{serbian}}
5715 \gls{AddTrackedLanguageIsoCodes}\marg{\opt{serbian}}
5716 \gls{SetTrackedDialectModifier}\marg{serbianlatin}\marg{latin}
5717 \gls{SetTrackedDialectScript}\marg{serbianlatin}\marg{\opt{Latn}}
5718 \end{codebox*}
5719
5720 As from v1.3, you can provide a script (for example,
5721 \opt{Latn} or \opt{Cyrl}) using:
5722 \cmddef{SetTrackedDialectScript}
5723 where \meta{dialect} is the dialect label and \meta{value} is the
5724 \idxn{15924} alpha-4 script identifier. For example:
5725 \begin{codebox*}
5726 \gls{AddTrackedDialect}\marg{serbiancyrl}\marg{\opt{serbian}}
5727 \gls{AddTrackedLanguageIsoCodes}\marg{serbian}
5728 \gls{SetTrackedDialectScript}\marg{serbiancyrl}\marg{\opt{Cyrl}}
5729 \end{codebox*}
5730
5731 As from v1.3, you can provide a variant for a given
5732 dialect using:
5733 \cmddef{SetTrackedDialectVariant}
5734 For example:
5735 \begin{codebox*}
5736 \gls{AddTrackedDialect}\marg{german1901}\marg{german}
5737 \gls{SetTrackedDialectVariant}\marg{german1901}\marg{1901}
5738 \end{codebox*}
5739
5740 As from v1.3, you can also provide a sub-language using:
5741 \cmddef{SetTrackedDialectSubLang}
5742 where \meta{dialect} is the dialect label and \meta{value} is the
5743 code. For example:
5744 \begin{codebox*}
5745 \gls{AddTrackedDialect}\marg{mandarin}\marg{\opt{chinese}}
5746 \gls{AddTrackedLanguageIsoCodes}\marg{\opt{chinese}}
5747 \gls{SetTrackedDialectSubLang}\marg{mandarin}\marg{cmn}
5748 \gls{AddTrackedIsoLanguage}\marg{639-3}\marg{cmn}\marg{mandarin}
5749 \end{codebox*}
5750
5751 As from v1.3, you can also provide additional information using:
5752 \cmddef{SetTrackedDialectAdditional}
5753 where \meta{dialect} is the dialect label and \meta{value} is the
5754 additional information.
5755
5756 \section{Example (\filefmt{alien.sty})}
5757 \label{sec:examplenewlang}
5758
5759 Suppose I want to create a language package \file{alien.sty} that defines the
5760 \optfmt{martian} language with regional dialects
5761 \optfmt{lowermartian} and \optfmt{uppermartian}. First, let's
5762 suppose that \sty{tracklang} recognises the root language
5763 \optfmt{martian}:
5764 \begin{codebox}
5765 \cmd{ProvidesPackage}\marg{alien}
5766 \codepar
5767 \gls{input}{tracklang}\comment{v1.3}
5768 \codepar
5769 \cmd{DeclareOption}\marg{martian}\marg{\comment{}
5770 \gls{TrackPredefinedDialect}\marg{martian}
5771 }
5772 \cmd{DeclareOption}\marg{lowermartian}\marg{\comment{}
5773 \gls{AddTrackedDialect}\marg{lowermartian}\marg{martian}
5774 \gls{AddTrackedLanguageIsoCodes}\marg{martian}
5775 \gls{AddTrackedIsoLanguage}\marg{3166-1}\marg{YY}\marg{lowermartian}
5776 \comment{other attributes such as}
5777 \comment{\gls{SetTrackedDialectVariant}\marg{lowermartian}\marg{...}}
5778 }
5779 \cmd{DeclareOption}\marg{uppermartian}\marg{\comment{}
5780 \gls{AddTrackedDialect}\marg{uppermartian}\marg{martian}
5781 \gls{AddTrackedLanguageIsoCodes}\marg{martian}
5782 \gls{AddTrackedIsoLanguage}\marg{3166-1}\marg{XX}\marg{uppermartian}
5783 \comment{other attributes such as}
5784 \comment{\gls{SetTrackedDialectVariant}\marg{uppermartian}\marg{...}}
5785 }
5786 \codepar
5787 \cmd{ProcessOptions}*
5788 \codepar
5789 \cmd{newcommand}*\marg{\gls{selectlanguage}}[1]\marg{\comment{}
5790 \cmd{def}\gls{languagename}\marg{\#1}\comment{}
5791 \comment{other stuff}
5792 \gls{SetCurrentTrackedDialect}\marg{\#1}\comment{}
5793 }
5794 \codepar
5795 \gls{AnyTrackedLanguages}
5796 \marg{
5797 \gls{ForEachTrackedDialect}\marg{\cmd{thisdialect}}
5798 \marg{\comment{}
5799 \gls{TrackLangRequireDialect}\marg{alien}\marg{\cmd{thisdialect}}
5800 }
5801 }
5802 \end{codebox}
5803 The caption commands and language set up are in the files
5804 \localefile{alien} as in the examples from
5805 \sectionref{sec:examples}. This allows for the user having already
5806 loaded \sty{tracklang} before \sty{alien} and used \gls{TrackLangFromEnv} to pick up
5807 the locale from the operating system's environment variables.
5808 (For example, they may have \envvar{LANG} set to
5809 \code{xx\idx{underscoresep}YY}.)
5810
5811 The resource files may need to set the mapping between the
5812 \sty{tracklang} dialect label and the \sty{alien} dialect
5813 label. For example, in \ldf{alien}{xx-YY}:
5814 \begin{codebox*}
5815 \gls{TrackLangProvidesResource}\marg{xx-YY}
5816 \codepar
5817 \gls{TrackLangRequireResource}\marg{martian}\comment{load common elements}
5818 \codepar
5819 \cmd{newcommand}\marg{\tklcaptions{lowermartian}}\marg{\comment{}
5820 \tklcaptions{martian}
5821 \cmd{def}\cmd{contentsname}\marg{X'flurp}\comment{regional variation}
5822 }
5823 \codepar
5824 \gls{SetTrackedDialectLabelMap}\marg{\gls{CurrentTrackedDialect}}\marg{lowermartian}
5825 \end{codebox*}
5826
5827 Now let's consider the case where \sty{tracklang} doesn't know
5828 about the \optfmt{martian} language. In this case the user can't
5829 track the dialect until the root language has been defined, so the
5830 user can't use \gls{TrackLangFromEnv} before using the \sty{alien}
5831 package.
5832
5833 With \sty{tracklang} v1.3. The new root language can be defined
5834 with a minor adjustment to the above code:
5835 \begin{codebox*}[fontupper=\small\ttfamily]
5836 \cmd{ProvidesPackage}\marg{alien}
5837 \codepar
5838 \gls{input}\marg{tracklang}\comment{needs v1.3}
5839 \codepar
5840 \gls{TrackLangIfKnownLang}\marg{martian}
5841 \marg{\comment{tracklang already knows about the martian language}
5842 }\comment{}
5843 \marg{
5844 \comment{tracklang doesn't known about the martian language,}
5845 \comment{so define it}
5846 \comment{with \idxn{639-1} (xx) and \idxn{639-2} (xxx) codes:}
5847 \gls{TrackLangNewLanguage}\marg{martian}\marg{xx}\marg{xxx}\marg{}\marg{}\marg{}\marg{\opt{Latn}}
5848 }
5849 \end{codebox*}
5850 The rest is as before.
5851
5852 Now other package writers who want to provide support
5853 for the Martian dialects can easily detect which language options
5854 the user requested through my package, \emph{without needing to know
5855 anything about my \sty{alien} package}.
5856
5857 \part{Summaries and Index}
5858 \appendix
5859
5860 \chapter{Region and Script Mappings}
5861 \label{sec:regscriptmappings}
5862
5863 Region mappings are listed in \tableref{tab:regionmappings}, and
5864 script mappings are listed in \tableref{tab:scriptmappings}.
5865
5866 \printunsrttable[type=index,
5867 title={Region Mappings},other={alpha3},blocks=2,
5868 block-style={name-other-desc},label={tab:regionmappings},
5869 init={%
5870 \renewcommand{\glstableNameTarget}[1]{\inlineglsdef[optdef]{##1}}%
5871 \renewcommand{\glstableiffilter}[3]{\glsifcategory{##1}{region}{##3}{##2}}%
5872 \renewcommand{\glstablenameheader}{Alpha-2}%
5873 \renewcommand{\glstableotherheader}{Alpha-3}%
5874 \renewcommand{\glstabledescheader}{Numeric}%
5875 \renewcommand{\glstableDesc}{\numerictag}%
5876 }
5877 ]
5878
5879 \printunsrttable[type=index,clearpage,par=ragged,
5880 title={Script Mappings},other=userii,blocks=1,
5881 block-style={name-symbol-other-desc},label={tab:scriptmappings},
5882 init={%
5883 \renewcommand{\glstableNameTarget}[1]{\inlineglsdef[optdef]{##1}}%
5884 \renewcommand{\glstableiffilter}[3]{\glsifcategory{##1}{script}{##3}{##2}}%
5885 \renewcommand{\glstablenameheader}{Alpha-2}%
5886 \renewcommand{\glstablesymbolheader}{Numeric}%
5887 \renewcommand{\glstableSymbol}{\numerictag}%
5888 \renewcommand{\glstableotherheader}{Direction}%
5889 }
5890 ]
5891
5892 \backmatter
5893 \printterms
5894 \printsummary
5895
5896 \renewcommand{\fnregion}{}%
5897 \glsdefpostname{bcplangregion}{ (option)}%
5898 \glsdefpostname{rootlang}{ (root language)}%
5899 \glsdefpostname{isocode}{ (\idx{ISO} code)}%
5900 \glsdefpostname{nonbcp}{ (option)}%
5901 \glsdefpostname{region}{ (region)}%
5902 \glsdefpostname{script}{ (script)}%
5903 \glsdefpostname{application}{ (application)}%
5904 \printuserguideindex
5905
5906 \end{document}