From c7892fe1a11367872de6f3ee0fa074b39824e59c Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Mon, 31 Oct 2022 03:04:01 +0000
Subject: CTAN sync 202210310303

---
 macros/generic/tracklang/tracklang.dtx | 3780 ++------------------------------
 1 file changed, 181 insertions(+), 3599 deletions(-)

(limited to 'macros/generic/tracklang/tracklang.dtx')

diff --git a/macros/generic/tracklang/tracklang.dtx b/macros/generic/tracklang/tracklang.dtx
index 22dd36860e..a36ec15205 100644
--- a/macros/generic/tracklang/tracklang.dtx
+++ b/macros/generic/tracklang/tracklang.dtx
@@ -1,3576 +1,112 @@
 %\iffalse
 % tracklang.dtx generated using makedtx version 1.2 (c) Nicola Talbot
 % Command line args:
-%   -src "tracklang.sty\Z=>tracklang.sty"
-%   -src "tracklang.tex\Z=>tracklang.tex"
-%   -src "tracklang-region-codes.tex\Z=>tracklang-region-codes.tex"
-%   -src "tracklang-scripts.sty\Z=>tracklang-scripts.sty"
-%   -src "tracklang-scripts.tex\Z=>tracklang-scripts.tex"
-%   -author "Nicola Talbot"
-%   -doc "tracklang-manual.tex"
-%   -section "chapter"
-%   tracklang
-% Created on 2020/6/30 11:55
-%\fi
-%\iffalse
-%<*package>
-%% \CharacterTable
-%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
-%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
-%%   Digits        \0\1\2\3\4\5\6\7\8\9
-%%   Exclamation   \!     Double quote  \"     Hash (number) \#
-%%   Dollar        \$     Percent       \%     Ampersand     \&
-%%   Acute accent  \'     Left paren    \(     Right paren   \)
-%%   Asterisk      \*     Plus          \+     Comma         \,
-%%   Minus         \-     Point         \.     Solidus       \/
-%%   Colon         \:     Semicolon     \;     Less than     \<
-%%   Equals        \=     Greater than  \>     Question mark \?
-%%   Commercial at \@     Left bracket  \[     Backslash     \\
-%%   Right bracket \]     Circumflex    \^     Underscore    \_
-%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
-%%   Right brace   \}     Tilde         \~}
-%</package>
-%\fi
-% \iffalse
-% Doc-Source file to use with LaTeX2e
-% Copyright (C) 2020 Nicola Talbot, all rights reserved.
-% \fi
-% \iffalse
-%<*driver>
-\documentclass[report,inlinetitle]{nlctdoc}
-
-\DeleteShortVerb{|}
-
-\usepackage[a4paper,marginpar=2in,marginparsep=10pt,
- left=2in,right=.5in]{geometry}
-\usepackage{graphicx}
-\usepackage[utf8]{inputenc}
-\usepackage[T1]{fontenc}
-\usepackage{tracklang}
-\usepackage{etoolbox}
-\usepackage{longtable}
-\usepackage{datatool-base}[2016/07/20]
-\let\orgtheindex\theindex
-\let\orgendtheindex\endtheindex
-\usepackage{imakeidx}
-\usepackage[colorlinks,
-            bookmarks,
-            hyperindex=false,
-            pdfauthor={Nicola L.C. Talbot},
-            pdftitle={tracklang: tracking language options}]{hyperref}
-
-\CheckSum{6210}
-
-\appto\MacroFont{\scriptsize}
-\renewcommand*{\usage}[1]{\textit{\hyperpage{#1}}}
-\renewcommand*{\main}[1]{\underline{\hyperpage{#1}}}
-\PageIndex
-\setcounter{IndexColumns}{2}
-\newcommand*{\PrintCodeIndex}{%
- \bgroup
-  \let\theindex\orgtheindex
-  \let\endtheindex\orgendtheindex
-  \PrintIndex
- \egroup
-}
-\IndexPrologue{%
-\clearpage\phantomsection
-\addcontentsline{toc}{chapter}{Code Index}%
-\chapter*{Code Index}\markboth{Code Index}{Code Index}%
-}
-
-\makeindex[name=user,title=Main Index,intoc]
-\renewcommand{\iapp}[1]{\index[user]{#1@\appfmt{#1}|hyperpage}}
-\renewcommand{\iterm}[1]{\index[user]{#1|hyperpage}}
-\renewcommand{\ics}[1]{\cs{#1}\index[user]{#1@\protect\cs{#1}|hyperpage}}
-\renewcommand*{\ipkgopt}[2][]{%
- \ifstrempty{#1}%
- {\index[user]{package options:!#2@\pkgoptfmt{#2}|hyperpage}}%
- {\index[user]{package options:!#2@\pkgoptfmt{#2}!#1@\pkgoptfmt{#1}|hyperpage}}%
-}
-\renewcommand*{\pkgopt}[2][]{%
- \pkgoptfmt{#2}\ifstrempty{#1}%
- {\index[user]{package options:!#2@\pkgoptfmt{#2}|hyperpage}}%
- {\index[user]{package options:!#2@\pkgoptfmt{#2}!#1@\pkgoptfmt{#1}|hyperpage}}%
-}
-\renewcommand*{\isty}[1]{%
- \index[user]{#1 package@\styfmt{#1} package|hyperpage}}
-
-\newcommand*{\envvar}[1]{%
- \texttt{#1}%
- \index[user]{#1@\texttt{#1}}}
-
-\newcommand*{\isopkgopts}{}
-\newcommand*{\nonisopkgopts}{}
-\newcommand*{\rootlangopts}{}
-
-\makeatletter
-\renewcommand*{\changes@}[3]{%
-  \protected@edef\@tempa{\noexpand\glossary{#1 (#2)\levelchar
-                                 \ifx\saved@macroname\@empty
-                                   \space
-                                   \actualchar
-                                   \generalname
-                                 \else
-                                   \expandafter\@gobble
-                                   \saved@macroname
-                                   \actualchar
-                                   \string\verb\quotechar*%
-                                   \verbatimchar\saved@macroname
-                                   \verbatimchar
-                                 \fi
-                                 :\levelchar #3\encapchar hyperpage}}%
-  \@tempa\endgroup\@esphack}
-
-
-\ifdim\overfullrule=0pt\relax % final mode
-  \typeout{Sorting available options. This may take a while.}%
-  \newcommand{\addopt}[3]{%
-    \expandafter\dtlinsertinto\expandafter{#1}{#2}{#3}%
-  }%
-\else
-  \newcommand{\addopt}[3]{%
-    \ifdefempty{#2}{\edef#2{#1}}{\eappto{#2}{,#1}}
-  }
-\fi
-
-
-\@for\thisdialect:=\@tracklang@declaredoptions\do{%
-  \ifdefempty\thisdialect
-  {}%
-  {%
-    \typeout{\thisdialect}%
-    \ifnum\pdfmatch {[a-z]{2,3}-[A-Z]{2}}{\thisdialect}=1\relax
-      \addopt{\thisdialect}{\isopkgopts}{\dtlcompare}%
-    \else
-      \TrackLangIfKnownLang{\thisdialect}
-      {%
-        \addopt{\thisdialect}{\rootlangopts}{\dtlcompare}%
-      }%
-      {%
-        \addopt{\thisdialect}{\nonisopkgopts}{\dtlicompare}%
-      }%
-    \fi
-  }%
-}
-
-\newcommand*{\isopkgoptstab}{\begin{table}[p]
-\caption[Predefined ISO Language-Region Dialects]%
-{Predefined ISO Language-Region Dialects. (May be used as a package
-option or with \cs{TrackPredefinedDialect}.)}\label{tab:isoopts}
-\medskip
-\centering
-\begin{tabular}{llll}%
-}
-
-\newcommand*{\fnregion}{\textsuperscript{\textdagger}}
-
-\newcommand*{\rootlangoptstab}{\begin{longtable}{lll}
-\caption[Predefined Root Languages]{Predefined Root Languages.
-(\fnregion Has an associated territory.)
-The corresponding
-language tag obtained with \cs{GetTrackedLanguageTag}\marg{dialect}
-is shown in parentheses.}\label{tab:rootlangopts}\\\endfirsthead
-\caption[]{Predefined Root Languages Continued.}\\\endhead
-}
-
-\newcommand*{\nonisopkgoptstab}{\begin{longtable}{ll}
-\caption[Predefined Non-ISO Dialects]{Predefined Non-ISO Dialects.
-(\fnregion Has an associated territory.)
-The corresponding
-language tag obtained with \cs{GetTrackedLanguageTag}\marg{dialect}
-is shown in parentheses. If the dialect has a corresponding mapping
-for the closest matching non-root language \cs{caption\ldots} or
-\cs{date\ldots}, this is also include after the tag following a
-slash.}%
-\label{tab:nonisoopts}\\\endfirsthead
-\caption[]{Predefined Non-ISO Dialects Continued}\\\endhead
-}
-
-\newcount\tmpctr
-
-\@for\thisdialect:=\isopkgopts\do{%
-  \advance\tmpctr by 1\relax  
-  \eappto\isopkgoptstab{\noexpand\pkgoptfmt{\thisdialect}&}%
-  {%locally track this dialect to pick up information
-    \TrackPredefinedDialect\thisdialect
-    \xappto\isopkgoptstab{\space
-     {\noexpand\small(\noexpand\texttt{%
-       \csname @tracklang@dialect\endcsname})}}%
-  }%
-  \ifnum\tmpctr>1
-    \tmpctr = 0\relax
-    \appto\isopkgoptstab{\\}%
-  \else
-    \appto\isopkgoptstab{&}%
-  \fi
-}
-
-\appto\isopkgoptstab{\end{tabular}\par
-\medskip
-Other combinations need to be set with \cs{TrackLocale} or
-\cs{TrackLanguageTag}.
-\end{table}}
-
-\tmpctr=0\relax
-
-\@for\thisdialect:=\nonisopkgopts\do{%
-  \advance\tmpctr by 1\relax  
-  \eappto\nonisopkgoptstab{\noexpand\pkgoptfmt{\thisdialect}}%
-  {%locally track this dialect to pick up information
-    \TrackPredefinedDialect\thisdialect
-    \IfTrackedLanguageHasIsoCode{3166-1}{\thisdialect}%
-    {\gappto\nonisopkgoptstab{\fnregion}}%
-    {}%
-    \IfTrackedDialectHasMapping\thisdialect
-    {\def\nonisopkgmap{ / 
-      \noexpand\texttt{\GetTrackedDialectToMapping\thisdialect}}}%
-    {\def\nonisopkgmap{}}%
-    \xappto\nonisopkgoptstab{\space
-     {\noexpand\small(\noexpand\texttt{\GetTrackedLanguageTag\thisdialect}%
-      \nonisopkgmap)}}%
-  }%
-  \ifnum\tmpctr>1
-    \tmpctr = 0\relax
-    \appto\nonisopkgoptstab{\\}%
-  \else
-    \appto\nonisopkgoptstab{&}%
-  \fi
-}
-
-\appto\nonisopkgoptstab{\end{longtable}}
-
-\tmpctr=0\relax
-
-\@for\thisdialect:=\rootlangopts\do{%
-  \advance\tmpctr by 1\relax  
-  \eappto\rootlangoptstab{\noexpand\pkgoptfmt{\thisdialect}}%
-  \TrackLangIfHasKnownCountry{\thisdialect}%
-  {%
-    \appto\rootlangoptstab{\fnregion}%
-  }%
-  {}%
-  {%locally track this language to pick up information
-    \TrackPredefinedDialect\thisdialect
-    \xappto\rootlangoptstab{\space
-     {\noexpand\small(\noexpand\texttt{\GetTrackedLanguageTag\thisdialect})}}%
-  }%
-  \ifnum\tmpctr>2
-    \tmpctr = 0\relax
-    \appto\rootlangoptstab{\\}%
-  \else
-    \appto\rootlangoptstab{&}%
-  \fi
-}
-
-\appto\rootlangoptstab{\end{longtable}}
-
-\makeatother
-
-\newcommand*{\refoptstables}{tables~\ref{tab:isoopts}, \ref{tab:rootlangopts}
-and~\ref{tab:nonisoopts}}
-
-\begin{document}
-\DocInput{tracklang.dtx}
-\end{document}
-%</driver>
-%\fi
-%
-%\MakeShortVerb{"}
-%
-%\title{tracklang v1.5:
-%tracking language options}
-%\author{Nicola L. C. Talbot\\\url{http://www.dickimaw-books.com/}}
-%
-%\date{2020-06-30}
-%\maketitle
-%
-%\begin{abstract}
-%The \styfmt{tracklang} package is provided for package developers
-%who want a simple interface to find out which languages the user has
-%requested through packages such as \sty{babel} and
-%\sty{polyglossia}. \emph{This package doesn't provide any
-%translations.}
-%Its purpose is simply to track which languages have been requested by the
-%user. Generic \TeX\ code is in \texttt{tracklang.tex} for
-%non-\LaTeX\ users.
-%
-%If the shell escape is enabled or \ics{directlua} is available,
-%this package may also be used to query the \envvar{LC\_ALL}
-%or \envvar{LANG} environment variable (see
-%\sectionref{sec:langsty}). Windows users, who don't have the locale
-%stored in environment variables, can use \app{texosquery}
-%in combination with \styfmt{tracklang}. (Similarly if \envvar{LC\_ALL}
-%or \envvar{LANG} don't contain sufficient information.) In order to
-%use \app{texosquery} through the restricted shell escape, you must
-%have at least Java~8 and set up \texttt{texosquery.cfg}
-%appropriately. (See the \app{texosquery} manual for further details.)
-%\end{abstract}
-%
-%The fundamental aim of this generic package is to be able to
-%effectively say:
-%\begin{quote}
-%The user (that is, the \emph{document} author) wants to use
-%dialects \texttt{xx-XX}, \texttt{yy-YY-Scrp}, etc in their
-%document. Any packages used by their document that provide 
-%multilingual or region-dependent support should do whatever is
-%required to activate the settings for those languages and regions
-%(or warn the user that there's no support).
-%\end{quote}
-%Naturally, this is only of use if the locale-sensitive packages use
-%\styfmt{tracklang} to pick up this information, which is entirely up
-%to the package authors, but at the moment there's no standard method
-%for packages to detect the required language and region. The aim of
-%\styfmt{tracklang} is to provide that method. In particular, the
-%emphasis is on using ISO language and region codes rather than
-%hard-coding the various language labels used by different language
-%packages.
-%
-%Related articles: \qt{Localisation of \TeX\ documents: 
-%\styfmt{tracklang}.} TUGBoat, Volume~37 (2016), No.~3
-%(\url{http://www.tug.org/TUGboat/tb37-3/tb117talbot.pdf}),
-%\href{https://www.dickimaw-books.com/latex/tracklang}{Localisation
-%with \texttt{tracklang.tex}},
-%and
-%\href{https://www.dickimaw-books.com/faq.php?action=view&category=tracklang}{\texttt{tracklang}
-%FAQ}.
-%
-%\clearpage
-%\tableofcontents
-%\clearpage\phantomsection
-%\pdfbookmark{Tables}{lot}%
-%\listoftables
-%
-%\chapter{Introduction}
-%\label{sec:intro}
-%
-%When I'm developing a package that provides multilingual support
-%(for example, \styfmt{glossaries}) it's cumbersome trying to work out
-%if the user has requested translations for fixed text.  This usually
-%involves checking if \sty{babel} or \sty{ngerman} or
-%\sty{translator} or \sty{polyglossia} has been loaded and, if so,
-%what language settings have been used. The result can be a tangled
-%mass of conditional code. The alternative is to tell users to add
-%the language as a~document class option, which they may or may not
-%want to do, or to tell them to supply the language settings to every
-%package they load that provides multilingual support, which users
-%are even less likely to want to do.
-%
-%The \styfmt{tracklang} package tries to neaten this up by working out
-%as much of this information as possible for you and providing a
-%command that iterates through the loaded languages. This way, you
-%can just iterate through the list of tracked languages and, for each
-%language, either define the translations or warn the user that
-%there's no translation for that language.
-%
-%This package works best with \sty{ngerman} or with recent versions
-%of \sty{babel} or when the language options are specified
-%in the document class option list. It works fairly well with
-%\sty{translator} but will additionally assume the root language was
-%also requested when a dialect is specified. So, for example,
-%\begin{verbatim}
-%\usepackage[british]{translator}
-%\usepackage{tracklang}
-%\end{verbatim}
-%is equivalent to
-%\begin{verbatim}
-%\usepackage[british]{translator}
-%\usepackage[english,british]{tracklang}
-%\end{verbatim}
-%This means that \ics{ForEachTrackedDialect} will iterate
-%through the list \qt{english,british} instead of just
-%\qt{british}, which can result in some redundancy.
-%
-%Unfortunately I can't work out how to pick up the language variant
-%or script from \sty{polyglossia}, so only the root languages are detected,
-%which is suboptimal but at least provides some information.
-%(\sty{polyglossia} now provides \cs{xpg@loaded}, which
-%\sty{tracklang} uses to track the root languages, but the language variant
-%command \cs{xpg@loaded} only seems to be set when the language
-%changes, which doesn't occur until the start of the \env{document}
-%environment.)
-%
-%I also can't find any way of detecting a list of languages loaded
-%through \sty{babel}'s new \ics{babelprovide} command. As far as I
-%can tell, the only stored list is in \cs{bbl@loaded} which only
-%contains the languages loaded through package options.
-%
-%If the \sty{ngerman} package has been loaded, \styfmt{tracklang}
-%effectively does
-%\begin{verbatim}
-%\TrackPredefinedDialect{ngerman}
-%\end{verbatim}
-%Similarly, if the \sty{german} package has been loaded, 
-%\styfmt{tracklang} effectively does
-%\begin{verbatim}
-%\TrackPredefinedDialect{german}
-%\end{verbatim}
-%
-%If any document class or package options are passed to
-%\styfmt{tracklang}, then \styfmt{tracklang} won't bother checking
-%for \sty{babel}, \sty{translator}, \sty{ngerman}, \sty{german} or
-%\sty{polyglossia}. So, if the above example is changed to:
-%\begin{verbatim}
-%\documentclass[british]{article}
-%\usepackage{translator}
-%\usepackage{tracklang}
-%\end{verbatim}
-%then the dialect list will just consist of \qt{british} rather than
-%\qt{english,british}. This does, however, mean that if the user mixes
-%class and package options, only the class options will be detected.
-%For example:
-%\begin{verbatim}
-%\documentclass[british]{article}
-%\usepackage[french]{babel}
-%\usepackage{tracklang}
-%\end{verbatim}
-%In this case, only the \qt{british} option will be detected. The user
-%can therefore use the document class option (or \styfmt{tracklang}
-%package option) to override the dialect and set the country code
-%(where provided). For example:
-%\begin{verbatim}
-%\documentclass[es-MX]{article}
-%\usepackage[spanish]{babel}
-%\usepackage{tracklang}
-%\end{verbatim}
-%This sets the dialect to \qt{mexicanspanish} and the root language to
-%\qt{spanish}. 
-%
-%Predefined dialects are listed in \refoptstables. These may be 
-%passed in the document class options or
-%used in \ics{TrackPredefinedDialect}, as illustrated above. 
-%
-%\sectionref{sec:summary} provides brief examples of use for those
-%who want a general overview before reading the more detailed
-%sections.
-%\sectionref{sec:generic} describes generic commands for
-%identifying the document languages.
-%\sectionref{sec:user} is for package writers who want to
-%add multilingual support to their package and need to know which
-%settings the user has requested through language packages like
-%\sty{babel}. \sectionref{sec:langsty} is for
-%developers of language definition packages who want to help other
-%package writers to detect what languages have been requested.
-%
-%\isopkgoptstab
-%
-%\clearpage
-%
-%\rootlangoptstab
-%
-%\clearpage
-%
-%\nonisopkgoptstab
-%
-%\chapter{Summary of Use}
-%\label{sec:summary}
-%
-%There are three levels of use:
-%\begin{enumerate}
-%\item document level (code used by document authors);
-%\item locale-sensitive package level 
-%(code for package authors who need to 
-%know what languages or locale the document is
-%using, such as \styfmt{glossaries} to translate commands like
-%\cs{descriptionname} or \styfmt{datetime2} to provide localised 
-%formats or time zone information);
-%\item language set-up level (code for packages that set up
-%the document languages, such as \sty{babel} or \sty{polyglossia}).
-%\end{enumerate}
-%
-%\section{Document Level}
-%\label{sec:summary-doc}
-%
-%\subsection{Generic \texorpdfstring{\TeX}{TeX}}
-%Unix user wants the locale information picked up from the 
-%locale environment variable:
-%\begin{verbatim}
-%\input tracklang % v1.3
-%\TrackLangFromEnv
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%
-%Windows user wants the locale information picked up from the 
-%operating system:
-%\begin{verbatim}
-%\input texosquery
-%\input tracklang % v1.3
-%\TrackLangFromEnv
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%Or (\sty{texosquery} v1.2)
-%\begin{verbatim}
-%\input texosquery % v1.2
-%\input tracklang % v1.3
-%
-%\TeXOSQueryLangTag{\langtag}
-%\TrackLanguageTag{\langtag}
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%Linux user who may or may not have \app{texosquery} setup to run in the
-%shell escape:
-%\begin{verbatim}
-%\input texosquery 
-%\input tracklang % v1.3
-%
-%\ifx\TeXOSQueryLangTag\undefined
-% \TrackLangFromEnv
-%\else
-% \TeXOSQueryLangTag{\langtag}
-% \TrackLanguageTag{\langtag}
-%\fi
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%
-%User is writing in Italy in Armenian with a Latin
-%script and the arevela variant:
-%\begin{verbatim}
-%\input tracklang % v1.3
-%\TrackLanguageTag{hy-Latn-IT-arevela}
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%
-%User is writing in English in the UK:
-%\begin{verbatim}
-%\input tracklang
-%\TrackPredefinedDialect{british}
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%
-%Find out information about the current language (supplied
-%in \cs{languagename}):
-%\begin{verbatim}
-%\SetCurrentTrackedDialect{\languagename}
-%Dialect: \CurrentTrackedDialect.
-%Language: \CurrentTrackedLanguage.
-%ISO Code: \CurrentTrackedIsoCode.
-%Region: \CurrentTrackedRegion.
-%Modifier: \CurrentTrackedDialectModifier.
-%Variant: \CurrentTrackedDialectVariant.
-%Script: \CurrentTrackedDialectScript.
-%Sub-Lang: \CurrentTrackedDialectSubLang.
-%Additional: \CurrentTrackedDialectAdditional.
-%Language Tag: \CurrentTrackedLanguageTag.
-%\end{verbatim}
-%Additional information about the script can be obtained by
-%also loading \sty{tracklang-scripts}:
-%\begin{verbatim}
-%\input tracklang-scripts
-%\end{verbatim}
-%The name, numeric code and direction can now be obtained:
-%\begin{verbatim}
-%Name: \TrackLangScriptAlphaToName{\CurrentTrackedDialectScript}.
-%Numeric: \TrackLangScriptAlphaToNumeric{\CurrentTrackedDialectScript}.
-%Dir: \TrackLangScriptAlphaToDir{\CurrentTrackedDialectScript}.
-%\end{verbatim}
-%Test for a specific script:
-%\begin{verbatim}
-%Latin?
-%\ifx\CurrentTrackedDialectScript\TrackLangScriptLatn
-% Yes
-%\else
-% No
-%\fi
-%\end{verbatim}
-%
-%\subsection{\texorpdfstring{\LaTeX}{LaTeX}}
-%
-%For \sty{babel} users where the supplied \sty{babel} dialect
-%label is sufficient, there's no need to do anything special:
-%\begin{verbatim}
-%\documentclass[british,canadien]{article}
-%\usepackage[T1]{fontenc}
-%\usepackage{babel}
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%If the region is important but there's no \sty{babel} dialect
-%that represents it, there are several options.
-%
-%Use the class options recognised by \styfmt{tracklang}
-%and the root language labels when loading \sty{babel}:
-%\begin{verbatim}
-%\documentclass[en-IE,ga-IE]{article}
-%\usepackage[english,irish]{babel}
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%
-%This method is needed for \sty{polyglossia} where the regional
-%information is required. For example
-%\begin{verbatim}
-%\documentclass[en-GB]{article}
-%\usepackage{polyglossia}
-%\setmainlanguage[variant=uk]{english}
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%
-%Another method with \sty{babel} is to
-%use \cs{TrackLanguageTag} and map the new dialect label to
-%\sty{babel}'s nearest matching label:
-%\begin{verbatim}
-%\documentclass{article}
-%
-%\usepackage{tracklang}% v1.3
-%\TrackLanguageTag{en-MT}
-%\SetTrackedDialectLabelMap{\TrackLangLastTrackedDialect}{UKenglish}
-%
-%\usepackage[UKenglish]{babel}
-%% load packages that use tracklang for localisation
-%\end{verbatim}
-%This ensures that the \cs{captionsUKenglish} hook is detected
-%by the localisation packages. This mapping isn't needed
-%for \sty{polyglossia} as the caption hooks use the root language
-%label. This mapping also isn't needed if \texttt{british} is used
-%instead of \texttt{UKenglish} since the \pkgopt{en-MT}
-%(\pkgopt{maltaenglish})
-%predefined dialect automatically sets up a mapping to
-%\texttt{british}. (The default mappings are shown in
-%\tableref{tab:nonisoopts}.)
-%
-%\section{Locale-Sensitive Packages}
-%\label{sec:summary-localepkg}
-%
-%Let's suppose you are developing a package called 
-%\texttt{mypackage.sty} or \texttt{mypackage.tex} and you want
-%to find out what languages the document author has requested. (See also:
-%\href{https://www.dickimaw-books.com/latex/tracklang/otherpkg.shtml}{Using
-%\texttt{tracklang.tex} in Packages with Localisation Features}.)
-%
-%Generic use:
-%\begin{verbatim}
-%\input tracklang 
-%\end{verbatim}
-%(Most of the commands used in this section require at least
-%\styfmt{tracklang} version 1.3 but 1.4 is better if you want to
-%include the script tag in the ldf files.)
-%Note that \texttt{tracklang.tex} has a check to determine if
-%it's already been loaded, so you don't need to worry about that.
-%
-%\LaTeX\ use:
-%\begin{verbatim}
-%\RequirePackage{tracklang}[2019/11/30]% at least v1.4
-%\end{verbatim}
-%This will picked up any language options supplied in the document
-%class options and will also detect if \sty{babel} or
-%\sty{polyglossia} have been loaded.
-%
-%(\LaTeX) If you want to allow the user to set the locale in the 
-%package options:
-%\begin{verbatim}
-%\DeclareOption*{\TrackLanguageTag{\CurrentOption}}
-%\end{verbatim}
-%This means the user can do, say,
-%\begin{verbatim}
-%\usepackage[hy-Latn-IT-arevela]{mypackage}
-%\end{verbatim}
-%With at least version 1.4, it's better to use \ics{TrackIfKnownLanguage}:
-%\begin{verbatim}
-%\DeclareOption*{%
-% \TrackIfKnownLanguage{\CurrentOption}%
-% {\PackageInfo{mypackage}{Tracking language `\CurrentOption'}}% successful
-% {% failed
-%   \PackageError{mypackage}%
-%   {Unknown language specification `\CurrentOption'}%
-%   {You need to supply either a known dialect label or a valid language tag}%
-% }%
-%}
-%\end{verbatim}
-%
-%The rest of the example package in this section uses generic code.
-%
-%If you want to fetch the locale information from the operating
-%system when the user hasn't requested a language:
-%\begin{verbatim}
-%\AnyTrackedLanguages
-%{}
-%{% fetch locale information from the operating system
-%  \ifx\TeXOSQueryLangTag\undefined
-%    % texosquery v1.2 not available
-%    \TrackLangFromEnv
-%  \else
-%    % texosquery v1.2 available
-%    \TeXOSQueryLangTag{\langtag}
-%    \TrackLanguageTag{\langtag}
-%  \fi
-%}
-%\end{verbatim}
-%
-%Set up the defaults if necessary:
-%\begin{verbatim}
-%\def\fooname{Foo}
-%\def\barname{Bar}
-%\end{verbatim}
-%
-%Now load the resource files:
-%\begin{verbatim}
-%\AnyTrackedLanguages
-%{%
-%  \ForEachTrackedDialect{\thisdialect}{%
-%    \TrackLangRequireDialect{mypackage}{\thisdialect}%
-%  }%
-%}
-%{}% no tracked languages, default already set up
-%\end{verbatim}
-%
-%Each resource file has the naming scheme \meta{prefix}\texttt{-}
-%\meta{localeid}\texttt{.ldf}. In this example, the \meta{prefix} is
-%\texttt{mypackage}. The \meta{localeid} part may be the language or dialect label
-%(for example, \texttt{english} or \texttt{british}) or a combination of the ISO
-%language and region codes (for example, \texttt{en-GB} or 
-%\texttt{en} or \texttt{GB}). As from version 1.4, \meta{localeid} may
-%also include the script or variant. (See the definition of
-%\ics{IfTrackedLanguageFileExists} on page~\pageref{pg:filesearch}
-%for further details.)
-%
-%The simplest scheme is to use the root language label (not the
-%dialect label) for the base language settings and use the ISO
-%codes for regional support.
-%
-%For example, the file \texttt{mypackage-english.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{english}[2016/10/06 v1.0]% identify this file
-%
-%\TrackLangAddToCaptions{%
-%  \def\fooname{Foo}%
-%  \def\barname{Bar}%
-%}
-%\end{verbatim}
-%This sets up appropriate the \cs{captions\ldots} hook (if it's
-%found). For other hooks, such as \cs{date\ldots}, use 
-%\ics{TrackLangAddToHook}\marg{code}\marg{hook type} instead.
-%
-%With pre-v1.4 versions of \sty{tracklang}, the script isn't included
-%in the file search. If it's needed then either require at least v1.4
-%or have a base ldf file that tries to load a version for the
-%particular script (which can be accessed with
-%\cs{CurrentTrackedScript}).
-%Here's an example for a language with different writing systems.
-%The resource file for Serbian \texttt{mypackage-serbian.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{serbian}[2016/10/06 v1.0]% identify file
-%
-%\TrackLangRequestResource{serbian-\CurrentTrackedScript}
-%{}% file not found, do something sensible here
-%\end{verbatim}
-%The file \texttt{mypackage-serbian-Latn.ldf} sets up
-%the Latin script:
-%\begin{verbatim}
-%\TrackLangProvidesResource{serbian-Latn}[2016/10/06 v1.0]
-%
-%\TrackLangAddToCaptions{%
-%  \def\fooname{...}% provide appropriate Latin translations
-%  \def\barname{...}%
-%}
-%\end{verbatim}
-%The file \texttt{mypackage-serbian-Cyrl.ldf} sets up
-%the Cyrllic script:
-%\begin{verbatim}
-%\TrackLangProvidesResource{serbian-Cyrl}[2016/10/06 v1.0]
-%
-%\TrackLangAddToCaptions{%
-%  \def\fooname{...}% provide appropriate Cyrllic translations
-%  \def\barname{...}%
-%}
-%\end{verbatim}
-%
-%With v1.4+ you would just need \texttt{mypackage-sr-Latn.ldf},
-%\texttt{mypackage-sr-Cyrl.ldf} for the regionless versions.
-%
-%\section{Language Packages}
-%\label{sec:summary-langpkg}
-%
-%Let's suppose now you're the developer of a package that 
-%sets up the language, hyphenation patterns and so on.
-%It would be really helpful to the locale-sensitive packages 
-%in \sectionref{sec:summary-localepkg} to know what languages
-%the document author has requested. You can use the
-%\styfmt{tracklang} package to identify this information
-%by tracking the requested localisation, so that other packages
-%can have a consistent way of querying it. (See also:
-%\href{https://www.dickimaw-books.com/latex/tracklang/langpkg.shtml}{Integrating
-%\texttt{tracklang.tex} into Language Packages}.)
-%
-%Generic use:
-%\begin{verbatim}
-%\input tracklang
-%\end{verbatim}
-%Alternative \LaTeX\ use:
-%\begin{verbatim}
-%\RequirePackage{tracklang}[2019/11/30] % v1.4
-%\end{verbatim}
-%Unlike \cs{input}, \cs{RequirePackage} will allow \styfmt{tracklang}
-%to pick up the document class options, but using \cs{RequirePackage}
-%will also trigger the tests for known language packages.
-%(If you want to find out if \styfmt{tracklang} has already been
-%loaded and locales have already been tracked, you can use the
-%same code as in the previous section.)
-%
-%When a user requests a particular language through your package,
-%the simplest way of letting \styfmt{tracklang} know about it
-%is to use \cs{TrackPredefinedDialect} or \cs{TrackLanguageTag}.
-%For example, if the user requests \texttt{british}, that's a
-%predefined dialect so you can just do:
-%\begin{verbatim}
-%\TrackPredefinedDialect{british}
-%\end{verbatim}
-%Alternatively
-%\begin{verbatim}
-%\TrackLanguageTag{en-GB}
-%\end{verbatim}
-%If your package uses caption hooks, then you can set up 
-%a mapping between \styfmt{tracklang}'s internal dialect label
-%and your caption label. For example, let's suppose the
-%closest match to English used in Malta (\texttt{en-MT}) is the 
-%dialect \texttt{UKenglish} (for example, the date format is 
-%similar between GB and MT):
-%\begin{verbatim}
-%\TrackLanguageTag{en-MT}
-%\SetTrackedDialectLabelMap{\TrackLangLastTrackedDialect}{UKenglish}
-%\def\captionsUKenglish{%
-%  \def\contentsname{Contents}%
-%  %...
-%}
-%\end{verbatim}
-%(The predefined \pkgopt{maltaenglish} option provided by
-%\styfmt{tracklang} automatically sets the mapping to
-%\texttt{british}, but the above method will change that mapping
-%to \texttt{UKenglish}.)
-%
-%This now means that \cs{TrackLangAddToHook} and \cs{TrackLangRedefHook} commands can
-%find your language hooks. You don't need the map if your dialect
-%label is the same as \styfmt{tracklang}'s root language label
-%for that locale. For example:
-%\begin{verbatim}
-%\TrackLanguageTag{en-MT}
-%\def\captionsenglish{%
-%  \def\contentsname{Contents}%
-%  %...
-%}
-%\end{verbatim}
-%
-%When the user switches language through commands like
-%\ics{selectlanguage} it would be useful to also use
-%\ics{SetCurrentTrackedDialect}\marg{dialect} to make it easier
-%for the document author or locale-sensitive packages to pick
-%up the current locale. The \meta{dialect} argument may be
-%\styfmt{tracklang}'s internal dialect label or the dialect
-%label you assigned with \cs{SetTrackedDialectLabelMap}. It
-%may also be the root language label, in which case
-%\styfmt{tracklang} will search for the last dialect to be
-%tracked with that language. For example:
-%\begin{verbatim}
-%\def\selectlanguage#1{%
-%  \SetCurrentTrackedDialect{#1}%
-%  % set up hyphenation patterns etc
-%}
-%\end{verbatim}
-%See the example in \sectionref{sec:summary-doc} or the example in 
-%\href{https://www.dickimaw-books.com/latex/tracklang/langpkg.shtml}{Integrating
-%\texttt{tracklang.tex} into Language Packages}.
-%
-%\chapter{Generic Use}
-%\label{sec:generic}
-%
-%For plain \TeX\ you can input \texttt{tracklang.tex}:
-%\begin{verbatim}
-%\input tracklang
-%\end{verbatim}
-%or for \TeX\ formats that have an argument form for \ics{input}:
-%\begin{verbatim}
-%\input{tracklang}
-%\end{verbatim}
-%As from version 1.3, you don't need to change the category
-%code of \texttt{@} before loading \texttt{tracklang.tex}
-%as it will automatically be changed to 11 and switched
-%back at the end (if required).
-%
-%The \LaTeX\ package \texttt{tracklang.sty} 
-%inputs the generic \TeX\ code in \texttt{tracklang.tex}, but before 
-%it does so it defines
-%\begin{definition}
-%\cs{@tracklang@declareoption}\marg{name}
-%\end{definition}
-%to
-%\begin{definition}
-%\cs{DeclareOption}\marg{name}\{\cs{TrackPredefinedDialect}\marg{name}\}
-%\end{definition}
-%
-%This means that all the predefined languages and dialects
-%(\refoptstables) automatically become package options, so
-%the \styfmt{tracklang} package can pick up document class
-%options and add them to \styfmt{tracklang}'s internal list of tracked
-%document languages.
-%
-%If you're not using \LaTeX, this option isn't available
-%(although you could redefine the internal command 
-%\cs{@tracklang@declareoption}
-%to use something analogous to \cs{DeclareOption}).
-%Instead, the document languages need
-%to be explicitly identified (using any of the following commands)
-%so that \styfmt{tracklang} knows about them.
-%
-%\begin{definition}[\DescribeMacro\TrackPredefinedDialect]
-%\ics{TrackPredefinedDialect}\marg{dialect label}
-%\end{definition}
-%This will add the predefined dialect and its associated ISO codes to the list
-%of tracked document languages. The \meta{dialect label} may be any
-%of those listed in \refoptstables.
-%(See also \sectionref{sec:predefinedlang} and \sectionref{sec:predefined}.)
-%
-%For example:
-%\begin{verbatim}
-%\input tracklang
-%\TrackPredefinedDialect{british}
-%\end{verbatim}
-%is the Plain \TeX\ alternative to
-%\begin{verbatim}
-%\documentclass[british]{article}
-%\usepackage{tracklang}
-%\end{verbatim}
-%
-%Note that it's impractical to define every possible language
-%and region combination as it would significantly slow the
-%time taken to load \styfmt{tracklang} so, after version~1.3,
-%I don't intend adding any new predefined dialects. As from version
-%1.3, if you want to track a dialect that's not predefined by
-%\styfmt{tracklang}, then you can use:
-%\begin{definition}[\DescribeMacro\TrackLocale]
-%\cs{TrackLocale}\marg{locale}
-%\end{definition}
-%If \meta{locale} is a recognised dialect, this is equivalent to
-%using \cs{TrackPredefinedDialect}, otherwise \meta{locale}
-%needs to be in one the following formats:
-%\begin{itemize}
-%\item \meta{ISO lang}
-%\item \meta{ISO lang}\texttt{@}\meta{modifier}
-%\item \meta{ISO lang}\texttt{-}\meta{ISO country}
-%\item \meta{ISO lang}\texttt{-}\meta{ISO country}\texttt{@}\meta{modifier}
-%\end{itemize}
-%where \meta{ISO lang} is the ISO~639-1 or 639-2 code identifying
-%the language (lower case), \meta{ISO country} is the 3166-1
-%ISO code identifying the territory (upper case) and 
-%\meta{modifier} is the modifier or variant. The hyphen may be
-%replaced by an underscore character. Code set information in the
-%form \texttt{.}\meta{codeset} may optionally appear before the
-%modifier. For example, \texttt{de-DE.utf8@new} (modifier is
-%\texttt{new}) or \texttt{en-GB.utf8} (modifier is missing).
-%The codeset will be ignored if present, but it won't interfere
-%with the parsing.
-%
-%For example:
-%\begin{verbatim}
-%\TrackLocale{de-NA@new}
-%\end{verbatim}
-%indicates German in Namibia using the new spelling.
-%
-%\begin{important}
-%If a language has different \qt{T} and \qt{B} ISO~639-2 codes, then
-%the \qt{T} form should be used. (So for the above example,
-%\texttt{deu} may be used instead of \texttt{de}, but \texttt{ger}
-%won't be recognised.)
-%\end{important}
-%
-%Alternatively, you can use
-%\begin{definition}[\DescribeMacro\TrackLanguageTag]
-%\cs{TrackLanguageTag}\marg{tag}
-%\end{definition}
-%where \meta{tag} is a regular, well-formed language tag or a recognised dialect
-%label. (Irregular grandfather tags aren't recognised.)
-%This command will fully expand \meta{tag}.
-%A warning is issued if the tag is empty.
-%
-%If you want to first check that \meta{tag} includes a valid language
-%code, then you can instead use:
-%\begin{definition}[\DescribeMacro\TrackIfKnownLanguage]
-%\cs{TrackIfKnownLanguage}\marg{tag}\marg{success code}\marg{fail code}
-%\end{definition}
-%This will only track \meta{tag} (and then do \meta{success code}) if
-%\meta{tag} starts with a valid language code (or is a predefined
-%dialect) otherwise it will do \meta{fail code}. Both
-%\cs{TrackLanguageTag} and \cs{TrackIfKnownLanguage} will check if
-%\meta{tag} is a predefined option. (This saves parsing the tag if
-%it's recognised.)
-%
-%For example:
-%\begin{verbatim}
-%\TrackLanguageTag{hy-Latn-IT-arevela}
-%Latn-ME: \TrackIfKnownLanguage{Latn-ME}{success}{fail}.
-%brazilian: \TrackIfKnownLanguage{brazilian}{success}{fail}.
-%\end{verbatim}
-%This will track hy-Latn-IT-arevela and brazilian (pt-BR) but not
-%Latn-ME (because it doesn't contain a valid language code) even
-%though it's a valid script and country code. The above is just for
-%illustrative purposes. Typically the language tracking isn't
-%performed within the document text.
-%
-%The \sty{datetime2} package assumes that any unknown package option is a
-%language identifier. It could simply do:
-%\begin{verbatim}
-%\TrackLanguageTag{\CurrentOption}
-%\end{verbatim}
-%but users can make mistakes sometimes and this won't provide any
-%helpful information if they, for example, misspelt a package option
-%or forgot the ``\meta{key}='' part of a \meta{key}=\meta{value}
-%setting. Instead (as from v1.5.5) it does:
-%\begin{verbatim}
-%\TrackIfKnownLanguage{\CurrentOption}{...}{\PackageError{...}{...}{...}}
-%\end{verbatim}
-%This will now give the user some guidance. 
-%
-%If \meta{tag} contains a sub-language tag, this will be set
-%as the 639-3 code for the \emph{dialect} label. Note that this is
-%different to the root language codes which are set using the
-%language label. For example
-%\begin{verbatim}
-%\TrackLanguageTag{zh-cmn-Hans-CN}
-%\end{verbatim}
-%creates a new dialect with the label \texttt{zhcmnHansCN}.
-%The root language \texttt{chinese} has the ISO 639-1 code
-%\texttt{zh} and the dialect \texttt{zhcmnHansCN} has the
-%ISO 639-3 code \texttt{cmn}.
-%\begin{verbatim}
-%ISO 639-1: \TrackedIsoCodeFromLanguage{639-1}{chinese}.
-%ISO 639-3: \TrackedIsoCodeFromLanguage{639-3}{zhcmnHansCN}.
-%\end{verbatim}
-%
-%Version 1.2 of \sty{texosquery} provides the command \ics{TeXOSQueryLangTag},
-%which may be used to fetch the operating system's regional
-%information as a language tag. These commands can be used as
-%follows:
-%\begin{verbatim}
-%\input tracklang % v1.3
-%\input texosquery % v1.2
-%
-%\TeXOSQueryLangTag{\langtag}
-%\TrackLanguageTag{\langtag}
-%\end{verbatim}
-%(If the shell escape is disabled, \cs{langtag} will be empty, which
-%will trigger a~warning but no errors.)
-%
-%Some of the predefined root language options listed
-%in \tableref{tab:rootlangopts} have an associated region
-%(denoted by \fnregion).
-%If \cs{TrackLocale} is used with just the language ISO code,
-%no region is tracked for that language. For example
-%\begin{verbatim}
-%\TrackLocale{manx}
-%\end{verbatim}
-%will track the \qt{IM} ISO~3166-1 code but
-%\begin{verbatim}
-%\TrackLocale{gv}
-%\end{verbatim}
-%won't track the region.
-%Similarly for \cs{TrackLanguageTag}.
-%
-%(New to version 1.3.)
-%There's a similar command to \cs{TrackLocale} that doesn't take an argument:
-%\begin{definition}[\DescribeMacro\TrackLangFromEnv]
-%\cs{TrackLangFromEnv}
-%\end{definition}
-%If the shell escape has been enabled or
-%\ics{directlua} is available, this will try to get the language
-%information from the system environment variables 
-%\envvar{LC\_ALL} or \envvar{LANG}
-%and, if successful, track that.
-%
-%Since \styfmt{tracklang} is neither able to look up the POSIX locale
-%tables nor interpret file locales, if the result is \texttt{C} or
-%\texttt{POSIX} or starts with a forward slash \texttt{/} then
-%the locale value is treated as empty.
-%
-%\begin{important}
-%Not all operating systems use environment variables for
-%the system locale information. For example, Windows stores the
-%locale information in the registry. In which case, consider
-%using \styfmt{texosquery}.
-%\end{important}
-%
-%If the operating system locale can't be obtained from environment variables, then
-%\styfmt{tracklang} will use \ics{TeXOSQueryLocale} as a fallback if
-%\styfmt{texosquery} has been loaded. Since \sty{texosquery} requires
-%both the shell escape and the Java runtime environment,
-%\styfmt{tracklang} doesn't automatically load it.
-%
-%Plain \TeX\ example:
-%\begin{verbatim}
-%\input texosquery
-%\input tracklang
-%\TrackLangFromEnv
-%\end{verbatim}
-%with \texttt{etex -{}-shell-escape }\meta{filename}
-%
-%\LaTeX\ example:
-%\begin{verbatim}
-%\usepackage{texosquery}
-%\usepackage{tracklang}
-%\TrackLangFromEnv
-%\end{verbatim}
-%with \texttt{latex -{}-shell-escape }\meta{filename}
-%
-%If the locale can't be determined, there will be warning messages.
-%These can be suppressed using
-%\begin{definition}[\DescribeMacro\TrackLangShowWarningsfalse]
-%\cs{TrackLangShowWarningsfalse}
-%\end{definition}
-%or switched back on again using
-%\begin{definition}[\DescribeMacro\TrackLangShowWarningstrue]
-%\cs{TrackLangShowWarningstrue}
-%\end{definition}
-%
-%For example, I have the environment variable \envvar{LANG} set to 
-%\texttt{en\_GB.utf8} on my Linux system so instead of
-%\begin{verbatim}
-%\TrackPredefinedDialect{british}
-%\end{verbatim}
-%I can use
-%\begin{verbatim}
-%\TrackLangFromEnv
-%\end{verbatim}
-%
-%With \LaTeX\ documents I can do
-%\begin{verbatim}
-%\documentclass{article}
-%\usepackage{tracklang}
-%\TrackLangFromEnv
-%\end{verbatim}
-%However, this only helps subsequently loaded packages that
-%use \styfmt{tracklang} to determine the required regional 
-%settings. For example:
-%\begin{verbatim}
-%\documentclass{article}
-%\usepackage{tracklang}
-%\TrackLangFromEnv
-%\usepackage[useregional]{datetime2}
-%\end{verbatim}
-%In my case, with \envvar{LANG} set to \texttt{en\_GB.utf8} and
-%shell escape enabled, this automatically switches on the 
-%\texttt{en-GB} date style.
-%Naturally this doesn't help locale-sensitive packages that don't use
-%\styfmt{tracklang}.
-%
-%The \cs{TrackLangFromEnv} command also incidentally sets
-%\begin{definition}[\DescribeMacro\TrackLangEnv]
-%\cs{TrackLangEnv}
-%\end{definition}
-%to the value of the environment variable or empty if the
-%query was unsuccessful (for example, the shell escape is
-%unavailable).
-%
-%If \cs{TrackLangEnv} is already defined before 
-%\cs{TrackLangFromEnv} is used, then the environment variable
-%won't be queried and the value of \cs{TrackLangEnv} will be 
-%parsed instead.
-%
-%\begin{important}
-%The parser which splits the locale string into 
-%its component parts first tries splitting on the underscore
-%\texttt{\_} with its usual category code~8, then tries splitting 
-%on a hyphen \texttt{-} with category code~12, and then tries 
-%splitting on the underscore \texttt{\_} with category code~12.
-%\end{important}
-%
-%For example:
-%\begin{verbatim}
-%\def\TrackLangEnv{en-GB}
-%\TrackLangFromEnv
-%\end{verbatim}
-%This doesn't perform a shell escape since \cs{TrackLangEnv}
-%is already defined. In this case, you may just as well use
-%\begin{verbatim}
-%\TrackLocale{en-GB}
-%\end{verbatim}
-%(unless you happen to additionally require the component
-%commands that are set by \cs{TrackLangFromEnv}, see below.)
-%
-%If the shell escape is unavailable 
-%(for example, your \TeX\ installation prohibits it), you
-%can set this value when you invoke \TeX. For example,
-%if the document file is called \texttt{myDoc.tex} (and it's
-%in Plain \TeX):
-%\begin{verbatim}
-%tex "\\def\TrackLangEnv{$LANG}\\input myDoc"
-%\end{verbatim}
-%
-%The \cs{TrackLangFromEnv} command also happens to store the
-%component parts of the environment variable value in the
-%following commands. (These aren't provided by 
-%\cs{TrackLocale}.)
-%
-%The language code is stored in:
-%\begin{definition}[\DescribeMacro\TrackLangEnvLang]
-%\cs{TrackLangEnvLang}
-%\end{definition}
-%
-%The territory (if present) is stored in:
-%\begin{definition}[\DescribeMacro\TrackLangEnvTerritory]
-%\cs{TrackLangEnvTerritory}
-%\end{definition}
-%(Defined to empty if not present.)
-%
-%The codeset (if present) is stored in:
-%\begin{definition}[\DescribeMacro\TrackLangEnvCodeSet]
-%\cs{TrackLangEnvCodeSet}
-%\end{definition}
-%(Defined to empty if not present.)
-%
-%The modifier (if present) is stored in:
-%\begin{definition}[\DescribeMacro\TrackLangEnvModifier]
-%\cs{TrackLangEnvModifier}
-%\end{definition}
-%(Defined to empty if not present.)
-%
-%If you want to query the language environment, but don't
-%want to track the result, you can just use:
-%\begin{definition}[\DescribeMacro\TrackLangQueryEnv]
-%\cs{TrackLangQueryEnv}
-%\end{definition}
-%This only tries to fetch the value of the
-%language environment variable (and use \sty{texosquery} as
-%a fallback, if it has been loaded). It doesn't try to parse the 
-%result. The result is stored in \cs{TrackLangEnv} (empty if 
-%unsuccessful). Unlike \cs{TrackLangFromEnv}, this doesn't check if
-%\cs{TrackLangEnv} already exists. A warning will occur if the shell
-%escape is unavailable. For systems that store the locale information in
-%environment variables, this is more efficient than using
-%\sty{texosquery}'s \cs{TeXOSQueryLocale} command (which is what's
-%used as the fallback).
-%
-%The above queries \envvar{LC\_ALL} and, if that is unsuccessful,
-%then queries \envvar{LANG} (before optionally falling back on 
-%\sty{texosquery}). If you want another environment
-%variable tried after \envvar{LC\_ALL} and before \envvar{LANG},
-%you can instead use:
-%\begin{definition}[\DescribeMacro\TrackLangQueryOtherEnv]
-%\cs{TrackLangQueryOtherEnv}\marg{name}
-%\end{definition}
-%For example, to also query \envvar{LC\_MONETARY}:
-%\begin{verbatim}
-%\TrackLangQueryOtherEnv{LC_MONETARY}
-%\end{verbatim}
-%
-%Since this sets \cs{TrackLangEnv}, you can use it before
-%\cs{TrackLangFromEnv}. For example:
-%\begin{verbatim}
-%\TrackLangQueryOtherEnv{LC_MONETARY}
-%\TrackLangFromEnv
-%\end{verbatim}
-%Remember that if you only want to do the shell escape if
-%\cs{TrackLangEnv} hasn't already been defined, you can test for this
-%first:
-%\begin{verbatim}
-%\ifx\TrackLangEnv\undefined
-%  \TrackLangQueryOtherEnv{LC_MONETARY}
-%\fi
-%\TrackLangFromEnv
-%\end{verbatim}
-%
-%It's also possible to just parse the value of \cs{TrackLangEnv}
-%without tracking the result using:
-%\begin{definition}[\DescribeMacro\TrackLangParseFromEnv]
-%\cs{TrackLangParseFromEnv}
-%\end{definition}
-%This is like \cs{TrackLangFromEnv} but assumes that 
-%\cs{TrackLangEnv} has already been set and doesn't track the 
-%result. The component parts are stored as for \cs{TrackLangFromEnv}.
-%
-%Example (Plain \TeX):
-%\begin{verbatim}
-%\input tracklang
-%
-%\def\TrackLangEnv{fr-BE.utf8@euro}
-%
-%\TrackLangParseFromEnv
-%
-%Language: \TrackLangEnvLang.
-%Territory: \TrackLangEnvTerritory.
-%Codeset: \TrackLangEnvCodeSet.
-%Modifier: \TrackLangEnvModifier.
-%Any tracked languages? \AnyTrackedLanguages{Yes}{No}.
-%
-%\end{verbatim}
-%This produces:
-%
-%\medskip
-%
-%Language: fr. Territory: BE.  Codeset: utf8.  Modifier: euro.
-%Any tracked languages? No.
-%
-%\medskip
-%
-%Compare this with:
-%\begin{verbatim}
-%\input tracklang
-%
-%\def\TrackLangEnv{fr-BE.utf8@euro}
-%
-%\TrackLangFromEnv
-%
-%Language: \TrackLangEnvLang.
-%Territory: \TrackLangEnvTerritory.
-%Codeset: \TrackLangEnvCodeSet.
-%Modifier: \TrackLangEnvModifier.
-%Any tracked languages? \AnyTrackedLanguages{Yes}{No}.
-%Tracked dialect(s):%
-%\ForEachTrackedDialect{\thisdialect}{\space\thisdialect}.
-%\end{verbatim}
-%This produces:
-%
-%\medskip
-%
-%Language: fr. Territory: BE.  Codeset: utf8.  Modifier: euro.
-%Any tracked languages? Yes.
-%Tracked dialect(s): belgique.
-%
-%\medskip
-%
-%If \cs{TrackLangFromEnv} doesn't recognise the given language and
-%territory combination, it will define a new dialect and add that.
-%
-%For example, \styfmt{tracklang} doesn't recognise \texttt{en-BE}, so
-%the sample document below defines a new dialect labelled
-%\texttt{enBEeuro}:
-%\begin{verbatim}
-%\input tracklang
-%
-%\def\TrackLangEnv{en-BE.utf8@euro}
-%
-%\TrackLangFromEnv
-%
-%Language: \TrackLangEnvLang.
-%Territory: \TrackLangEnvTerritory.
-%Codeset: \TrackLangEnvCodeSet.
-%Modifier: \TrackLangEnvModifier.
-%Any tracked languages? \AnyTrackedLanguages{Yes}{No}.
-%Tracked dialect(s):%
-%\ForEachTrackedDialect{\thisdialect}{\space\thisdialect}.
-%\end{verbatim}
-%This now produces:
-%\medskip
-%
-%Language: en. Territory: BE.  Codeset: utf8.  Modifier: euro.
-%Any tracked languages? Yes.
-%Tracked dialect(s): enBEeuro.
-%
-%\chapter{Detecting the User's Requested Languages}
-%\label{sec:user}
-%
-%The \styfmt{tracklang} package tries to track the loaded languages and
-%the option names used to identify those languages. For want of a better
-%term, the language option names are referred to as dialects even if
-%they're only a synonym for the language rather than an actual
-%dialect.  For example, if the user
-%has requested \texttt{british}, the \emph{root language} label is
-%\texttt{english} and the dialect is \texttt{british}, whereas if the
-%user requested \texttt{UKenglish}, the root language label is
-%\texttt{english} and the dialect is \texttt{UKenglish}. The
-%exceptions to this are the \styfmt{tracklang} package options that have been
-%specified in the form \meta{iso lang}-\meta{iso country} (listed
-%in \tableref{tab:rootlangopts}). For
-%example, the package option \texttt{en-GB} behaves as though the
-%user requested the package option \texttt{british}.
-%
-%If \cs{TrackLocale} or \cs{TrackLangFromEnv} are used and the locale
-%isn't recognised a new dialect is created with the label formed from
-%the ISO codes (and modifier, if present). 
-%Similarly for \cs{TrackLanguageTag} a new
-%dialect is created with a label that's essentially the language tag
-%without the hyphen separators.  For example, 
-%\begin{verbatim}
-%\TrackLocale{xx-YY}
-%\end{verbatim}
-%will add a new dialect with the label \texttt{xxYY},
-%\begin{verbatim}
-%\TrackLocale{xx-YY@mod}
-%\end{verbatim}
-%will add a new dialect with the label \texttt{xxYYmod} and 
-%\begin{verbatim}
-%\TrackLanguageTag{xx-Latn-YY}
-%\end{verbatim}
-%will add a new dialect with the label \texttt{xxLatnYY}.
-%
-%\begin{important}
-%If \cs{TrackLocale} or \cs{TrackLangFromEnv} find a modifier, the 
-%value will be sanitized to allow it to be used as a label. If the
-%modifier is set explicitly using \cs{SetTrackedDialectModifier}, 
-%no sanitization is performed.
-%\end{important}
-%
-%In addition to the root language label and the dialect identifier,
-%many of the language options also have corresponding ISO codes. In
-%most cases there is an ISO~639-1 or an ISO~639-2 code (or both), and in some
-%cases there is an ISO~3166-1 code identifying the dialect region.
-%Where a language has both a \qt{T} and a \qt{B} ISO~639-2
-%code, the \qt{T} version is assumed.
-%
-%When the \styfmt{tracklang} \LaTeX\ package is loaded, it first attempts to find the
-%language options through the package options supplied to
-%\styfmt{tracklang}. This means that any languages that have been
-%supplied in the document class options should get identified
-%(provided that the document class has used the standard option
-%declaration mechanism).  If no languages have been supplied in this
-%way, \styfmt{tracklang} then attempts to identify any \sty{babel}
-%language options and failing that it will try the \sty{translator}
-%language options. It will then check if \sty{ngerman} or
-%\sty{polyglossia} have been loaded.
-%
-%Each identified language and dialect is added to the \emph{tracked
-%language} and \emph{tracked dialect} lists. Note that the tracked
-%language and tracked dialect are labels rather than proper nouns.
-%If a~dialect label is identical to its root language label, the
-%label will appear in both lists.
-%
-%You can check whether or not any languages have been detected using:
-%\begin{definition}[\DescribeMacro\AnyTrackedLanguages]
-%\cs{AnyTrackedLanguages}\marg{true part}\marg{false part}
-%\end{definition}
-%This will do \meta{true part} if one or more languages have been
-%detected otherwise it will do \meta{false part}. (Each detected
-%dialect will automatically have the root language label added
-%to the tracked language list, if it's not already present.)
-%
-%If you want to find out if any of the tracked dialects
-%matches a particular language tag, you can use:
-%\begin{definition}[\DescribeMacro\GetTrackedDialectFromLanguageTag]
-%\ics{GetTrackedDialectFromLanguageTag}\marg{tag}\marg{cs}
-%\end{definition}
-%If successful, the supplied control sequence \meta{cs} is set to the
-%dialect label, otherwise \meta{cs} is set to empty. The test is for an exact
-%match on the root language, script, sub-language, variant and
-%region. The control sequence \meta{cs} will be empty if none of the
-%tracked dialects matches all five of those elements. (If the script
-%isn't given explicitly, the default for that language is assumed.)
-%In the event that \meta{cs} is empty, you can now (as from v1.3.6)
-%get the closest match with
-%\begin{definition}[\DescribeMacro\TrackedDialectClosestSubMatch]
-%\ics{TrackedDialectClosestSubMatch}
-%\end{definition}
-%(which is set by \cs{GetTrackedDialectFromLanguageTag}).
-%This will be empty if no tracked dialects match on the root
-%language or if there's a tracked dialect label that exactly matches
-%the label formed by concatenating the language code, sub-language,
-%script, region, modifier and variant.
-%
-%For example (Plain \TeX):
-%\begin{verbatim}
-%\input tracklang
-%\TrackLanguageTag{en-826}
-%Has en-Latn-GB been tracked?
-%\GetTrackedDialectFromLanguageTag{en-Latn-GB}{\thisdialect}%
-%\ifx\thisdialect\empty
-% No!
-%\else
-% Yes! Dialect label: \thisdialect.
-%\fi
-%\bye
-%\end{verbatim}
-%This matches because the territory code 826 is recognised as
-%equivalent to the code GB, and the default script for
-%\texttt{english} is \texttt{Latn}. In this case, the dialect
-%label is \texttt{british}. Note that this doesn't require
-%the use of \cs{TrackLanguageTag} to track the dialect. 
-%It also works if the dialect has been tracked using other commands,
-%such as \cs{TrackLocale}.
-%
-%Here's an example that doesn't have an exact match, but does have a
-%partial match:
-%\begin{verbatim}
-%\input tracklang
-%\TrackLanguageTag{de-CH-1996}
-%Has de-DE-1996 been tracked?
-%\GetTrackedDialectFromLanguageTag{de-DE-1996}{\thisdialect}%
-%\ifx\thisdialect\empty
-% No!
-%  \ifx\TrackedDialectClosestSubMatch\empty
-%    No match on root language.
-%  \else
-%    Closest match: \TrackedDialectClosestSubMatch.
-%  \fi
-%\else
-% Yes! Dialect label: \thisdialect.
-%\fi
-%\bye
-%\end{verbatim}
-%In this case the result is:
-%\begin{quote}
-%Has de-DE-1996 been tracked? No! Closest match: nswissgerman.
-%\end{quote}
-%
-%You can iterate through each tracked dialect using:
-%\begin{definition}[\DescribeMacro\ForEachTrackedDialect]
-%\cs{ForEachTrackedDialect}\marg{cs}\marg{code}
-%\end{definition}
-%At the start of each iteration, this sets the control sequence 
-%\meta{cs} to the tracked dialect and does \meta{code}.
-%
-%You can iterate through each tracked language using:
-%\begin{definition}[\DescribeMacro\ForEachTrackedLanguage]
-%\cs{ForEachTrackedLanguage}\marg{cs}\marg{code}
-%\end{definition}
-%At the start of each iteration, this sets the control sequence \meta{cs} to the 
-%tracked language and does \meta{code}.
-%
-%The above for-loops use the same internal mechanism as \LaTeX's
-%\cs{@for} loop. The provided control sequence \meta{cs} is updated at the
-%start of each iteration to the current element. The loop is
-%terminated when this control sequence is set to \cs{@nil}. This
-%special control sequence should never been used as it's just a
-%marker and isn't actually defined. If you get an error message
-%stating that \cs{@nil} is undefined, then it's most likely due to a
-%loop control sequence being used outside the loop. This can occur if
-%the loop contains code that isn't expanded until later. For example,
-%if the loop code includes \cs{AtBeginDocument}, you need to ensure
-%that the loop control sequence is expanded before being added to the
-%hook.
-%
-%You can test if a root language has been detected using:
-%\begin{definition}[\DescribeMacro\IfTrackedLanguage]
-%\cs{IfTrackedLanguage}\marg{label}\marg{true part}\marg{false part}
-%\end{definition}
-%where \meta{label} is the language label. If
-%true, this does \meta{true part} otherwise it does \meta{false
-%part}.
-%
-%You can test if a particular dialect has been detected using:
-%\begin{definition}[\DescribeMacro\IfTrackedDialect]
-%\cs{IfTrackedDialect}\marg{label}\marg{true part}\marg{false part}
-%\end{definition}
-%where \meta{label} is the dialect label. If the root language was explicitly specified, then it will
-%also be detected as a dialect.
-%
-%For example:
-%\begin{verbatim}
-%\documentclass[british,dutch]{article}
-%
-%\usepackage{tracklang}
-%
-%\begin{document}
-%``english'' \IfTrackedDialect{english}{has}{hasn't} been specified.
-%
-%``british'' \IfTrackedDialect{british}{has}{hasn't} been specified.
-%
-%``flemish'' \IfTrackedDialect{flemish}{has}{hasn't} been specified.
-%
-%``dutch'' \IfTrackedDialect{dutch}{has}{hasn't} been specified.
-%
-%``english'' or an English variant 
-%\IfTrackedLanguage{english}{has}{hasn't} been specified.
-%
-%\end{document}
-%\end{verbatim}
-%This produces:
-%\begin{quote}
-%``english'' hasn't been specified.
-%
-%``british'' has been specified.
-%
-%``flemish'' hasn't been specified.
-%
-%``dutch'' has been specified.
-%
-%``english'' or an English variant has been specified.
-%\end{quote}
-%
-%You can find the root language label for a given tracked dialect
-%using:
-%\begin{definition}[\DescribeMacro\TrackedLanguageFromDialect]
-%\cs{TrackedLanguageFromDialect}\marg{dialect}
-%\end{definition}
-%If \meta{dialect} hasn't been defined this does nothing otherwise it
-%expands to the root language label.
-%
-%You can find the tracked dialects from a given root language
-%using:
-%\begin{definition}[\DescribeMacro\TrackedDialectsFromLanguage]
-%\cs{TrackedDialectsFromLanguage}\marg{root language label}
-%\end{definition}
-%This will expand to a~comma-separated list of dialect labels
-%if the root language label has been defined, otherwise it
-%does nothing.
-%
-%
-%You can test if a language or dialect has a corresponding ISO code using:
-%\begin{definition}[\DescribeMacro\IfTrackedLanguageHasIsoCode]
-%\cs{IfTrackedLanguageHasIsoCode}\marg{code
-%type}\marg{label}\marg{true part}\marg{false part}
-%\end{definition}
-%where \meta{code type} is the type of ISO code (for example,
-%\texttt{639-1} for root languages or \texttt{3166-1} for regional
-%dialects), and \meta{label} is the language or dialect label.
-%Note that the \texttt{639-3} may be set for the dialect
-%rather than root language for sub-languages parsed using
-%\ics{TrackLanguageTag}.
-%
-%Alternatively, you can test if a particular ISO code has been
-%defined using:
-%\begin{definition}[\DescribeMacro\IfTrackedIsoCode]
-%\cs{IfTrackedIsoCode}\marg{code type}\marg{code}\marg{true
-%part}\marg{false part}
-%\end{definition}
-%where \meta{code type} is again the type of ISO code (for example,
-%\texttt{639-1} or \texttt{3166-1}), and \meta{code} is the
-%particular code (for example, \texttt{en} for ISO 639-1 or
-%\texttt{GB} for ISO 3166-1).
-%
-%You can fetch the language (or dialect) label associated with a
-%given ISO code using:
-%\begin{definition}[\DescribeMacro\TrackedLanguageFromIsoCode]
-%\cs{TrackedLanguageFromIsoCode}\marg{code type}\marg{code}
-%\end{definition}
-%This does nothing if the given \meta{code} for the given ISO
-%\meta{code type} has not been defined, otherwise it expands
-%a~comma-separated list of language or dialect labels.
-%
-%You can fetch the ISO code for a given code type using:
-%\begin{definition}[\DescribeMacro\TrackedIsoCodeFromLanguage]
-%\cs{TrackedIsoCodeFromLanguage}\marg{code type}\marg{label}
-%\end{definition}
-%where \meta{label} is the language or dialect label and \meta{code
-%type} is the ISO code type (for example, \texttt{639-1} or
-%\texttt{3166-1}). Unlike \ics{TrackedLanguageFromIsoCode}, this
-%command only expands to a single label rather than a~comma-separated
-%list.
-%
-%The above commands do nothing in the event of an unknown code or
-%code type,
-%so if you accidentally get the wrong code type, you won't get an error.
-%If you're unsure of the code type, you can use the following commands:
-%\begin{definition}[\DescribeMacro\TwoLetterIsoCountryCode]
-%\cs{TwoLetterIsoCountryCode}
-%\end{definition}
-%This expands to 3166-1 and is used for the two-letter country codes.
-%
-%\begin{definition}[\DescribeMacro\TwoLetterIsoLanguageCode]
-%\cs{TwoLetterIsoLanguageCode}
-%\end{definition}
-%This expands to 639-1 and is used for the two-letter root language codes.
-%
-%\begin{definition}[\DescribeMacro\ThreeLetterIsoLanguageCode]
-%\cs{ThreeLetterIsoLanguageCode}
-%\end{definition}
-%This expands to 639-2 and is used for the three-letter root language
-%codes.
-%
-%\begin{definition}[\DescribeMacro\ThreeLetterExtIsoLanguageCode]
-%\cs{ThreeLetterExtIsoLanguageCode}
-%\end{definition}
-%(New to v1.3.) This expands to 639-3. This code is only used for a root language if 
-%there's no 639-1 or 639-2 code. It may also be used for a
-%dialect if a sub-language part has been set in the language
-%tag parsed by \cs{TrackLanguageTag}.
-%
-%The \cs{Get\ldots} commands below are designed to be expandable.
-%If the supplied \meta{dialect} is unrecognised they expand to empty.
-%Remember that the dialect must first be identified as a tracked 
-%language for it to be recognised.
-%
-%As from v1.3, the language tag for a given dialect can be obtained
-%using:
-%\begin{definition}[\DescribeMacro\GetTrackedLanguageTag]
-%\cs{GetTrackedLanguageTag}\marg{dialect}
-%\end{definition}
-%where \meta{dialect} is the label identifying the dialect.
-%Uses the \texttt{und} (undetermined) code for unknown languages.
-%
-%As from v1.3, each tracked dialect may also have an associated 
-%modifier, which can be fetched using:
-%\begin{definition}[\DescribeMacro\GetTrackedDialectModifier]
-%\cs{GetTrackedDialectModifier}\marg{dialect}
-%\end{definition}
-%where \meta{dialect} is the label identifying the dialect.
-%This value is typically obtained by parsing a POSIX locale identifier
-%with \cs{TrackLocale} or \cs{TrackLangFromEnv} but may be set explicitly.
-%(See \sectionref{sec:langsty} for setting this value. Likewise for
-%the following commands.)
-%
-%You can test if a dialect has an associated modifier using:
-%\begin{definition}[\DescribeMacro\IfHasTrackedDialectModifier]
-%\cs{IfHasTrackedDialectModifier}\marg{dialect}\marg{true}\marg{false}
-%\end{definition}
-%If the dialect has an associated modifier this does \meta{true}
-%otherwise it does \meta{false}.
-%
-%For example:
-%\begin{verbatim}
-%\documentclass[british,francais,american,canadian,canadien,dutch]{article}
-%
-%\usepackage{tracklang}
-%
-%\begin{document}
-%
-%Languages: \ForEachTrackedLanguage{\ThisLanguage}{\ThisLanguage\space
-%(ISO \TwoLetterIsoLanguageCode: 
-%``\TrackedIsoCodeFromLanguage{\TwoLetterIsoLanguageCode}{\ThisLanguage}''). }
-%
-%Dialects: \ForEachTrackedDialect{\ThisDialect}{\ThisDialect\space 
-%(\IfTrackedLanguageHasIsoCode{\TwoLetterIsoCountryCode}{\ThisDialect}%
-% {ISO \TwoLetterIsoCountryCode: 
-%  ``\TrackedIsoCodeFromLanguage{\TwoLetterIsoCountryCode}{\ThisDialect}''}%
-% {no specific region};
-%root: \TrackedLanguageFromDialect{\ThisDialect}). }
-%
-%Language for ISO \TwoLetterIsoCountryCode\ ``GB'':
-%\TrackedLanguageFromIsoCode{\TwoLetterIsoCountryCode}{GB}.
-%
-%Language for ISO \TwoLetterIsoCountryCode\ ``CA'': 
-%\TrackedLanguageFromIsoCode{\TwoLetterIsoCountryCode}{CA}.
-%
-%Country ISO \TwoLetterIsoCountryCode\ code for ``canadian'':
-%\TrackedIsoCodeFromLanguage{\TwoLetterIsoCountryCode}{canadian}.
-%
-%\end{document}
-%\end{verbatim}
-%This produces:
-%\begin{quote}
-%Languages: english (ISO 639-1: ``en''). french (ISO 639-1: ``fr'').
-%dutch (ISO 639-1: ``nl'').
-%
-%Dialects: american (ISO 3166-1: ``US''; root: english).
-%british (ISO 3166-1: ``GB''; root: english).
-%canadian (ISO 3166-1: ``CA''; root: english).
-%canadien (ISO 3166-1: ``CA''; root: french).
-%dutch (no specific region; root: dutch).
-%francais (no specific region; root: french).
-%
-%Language for ISO 3166-1 ``GB'': british.
-%
-%Language for ISO 3166-1 ``CA'': canadian,canadien.
-%
-%Country ISO 3166-1 code for ``canadian'': CA.
-%
-%\end{quote}
-%
-%As from v1.3, each tracked dialect may also have an associated 
-%variant, which can be fetched using:
-%\begin{definition}[\DescribeMacro\GetTrackedDialectVariant]
-%\cs{GetTrackedDialectVariant}\marg{dialect}
-%\end{definition}
-%where \meta{dialect} is the label identifying the dialect.
-%This value is typically obtained by parsing a language tag
-%with \cs{TrackLanguageTag} but may be set explicitly.
-%
-%You can test if a dialect has an associated variant using:
-%\begin{definition}[\DescribeMacro\IfHasTrackedDialectVariant]
-%\cs{IfHasTrackedDialectVariant}\marg{dialect}\marg{true}\marg{false}
-%\end{definition}
-%
-%As from v1.3, each tracked dialect may also have an associated 
-%script, which can be fetched using:
-%\begin{definition}[\DescribeMacro\GetTrackedDialectScript]
-%\cs{GetTrackedDialectScript}\marg{dialect}
-%\end{definition}
-%where \meta{dialect} is the label identifying the dialect.
-%
-%You can test if a dialect has an associated script using:
-%\begin{definition}[\DescribeMacro\IfHasTrackedDialectScript]
-%\cs{IfHasTrackedDialectScript}\marg{dialect}\marg{true}\marg{false}
-%\end{definition}
-%If the dialect has an associated script this does \meta{true}
-%otherwise it does \meta{false}. This information is provided
-%for language packages that need to know what script is required,
-%but there's no guarantee that the script will actually be set
-%in the document. Similarly for all the other attributes described
-%here.
-%
-%Note that the script should be a recognised four-letter ISO 15924
-%code, such as \texttt{Latn} or \texttt{Cyrl}. If a~dialect
-%doesn't have an associated script then the default for the root
-%language should be assumed. For example, \qt{Latn} for English dialects or
-%\qt{Cyrl} for Russian dialects. (The default script for
-%known languages can be obtained using
-%\cs{TrackLangGetDefaultScript}, see
-%\sectionref{sec:code:knownlangs} for further details.
-%Most root languages have a default script, but there
-%are a few without one as it may depend on region, politics
-%or ideology.)
-%
-%There's a convenient expandable command for testing the script:
-%\begin{definition}
-%\cs{IfTrackedDialectIsScriptCs}\marg{dialect}\marg{cs}\marg{true}\marg{false}
-%\end{definition}
-%This tests if the given tracked dialect has an associated script and
-%compares the value with the replacement text of \meta{cs}.
-%If the dialect hasn't been explicitly assigned a script,
-%then test is performed against the default script for the root
-%language.
-%
-%The supplementary package \sty{tracklang-scripts} provides some
-%additional commands relating to writing systems, including commands 
-%in the form \ics{TrackLangScript\meta{code}} where
-%\meta{code} is the ISO 15924 four-letter code. If the dialect
-%doesn't have an associated script, \meta{false} is done.
-%This package isn't
-%loaded automatically, so you'll need to explicitly load it. The
-%generic code is in \texttt{tracklang-scripts.tex}:
-%\begin{verbatim}
-%\input tracklang-scripts
-%\end{verbatim}
-%There's a convenient \LaTeX\ wrapper \texttt{tracklang-scripts.sty}:
-%\begin{verbatim}
-%\usepackage{tracklang-scripts}
-%\end{verbatim}
-%See \sectionref{sec:tracklang-scripts.tex} for further details of
-%that package.
-%
-%For example, the following defines a command to check if
-%the given dialect should use a Latin script:
-%\begin{verbatim}
-%\input tracklang-scripts
-%\def\islatin#1#2#3{%
-%  \IfTrackedDialectIsScriptCs{#1}{\TrackLangScriptLatn}{#2}{#3}%
-%}
-%\end{verbatim}
-%
-%\begin{important}
-%Note that the script value doesn't mean that the document is
-%actually using that script. It means that this is the user's
-%\emph{desired} script, but whether that script is actually set relies
-%on the appropriate settings in the relevant language package (such
-%as \sty{polyglossia}'s \texttt{script} key).
-%\end{important}
-%
-%As from v1.3, each tracked dialect may also have a sub-language
-%identifier (for example, \texttt{arevela}), which can be fetched
-%using:
-%\begin{definition}[\DescribeMacro\GetTrackedDialectSubLang]
-%\cs{GetTrackedDialectSubLang}\marg{dialect}
-%\end{definition}
-%where \meta{dialect} is the label identifying the dialect.
-%
-%You can test if a dialect has an associated sub-tag using:
-%\begin{definition}[\DescribeMacro\IfHasTrackedDialectSubLang]
-%\cs{IfHasTrackedDialectSubLang}\marg{dialect}\marg{true}\marg{false}
-%\end{definition}
-%If the dialect has an associated sub-tag this does \meta{true}
-%otherwise it does \meta{false}.
-%
-%As from v1.3, each tracked dialect may also have additional
-%information, which can be fetched using:
-%\begin{definition}[\DescribeMacro\GetTrackedDialectAdditional]
-%\cs{GetTrackedDialectAdditional}\marg{dialect}
-%\end{definition}
-%where \meta{dialect} is the label identifying the dialect.
-%
-%You can test if a dialect has additional information using:
-%\begin{definition}[\DescribeMacro\IfHasTrackedDialectAdditional]
-%\cs{IfHasTrackedDialectAdditional}\marg{dialect}\marg{true}\marg{false}
-%\end{definition}
-%If the dialect has additional information this does \meta{true}
-%otherwise it does \meta{false}.
-%
-%
-%Most packages that implement multilingual support have a~set of
-%language definition files for each supported language or dialect.
-%It may be that only the root language is needed, if there are no
-%variations between that language's dialect (for the purposes of that
-%package), or it may be that separate definition files are required
-%for each dialect. However it can be awkward trying to map the
-%requested dialect or language label to the file name. Should, say,
-%the file containing the French code be called
-%\meta{prefix}\texttt{-french-}\meta{suffix} or 
-%\meta{prefix}\texttt{-frenchb-}\meta{suffix} or 
-%\meta{prefix}\texttt{-francais-}\meta{suffix}?
-%Should, say, the file containing the British English code be called
-%\meta{prefix}\texttt{-british-}\meta{suffix} or 
-%\meta{prefix}\texttt{-UKenglish-}\meta{suffix}?
-%If you want to modularise the language support for your package so
-%that each language module has a different maintainer will the
-%maintainers know what tag to use for their language?
-%
-%\label{pg:filesearch}To help with this, \styfmt{tracklang} provides:
-%\begin{definition}
-%\ics{IfTrackedLanguageFileExists}\marg{dialect}\marg{prefix}\marg{suffix}\marg{true part}\marg{false part}
-%\end{definition}
-%This attempts to find the file called
-%\meta{prefix}\meta{localeid}\meta{suffix} where \meta{localeid} is determined
-%from \meta{dialect} (see below). If the file is found
-%\begin{definition}
-%\ics{CurrentTrackedTag}
-%\end{definition}
-%is set to \meta{localeid} and \meta{true part} is done, otherwise
-%\meta{false part} is done.  If this command
-%is empty, then the dialect hasn't been detected. If the dialect
-%has been detected, but no file can be found, then
-%\ics{CurrentTrackedTag} is set to the final attempt at determining
-%\meta{localeid}.
-%
-%There's a convenient shortcut command new to version 1.3:
-%\begin{definition}[\DescribeMacro\TrackLangRequireDialect]
-%\cs{TrackLangRequireDialect}\oarg{load code}\marg{pkgname}\marg{dialect}
-%\end{definition}
-%which uses \cs{IfTrackedLanguageFileExists} to input the resource
-%file if found. The prefix is given by \meta{pkgname}\texttt{-} and
-%the suffix is \texttt{.ldf}. A warning is issued if no resource file
-%is found. Note that while it makes sense for \meta{pkgname}
-%to be the same as the base name of the package that uses these
-%resource files, they don't have to be the same. This command
-%additionally defines
-%\begin{definition}[\DescribeMacro\TrackLangRequireDialectPrefix]
-%\cs{TrackLangRequireDialectPrefix}
-%\end{definition}
-%to \meta{pkgname}, which allows the prefix to be picked up by
-%resource file commands, such as \cs{TrackLangProvidesResource}
-%and \cs{TrackLangRequireResource}.  (See below.)
-%
-%The optional argument \meta{load code} is the code that actually
-%inputs the required file. This defaults to
-%\begin{verbatim}
-%\TrackLangRequireResource{\CurrentTrackedTag}
-%\end{verbatim}
-%
-%
-%The \ics{IfTrackedLanguageFileExists} command sets up the current
-%tracked dialect with
-%\ics{SetCurrentTrackedDialect}\marg{dialect}, which enables the following
-%commands that may be used within \meta{true part} or \meta{false
-%part}:
-%\begin{definition}
-%\ics{CurrentTrackedDialect}
-%\end{definition}
-%The dialect label.
-%
-%\begin{definition}
-%\ics{CurrentTrackedLanguage}
-%\end{definition}
-%If the dialect hasn't been detected, this command will be empty,
-%otherwise it will expand to the root language label (which may
-%be the same as the dialect label).
-%
-%\begin{definition}
-%\ics{CurrentTrackedRegion}
-%\end{definition}
-%If the dialect hasn't been detected, this command will be empty.
-%If the dialect has been assigned an ISO~3166-1 code,
-%\ics{CurrentTrackedRegion} will expand to that code, otherwise it
-%will be empty.
-%
-%\begin{definition}
-%\ics{CurrentTrackedIsoCode}
-%\end{definition}
-%If the dialect hasn't been detected, this command will be empty.
-%Otherwise it may be empty or it may expand to the
-%ISO~639-1 or ISO~639-2 or ISO~639-3 code.
-%
-%\begin{definition}
-%\ics{CurrentTrackedDialectModifier}
-%\end{definition}
-%The dialect's modifier or empty if not set. (This is set but not
-%used in the set of possible \meta{localeid} values.)
-%
-%\begin{definition}
-%\ics{CurrentTrackedDialectVariant}
-%\end{definition}
-%The dialect's variant or empty if not set.
-%
-%\begin{definition}
-%\ics{CurrentTrackedDialectSubTag}
-%\end{definition}
-%The dialect's sub-language code or empty if not set.
-%
-%\begin{definition}
-%\ics{CurrentTrackedDialectAdditional}
-%\end{definition}
-%The dialect's additional information or empty if not set.
-%
-%\begin{definition}
-%\ics{CurrentTrackedLanguageTag}
-%\end{definition}
-%The dialect's language tag. Take care not to confuse this
-%with \cs{CurrentTrackedTag}.
-%
-%\begin{definition}
-%\ics{CurrentTrackedDialectScript}
-%\end{definition}
-%The dialect's script. If the dialect doesn't have the script set,
-%the default script for the language is used instead.
-%
-%\cs{IfTrackedLanguageFileExists} behaves as follows:
-%\begin{itemize}
-% \item If no dialect with the given label has been
-%  detected, the condition evaluates to \emph{false} and
-% \ics{CurrentTrackedTag} is empty.
-% \item If a dialect with the given label has been detected, then:
-% \begin{itemize}
-% \item For each possible \meta{localeid} in an ordered set of tags determined by
-%   the dialect label (see below), the first file matching
-%   \meta{prefix}\meta{localeid}\meta{suffix} that's found on
-%   \TeX's path results in the condition evaluating to \emph{true} and
-%   \ics{CurrentTrackedTag} is set to the current \meta{localeid} in the
-%   set. The rest of the set of possible values of \meta{localeid} is skipped.
-% \item If no file matching \meta{prefix}\meta{localeid}\meta{suffix} is
-%   found on \TeX's path, then the condition evaluates to \emph{false}
-%   and \ics{CurrentTrackedTag} is set to the final \meta{localeid} in the
-%   set (the language label).
-% \end{itemize}
-%\end{itemize}
-%
-%The ordered set of possible values of \meta{localeid} is determined from
-%the given dialect.
-%\begin{important}
-%The ordering has changed in version 1.4, which now also includes the
-%script and variant. This new ordering should typically make the more
-%common combinations closer to the start of the search.
-%\end{important}
-%The possible values of \meta{localeid} are listed below in the order of priority used
-%by \cs{IfTrackedLanguageFileExists}. Note that the set may contain
-%repetitions (for example, if the dialect label is the same as the
-%root language label). If an item contains an element that hasn't
-%been set (such as the ISO~639-3 code or a sub-language \meta{sublang} or variant) then
-%that item is skipped.
-%\begin{enumerate}
-%\item \meta{localeid} is just the value of \ics{CurrentTrackedLanguageTag}.
-%\item \meta{localeid} is just the dialect label.
-%
-%\item \meta{localeid} is
-%\meta{ISO~639-1}\texttt{-}\meta{sublang}\texttt{-}\meta{script}\texttt{-}\meta{region}.
-%\item \meta{localeid} is
-%\meta{ISO~639-1}\texttt{-}\meta{script}\texttt{-}\meta{region}.
-%\item \meta{localeid} is
-%\meta{ISO~639-1}\texttt{-}\meta{sublang}\texttt{-}\meta{region} (if there's no script or if
-%the script is the default for the given language).
-%\meta{ISO~639-1}\texttt{-}\meta{region} (if there's no script or if
-%the script is the default for the given language).
-%\item \meta{localeid} is
-%\meta{ISO~639-1}\texttt{-}\meta{sublang}\texttt{-}\meta{script}.
-%\item \meta{localeid} is
-%\meta{ISO~639-1}\texttt{-}\meta{script}.
-%\item \meta{localeid} is \meta{ISO~639-1}\texttt{-}\meta{sublang}.
-%\item \meta{localeid} is just \meta{ISO~639-1}.
-%
-%\item \meta{localeid} is
-%\meta{ISO~639-2}\texttt{-}\meta{sublang}\texttt{-}\meta{script}\texttt{-}\meta{region}.
-%\item \meta{localeid} is
-%\meta{ISO~639-2}\texttt{-}\meta{script}\texttt{-}\meta{region}.
-%\item \meta{localeid} is
-%\meta{ISO~639-2}\texttt{-}\meta{sublang}\texttt{-}\meta{region} (if there's no script or if
-%the script is the default for the given language).
-%\meta{ISO~639-2}\texttt{-}\meta{region} (if there's no script or if
-%the script is the default for the given language).
-%\item \meta{localeid} is
-%\meta{ISO~639-2}\texttt{-}\meta{sublang}\texttt{-}\meta{script}.
-%\item \meta{localeid} is
-%\meta{ISO~639-2}\texttt{-}\meta{script}.
-%\item \meta{localeid} is \meta{ISO~639-2}\texttt{-}\meta{sublang}.
-%\item \meta{localeid} is just \meta{ISO~639-2}.
-%
-%\item \meta{localeid} is
-%\meta{ISO~639-3}\texttt{-}\meta{sublang}\texttt{-}\meta{script}\texttt{-}\meta{region}.
-%\item \meta{localeid} is
-%\meta{ISO~639-3}\texttt{-}\meta{script}\texttt{-}\meta{region}.
-%\item \meta{localeid} is
-%\meta{ISO~639-3}\texttt{-}\meta{sublang}\texttt{-}\meta{region} (if there's no script or if
-%the script is the default for the given language).
-%\meta{ISO~639-3}\texttt{-}\meta{region} (if there's no script or if
-%the script is the default for the given language).
-%\item \meta{localeid} is
-%\meta{ISO~639-3}\texttt{-}\meta{sublang}\texttt{-}\meta{script}.
-%\item \meta{localeid} is
-%\meta{ISO~639-3}\texttt{-}\meta{script}.
-%\item \meta{localeid} is \meta{ISO~639-3}\texttt{-}\meta{sublang}.
-%\item \meta{localeid} is just \meta{ISO~639-3}.
-%
-%\item \meta{localeid} is just \meta{region}.
-%
-%\item \meta{localeid} is
-%\meta{ISO~639-1}\texttt{-}\meta{sublang}\texttt{-}\meta{variant}
-%or \meta{ISO~639-1}\texttt{-}\meta{variant} if \meta{sublang} is missing.
-%
-%\item \meta{localeid} is
-%\meta{ISO~639-2}\texttt{-}\meta{sublang}\texttt{-}\meta{variant}
-%or \meta{ISO~639-2}\texttt{-}\meta{variant} if \meta{sublang} is missing.
-%
-%\item \meta{localeid} is
-%\meta{ISO~639-3}\texttt{-}\meta{sublang}\texttt{-}\meta{variant}
-%or \meta{ISO~639-3}\texttt{-}\meta{variant} if \meta{sublang} is missing.
-%
-%\item \meta{localeid} is just the value of \ics{CurrentTrackedLanguage}
-%(the root language label).
-%\end{enumerate}
-%
-%For example (pre v1.3):
-%\begin{verbatim}
-%\AnyTrackedLanguages
-%{%
-%  \ForEachTrackedDialect{\ThisDialect}%
-%  {% try to load the language file for this dialect
-%    \IfTrackedLanguageFileExists{\ThisDialect}%
-%    {mypackage-}% file prefix
-%    {.ldf}% file suffix
-%    {\input mypackage-\CurrentTrackedTag.ldf}% file found
-%    {% file not found
-%      \PackageWarning{mypackage}{No support for language
-%       `\ThisDialect'}%
-%    }%
-%  }%
-%}
-%{% no languages detected so use defaults
-%}
-%\end{verbatim}
-%With version 1.3 onwards, this can be written more concisely as:
-%\begin{verbatim}
-%\AnyTrackedLanguages
-%{%
-%  \ForEachTrackedDialect{\ThisDialect}%
-%  {% try to load the language file for this dialect
-%    \TrackLangRequireDialect{mypackage}{\ThisDialect}%
-%  }%
-%}
-%{% no languages detected so use defaults
-%}
-%\end{verbatim}
-%which additionally enables the \styfmt{tracklang} version 1.3 commands described below,
-%such as \cs{TrackLangRequireResource}.
-%
-%If, for example, \ics{ThisDialect} is \texttt{british}, then the file search will
-%be in the order:
-%\begin{enumerate}
-%\item \texttt{mypackage-en-GB.ldf} (language tag)
-%\item \texttt{mypackage-british.ldf} (dialect label)
-%
-%\item \texttt{mypackage-en-Latn-GB.ldf} (639-1 language code, script, region)
-%\item \texttt{mypackage-en-GB.ldf} (639-1 language code, region)
-%\item \texttt{mypackage-en-Latn.ldf} (639-1 language code, script)
-%\item \texttt{mypackage-en.ldf} (639-1 language code)
-%
-%\item \texttt{mypackage-eng-Latn-GB.ldf} (639-2 language code, script, region)
-%\item \texttt{mypackage-eng-GB.ldf} (639-2 language code, region)
-%\item \texttt{mypackage-eng-Latn.ldf} (639-2 language code, script)
-%\item \texttt{mypackage-eng.ldf} (639-2 language code)
-%
-%\item \texttt{mypackage-GB.ldf} (region)
-%\item \texttt{mypackage-english.ldf} (language label)
-%\end{enumerate}
-%
-%If, for example, \ics{ThisDialect} is \texttt{naustrian}, then the file search will
-%be in the order:
-%\begin{enumerate}
-%\item \texttt{mypackage-de-AT-1996.ldf} (language tag)
-%\item \texttt{mypackage-naustrian.ldf} (dialect label)
-%
-%\item \texttt{mypackage-de-Latn-AT.ldf} (639-1 language code, script, region)
-%\item \texttt{mypackage-de-AT.ldf} (639-1 language code, region)
-%\item \texttt{mypackage-de-Latn.ldf} (639-1 language code, script)
-%\item \texttt{mypackage-de.ldf} (639-1 language code)
-%
-%\item \texttt{mypackage-deu-Latn-AT.ldf} (639-2 language code, script, region)
-%\item \texttt{mypackage-deu-AT.ldf} (639-2 language code, region)
-%\item \texttt{mypackage-deu-Latn.ldf} (639-2 language code, script)
-%\item \texttt{mypackage-deu.ldf} (639-2 language code)
-%
-%\item \texttt{mypackage-AT.ldf} (region)
-%
-%\item \texttt{mypackage-de-1996.ldf} (639-1 language code, variant)
-%\item \texttt{mypackage-deu-1996.ldf} (639-2 language code, variant)
-%
-%\item \texttt{mypackage-german.ldf} (language label)
-%\end{enumerate}
-%
-%If, for example, \ics{ThisDialect} is \texttt{francais}, then the file search will
-%be in the order: 
-%\begin{enumerate}
-%\item \texttt{mypackage-fr.ldf} (language tag)
-%\item \texttt{mypackage-francais.ldf} (dialect label)
-%\item \texttt{mypackage-fr-Latn.ldf} (639-1 language code, script)
-%\item \texttt{mypackage-fr.ldf} (639-1 language code)
-%\item \texttt{mypackage-fra-Latn.ldf} (639-2 language code, script)
-%\item \texttt{mypackage-fra.ldf} (639-2 language code)
-%\item \texttt{mypackage-french.ldf} (language)
-%\end{enumerate}
-%This is because the predefined \texttt{francais} option has no
-%region assigned to it. Be careful if the dialect label is the actual
-%root language. For example, if \cs{ThisDialect} is \texttt{french},
-%then the file search will be in the order:
-%\begin{enumerate}
-%\item \texttt{mypackage-fr.ldf} (language tag)
-%\item \texttt{mypackage-french.ldf} (dialect label)
-%\item \texttt{mypackage-fr-Latn.ldf} (639-1 language code, script)
-%\item \texttt{mypackage-fr.ldf} (639-1 language code)
-%\item \texttt{mypackage-fra-Latn.ldf} (639-2 language code, script)
-%\item \texttt{mypackage-fra.ldf} (639-2 language code)
-%\item \texttt{mypackage-french.ldf} (language)
-%\end{enumerate}
-%Note that the last try will always fail in this case since if the
-%file exists, it will be found on the second try.
-%
-%If the dialect label is identical to the root language label then it
-%means that all associated information is the default
-%for that language. For example, in the above case of \texttt{french},
-%the script is \texttt{Latn} and the region is unspecified. The root
-%language label can therefore be used as the fallback in the event of
-%no other match but for the specific case where the dialect is
-%identical to the root language then all unnecessary file name checks
-%can be skipped.
-%
-%If you're only providing support for the root languages (pre v1.3):
-%\begin{verbatim}
-%\AnyTrackedLanguages
-%{%
-%  \ForEachTrackedLanguage{\ThisLanguage}%
-%  {% try to load the language file for this root language
-%    \IfTrackedLanguageFileExists{\ThisLanguage}%
-%    {mypackage-}% file prefix
-%    {.ldf}% file suffix
-%    {\input mypackage-\CurrentTrackedTag.ldf}% file found
-%    {% file not found
-%      \PackageWarning{mypackage}{No support for language
-%       `\ThisLanguage'}%
-%    }%
-%  }%
-%}
-%{% no languages detected so use defaults
-%}
-%\end{verbatim}
-%With version 1.3 onwards, this can be written more concisely as:
-%\begin{verbatim}
-%\AnyTrackedLanguages
-%{%
-%  \ForEachTrackedLanguage{\ThisLanguage}%
-%  {% try to load the language file for this root language
-%    \TrackLangRequireDialect{mypackage}{\ThisLanguage}%
-%  }%
-%}
-%{% no languages detected so use defaults
-%}
-%\end{verbatim}
-%which additionally enables the commands described below.
-%Note that in this case, if more than one dialect for the same
-%language has been tracked, only the hooks for the last dialect for
-%that language will be adjusted, so it's usually best to iterate over
-%the dialects.
-%
-%The following \cs{TrackLang\ldots Resource\ldots} commands may 
-%only be used in resource files that are loaded using
-%\ics{TrackLangRequireDialect}. An error will occur if the file is
-%input through some other method.
-%
-%Within the resource file
-%\meta{pkgname}\texttt{-}\meta{localeid}\texttt{.ldf}, 
-%you can identify the file using (new to version 1.3):
-%\begin{definition}[\DescribeMacro\TrackLangProvidesResource]
-%\cs{TrackLangProvidesResource}\marg{tag}\oarg{version info}
-%\end{definition}
-%
-%If \cs{ProvidesFile} is defined (through the \LaTeX\ kernel) this is
-%used, otherwise a simplified generic alternative is used that's 
-%suitable for other \TeX\ formats.
-%
-%The resource file can load another resource file 
-%\meta{pkgname}\texttt{-}\meta{localeid2}\texttt{.ldf}, 
-%using (new to version 1.3):
-%\begin{definition}[\DescribeMacro\TrackLangRequireResource]
-%\cs{TrackLangRequireResource}\marg{localeid2}
-%\end{definition}
-%For example, the dialect file \texttt{foo-en-GB.ldf} might need to
-%load the root language resource file \texttt{foo-english.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{en-GB}
-%\TrackLangRequireResource{english}
-%\end{verbatim}
-%If \texttt{foo-english.ldf} is also identified with
-%\cs{TrackLangProvidesResource}, this will ensure that it's only
-%loaded once.
-%
-%If you require the resource file and want to perform
-%\meta{code1} if it's loaded at this point or \meta{code2} if it's
-%already been loaded then you can use (new to version 1.3):
-%\begin{definition}[\DescribeMacro\TrackLangRequireResourceOrDo]
-%\cs{TrackLangRequireResourceOrDo}\marg{localeid2}\marg{code1}\marg{code2}
-%\end{definition}
-%
-%If you want to load a resource file if it exists (without an
-%error if it doesn't exist), then you can use
-%\begin{definition}[\DescribeMacro\TrackLangRequestResource]
-%\cs{TrackLangRequestResource}\marg{localeid2}\marg{not found code}
-%\end{definition}
-%If the file doesn't exist, \meta{not found code} is done.
-%
-%\begin{important}
-%Note that these \cs{\ldots}\texttt{Resource} commands are only
-%permitted within the resource files. They are internally enabled
-%through \cs{TrackLangRequireDialect}.
-%\end{important}
-%
-%The above restriction on the resource files loaded through
-%\cs{TrackLangRequireDialect}, and the fact that it internally uses
-%\cs{IfTrackedLanguageFileExists}, means that commands like
-%\cs{CurrentTrackedLanguage} or \cs{CurrentTrackedDialect} may be
-%used in those files. This means that the name of the captions hook
-%can be obtained through them. (Remember that the file
-%\texttt{foo-en-GB.ldf} might have been loaded with, say, the
-%\texttt{british} dialect or with the synonymous \texttt{UKenglish}
-%dialect or with a dialect label that doesn't have a corresponding
-%caption hook, such as \texttt{enGBLatn}.)
-%
-%The \sty{polyglossia} package has caption hooks in the form 
-%\cs{captions\meta{language}} whereas \sty{babel} has captions hooks
-%in the form \cs{captions\meta{dialect}}. This leads to a rather
-%cumbersome set of conditionals:
-%\begin{verbatim}
-%\ifcsundef{captions\CurrentTrackedLanguage}
-%{%
-%  \ifcsundef{captions\CurrentTrackedDialect}%
-%  {}%
-%  {%
-%    \csgappto{captions\CurrentTrackedDialect}{%
-%      % code to append to hook
-%    }%
-%  }%
-%}%
-%{%
-%  \csgappto{captions\CurrentTrackedLanguage}{%
-%    % code to append to hook
-%  }%
-%}
-%% do code now to initialise
-%\end{verbatim}
-%Note that the above has been simplified through the use of
-%\sty{etoolbox} commands, which isn't suitable for generic use.
-%It also doesn't query the mapping from \styfmt{tracklang}'s dialect
-%label to the closest matching \sty{babel} dialect label.
-%
-%Instead (new to version 1.3), \styfmt{tracklang} provides a command
-%to perform this set of conditionals using generic code:
-%\begin{definition}[\DescribeMacro\TrackLangAddToHook]
-%\cs{TrackLangAddToHook}\marg{code}\marg{type}
-%\end{definition}
-%where \meta{code} is the code to append to the \meta{type} hook.
-%This always performs \meta{code} after testing for the hook in case
-%the hook is undefined or has already been called (for example, \sty{ngerman} uses
-%\cs{captionsngerman} when the package is loaded, not at the start of
-%the document).
-%
-%Note that this command is enabled through
-%\cs{TrackLangRequireDialect} so should only be used inside resource
-%files.
-%
-%Since \texttt{captions} is a commonly used hook type, there's 
-%a~shortcut command provided:
-%\begin{definition}[\DescribeMacro\TrackLangAddToCaptions]
-%\cs{TrackLangAddToCaptions}\marg{code}
-%\end{definition}
-%This is equivalent to
-%\cs{TrackLangAddToHook}\marg{code}\verb|{captions}|.
-%
-%There may be some hooks, such as \cs{date}\meta{label}, that need
-%redefining rather than appending to.  As from v1.4, there's an
-%analogous command:
-%\begin{definition}[\DescribeMacro\TrackLangRedefHook]
-%\cs{TrackLangRedefHook}\marg{code}\marg{type}
-%\end{definition}
-%which will redefined the hook to do \meta{code}.
-%
-%Note that no expansion is performed on \meta{code} when appending or
-%redefining a hook.
-%
-%\section{Examples}
-%\label{sec:examples}
-%
-%The examples in this section illustrate the above commands.
-%
-%\subsection{animals.sty}
-%\label{sec:animals}
-%
-%This example is for a trivial package called \sty{animals.sty}
-%that defines three textual commands: \cs{catname}, \cs{dogname}
-%and \cs{ladybirdname}. The default values are: \qt{cat}, \qt{dog} and
-%\qt{bishy-barney-bee}.\footnote{Thass Broad Norfolk, my bewties
-%\texttt{:-P}}
-%
-%The supported languages are defined in files
-%with the prefix \texttt{animals-} and the suffix \texttt{.ldf}.
-%
-%Here's the code for \texttt{animals.sty}:
-%\begin{verbatim}
-% \NeedsTeXFormat{LaTeX2e}
-% \ProvidesPackage{animals}
-%
-% \RequirePackage{tracklang}[2019/11/30] %v1.4
-%
-% % Any undeclared options are language settings:
-%
-% \DeclareOption*{%
-%  \TrackIfKnownLanguage{\CurrentOption}%
-%  {\PackageInfo{animals}{Tracking language `\CurrentOption'}}% successful
-%  {% failed
-%    \PackageError{animals}%
-%    {Unknown language specification `\CurrentOption'}%
-%    {You need to supply either a known dialect label or a valid language tag}%
-%  }%
-% }
-%
-% \ProcessOptions
-%
-% % Default definitions
-% \newcommand\catname{cat}
-% \newcommand\dogname{dog}
-% \newcommand\ladybirdname{bishy-barney-bee}
-%
-% \AnyTrackedLanguages
-% {%
-%   \ForEachTrackedDialect{\this@dialect}{%
-%     \TrackLangRequireDialect{animals}{\this@dialect}%
-%   }%
-% }
-% {% no tracked languages, default already set up
-% }
-%
-% \endinput
-%\end{verbatim}
-%Here's a Plain \TeX\ version that picks up the language from the
-%locale environment variable:
-%\begin{verbatim}
-% \input tracklang
-%
-% \TrackLangFromEnv
-%
-% % Default definitions
-% \def\catname{cat}
-% \def\dogname{dog}
-% \def\ladybirdname{bishy-barney-bee}
-%
-% \AnyTrackedLanguages
-% {%
-%   \ForEachTrackedDialect{\thisdialect}{%
-%     \TrackLangRequireDialect{animals}{\thisdialect}%
-%   }%
-% }
-% {% no tracked languages, default already set up
-% }
-%\end{verbatim}
-%In the event that a user or supplementary package for some 
-%reason wants to load a resource
-%file for a language that hasn't been tracked, it might be worth
-%providing a command for this purpose:
-%\begin{verbatim}
-%\newcommand*{\RequireAnimalsDialect}[1]{%
-%  \TrackLangRequireDialect{animals}{#1}%
-%}
-%\end{verbatim}
-%The loop can then be changed to:
-%\begin{verbatim}
-%  \ForEachTrackedDialect{\this@dialect}{%
-%    \RequireAnimalsDialect\this@dialect
-%  }%
-%\end{verbatim}
-%
-%The \texttt{animals-english.ldf} file valid for both the Plain \TeX\
-%and \LaTeX\ formats contains:
-%\begin{verbatim}
-%\TrackLangProvidesResource{english}
-%
-%\def\englishanimals{%
-%  \def\catname{cat}%
-%  \def\dogname{dog}%
-%  \def\ladybirdname{bishy-barney-bee}%
-%}
-%
-%\TrackLangAddToCaptions{\englishanimals}
-%\end{verbatim}
-%The \texttt{animals-en-GB.ldf} file contains:
-%\begin{verbatim}
-%\TrackLangProvidesResource{en-GB}
-%\TrackLangRequireResource{english}
-%
-%\def\enGBanimals{%
-%  \englishanimals
-%  \def\ladybirdname{ladybird}%
-%}
-%\TrackLangAddToCaptions{\enGBanimals}
-%\end{verbatim}
-%The \texttt{animals-en-US.ldf} file contains:
-%\begin{verbatim}
-%\TrackLangProvidesResource{en-US}
-%\TrackLangRequireResource{english}
-%
-%\def\enUSanimals{%
-%  \englishanimals
-%  \def\ladybirdname{ladybug}%
-%}
-%\TrackLangAddToCaptions{\enUSanimals}
-%\end{verbatim}
-%Here's a German version in the file \texttt{animals-german.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{german}
-%
-%\def\germananimals{%
-%  \def\catname{Katze}%
-%  \def\dogname{Hund}%
-%  \def\ladybirdname{Marienk\"afer}%
-%}
-%
-%\TrackLangAddToCaptions{\germananimals}
-%\end{verbatim}
-%
-%This means that if \sty{babel} or \sty{polyglossia} are loaded, the
-%redefinitions are automatically performed whenever the language is
-%changed, but if there's no caption mechanism the user can switch
-%the fixed names using the \cs{\ldots animals} commands.
-%
-%Here's an example \LaTeX\ document that doesn't have any caption
-%hooks:
-%\begin{verbatim}
-%\documentclass[english,german,a4paper]{article}
-%
-%\usepackage{animals}
-%
-%\begin{document}
-%\englishanimals
-%
-%\catname.
-%\dogname.
-%\ladybirdname.
-%
-%\germananimals
-%
-%\catname.
-%\dogname.
-%\ladybirdname.
-%\end{document}
-%\end{verbatim}
-%Here's a \sty{babel} example document:
-%\begin{verbatim}
-%\documentclass[american,german,british,a4paper]{article}
-%
-%\usepackage{babel}
-%\usepackage{animals}
-%
-%\begin{document}
-%\selectlanguage{american}
-%
-%\catname.
-%\dogname.
-%\ladybirdname.
-%
-%\selectlanguage{german}
-%
-%\catname.
-%\dogname.
-%\ladybirdname.
-%
-%\selectlanguage{british}
-%
-%\catname.
-%\dogname.
-%\ladybirdname.
-%
-%\end{document}
-%\end{verbatim}
-%
-%There is some redundancy with the above resource files. Consider the
-%\sty{babel} example above. The \texttt{american} dialect is the
-%first option, so in that case \texttt{animals-en-US.ldf} is loaded
-%followed by \texttt{animals-english.ldf}. This means that the
-%\cs{captionsamerican} hook now includes
-%\begin{verbatim}
-%\englishanimals
-%\enUSanimals
-%\end{verbatim}
-%Since \cs{enUSanimals} includes \cs{englishanimals}, there is
-%redundant code. However, when the \texttt{british} dialect is
-%processed, this loads the file \texttt{animals-en-GB.ldf} but not
-%the file \texttt{animals-english.ldf} (since it's already been loaded). This
-%means that \cs{captionsbritish} contains \cs{enGBanimals} but not 
-%\cs{englishanimals}.
-%
-%If this redundancy is an issue (for example, there are so many
-%redefinitions needed that it significantly slows the document build
-%process), then it can be addressed with the following modifications.
-%The \texttt{animals-en-GB.ldf} file is now:
-%\begin{verbatim}
-%\TrackLangProvidesResource{en-GB}
-%
-%\def\enGBanimals{%
-%  \englishanimals
-%  \def\ladybirdname{ladybird}%
-%}
-%
-%\TrackLangRequireResourceOrDo{english}%
-%{
-%  \TrackLangAddToCaptions{%
-%    \def\ladybirdname{ladybird}%
-%  }%
-%}
-%{
-%  \TrackLangAddToCaptions{\enGBanimals}
-%}
-%\end{verbatim}
-%The \texttt{animals-en-US.ldf} file is now:
-%\begin{verbatim}
-%\TrackLangProvidesResource{en-US}
-%
-%\providecommand*{\enUSanimals}{%
-%  \englishanimals
-%  \renewcommand*{\ladybirdname}{ladybug}%
-%}
-%
-%\TrackLangRequireResourceOrDo{english}
-%{
-%  \TrackLangAddToCaptions{%
-%    \renewcommand*{\ladybirdname}{ladybird}%
-%  }%
-%}
-%{
-%  \TrackLangAddToCaptions{\enUSanimals}{captions}
-%}
-%\end{verbatim}
-%This means that the document that has the dialects listed in the
-%order \texttt{american}, \texttt{british} now has
-%\begin{verbatim}
-%\englishanimals
-%\def\ladybirdname{ladybird}
-%\end{verbatim}
-%in the \cs{captionsbritish} hook and just \cs{enUSanimals} in the
-%\cs{captionsamerican} hook, which has removed most of the redundancy.
-%
-%Note that \sty{polyglossia} has a \cs{captionsenglish} hook but not
-%\cs{captionsamerican} or \cs{captionsbritish}, so this code doesn't
-%allow for switching between variants of the same language with
-%\sty{polyglossia}.
-%
-%\subsection{regions.sty}
-%\label{sec:regions}
-%
-%Earlier, I~mentioned the search order for
-%\ics{IfTrackedLanguageFileExists} where if, for example, the dialect
-%is \texttt{british}, the file search (v1.4+) will be:
-%\begin{enumerate}
-%\item \texttt{mypackage-british.ldf}
-%\item \texttt{mypackage-en-GB.ldf}
-%\item \texttt{mypackage-en.ldf}
-%\item \texttt{mypackage-eng-GB.ldf}
-%\item \texttt{mypackage-eng.ldf}
-%\item \texttt{mypackage-GB.ldf}
-%\item \texttt{mypackage-english.ldf}
-%\end{enumerate}
-%You may have wondered why
-%\texttt{mypackage-GB.ldf} is included in the search given that some
-%countries have multiple official languages, which means that the country code on its
-%own may not indicate the language.
-%
-%The reason for including just the country code as the \meta{localeid} in the 
-%file search is to allow for region rather than language dependent
-%settings. For example, suppose I~want to write a package that needs
-%to know whether to use imperial or metric measurements in the
-%document, but I also want to provide multilingual support. The
-%language alone won't tell me whether to use imperial or metric (for
-%example, the US uses imperial and the UK uses metric for most
-%product attributes). I could provide \texttt{.ldf} files for every
-%language and region combination, but this would result in a lot
-%redundancy.
-%
-%\cs{TrackLangRequireDialect} has an optional argument for adjusting
-%the way the resource files are loaded. Suppose I have
-%\texttt{regions-}\meta{localeid}\texttt{.ldf} resource files, then
-%\begin{verbatim}
-%\TrackLangRequireDialect{regions}{\this@dialect}
-%\end{verbatim}
-%loads the resource file for the dialect given by \cs{this@dialect}
-%using
-%\begin{verbatim}
-%\TrackLangRequireResource{\CurrentTrackedTag}
-%\end{verbatim}
-%I can use the optional argument to also load the resource file for the
-%root language as well:
-%\begin{verbatim}
-%\newcommand*{\RequireRegionsDialect}[1]{%
-% \TrackLangRequireDialect
-%    [\TrackLangRequireResource{\CurrentTrackedTag}%
-%     \TrackLangRequireResource{\CurrentTrackedLanguage}%
-%    ]%
-%    {regions}{#1}%
-%}
-%\end{verbatim}
-%Now the dialect \texttt{british} can load both
-%\texttt{regions-GB.ldf} and \texttt{regions-english.ldf}.
-%
-%The example package (\texttt{regions.sty}) below illustrates this.
-%\begin{verbatim}
-%\NeedsTeXFormat{LaTeX2e}
-%\ProvidesPackage{regions}
-%
-%\RequirePackage{tracklang}[2016/10/07]
-%
-%\DeclareOption*{\TrackLanguageTag{\CurrentOption}}
-%\ProcessOptions
-%
-%\newcommand*{\weightunit}{kg}
-%\newcommand*{\lengthunit}{mm}
-%\newcommand*{\currencyunit}{EUR}
-%
-%\newcommand*{\unitname}{units}
-%
-%\newcommand*{\RequireRegionsDialect}[1]{%
-% \TrackLangRequireDialect
-%    [\TrackLangRequireResource{\CurrentTrackedTag}%
-%     \TrackLangRequireResource{\CurrentTrackedLanguage}%
-%    ]%
-%    {regions}{#1}%
-%}
-%
-%\AnyTrackedLanguages
-%{%
-%  \ForEachTrackedDialect{\this@dialect}{%
-%    \RequireRegionsDialect\this@dialect
-%  }%
-%}
-%{% no tracked languages, default already set up
-%}
-%
-%\endinput
-%\end{verbatim}
-%There are separate \texttt{.ldf} files for region and language.
-%First are the regions.
-%
-%\begin{itemize}
-%\item \texttt{regions-BE.ldf} (Belgium):
-%\begin{verbatim}
-%\TrackLangProvidesResource{BE}
-%
-%\providecommand*{\BEunits}{%
-%  \renewcommand*{\weightunit}{kg}%
-%  \renewcommand*{\lengthunit}{mm}%
-%  \renewcommand*{\currencyunit}{EUR}%
-%}
-%
-%\TrackLangAddToCaptions{\BEunits}
-%\end{verbatim}
-%
-%\item \texttt{regions-CA.ldf} (Canada):
-%\begin{verbatim}
-%\TrackLangProvidesResource{CA}
-%
-%\providecommand*{\CAunits}{%
-%  \renewcommand*{\weightunit}{kg}%
-%  \renewcommand*{\lengthunit}{mm}%
-%  \renewcommand*{\currencyunit}{CAD}%
-%}
-%
-%\TrackLangAddToCaptions{\CAunits}
-%\end{verbatim}
-%
-%\item \texttt{regions-GB.ldf} (Great Britain):
-%\begin{verbatim}
-%\TrackLangProvidesResource{GB}
-%
-%\providecommand*{\GBunits}{%
-%  \renewcommand*{\weightunit}{kg}%
-%  \renewcommand*{\lengthunit}{mm}%
-%  \renewcommand*{\currencyunit}{GBP}%
-%}
-%
-%\TrackLangAddToCaptions{\GBunits}
-%\end{verbatim}
-%
-%\item \texttt{regions-US.ldf} (USA):
-%\begin{verbatim}
-%\TrackLangProvidesResource{US}
-%
-%\providecommand*{\USunits}{%
-%  \renewcommand*{\weightunit}{lb}%
-%  \renewcommand*{\lengthunit}{in}%
-%  \renewcommand*{\currencyunit}{USD}%
-%}
-%
-%\TrackLangAddToCaptions{\USunits}
-%\end{verbatim}
-%\end{itemize}
-%Now the language files:
-%
-%\begin{itemize}
-%\item \texttt{regions-dutch.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{dutch}
-%
-%\providecommand*{\dutchnames}{%
-%  \renewcommand*{\unitname}{meeteenheden}%
-%}
-%
-%\TrackLangAddToCaptions{\dutchnames}
-%\end{verbatim}
-%
-%\item \texttt{regions-english.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{english}
-%
-%\providecommand*{\englishnames}{%
-%  \renewcommand*{\unitname}{units}%
-%}
-%
-%\TrackLangAddToCaptions{\englishnames}
-%\end{verbatim}
-%
-%\item \texttt{regions-french.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{french}
-%
-%\providecommand*{\frenchnames}{%
-%  \renewcommand*{\unitname}{unit\'es}%
-%}
-%
-%\TrackLangAddToCaptions{\frenchnames}
-%\end{verbatim}
-%
-%\item \texttt{regions-german.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{french}
-%
-%\providecommand*{\germannames}{%
-%  \renewcommand*{\unitname}{Ma\ss einheiten}%
-%}
-%
-%\TrackLangAddToCaptions{\germannames}
-%\end{verbatim}
-%\end{itemize}
-%
-%Here's an example document that uses this package:
-%\begin{verbatim}
-%\documentclass[canadien]{article}
-%
-%\usepackage{regions}
-%
-%\begin{document}
-%
-%\unitname: \weightunit, \lengthunit, \currencyunit.
-%
-%\end{document}
-%\end{verbatim}
-%
-%This works because the \meta{localeid} search looks for the
-%country code before the root language label. However, this will fail if 
-%the dialect label is the same as a root language label that has an
-%associated territory, marked with \fnregion\ in
-%\tableref{tab:rootlangopts}, as then it will be picked up before the
-%country code.
-%
-%In the above example, 
-%\texttt{regions-CA.ldf} is matched rather than
-%\texttt{regions-french.ldf}, so \texttt{regions-CA.ldf} is loaded by
-%\begin{verbatim}
-%\TrackLangRequireResource{\CurrentTrackedTag}
-%\end{verbatim}
-%After this, the language file \texttt{regions-french.ldf} is then loaded:
-%\begin{verbatim}
-%\TrackLangRequireResource{\CurrentTrackedLanguage}
-%\end{verbatim}
-%
-%This assumes that there's a country code \texttt{.ldf} file
-%available. This example needs a little modification to use default
-%units in case the region is missing:
-%\begin{verbatim}
-%\NeedsTeXFormat{LaTeX2e}
-%\ProvidesPackage{regions}
-%
-%% Pass all options to tracklang:
-%\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{tracklang}}
-%\ProcessOptions
-%
-%\RequirePackage{tracklang}
-%
-%\newcommand*{\weightunit}{kg}
-%\newcommand*{\lengthunit}{mm}
-%\newcommand*{\currencyunit}{EUR}
-%
-%\newcommand*{\unitname}{units}
-%
-%\newcommand*{\defaultunits}{%
-%  \renewcommand*{\weightunit}{kg}%
-%  \renewcommand*{\lengthunit}{mm}%
-%  \renewcommand*{\currencyunit}{EUR}%
-%}
-%
-%\newcommand*{\RequireRegionsDialect}[1]{%
-%    \TrackLangRequireDialect
-%    [\TrackLangRequireResource{\CurrentTrackedTag}%
-%      \ifx\CurrentTrackedTag\CurrentTrackedLanguage
-%        \TrackLangAddToCaptions{\defaultunits}%
-%      \else
-%        \TrackLangRequireResource{\CurrentTrackedLanguage}%
-%      \fi
-%    ]%
-%    {regions}{#1}%
-%}
-%
-%\AnyTrackedLanguages
-%{%
-%  \ForEachTrackedDialect{\this@dialect}{%
-%    \RequireRegionsDialect\this@dialect
-%  }%
-%}
-%{% no tracked languages, default already set up
-%}
-%
-%\endinput
-%\end{verbatim} 
-%Note that we still have a problem for dialect labels that are
-%identical to root language labels with an associated territory (such
-%as \pkgopt{manx}). This case can be checked with the following
-%adjustment:
-%\begin{verbatim}
-%\newcommand*{\RequireRegionsDialect}[1]{%
-%    \TrackLangRequireDialect
-%    [\TrackLangRequireResource{\CurrentTrackedTag}%
-%      \ifx\CurrentTrackedTag\CurrentTrackedLanguage
-%        \ifx\CurrentTrackedRegion\empty
-%          \TrackLangAddToCaptions{\defaultunits}%
-%        \else
-%          \TrackLangRequireResource{\CurrentTrackedRegion}%
-%        \fi
-%      \else
-%        \TrackLangRequireResource{\CurrentTrackedLanguage}%
-%      \fi
-%    ]%
-%    {regions}{#1}%
-%}
-%\end{verbatim}
-%In the case where both the dialect and root language label are
-%\texttt{manx} with the resource files \texttt{regions-manx.ldf}
-%and \texttt{regions-IM.ldf}, then \cs{CurrentTrackedTag} will be
-%\texttt{manx} (the dialect label) so \texttt{regions-manx.ldf} will
-%be loaded with:
-%\begin{verbatim}
-%\TrackLangRequireResource{\CurrentTrackedTag}
-%\end{verbatim}
-%In this case \cs{CurrentTrackedRegion} is \texttt{IM} (that is, it's
-%not empty) so then \texttt{regions-IM.ldf} will be loaded with:
-%\begin{verbatim}
-%\TrackLangRequireResource{\CurrentTrackedRegion}
-%\end{verbatim}
-%
-%Here's another document that sets up dialects with
-%\styfmt{tracklang} labels that aren't recognised by \sty{babel}.
-%This means that there's no corresponding \cs{captions\ldots} hook
-%for either the dialect label or the root language label,
-%so mappings need to be defined from the \styfmt{tracklang} dialect
-%label to the matching \sty{babel} dialect label.
-%
-%\begin{verbatim}
-%\documentclass{article}
-%
-%\usepackage{tracklang}
-%
-%\TrackLanguageTag{de-US-1996}
-%\SetTrackedDialectLabelMap{\TrackLangLastTrackedDialect}{ngerman}
-%
-%\TrackLanguageTag{en-MT}
-%\SetTrackedDialectLabelMap{\TrackLangLastTrackedDialect}{UKenglish}
-%
-%\usepackage[main=ngerman,UKenglish]{babel}
-%\usepackage{regions}
-%
-%\begin{document}
-%\selectlanguage{ngerman}
-%
-%\unitname: \weightunit, \lengthunit, \currencyunit.
-%
-%\selectlanguage{UKenglish}
-%
-%\unitname: \weightunit, \lengthunit, \currencyunit.
-%
-%\end{document}
-%\end{verbatim}
-%This produces:
-%\begin{quote}
-%Ma\ss einheiten: lb, in, USD.
-%
-%units: kg, mm, EUR.
-%\end{quote}
-%Compare this with:
-%\begin{verbatim}
-%\documentclass{article}
-%
-%\usepackage[main=ngerman,UKenglish]{babel}
-%\usepackage{regions}
-%
-%\begin{document}
-%\selectlanguage{ngerman}
-%
-%\unitname: \weightunit, \lengthunit, \currencyunit.
-%
-%\selectlanguage{UKenglish}
-%
-%\unitname: \weightunit, \lengthunit, \currencyunit.
-%
-%\end{document}
-%\end{verbatim}
-%which produces:
-%\begin{quote}
-%Ma\ss einheiten: kg, mm, EUR.
-%
-%units: kg, mm, GBP.
-%\end{quote}
-%
-%Note that these mappings aren't needed if \sty{babel}
-%is loaded with the root language labels instead. For example:
-%\begin{verbatim}
-%\documentclass{article}
-%
-%\usepackage{tracklang}
-%
-%\TrackLanguageTag{de-US-1996}
-%\SetTrackedDialectLabelMap{\TrackLangLastTrackedDialect}{ngerman}
-%
-%\TrackLanguageTag{en-MT}
-%
-%\usepackage[main=ngerman,english]{babel}
-%\usepackage{regions2}
-%
-%\begin{document}
-%\selectlanguage{ngerman}
-%
-%\unitname: \weightunit, \lengthunit, \currencyunit.
-%
-%\selectlanguage{english}
-%
-%\unitname: \weightunit, \lengthunit, \currencyunit.
-%
-%\end{document}
-%\end{verbatim}
-%No mapping is required for the \texttt{en-MT} locale as
-%it can pick up \cs{captionsenglish} when \cs{TrackLangAddToHook}
-%(used by \cs{TrackLangAddToCaptions})
-%queries the root language label after failing to find the
-%language hook from the dialect label.
-%
-%Some of the predefined \styfmt{tracklang} dialects come with
-%a mapping to the closest matching \sty{babel} dialect label.
-%For example, the option \pkgopt{ngermanDE} listed in
-%\tableref{tab:nonisoopts} automatically provides a mapping
-%to \texttt{ngerman}. Since a \styfmt{tracklang} dialect label 
-%can only map to one \styfmt{babel} label, this can be problematic
-%for synonymous labels such as
-%\texttt{british}\slash\texttt{UKenglish} or
-%\texttt{american}\slash\texttt{USenglish}. The default mappings used
-%by \styfmt{tracklang} are shown in \tableref{tab:nonisoopts}.
-%
-%\chapter{Adding Support for Language Tracking}
-%\label{sec:langsty}
-%
-%If you are writing a package that \emph{sets up} the document languages (rather
-%than a package that provides multilingual support if the user has
-%already loaded a language package) then you can load \styfmt{tracklang}
-%and use the commands below to help other packages track your
-%provided languages. (See also:
-%\href{https://www.dickimaw-books.com/latex/tracklang/langpkg.shtml}{Integrating
-%\texttt{tracklang.tex} into Language Packages}.)
-%
-%The \styfmt{tracklang} package can be loaded using
-%\begin{verbatim}
-%\input tracklang
-%\end{verbatim}
-%or (\LaTeX\ only)
-%\begin{verbatim}
-%\RequirePackage{tracklang}
-%\end{verbatim}
-%
-%When using \LaTeX, there's a difference between the two.
-%The first case prevents \styfmt{tracklang} from picking up
-%the document class options but skips the check for known
-%language packages. This check is redundant since your package is
-%the language package, so you need to decide is whether or
-%not to allow the user to set up the localisation information
-%through the document class options.
-%
-%If you prefer \cs{RequirePackage} over \cs{input} but you want to make 
-%\texttt{tracklang.sty} skip the check for known
-%language packages then (as from v1.3.8) define the pre-language
-%package check hook as follows:
-%\begin{verbatim}
-%\providecommand\@tracklang@prelangpkgcheck@hook{\endinput}
-%\RequirePackage{tracklang}[2019/10/06]
-%\end{verbatim}
-%This will still pick up languages supplied through the
-%document class options.
-%
-%If you just use \cs{input}, there's a test at the start of
-%\texttt{tracklang.tex} to determine if it's already been loaded, so
-%you don't need to worry if the document has already loaded it.
-%
-%To integrate \sty{tracklang} into your language package, you need to consider the following
-%steps:
-%\begin{enumerate}
-%\item Does \sty{tracklang} define your supported ISO~15924 language
-%scripts in the \texttt{tracklang-scripts.tex} file?
-%
-%If yes, then skip this step. Otherwise create a file with the
-%relevant \ics{TrackLangScriptMap} command for each unknown script and identify
-%this new file with \ics{TrackLangAddExtraScriptFile} (see
-%\sectionref{sec:newscripts}). This usually
-%won't be necessary unless you have a custom script or a child script
-%(a script that's a sub-category of another script).
-%
-%\item Does \sty{tracklang} recognise the root language?
-%
-%If yes, then skip this step.
-%
-%If your package is setting up a language that \sty{tracklang}
-%doesn't recognise then you will need to define the root language
-%using \cs{TrackLangNewLanguage} (see \sectionref{sec:newlanguages}).
-%
-%This usually won't be the case as \sty{tracklang} should support all
-%languages that have an official ISO~639-1 alpha-2 code.
-%
-%If you simply have a different label from \sty{tracklang} identifying the root language,
-%then you can just set up your label as a dialect using
-%\cs{TrackLangProvidePredefinedDialect} (see \sectionref{sec:predefinedlabels}).
-%
-%\item Does \sty{tracklang} define the relevant ISO~3166 region codes
-%in the \texttt{tracklang-region-codes.tex} file?
-%
-%If yes, then skip this step. Otherwise create a file with the
-%relevant \ics{TrackLangRegionMap} command for each new region and
-%identify this new file with \ics{TrackLangAddExtraRegionFile} (see
-%\sectionref{sec:newregions}). This usually won't be necessary as
-%\sty{tracklang} should recognise all countries that have an alpha-2
-%region code, but you may require it if you need a broader region,
-%such as EU.
-%
-%\item Do you want to define some convenient dialect labels that can
-%be used with \ics{TrackPredefinedDialect}?
-%
-%If no, then skip this step. Otherwise you can use
-%\ics{TrackLangProvidePredefinedLanguage} for root languages
-%and \ics{TrackLangProvidePredefinedDialect} for dialects with
-%additional information, such as a region, sub-language or script
-%(see \sectionref{sec:predefinedlabels}).
-%
-%\item In your language initialisation code, add the \sty{tracklang}
-%code to track the particular dialect (for example, use
-%\cs{TrackPredefinedDialect} for recognised dialect labels or
-%use the \cs{AddTracked}\ldots\ set of commands). See
-%\sectionref{sec:initnewlang}.
-%
-%\item In your language selection code (such as \cs{selectlanguage}), add
-%\cs{SetCurrentTrackedDialect}\marg{label} to allow the document
-%author to easily query the current localisation settings (such as
-%the region). See \sectionref{sec:selectlanguage}.
-%\end{enumerate}
-%
-%\section{Initialising a New Language or Dialect}
-%\label{sec:initnewlang}
-%
-%When the user requests a particular dialect through your language
-%package, you can notify \styfmt{tracklang} of this choice using
-%\begin{definition}
-%\cs{TrackPredefinedDialect}\marg{dialect}
-%\end{definition}
-%provided the dialect label is recognised by \styfmt{tracklang} (all those
-%listed in \refoptstables).
-%
-%If there's no matching dialect predefined by \styfmt{tracklang}, you
-%can just use \cs{TrackLocale} or \cs{TrackLanguageTag} 
-%(described in \sectionref{sec:generic}) 
-%with the appropriate ISO codes \emph{if you're not providing caption
-%hooks}.
-%
-%If you are providing a captions hook mechanism
-%in the form \ics{captions\meta{dialect}}, then if \meta{dialect}
-%doesn't match the corresponding \styfmt{tracklang} dialect label,
-%you can provide a mapping using
-%\cs{SetTrackedDialectLabelMap}, described below.
-%
-%\section{Switching Language or Dialect}
-%\label{sec:selectlanguage}
-%
-%When the document author switches to a different language or
-%dialect, the current localisation information can be set with:
-%\begin{definition}[\DescribeMacro\SetCurrentTrackedDialect]
-%\cs{SetCurrentTrackedDialect}\marg{dialect}
-%\end{definition}
-%where \meta{dialect} may the \styfmt{tracklang} dialect label,
-%or the mapped label previously set through \cs{SetTrackedDialectLabelMap},
-%described below, or the language label (in which case the
-%last dialect to be tracked with that root language will
-%be assumed).
-%
-%This will make the following commands available which may be
-%of use to other packages:
-%\begin{itemize}
-%\item\ics{CurrentTrackedDialect} The dialect label recognised
-%by \styfmt{tracklang} (which may not be the same as \meta{dialect}).
-%
-%\item\ics{CurrentTrackedLanguage}
-%The root language label used by \styfmt{tracklang}.
-%\item\ics{CurrentTrackedDialectModifier} The dialect modifier.
-%\item\ics{CurrentTrackedDialectVariant} The dialect variant.
-%\item\ics{CurrentTrackedDialectScript} The dialect script.
-%Note that if \sty{tracklang-scripts} is also loaded, this allows the
-%script direction to be accessed using
-%\begin{verbatim}
-%\TrackLangScriptAlphaToDir{\CurrentTrackedDialectScript}
-%\end{verbatim}
-%See \sectionref{sec:tracklang-scripts.tex} for further details.
-%\item\ics{CurrentTrackedDialectSubLang} The dialect sub-language
-%code.
-%\item\ics{GetTrackedDialectAdditional} The dialect's additional
-%information.
-%\item\ics{CurrentTrackedIsoCode} The dialect's root language 
-%ISO code. (The first found in the sequence 639-1, 639-2, 639-3.)
-%\item\ics{CurrentTrackedRegion} The dialect's ISO 3166-1 region 
-%code.
-%\item\ics{CurrentTrackedLanguageTag} The dialect's language tag.
-%\end{itemize}
-%(Without this automated use of \cs{SetCurrentTrackedDialect},
-%the same information can be picked up using commands
-%like \cs{GetTrackedDialectScript}, but that's less convenient,
-%especially if \cs{languagename} needs to be converted
-%to \meta{dialect}. See the accompanying sample file
-%\texttt{sample-setlang.tex} for an example.)
-%
-%\section{Defining New Scripts}
-%\label{sec:newscripts}
-%
-%The \texttt{tracklang-scripts.tex} file isn't automatically loaded,
-%but if it is then, as from v1.4, it contains a hook at the end of
-%the file that can be used to load additional files that define
-%supplementary scripts. This entails creating a file called, say,
-%\texttt{mypackage-scripts.tex} that contains:
-%\begin{definition}[\DescribeMacro\TrackLangScriptMap]
-%\cs{TrackLangScriptMap}\marg{alpha code}\marg{numeric
-%code}\marg{name}\marg{direction}\marg{parent}
-%\end{definition}
-%The first argument \meta{alpha code} is the four-letter ISO~15924 code (such as
-%\texttt{Latn}), the second argument is the numeric code (such as
-%215), the third argument \meta{name} is the name of the script (such
-%as \texttt{Latin}), the fourth argument is the direction (such as
-%\texttt{LR} for left-to-right) and the final argument is the parent
-%script (leave blank if there's no parent). Note that this command will override any previous
-%mapping for those codes. No check is performed to determine if they
-%have already been defined.
-%
-%The supplementary file should be identified with:
-%\begin{definition}[\DescribeMacro\TrackLangAddExtraScriptFile]
-%\cs{TrackLangAddExtraScriptFile}\marg{filename}
-%\end{definition}
-%
-%\section{Defining New Regions}
-%\label{sec:newregions}
-%
-%The \texttt{tracklang-region-codes.tex} file isn't automatically loaded,
-%but if it is then, as from v1.4, it contains a hook at the end of
-%the file that can be used to load additional files that define
-%supplementary regions. This entails creating a file called, say,
-%\texttt{mypackage-regions.tex} that contains:
-%\begin{definition}[\DescribeMacro\TrackLangRegionMap]
-%\cs{TrackLangRegionMap}\marg{numeric code}\marg{alpha-2 code}\marg{alpha-3 code}
-%\end{definition}
-%where the first argument is the numeric region code (such as 826),
-%the second argument is the alpha-2 region code (such as \texttt{GB})
-%and the third argument is the alpha-3 region code (such as
-%\texttt{GBR}). Note that this command will override any previous
-%mapping for those codes. No check is performed to determine if they
-%have already been defined.
-%
-%The supplementary file should be identified with:
-%\begin{definition}[\DescribeMacro\TrackLangAddExtraRegionFile]
-%\cs{TrackLangAddExtraRegionFile}\marg{filename}
-%\end{definition}
-%
-%\section{Defining a New Language}
-%\label{sec:newlanguages}
-%
-%(New to version 1.3.)
-%If the root language isn't recognised by \styfmt{tracklang}
-%(not listed in \tableref{tab:rootlangopts}), then
-%it can be defined (but not tracked at this point) using:
-%\begin{definition}[\DescribeMacro\TrackLangNewLanguage]
-%\cs{TrackLangNewLanguage}\marg{language name}\marg{639-1
-%code}\marg{639-2 (T)}\marg{639-2 (B)}\marg{639-3}\marg{3166-1}\marg{default
-%script}
-%\end{definition}
-%where \meta{language name} is the root language name, 
-%\meta{639-1 code} is the ISO 639-1 code for that language (may be
-%empty if there isn't one), \meta{639-2 (T)} is the ISO 639-2 (T)
-%code for that language (may be empty if there isn't one),
-%\meta{639-2 (B)} is the ISO 639-2 (B) code for that language (may be
-%empty if it's the same as \meta{639-2 (T)}), \meta{639-3} is the ISO
-%639-3 code for that language (empty if the same as the 639-2
-%code), \meta{3166-1} is the territory ISO code for languages that are only spoken in one
-%territory (should be empty if the language is spoken in multiple
-%territories), and \meta{default script} is the default script (empty
-%if disputed or varies according to region).
-%
-%You can then track this language using \cs{AddTrackedDialect} for
-%dialects or, if no regional variant is needed, you can instead use:
-%\begin{definition}[\DescribeMacro\AddTrackedLanguage]
-%\cs{AddTrackedLanguage}\marg{root language label}
-%\end{definition}
-%This is equivalent to \ics{AddTrackedDialect}\marg{root language
-%label}\marg{root language label}.
-%
-%
-%\section{Defining New \styfmt{tracklang} Labels}
-%\label{sec:predefinedlabels}
-%
-%A dialect label may be predefined with associated information that
-%allows that particular combination to be easily tracked with
-%\cs{TrackPredefinedDialect}. In the case of a dialect label that
-%only requires the information provided in \cs{TrackLangNewLanguage}
-%you can use:
-%\begin{definition}[\DescribeMacro\TrackLangProvidePredefinedLanguage]
-%\cs{TrackLangProvidePredefinedLanguage}\marg{label}
-%\end{definition}
-%where \meta{label} corresponds to the language label used in
-%\cs{TrackLangNewLanguage}. This allows
-%\cs{TrackPredefinedDialect}\marg{label} to not only track the root
-%language but also the associated ISO codes.
-%
-%If the dialect label doesn't match the root language label then use:
-%\begin{definition}[\DescribeMacro\TrackLangProvidePredefinedDialect]
-%\cs{TrackLangProvidePredefinedDialect}\marg{dialect}\marg{language}\marg{region}\marg{modifier}\marg{variant}\marg{map}\marg{script}
-%\end{definition}
-%where \meta{dialect} is the new \sty{tracklang} dialect label,
-%\marg{language} is the \sty{tracklang} root language label,
-%\meta{region} is the ISO~3166-1 region code (may be empty),
-%\meta{modifier} is the modifier (may be empty), \meta{variant}
-%is the variant information (may be empty), \meta{map} is your
-%package's language label that corresponds to the \sty{tracklang}
-%dialect label supplied in the first argument (may be empty if
-%identical), and \meta{script} is the ISO~15914 alpha-4 script code
-%(may be empty if it's the same as the default script for the root
-%language).
-%
-%For compatibility with pre version 1.3, 
-%if the dialect isn't predefined by
-%\styfmt{tracklang}, then you can use:
-%\begin{definition}[\DescribeMacro\AddTrackedDialect]
-%\cs{AddTrackedDialect}\marg{dialect}\marg{root language label}
-%\end{definition}
-%where \meta{root language label} is the label for the dialect's root
-%language (\tableref{tab:rootlangopts}) and \meta{dialect} matches
-%the captions hook. If the dialect is already in the tracked dialect
-%list, it won't be added again. If the root language is already in
-%the tracked language list, it won't be added again. As from version
-%1.3 this additionally defines:
-%\begin{definition}[\DescribeMacro\TrackLangLastTrackedDialect]
-%\cs{TrackLangLastTrackedDialect}
-%\end{definition}
-%to \meta{dialect} for convenient reference if required.
-%Note that \cs{AddTrackedDialect} is internally used by commands like
-%\cs{TrackPredefinedDialect}, \cs{TrackLocale} and
-%\cs{TrackLanguageTag}.
-%
-%(New to version 1.3.) Many of the \styfmt{tracklang} dialect
-%labels don't have a corresponding match in various language packages. For 
-%example, \styfmt{tracklang} provides \texttt{ngermanDE} but the
-%closest match in \sty{babel} is \texttt{ngerman}. This means that
-%the caption hook \cs{captionsngerman} can't be accessed
-%through
-%\begin{verbatim}
-%\csname captions\CurrentTrackedDialect\endcsname
-%\end{verbatim}
-%in the resource files. In this case, a mapping may be defined
-%between the \styfmt{tracklang} dialect label and the closest
-%matching label used by the language hooks. This is done through
-%\begin{definition}[\DescribeMacro\SetTrackedDialectLabelMap]
-%\cs{SetTrackedDialectLabelMap}\marg{from}\marg{to}
-%\end{definition}
-%where \meta{from} is the \styfmt{tracklang} label and \meta{to}
-%is the language hook label. For example:
-%\begin{verbatim}
-%\TrackLanguageTag{de-AR-1996}
-%\SetTrackedDialectLabelMap{\TrackLangLastTrackedDialect}{ngerman}
-%\end{verbatim}
-%Since \cs{TrackLanguageTag} internally uses \cs{AddTrackedDialect}
-%the dialect label created by \styfmt{tracklang} can be accessed
-%using \cs{TrackLangLastTrackedDialect}. This means that
-%\ics{TrackLangAddToCaptions} can now find the \cs{captionsngerman}
-%hook even though the \styfmt{tracklang} dialect label isn't \texttt{ngerman}.
-%
-%(New to version 1.3.)
-%If the root language label is recognised by \styfmt{tracklang}, you
-%can add the ISO codes using:
-%\begin{definition}[\DescribeMacro\AddTrackedLanguageIsoCodes]
-%\cs{AddTrackedLanguageIsoCodes}\marg{root language}
-%\end{definition}
-%
-%As from v1.3, you can also provide a modifier for a given
-%dialect using:
-%\begin{definition}[\DescribeMacro\SetTrackedDialectModifier]
-%\cs{SetTrackedDialectModifier}\marg{dialect}\marg{value}
-%\end{definition}
-%where \meta{dialect} is the dialect label and \meta{value}
-%is the modifier value. For example:
-%\begin{verbatim}
-%\AddTrackedDialect{oldgerman}{german}
-%\AddTrackedLanguageIsoCodes{german}
-%\SetTrackedDialectModifier{oldgerman}{old}
-%\end{verbatim}
-%
-%Note that no sanitization is performed on \meta{value} when the
-%modifier is set explicitly through \cs{SetTrackedDialectModifier},
-%since it's assumed that any package that specifically sets the
-%modifier in this way is using a sensible labelling system. If the
-%modifier is obtained through commands like \cs{TrackLocale}, then
-%the modifier is sanitized as the value may have been obtained from
-%the operating system and there's no guarantee that it won't contain
-%problematic characters.
-%
-%The modifier is typically obtained by parsing locale information in
-%POSIX format.
-%\begin{display}
-%\meta{language}[\_\meta{territory}][.\meta{codeset}][@\meta{modifier}]
-%\end{display}
-%whereas the variant is typically obtained by parsing the language
-%tag.
-%
-%The information provided in the commands below (such as the script)
-%are typically obtained by parsing the language tag. For example,
-%with Serbian in the Latin alphabet the modifier would be \texttt{latin}
-%whereas the script would be \texttt{Latn}:
-%\begin{verbatim}
-%\AddTrackedDialect{serbianlatin}{serbian}
-%\AddTrackedLanguageIsoCodes{serbian}
-%\SetTrackedDialectModifier{serbianlatin}{latin}
-%\SetTrackedDialectScript{serbianlatin}{Latn}
-%\end{verbatim}
-%
-%As from v1.3, you can provide a script (for example,
-%\qt{Latn} or \qt{Cyrl}) using:
-%\begin{definition}[\DescribeMacro\SetTrackedDialectScript]
-%\cs{SetTrackedDialectScript}\marg{dialect}\marg{value}
-%\end{definition}
-%where \meta{dialect} is the dialect label and \meta{value} is the
-%four letter script identifier. For example:
-%\begin{verbatim}
-%\AddTrackedDialect{serbiancyrl}{serbian}
-%\AddTrackedLanguageIsoCodes{serbian}
-%\SetTrackedDialectScript{serbiancyrl}{Cyrl}
-%\end{verbatim}
-%
-%As from v1.3, you can provide a variant for a given
-%dialect using:
-%\begin{definition}[\DescribeMacro\SetTrackedDialectVariant]
-%\cs{SetTrackedDialectVariant}\marg{dialect}\marg{value}
-%\end{definition}
-%For example:
-%\begin{verbatim}
-%\AddTrackedDialect{german1901}{german}
-%\SetTrackedDialectVariant{german1901}{1901}
-%\end{verbatim}
-%
-%As from v1.3, you can also provide a sub-language using:
-%\begin{definition}[\DescribeMacro\SetTrackedDialectSubLang]
-%\cs{SetTrackedDialectSubLang}\marg{dialect}\marg{value}
-%\end{definition}
-%where \meta{dialect} is the dialect label and \meta{value} is the
-%code. For example:
-%\begin{verbatim}
-%\AddTrackedDialect{mandarin}{chinese}
-%\AddTrackedLanguageIsoCodes{chinese}
-%\SetTrackedDialectSubLang{mandarin}{cmn}
-%\AddTrackedIsoLanguage{639-3}{cmn}{mandarin}
-%\end{verbatim}
-%
-%As from v1.3, you can also provide additional information using:
-%\begin{definition}[\DescribeMacro\SetTrackedDialectAdditional]
-%\cs{SetTrackedDialectAdditional}\marg{dialect}\marg{value}
-%\end{definition}
-%where \meta{dialect} is the dialect label and \meta{value} is the
-%additional information.
-%
-%\section{Example}
-%
-%Suppose I want to create a language package \texttt{alien.sty} that defines the
-%\texttt{martian} language with regional dialects
-%\texttt{lowermartian} and \texttt{uppermartian}. First, let's
-%suppose that \styfmt{tracklang} recognises the root language
-%\texttt{martian}:
-%\begin{verbatim}
-% \ProvidesPackage{alien}
-%
-% \input{tracklang}% v1.3
-%
-% \DeclareOption{martian}{%
-%   \TrackPredefinedDialect{martian}
-% }
-% \DeclareOption{lowermartian}{%
-%   \AddTrackedDialect{lowermartian}{martian}
-%   \AddTrackedIsoCodes{martian}
-%   \AddTrackedIsoLanguage{3166-1}{YY}{lowermartian}
-%   % other attributes such as
-%   % \SetTrackedDialectVariant{lowermartian}{...}
-% }
-% \DeclareOption{uppermartian}{%
-%   \AddTrackedDialect{uppermartian}{martian}
-%   \AddTrackedIsoCodes{martian}
-%   \AddTrackedIsoLanguage{3166-1}{XX}{uppermartian}
-%   % other attributes such as
-%   % \SetTrackedDialectVariant{uppermartian}{...}
-% }
-%
-% \ProcessOptions
-%
-% \newcommand*{\selectlanguage}[1]{%
-%   \def\languagename{#1}%
-%   % other stuff
-%   \SetCurrentTrackedDialect{#1}% 
-% }
-%
-% \AnyTrackedLanguages
-% {
-%   \ForEachTrackedDialect{\thisdialect}
-%   {%
-%     \TrackLangRequireDialect{alien}{\thisdialect}
-%   }
-% }
-%\end{verbatim}
-%The caption commands and language set up are in the files
-%\texttt{alien-}\meta{localeid}\texttt{.ldf} as in the examples from
-%\sectionref{sec:examples}. This allows for the user having already
-%loaded \styfmt{tracklang} before \styfmt{alien} and used \cs{TrackLangFromEnv} to pick up
-%the locale from the operating system's environment variables.
-%(For example, they may have \envvar{LANG} set to \texttt{xx\_YY}.)
-%
-%The resource files may need to set the mapping between the
-%\styfmt{tracklang} dialect label and the \styfmt{alien} dialect
-%label. For example, in \texttt{alien-xx-YY.ldf}:
-%\begin{verbatim}
-%\TrackLangProvidesResource{xx-YY}
-%
-%\TrackLangRequireResource{martian}% load common elements
-%
-%\newcommand{\captionslowermartian}{%
-%  \captionsmartian
-%  \def\contentsname{X'flurp}% regional variation
-%}
+%   -doc "tracklang-codedoc.tex"
+%   -author "Nicola Talbot"
+%   -codetitle "Main Package Code"
+%   -src "tracklang.sty\Z=>tracklang.sty"
+%   -src "tracklang.tex\Z=>tracklang.tex"
+%   -src "tracklang-region-codes.tex\Z=>tracklang-region-codes.tex"
+%   -src "tracklang-scripts.sty\Z=>tracklang-scripts.sty"
+%   -src "tracklang-scripts.tex\Z=>tracklang-scripts.tex"
+%   tracklang
+% Created on 2022/10/29 18:01
+%\fi
+%\iffalse
+%<*package>
+%% \CharacterTable
+%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%%   Digits        \0\1\2\3\4\5\6\7\8\9
+%%   Exclamation   \!     Double quote  \"     Hash (number) \#
+%%   Dollar        \$     Percent       \%     Ampersand     \&
+%%   Acute accent  \'     Left paren    \(     Right paren   \)
+%%   Asterisk      \*     Plus          \+     Comma         \,
+%%   Minus         \-     Point         \.     Solidus       \/
+%%   Colon         \:     Semicolon     \;     Less than     \<
+%%   Equals        \=     Greater than  \>     Question mark \?
+%%   Commercial at \@     Left bracket  \[     Backslash     \\
+%%   Right bracket \]     Circumflex    \^     Underscore    \_
+%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
+%%   Right brace   \}     Tilde         \~}
+%</package>
+%\fi
+% \iffalse
+% Doc-Source file to use with LaTeX2e
+% Copyright (C) 2022 Nicola Talbot, all rights reserved.
+% \fi
+% \iffalse
+%<*driver>
+\iffalse
+tracklang-codedoc.tex is a stub file used by makedtx to create
+tracklang.dtx
+\fi
+
+\documentclass{article}
+\usepackage{doc}
+
+\CheckSum{6236}
+
+\RecordChanges
+\PageIndex
+\SetupDoc{reportchangedates}
+\setcounter{IndexColumns}{2}
+
+\usepackage[T1]{fontenc}
+\usepackage{tcolorbox}
+
+\definecolor{defbackground}{rgb}{1,1,0.75}
+
+\newtcolorbox{definition}{halign=flush left,
+ colframe=black,colback=defbackground,
+ fontupper=\ttfamily,
+ before upper={\frenchspacing\obeylines},
+ after={\par\noindent\ignorespacesafterend}
+}
+
+\NewDocElement{Option}{option}
+
+\providecommand{\sty}[1]{\styfmt{#1}}
+\providecommand{\styfmt}[1]{\textsf{#1}}
+\providecommand{\pkgoptfmt}[1]{\textsf{#1}}
+\providecommand{\envvar}[1]{\texttt{#1}}
+\providecommand{\app}[1]{\texttt{#1}}
+\providecommand{\qt}[1]{``#1''}
+\providecommand{\sectionref}[1]{\S\ref{#1}}
+
+\providecommand\marg[1]{%
+  \texorpdfstring{\allowbreak{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
+  {\{#1\}}}
+\providecommand\oarg[1]{%
+  \texorpdfstring{\allowbreak{\ttfamily[}\meta{#1}{\ttfamily]}}
+  {[#1]}}
+
+\begin{document}
+\DocInput{tracklang.dtx}
+\end{document}
+%</driver>
+%\fi
 %
-%\SetTrackedDialectLabelMap{\CurrentTrackedDialect}{lowermartian}
-%\end{verbatim}
+% \title{Documented Code For tracklang v1.6}
+% \author{Nicola L.C. Talbot\\[10pt]
+%Dickimaw Books\\
+%\url{http://www.dickimaw-books.com/}}
 %
-%Now let's consider the case where \styfmt{tracklang} doesn't know
-%about the \texttt{martian} language. In this case the user can't 
-%track the dialect until the root language has been defined, so the
-%user can't use \cs{TrackLangFromEnv} before using the \styfmt{alien}
-%package.
+% \date{2022-10-29}
+% \maketitle
 %
-%With \styfmt{tracklang} v1.3. The new root language can be defined
-%with a minor adjustment to the above code:
-%\begin{verbatim}
-% \ProvidesPackage{alien}
+%\tableofcontents
 %
-% \input{tracklang}% needs v1.3
+%\section{Introduction}
 %
-% \TrackLangIfKnownLang{martian}
-% {}% tracklang already knows about the martian language
-% {
-%   % tracklang doesn't known about the martian language, so define it
-%   % with ISO 639-1 (xx) and ISO 639-2 (xxx) codes:
-%   \TrackLangNewLanguage{martian}{xx}{xxx}{}{}{}{Latn}
-% }
-%\end{verbatim}
-%The rest is as before.
+%This is the documented code for the \sty{tracklang} package.
+%See \texttt{tracklang-manual.pdf} for the main user guide.
 %
-%Now other package writers who want to provide support
-%for the Martian dialects can easily detect which language options
-%the user requested through my package, \emph{without needing to know
-%anything about my \styfmt{alien} package}.
+%\StopEventually{\clearpage\PrintChanges \clearpage\PrintIndex}
 %
-%\StopEventually{%
-% \printindex[user]
-% \PrintCodeIndex
-% \PrintChanges
-%}
 %
 %
-%\chapter{The Code}
+%\section{Main Package Code}
 %\iffalse
 %    \begin{macrocode}
 %<*tracklang.sty>
@@ -3583,7 +119,7 @@ and~\ref{tab:nonisoopts}}
 % packages such as \styfmt{etoolbox}.
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{tracklang}[2020/06/30 v1.5 (NLCT) Track Languages]
+\ProvidesPackage{tracklang}[2022/10/29 v1.6 (NLCT) Track Languages]
 %    \end{macrocode}
 %\begin{macro}{\@tracklang@declareoption}
 % Set up package options.
@@ -3673,6 +209,15 @@ and~\ref{tab:nonisoopts}}
            \@ifpackageloaded{polyglossia}
            {%
 %    \end{macrocode}
+%\sty{polyglossia} now provides \cs{xpg@bcp@loaded}, which contains
+%a comma-separated list of language tags, so use that if
+%it exists.
+%\changes{1.6}{2022-10-29}{added check for \cs{xpg@bcp@loaded}}
+%    \begin{macrocode}
+             \@ifundefined{xpg@bcp@loaded}%
+             {% 
+%    \end{macrocode}
+% Older versions:
 % \sty{polyglossia} sets \cs{\meta{lang}@loaded} for each loaded
 % language, so check this for all known languages. I don't know how
 % to consistently check for variants. (Conditionals such as
@@ -3687,34 +232,70 @@ and~\ref{tab:nonisoopts}}
 %\changes{1.3}{2016-10-07}{removed hard-coded polyglossia language list}
 %\changes{1.3.5}{2018-02-21}{check for \cs{xpg@loaded}}
 %    \begin{macrocode}
-             \@ifundefined{xpg@loaded}%
-             {%
+               \@ifundefined{xpg@loaded}%
+               {%
 %    \end{macrocode}
 %\cs{xpg@loaded} isn't defined, so iterate over known options and
 %check if the language has been loaded.
 %    \begin{macrocode}
-               \PackageInfo{tracklang}{polyglossia loaded but
-               \string\xpg@loaded\space not defined. Will attempt
-               to track known languages.}%
-                \@for\this@language:=\@tracklang@declaredoptions\do{%
-                  \@ifundefined{\this@language @loaded}%
-                  {}%
-                  {\@nameuse{@tracklang@add@\this@language}}%
-                }%
-             }%
-             {%
-                \@for\this@language:=\xpg@loaded\do{%
-                  \@ifundefined{@tracklang@add@\this@language}%
-                  {%
-                     \PackageWarning{tracklang}%
-                       {Adding unknown polyglossia language `\this@language'}%
+                 \PackageInfo{tracklang}{polyglossia loaded but
+                 \string\xpg@loaded\space not defined. Will attempt
+                 to track known languages.}%
+                  \@for\this@language:=\@tracklang@declaredoptions\do{%
+                    \@ifundefined{\this@language @loaded}%
+                    {}%
+                    {\@nameuse{@tracklang@add@\this@language}}%
+                  }%
+                 }%
+                 {%
+                  \@for\this@language:=\xpg@loaded\do{%
+                    \@ifundefined{@tracklang@add@\this@language}%
+                    {%
+                       \PackageWarning{tracklang}%
+                         {Adding unknown polyglossia language `\this@language'}%
 %    \end{macrocode}
 %\changes{1.3.7}{2019-08-31}{corrected misspelt command}
 %    \begin{macrocode}
-                     \AddTrackedLanguage{\this@language}%
+                       \AddTrackedLanguage{\this@language}%
+                    }%
+                    {\@nameuse{@tracklang@add@\this@language}}%
                   }%
-                  {\@nameuse{@tracklang@add@\this@language}}%
-                }%
+               }%
+             }%
+             {%
+               \@for\this@language:=\xpg@bcp@loaded\do{%
+%    \end{macrocode}
+%These are language tags, which is more convenient.
+%    \begin{macrocode}
+                  \expandafter\TrackLanguageTag{\this@language}%
+               }%
+             }%
+%    \end{macrocode}
+%The \cs{xpg@bcp@loaded} list doesn't seem to include the main
+%language until the start of the document environment but
+%\cs{mainbabelname} is defined after \cs{setmainlanguage}. I'm not
+%sure if \cs{mainbabelname} was provided in the same version of
+%\sty{polyglossia} as \cs{xpg@bcp@loaded} or a different one, so
+%have a separate conditional.
+%    \begin{macrocode}
+             \@ifundefined{mainbabelname}{}%
+             {%
+               \let\@org@tracklang@add@latex\@tracklang@add@latex
+               \def\@tracklang@add@latex{%
+                 \PackageWarning{tracklang}%
+                   {Can't detect polyglossia main language. It may
+                     not have been set yet}%
+               }%
+               \@ifundefined{@tracklang@add@\mainbabelname}%
+               {%
+                 \PackageWarning{tracklang}%
+                   {Adding unknown polyglossia main babel name `\mainbabelname'}%
+                 \expandafter\AddTrackedLanguage{\mainbabelname}%
+               }%
+               {%
+                 \@nameuse{@tracklang@add@\mainbabelname}%
+               }%
+               \let\@tracklang@add@latex\@org@tracklang@add@latex
              }%
            }%
            {%
@@ -3879,7 +460,7 @@ and~\ref{tab:nonisoopts}}
 % Version info.
 %    \begin{macrocode}
 \expandafter\def\csname ver@tracklang.tex\endcsname{%
- 2020/06/30 v1.5 (NLCT) Track Languages Generic Code}
+ 2022/10/29 v1.6 (NLCT) Track Languages Generic Code}
 %    \end{macrocode}
 % Define a long command for determining the existence of a control
 % sequence by its name. (\cs{relax} is considered undefined.)
@@ -4348,18 +929,19 @@ and~\ref{tab:nonisoopts}}
 %    \end{macrocode}
 %\begin{macro}{\TrackLangQueryEnv}
 %\changes{1.3}{2016-10-07}{new}
+%\changes{1.6}{2022-10-29}{changed \cs{x} to \cs{@tracklang@x}}
 %    \begin{macrocode}
      \def\TrackLangQueryEnv{%
        \begingroup\endlinechar=-1\relax
        \everyeof{\noexpand}%
-       \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
-         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\x
+       \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
+         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\@tracklang@x
        \@tracklang@checklocale
        \ifx\TrackLangEnv\empty
          \begingroup\endlinechar=-1\relax
          \everyeof{\noexpand}%
-         \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
-           \@tracklang@input|"kpsewhich --var-value LANG" }}\x
+         \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
+           \@tracklang@input|"kpsewhich --var-value LANG" }}\@tracklang@x
 %    \end{macrocode}
 %Not sure if a path is likely to occur with \app{kpsewhich}
 %but check for it just in case.
@@ -4392,20 +974,20 @@ and~\ref{tab:nonisoopts}}
      \def\TrackLangQueryOtherEnv#1{%
        \begingroup\endlinechar=-1\relax
        \everyeof{\noexpand}%
-       \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
-         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\x
+       \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
+         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\@tracklang@x
        \@tracklang@checklocale
        \ifx\TrackLangEnv\empty
          \begingroup\endlinechar=-1\relax
          \everyeof{\noexpand}%
-         \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
-           \@tracklang@input|"kpsewhich --var-value #1" }}\x
+         \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
+           \@tracklang@input|"kpsewhich --var-value #1" }}\@tracklang@x
          \@tracklang@checklocale
          \ifx\TrackLangEnv\empty
            \begingroup\endlinechar=-1\relax
            \everyeof{\noexpand}%
-           \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
-             \@tracklang@input|"kpsewhich --var-value LANG"}}\x
+           \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
+             \@tracklang@input|"kpsewhich --var-value LANG"}}\@tracklang@x
            \@tracklang@checklocale
            \ifx\TrackLangEnv\empty
 %    \end{macrocode}
@@ -5231,6 +1813,7 @@ and~\ref{tab:nonisoopts}}
 %\end{macro}
 %
 %\begin{macro}{\ThreeLetterExtIsoLanguageCode}
+%\changes{1.3}{2016-10-07}{new}
 %    \begin{macrocode}
 \def\ThreeLetterExtIsoLanguageCode{639-3}
 %    \end{macrocode}
@@ -5688,7 +2271,7 @@ and~\ref{tab:nonisoopts}}
 %\begin{definition}
 %\cs{AddTrackedLanguageIsoCodes}\marg{language}
 %\end{definition}
-%Adds the ISO 639-1, 639-2 and 639-3 ISO codes for the given language,
+%Adds the 639-1, 639-2 and 639-3 ISO codes for the given language,
 %which must have previously been declared using
 %\cs{TrackLangNewLanguage}.
 %    \begin{macrocode}
@@ -12437,7 +9020,7 @@ and~\ref{tab:nonisoopts}}
 % Version info.
 %    \begin{macrocode}
 \expandafter\def\csname ver@tracklang-region-codes.tex\endcsname{%
- 2020/06/30 v1.5 (NLCT) Track Languages Regions}%
+ 2022/10/29 v1.6 (NLCT) Track Languages Regions}%
 %    \end{macrocode}
 %
 %\begin{macro}{\TrackLangRegionMap}
@@ -12830,7 +9413,7 @@ and~\ref{tab:nonisoopts}}
 %\changes{1.3}{2016-10-07}{added tracklang-scripts.sty}
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{tracklang-scripts}[2020/06/30 v1.5 (NLCT) Track
+\ProvidesPackage{tracklang-scripts}[2022/10/29 v1.6 (NLCT) Track
 Language Scripts (LaTeX)]
 \RequirePackage{tracklang}
 \input{tracklang-scripts}
@@ -12872,10 +9455,10 @@ Language Scripts (LaTeX)]
 % Version info.
 %    \begin{macrocode}
 \expandafter\def\csname ver@tracklang-scripts.tex\endcsname{%
- 2020/06/30 v1.5 (NLCT) Track Languages Scripts (Generic)}%
+ 2022/10/29 v1.6 (NLCT) Track Languages Scripts (Generic)}%
 %    \end{macrocode}
 %
-%\begin{macro}{\TrackLangScriptsMap}
+%\begin{macro}{\TrackLangScriptMap}
 %\changes{1.3}{2016-10-07}{new}
 %\begin{definition}
 %\cs{TrackLangScriptMap}\marg{letter
@@ -13193,7 +9776,6 @@ Language Scripts (LaTeX)]
 \TrackLangScriptMap{Tale}{353}{Tai Le}{LR}{}%
 \TrackLangScriptMap{Talu}{354}{New Tai Lue}{LR}{}%
 \TrackLangScriptMap{Taml}{346}{Tamil}{LR}{}%
-\TrackLangScriptMap{Taml}{346}{Tamil}{LR}{}%
 \TrackLangScriptMap{Tang}{520}{Tangut}{LR}{}%
 \TrackLangScriptMap{Tavt}{359}{Tai Viet}{LR}{}%
 \TrackLangScriptMap{Telu}{340}{Telugu}{LR}{}%
-- 
cgit v1.2.3

