%\iffalse
% tracklang.dtx generated using makedtx version 1.2 (c) Nicola Talbot
% Command line args:
%   -doc "tracklang-manual.tex"
%   -author "Nicola Talbot"
%   -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"
%   -section "chapter"
%   tracklang
% Created on 2019/12/1 17:41
%\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) 2019 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{6156}

\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.4:
%tracking language options}
%\author{Nicola L. C. Talbot\\\url{http://www.dickimaw-books.com/}}
%
%\date{2019-11-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
%}
%
%\SetTrackedDialectLabelMap{\CurrentTrackedDialect}{lowermartian}
%\end{verbatim}
%
%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.
%
%With \styfmt{tracklang} v1.3. The new root language can be defined
%with a minor adjustment to the above code:
%\begin{verbatim}
% \ProvidesPackage{alien}
%
% \input{tracklang}% needs v1.3
%
% \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.
%
%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{%
% \printindex[user]
% \PrintCodeIndex
% \PrintChanges
%}
%
%
%\chapter{The Code}
%\iffalse
%    \begin{macrocode}
%<*tracklang.sty>
%    \end{macrocode}
%\fi
%\changes{1.0}{2014-09-29}{Initial release}
%\section{\LaTeX\ Code (\texttt{tracklang.sty})}
% To ensure maximum portability this file only uses \LaTeX\ kernel
% commands, rather than using more convenient commands provided by
% packages such as \styfmt{etoolbox}.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tracklang}[2019/11/30 v1.4 (NLCT) Track Languages]
%    \end{macrocode}
%\begin{macro}{\@tracklang@declareoption}
% Set up package options.
%    \begin{macrocode}
\providecommand*{\@tracklang@declareoption}[1]{%
  \DeclareOption{#1}{\TrackPredefinedDialect{#1}}%
}
%    \end{macrocode}
%\end{macro}
% Load generic code:
%    \begin{macrocode}
\input{tracklang}
%    \end{macrocode}
% There are no other options as this package will typically
% be loaded using \cs{RequirePackage} by a package. Explicitly
% adding an option at that point might create a package option
% clash. The declared package options are all the possible
% language names that might be passed as a document class option.
% (Also, adding any non-language options here will interfere
% with \cs{@tracklang@declaredoptions}.)
%    \begin{macrocode}
\let\@tracklang@declaredoptions\@declaredoptions
\ProcessOptions
%    \end{macrocode}
% Unset \cs{@tracklang@declareoption}:
%    \begin{macrocode}
\let\@tracklang@declareoption\@gobble
%    \end{macrocode}
%
% In the event that the language hasn't been supplied through the
% package options (or through the class options, which the package
% options should process provided the document class has used the
% standard option declarations) we need to check if any of the known
% language packages have been loaded. This is a bit risky as it
% relies on the packages not changing their internal language
% macros. It would be easier if all the language packages could
% provide a reliable user interface to determine which languages
% (and variants) have been loaded.
%
%\begin{macro}{\@tracklang@prelangpkgcheck@hook}
%In the event that any of the language packages choose to load this
%package and use \texttt{tracklang.tex}'s commands to identify the
%tracked languages and regions, then they can first define
%\cs{@tracklang@prelangpkgcheck@hook} to do \cs{endinput} which will
%skip the checks.
%\changes{1.3.8}{2019-10-06}{new}
%    \begin{macrocode}
\csname @tracklang@prelangpkgcheck@hook\endcsname
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
\ifx\@tracklang@languages\@empty
%    \end{macrocode}
% First try \sty{babel}. If \sty{babel} has been loaded, the
% languages are stored in \cs{bbl@loaded}, so check if this command
% has been defined, and if it has add those languages.
%    \begin{macrocode}
  \@ifundefined{bbl@loaded}%
  {%
%    \end{macrocode}
% If \sty{translator} has been loaded, the languages are stored in
% \cs{trans@languages}
%    \begin{macrocode}
    \@ifundefined{trans@languages}
    {%
%    \end{macrocode}
% Has \sty{ngerman} been loaded?
%    \begin{macrocode}
       \@ifpackageloaded{ngerman}%
       {%
         \@tracklang@add@ngerman
       }%
       {%
%    \end{macrocode}
% Has \sty{german} been loaded?
%\changes{1.3}{2016-10-07}{added test for german.sty}
%    \begin{macrocode}
         \@ifpackageloaded{german}%
         {%
           \@tracklang@add@german
         }%
         {%
%    \end{macrocode}
% Has \sty{polyglossia} been loaded? 
%    \begin{macrocode}
           \@ifpackageloaded{polyglossia}
           {%
%    \end{macrocode}
% \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
% \cs{if@british@locale} are set immediately with
% \cs{setotherlanguage} but are deferred to the start of the
% document with \cs{setmainlanguage}, which is too late for
% \styfmt{tracklang}.) Script names seem to be stored in 
% \cs{xpg:scripttag@\meta{language}} but again this doesn't seem to be set
% for the main language until the start of the document.
% New versions of \sty{polyglossia} store the list of loaded
% languages in \cs{xpg@loaded}, so check if this is defined.
%\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}%
             {%
%    \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'}%
%    \end{macrocode}
%\changes{1.3.7}{2019-08-31}{corrected misspelt command}
%    \begin{macrocode}
                     \AddTrackedLanguage{\this@language}%
                  }%
                  {\@nameuse{@tracklang@add@\this@language}}%
                }%
             }%
           }%
           {%
%    \end{macrocode}
% None of the known packages have been loaded, so do nothing in case
% another package wants to load this one before setting up the
% language options. However, if at this point \sty{babel} has been
% loaded, then it's an older version that hasn't defined
% \cs{bbl@loaded} so check for this.
%    \begin{macrocode}
             \@ifpackageloaded{babel}
             {%
               \PackageInfo{tracklang}{babel loaded but
               \string\bbl@loaded\space not defined. Will attempt
               to track known languages.}%
               \@for\this@language:=\@tracklang@declaredoptions\do{%
                 \@ifundefined{captions\this@language}%
                 {}%
                 {\@nameuse{@tracklang@add@\this@language}}%
               }%
             }%
             {}%
           }%
         }%
       }%
    }%
    {%
%    \end{macrocode}
% Add from \sty{translator}.
% If \sty{translator} has been loaded, the language names are
% stored in \cs{trans@languages} but these are labels used by
% \sty{translator}, so some mapping is required.
%    \begin{macrocode}
      \let\@tracklang@add@Acadian\@tracklang@add@acadian
      \let\@tracklang@add@French\@tracklang@add@french
      \let\@tracklang@add@Afrikaans\@tracklang@add@afrikaans
      \let\@tracklang@add@Dutch\@tracklang@add@dutch
      \let\@tracklang@add@AmericanEnglish\@tracklang@add@american
      \let\@tracklang@add@Austrian\@tracklang@add@austrian
      \@namedef{@tracklang@add@Austrian1997}{\@tracklang@add@naustrian}
      \let\@tracklang@add@Bahasa\@tracklang@add@bahasa
      \let\@tracklang@add@Basque\@tracklang@add@basque
      \let\@tracklang@add@Brazilian\@tracklang@add@brazil
      \let\@tracklang@add@Portuguese\@tracklang@add@portuguese
      \let\@tracklang@add@Breton\@tracklang@add@breton
      \let\@tracklang@add@BritishEnglish\@tracklang@add@british
      \let\@tracklang@add@Bulgarian\@tracklang@add@bulgarian
      \let\@tracklang@add@Canadian\@tracklang@add@canadian
      \let\@tracklang@add@Canadien\@tracklang@add@canadien
      \let\@tracklang@add@Catalan\@tracklang@add@catalan
      \let\@tracklang@add@Croatian\@tracklang@add@croatian
      \let\@tracklang@add@Czech\@tracklang@add@czech
      \let\@tracklang@add@Danish\@tracklang@add@danish
      \let\@tracklang@add@Dutch\@tracklang@add@dutch
      \let\@tracklang@add@English\@tracklang@add@english
      \let\@tracklang@add@Esperanto\@tracklang@add@esperanto
      \let\@tracklang@add@Estonian\@tracklang@add@estonian
      \let\@tracklang@add@Finnish\@tracklang@add@finnish
      \let\@tracklang@add@French\@tracklang@add@french
      \let\@tracklang@add@Galician\@tracklang@add@galician
      \let\@tracklang@add@German\@tracklang@add@german
      \@namedef{@tracklang@add@German1997}{\@tracklang@add@ngerman}
      \let\@tracklang@add@Greek\@tracklang@add@greek
      \let\@tracklang@add@Polutoniko\@tracklang@add@polutoniko
      \let\@tracklang@add@Hebrew\@tracklang@add@hebrew
      \let\@tracklang@add@Hungarian\@tracklang@add@hungarian
      \let\@tracklang@add@Icelandic\@tracklang@add@icelandic
      \let\@tracklang@add@Irish\@tracklang@add@irish
      \let\@tracklang@add@Italian\@tracklang@add@italian
      \let\@tracklang@add@Latin\@tracklang@add@latin
      \let\@tracklang@add@LowerSorbian\@tracklang@add@lowersorbian
      \let\@tracklang@add@Magyar\@tracklang@add@magyar
      \let\@tracklang@add@Nynorsk\@tracklang@add@nynorsk
      \let\@tracklang@add@Norsk\@tracklang@add@norsk
      \let\@tracklang@add@Polish\@tracklang@add@polish
      \let\@tracklang@add@Portuguese\@tracklang@add@portuguese
      \let\@tracklang@add@Romanian\@tracklang@add@romanian
      \let\@tracklang@add@Russian\@tracklang@add@russian
      \let\@tracklang@add@Scottish\@tracklang@add@scottish
      \let\@tracklang@add@Serbian\@tracklang@add@serbian
      \let\@tracklang@add@Slovak\@tracklang@add@slovak
      \let\@tracklang@add@Slovene\@tracklang@add@slovene
      \let\@tracklang@add@Spanish\@tracklang@add@spanish
      \let\@tracklang@add@Swedish\@tracklang@add@swedish
      \let\@tracklang@add@Turkish\@tracklang@add@turkish
      \let\@tracklang@add@Ukrainian\@tracklang@add@ukrainian
      \let\@tracklang@add@UpperSorbian\@tracklang@add@uppersorbian
      \let\@tracklang@add@Welsh\@tracklang@add@welsh
%    \end{macrocode}
% Now iterate through the declared languages:
%    \begin{macrocode}
      \@for\this@language:=\trans@languages\do{%
         \@ifundefined{@tracklang@add@\this@language}{}%
         {\@nameuse{@tracklang@add@\this@language}}%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% Add from \sty{babel}
%    \begin{macrocode}
    \@for\this@language:=\bbl@loaded\do{%
       \@ifundefined{@tracklang@add@\this@language}%
       {%
         \PackageWarning{tracklang}%
           {Adding unknown babel language `\this@language'}%
%    \end{macrocode}
%\changes{1.3.7}{2019-08-31}{corrected misspelt command}
%    \begin{macrocode}
         \AddTrackedLanguage{\this@language}%
       }%
       {\@nameuse{@tracklang@add@\this@language}}%
     }%
%    \end{macrocode}
% If \sty{babel} has been loaded with \pkgoptfmt{serbian}, then 
% the script needs to be set to \texttt{Latn}. (The Cyrillic
% script is provided with \pkgoptfmt{serbianc}.)
%    \begin{macrocode}
     \ifx\captionsserbian\undefined
     \else
       \SetTrackedDialectScript{serbian}{Latn}%
     \fi
  }
%    \end{macrocode}
% End of check for language packages
%    \begin{macrocode}
\fi
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</tracklang.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*tracklang.tex>
%    \end{macrocode}
%\fi
%\section{Generic Code (\texttt{tracklang.tex})}
% Does the category code of \verb|@| need changing?
%\changes{1.3}{2016-10-07}{added check for @ category code}
%\begin{macro}{\@tracklang@restore@at}
%    \begin{macrocode}
\ifnum\catcode`\@=11\relax
  \def\@tracklang@restore@at{}%
\else
  \expandafter\edef\csname @tracklang@restore@at\endcsname{%
    \noexpand\catcode`\noexpand\@=\number\catcode`\@\relax
  }%
 \catcode`\@=11\relax
\fi
%    \end{macrocode}
%\end{macro}
% First check if this file has already been loaded:
%    \begin{macrocode}
\ifx\@tracklang@languages\undefined
\else
  \@tracklang@restore@at
  \expandafter\endinput
\fi
%    \end{macrocode}
% Version info.
%    \begin{macrocode}
\expandafter\def\csname ver@tracklang.tex\endcsname{%
 2019/11/30 v1.4 (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.)
%\begin{macro}{\@tracklang@ifundef}
%    \begin{macrocode}
\long\def\@tracklang@ifundef#1#2#3{%
  \ifcsname#1\endcsname
    \expandafter\ifx\csname #1\endcsname\relax
      #2%
    \else 
      #3%
    \fi
  \else
    \expandafter\ifx\csname #1\endcsname\relax
      #2%
    \else 
      #3%
    \fi
  \fi
}
%    \end{macrocode}
%\changes{1.3}{2016-10-07}{added check for \cs{ifcsname}}
%\cs{ifcsname} is an e\TeX\ primitive. Need to check if it's
%defined.
%    \begin{macrocode}
\ifx\ifcsname\undefined
%    \end{macrocode}
%Not using e\TeX.
%    \begin{macrocode}
  \long\def\@tracklang@ifundef#1#2#3{%
    \expandafter\ifx\csname #1\endcsname\relax
      #2%
    \else 
      #3%
    \fi
  }
%    \end{macrocode}
%Can't have an else part here as \TeX\ won't recognise
%\cs{ifcsname} and we'll have an unmatched end brace.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%\end{macro}
%
% The shell escape stuff needs the Plain \TeX\ version of
% \cs{input}. This is \cs{@@input} if we're using \LaTeX.
%\begin{macro}{\@tracklang@input}
%    \begin{macrocode}
\ifx\@@input\undefined
   \let\@tracklang@input\input
\else
   \let\@tracklang@input\@@input
\fi
%    \end{macrocode}
%\end{macro}
%
% Provide some commands in case the \LaTeX\ kernel hasn't been loaded.
%\begin{macro}{\@tracklang@nnil}
%    \begin{macrocode}
\ifx\@nnil\undefined
  \def\@tracklang@nnil{\@nil}
\else
  \let\@tracklang@nnil\@nnil
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@for}
%    \begin{macrocode}
\ifx\@for\undefined
  \long\def\@tracklang@for#1:=#2\do#3{%
    \expandafter\def\expandafter\@fortmp\expandafter{#2}%
    \ifx\@fortmp\empty
    \else
      \expandafter
        \@tracklang@forloop #2,\@nil,\@nil\@@ #1{#3}%
    \fi
  }
  \long\def\@tracklang@forloop#1,#2,#3\@@ #4#5{%
   \def #4{#1}%
   \ifx#4\@tracklang@nnil
   \else
     #5%
     \def #4{#2}%
     \ifx#4\@tracklang@nnil
     \else
       #5%
       \@tracklang@iforloop #3\@@ #4{#5}%
     \fi
   \fi
  }
  \long\def\@tracklang@iforloop#1,#2\@@ #3#4{%
    \def#3{#1}%
    \ifx#3\@tracklang@nnil
      \expandafter
        \@tracklang@fornoop
    \else
      #4\relax
      \expandafter\@tracklang@iforloop
    \fi
    #2\@@ #3{#4}%
  }
  \long\def\@tracklang@fornoop#1\@@ #2#3{}
\else
  \let\@tracklang@for\@for
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@namedef}
%    \begin{macrocode}
\ifx\@namedef\undefined
  \def\@tracklang@namedef#1{\expandafter\def\csname#1\endcsname}
\else
  \let\@tracklang@namedef\@namedef
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@enamedef}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@enamedef#1{\expandafter\edef\csname#1\endcsname}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@nameuse}
%\changes{1.3}{2016-10-07}{added check for undef}
%    \begin{macrocode}
\def\@tracklang@nameuse#1{%
  \@tracklang@ifundef{#1}{}{\csname#1\endcsname}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifcseqcsname}
%\changes{1.4}{2019-11-30}{new}
%\begin{definition}
%\cs{@tracklang@ifcseqcsname}\marg{cs}\marg{csname}\marg{true}\marg{false}
%\end{definition}
%Compares two commands, the first is reference as a control sequence
%the second is referenced as a control sequence name. Condition is
%false if the second isn't defined (no check for the existence of
%the first).
%    \begin{macrocode}
\def\@tracklang@ifcseqcsname#1#2#3#4{%
  \@tracklang@ifundef{#2}{#4}%
  {%
    \expandafter\ifx\expandafter#1\csname#2\endcsname
      #3%
    \else
      #4%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@sanitize}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\ifx\@onelevel@sanitize\undefined
  \def\@tracklang@sanitize#1{%
    \edef#1{\expandafter\@tracklang@strip@prefix\meaning#1}%
  }
  \def\@tracklang@strip@prefix#1>{}
\else
  \let\@tracklang@sanitize\@onelevel@sanitize
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@firstoftwo}
%\changes{1.3}{2016-10-07}{new}
%\changes{1.4}{2019-11-30}{made long}
%    \begin{macrocode}
\long\def\@tracklang@firstoftwo#1#2{#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@secondoftwo}
%\changes{1.3}{2016-10-07}{new}
%\changes{1.4}{2019-11-30}{made long}
%    \begin{macrocode}
\long\def\@tracklang@secondoftwo#1#2{#2}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@err}
%\changes{1.3.4}{2017-03-25}{fixed typo in \cs{errhelp} command name}
%    \begin{macrocode}
\ifx\PackageError\undefined
  \def\@tracklang@err#1#2{%
    \errhelp{#2}%
    \errmessage{tracklang: #1}}
\else
  \def\@tracklang@err#1#2{\PackageError{tracklang}{#1}{#2}}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifTrackLangShowWarnings}
%\changes{1.3}{2016-10-07}{new}
%Allow user to switch warnings on or off.
%    \begin{macrocode}
\newif\ifTrackLangShowWarnings
\TrackLangShowWarningstrue
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@pkgwarn}
%\changes{1.3.4}{2017-03-25}{new}
%Provided for related packages such as \sty{texosquery}.
%    \begin{macrocode}
\ifx\PackageWarning\undefined
  \def\@tracklang@pkgwarn#1#2{%
    \ifTrackLangShowWarnings
      {%
        \newlinechar=`\^^J
        \def\MessageBreak{^^J}%
        \message{^^J#1 Warning: #2 on line \the\inputlineno.^^J}%
      }%
    \fi
  }
\else
  \def\@tracklang@pkgwarn#1#2{%
    \ifTrackLangShowWarnings
      \PackageWarning{#1}{#2}%
    \fi
  }
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@warn}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@warn#1{\@tracklang@pkgwarn{tracklang}{#1}}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifTrackLangShowInfo}
%\changes{1.3}{2016-10-07}{new}
%Allow user to switch information messages on or off.
%    \begin{macrocode}
\newif\ifTrackLangShowInfo
\TrackLangShowInfotrue
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@info}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\ifx\PackageInfo\undefined
  \def\@tracklang@info#1{%
   \ifTrackLangShowInfo
     {%
       \newlinechar=`\^^J
       \def\MessageBreak{^^J}%
       \message{^^Jtracklang Info: #1 on line \the\inputlineno.^^J}%
     }%
   \fi
  }%
\else
  \def\@tracklang@info#1{%
    \ifTrackLangShowInfo
      \PackageInfo{tracklang}{#1}%
    \fi
  }%
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifTrackLangShowVerbose}
%\changes{1.4}{2019-11-30}{new}
% Allow user to switch verbose (debugging) information messages on or off.
% Note that verbose information will be off regardless of this
% switch if the info switch is off.
%    \begin{macrocode}
\newif\ifTrackLangShowVerbose
\TrackLangShowVerbosefalse
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@verbose}
%\changes{1.4}{2019-11-30}{new}
%    \begin{macrocode}
\def\@tracklang@verbose#1{%
  \ifTrackLangShowVerbose
    \@tracklang@info{#1}%
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@IfFileExists}
%    \begin{macrocode}
\ifx\IfFileExists\undefined
 \long\def\@tracklang@IfFileExists#1#2#3{%
   \openin0=#1 %
   \ifeof0\relax
     \def\@tracklang@tmp{#3}%
   \else
     \closein0\relax
     \edef\@filef@und{#1 }%
     \def\@tracklang@tmp{#2}%
   \fi
   \@tracklang@tmp
 }

\else
  \let\@tracklang@IfFileExists\IfFileExists
\fi
%    \end{macrocode}
%\end{macro}
%
%Provide a way to query the environment variables \envvar{LC\_ALL}
%or \envvar{LANG} to determine the region and language. The result
% is stored in \cs{TrackLangEnv} if it can be obtained. If
% it can't be obtained, \cs{TrackLangEnv} is set to empty.
% Also define \cs{TrackLangQueryOtherEnv}\marg{name} to query
% \texttt{LC\_ALL}, \meta{name}, \texttt{LANG}.
% For example
%\begin{verbatim}
%\TrackLangQueryOtherEnv{LC\_MONETARY}
%\end{verbatim}
%Note that there's not much that can be done from within \TeX\
%for the C or POSIX locale or a locale starting with a slash, so
%provide a check for them.
%\begin{macro}{\@tracklang@checklocale}
%    \begin{macrocode}
\def\@tracklang@checklocale{%
  \ifx\TrackLangEnv\empty
  \else
    \ifx\TrackLangEnv\@tracklang@locale@posix
      \def\TrackLangEnv{}%
    \else
      \ifx\TrackLangEnv\@tracklang@locale@c
        \def\TrackLangEnv{}%
      \else
        \expandafter\@@tracklang@checklocale
           \TrackLangEnv\empty\relax
      \fi
    \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@@tracklang@checklocale}
%\changes{1.3}{2016-10-07}{new}
%Check for leading slash.
%    \begin{macrocode}
\def\@@tracklang@checklocale#1#2\relax{%
  \ifx#1/\relax
    \def\TrackLangEnv{}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@locale@posix}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@locale@posix{POSIX}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@locale@c}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@locale@c{C}
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
\ifx\directlua\undefined
%    \end{macrocode}
%We can't use Lua, so we'll have to use the shell escape if it's
%enabled. First determine if the shell escape is available.
%\begin{macro}{\@tracklang@tryshellescape}
%No shell escape.
%    \begin{macrocode}
  \def\@tracklang@tryshellescape#1{%
   \def\TrackLangQueryEnv{%
     \@tracklang@warn{\string\TrackLangQueryEnv\space
     non-operational as shell escape has been disabled}%
     \def\TrackLangEnv{}%
   }%
   \def\TrackLangQueryOtherEnv##1{%
     \@tracklang@warn{\string\TrackLangQueryOtherEnv{##1}\space
     non-operational as shell escape has been disabled}%
     \def\TrackLangEnv{}%
   }%
  }%
%    \end{macrocode}
%\changes{1.3.2}{2016-10-11}{added check if \cs{shellescape} has
%been set to \cs{relax}}
%    \begin{macrocode}
   \ifx\pdfshellescape\undefined
     \ifx\shellescape\undefined
%    \end{macrocode}
% Can't determine if the shell escape has been enabled.
%    \begin{macrocode}
        \def\@tracklang@tryshellescape#1{%
          \def\TrackLangQueryEnv{%
            \@tracklang@warn{\string\TrackLangQueryEnv\space
            non-operational as can't determine if the 
            shell escape has been enabled. (Consider using
            eTeX or pdfTeX.)}%
            \def\TrackLangEnv{}%
          }%
          \def\TrackLangQueryOtherEnv##1{%
            \@tracklang@warn{\string\TrackLangQueryOtherEnv{##1}\space
            non-operational as can't determine if the 
            shell escape has been enabled. (Consider using
            eTeX or pdfTeX.)}%
            \def\TrackLangEnv{}%
          }%
        }%
     \else
%    \end{macrocode}
%\cs{shellescape} is defined. Check no one's been messing around
%with it and set it to \cs{relax}.
%    \begin{macrocode}
       \ifx\shellescape\relax
       \else
         \ifnum\shellescape=0\relax
         \else
           \def\@tracklang@tryshellescape#1{#1}%
         \fi
       \fi
     \fi
   \else
%    \end{macrocode}
%\cs{pdfshellescape} is defined. Check no one's been messing around
%with it and set it to \cs{relax}. (Default no-op already set.)
%    \begin{macrocode}
     \ifx\pdfshellescape\relax
%    \end{macrocode}
%\cs{pdfshellescape} has been set to \cs{relax}. Is it possible that
%\cs{shellescape} is available?
%    \begin{macrocode}
       \ifx\shellescape\undefined
       \else
         \ifx\shellescape\relax
         \else
%    \end{macrocode}
%\cs{shellescape} is available.
%    \begin{macrocode}
           \ifnum\shellescape=0\relax
           \else
             \def\@tracklang@tryshellescape#1{#1}%
           \fi
         \fi
       \fi
     \else
       \ifnum\pdfshellescape=0\relax
       \else
         \def\@tracklang@tryshellescape#1{#1}%
       \fi
     \fi
   \fi
%    \end{macrocode}
%\end{macro}
% Try the shell escape:
%    \begin{macrocode}
   \@tracklang@tryshellescape
   {%
%    \end{macrocode}
%\begin{macro}{\TrackLangQueryEnv}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
     \def\TrackLangQueryEnv{%
       \begingroup\endlinechar=-1\relax
       \everyeof{\noexpand}%
       \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\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
%    \end{macrocode}
%Not sure if a path is likely to occur with \app{kpsewhich}
%but check for it just in case.
%    \begin{macrocode}
         \@tracklang@checklocale
         \ifx\TrackLangEnv\empty
%    \end{macrocode}
% Try texosquery if available.
%    \begin{macrocode}
           \ifx\TeXOSQueryLocale\undefined
             \@tracklang@warn{Locale environment variables
              unavailable (tried LC\string_ALL and LANG)}%
           \else
             \@tracklang@info{Using texosquery to find locale}%
             \TeXOSQueryLocale\TrackLangEnv
             \ifx\TrackLangEnv\empty
               \@tracklang@warn{Locale can't be found 
               (tried querying LC\string_ALL and LANG variables and
               tried using texosquery)}%
             \fi
           \fi
         \fi
       \fi
     }%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\TrackLangQueryOtherEnv}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
     \def\TrackLangQueryOtherEnv#1{%
       \begingroup\endlinechar=-1\relax
       \everyeof{\noexpand}%
       \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\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
         \@tracklang@checklocale
         \ifx\TrackLangEnv\empty
           \begingroup\endlinechar=-1\relax
           \everyeof{\noexpand}%
           \edef\x{\endgroup\def\noexpand\TrackLangEnv{%
             \@tracklang@input|"kpsewhich --var-value LANG"}}\x
           \@tracklang@checklocale
           \ifx\TrackLangEnv\empty
%    \end{macrocode}
% Try texosquery if available.
%    \begin{macrocode}
             \ifx\TeXOSQueryLocale\undefined
             \@tracklang@warn{Locale environment variables unavailable
              (tried LC\string_ALL, #1 and LANG)}%
             \else
               \@tracklang@info{Using texosquery to find locale}%
               \TeXOSQueryLocale\TrackLangEnv
               \ifx\TrackLangEnv\empty
                 \@tracklang@warn{Locale can't be found 
                 (tried querying LC\string_ALL, #1 and LANG variables and
                 tried using texosquery)}%
               \fi
             \fi
           \fi
         \fi
       \fi
     }%
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
  }%
\else
%    \end{macrocode}
%\cs{directlua} is defined, so we can query it through Lua:
%\begin{macro}{\TrackLangQueryEnv}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
   \def\TrackLangQueryEnv{%
     \edef\TrackLangEnv{\directlua{
       l = os.getenv("LC_ALL")
       if l == nil or l == "" or l == "C" or l == "POSIX"
                   or string.find(l, "^/") then
         l = os.getenv("LANG")
         if l == nil or l == "" or l == "C" or l == "POSIX"
                     or string.find(l, "^/") then
           l=os.setlocale(nil)
           if l == nil or l == "C" or l == "POSIX"
                       or string.find(l, "^/") then
             l = ""
           end
         end
       end
       tex.print(l)}}%
       \ifx\TrackLangEnv\empty
%    \end{macrocode}
% Try texosquery if available.
%    \begin{macrocode}
         \ifx\TeXOSQueryLocale\undefined
         \@tracklang@warn{Locale can't be found through Lua
          (tried querying LC\string_ALL and LANG variables and
           os.setlocale(nil))}%
         \else
           \TeXOSQueryLocale\TrackLangEnv
           \ifx\TrackLangEnv\empty
             \@tracklang@warn{Locale can't be found through Lua
             (tried querying LC\string_ALL and LANG variables and
             os.setlocale(nil) and tried using texosquery)}%
           \fi
         \fi
       \fi
   }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\TrackLangQueryOtherEnv}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
   \def\TrackLangQueryOtherEnv#1{%
     \edef\TrackLangEnv{\directlua{
       l = os.getenv("LC_ALL")
       if l == nil or l == "" or l == "C" or l == "POSIX"
                   or string.find(l, "^/") then
         l = os.getenv("#1")
         if l == nil or l == "" or l == "C" or l == "POSIX"
                     or string.find(l, "^/") then
           l = os.getenv("LANG")
           if l == nil or l == "" or l == "C" or l == "POSIX"
                       or string.find(l, "^/") then
             l=os.setlocale(nil)
             if l == nil or l == "C" or l == "POSIX"
                         or string.find(l, "^/") then
               l = ""
             end
           end
         end
       end
       tex.print(l}}%
       \ifx\TrackLangEnv\empty
%    \end{macrocode}
% Try texosquery if available.
%    \begin{macrocode}
         \ifx\TeXOSQueryLocale\undefined
         \@tracklang@warn{Locale can't be found through Lua
          (tried querying LC\string_ALL, #1 and LANG variables and
           os.setlocale(nil))}%
         \else
           \TeXOSQueryLocale\TrackLangEnv
           \ifx\TrackLangEnv\empty
             \@tracklang@warn{Locale can't be found through Lua
             (tried querying LC\string_ALL, #1 and LANG variables and
             os.setlocale(nil) and tried using texosquery)}%
           \fi
         \fi
       \fi
   }
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% Allowed formats for the localisation environment variables are 
%\begin{definition}
%\meta{iso-lang}[\_\meta{iso-territory}][\texttt{.}\meta{encoding}][@\meta{modifier}]
%\end{definition}
%(where the square brackets above indicate an optional component not that
%there are literal square brackets.) This is a bit fiddly, so it
%needs to be broken up into manageable chunks.
%
%\begin{macro}{\TrackLangParseFromEnv}
%\changes{1.3}{2016-10-07}{new}
%Parse \cs{TrackLangEnv}, if it has been
%set, and set \cs{TrackLangEnvLang}, \cs{TrackLangEnvTerritory}
% and \cs{TrackLangEnvCodeSet}. If the information is unavailable, 
% the relevant commands will be set to empty. Use
% \cs{TrackLangFromEnv} to query, parse and set.
%    \begin{macrocode}
\def\TrackLangParseFromEnv{%
  \ifx\TrackLangEnv\undefined
     \@tracklang@warn{\string\TrackLangParseFromEnv\space
     non-operational as \string\TrackLangEnv\space hasn't been
     defined}%
     \def\TrackLangEnvLang{}%
     \def\TrackLangEnvTerritory{}%
     \def\TrackLangEnvCodeSet{}%
     \def\TrackLangEnvModifier{}%
  \else
    \ifx\TrackLangEnv\empty
      \@tracklang@warn{\string\TrackLangParseFromEnv\space
      non-operational as \string\TrackLangEnv\space is empty}%
      \def\TrackLangEnvLang{}%
      \def\TrackLangEnvTerritory{}%
      \def\TrackLangEnvCodeSet{}%
      \def\TrackLangEnvModifier{}%
    \else
      \@tracklang@parse@locale{\TrackLangEnv}%
      \let\TrackLangEnvLang\@TrackLangEnvLang
      \let\TrackLangEnvTerritory\@TrackLangEnvTerritory
      \let\TrackLangEnvCodeSet\@TrackLangEnvCodeSet
      \let\TrackLangEnvModifier\@TrackLangEnvModifier
    \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@parse@locale}
%\changes{1.3}{2016-10-07}{new}
%Parse localisation format.
%    \begin{macrocode}
\def\@tracklang@parse@locale#1{%
%    \end{macrocode}
%Initialise.
%    \begin{macrocode}
  \def\@TrackLangEnvLang{}%
  \def\@TrackLangEnvSubLang{}%
  \def\@TrackLangEnvFirstSubLang{}%
  \def\@TrackLangEnvTerritory{}%
  \def\@TrackLangEnvCodeSet{}%
  \def\@TrackLangEnvVariant{}%
  \def\@TrackLangEnvModifier{}%
  \def\@TrackLangEnvScript{}%
  \def\@TrackLangEnvAdditional{}%
%    \end{macrocode}
%Just in case argument is empty or \cs{relax}.
%    \begin{macrocode}
  \expandafter\ifx\expandafter\relax#1\relax
  \else
%    \end{macrocode}
% Parse codeset and modifier first.
%    \begin{macrocode}
    \expandafter\@tracklang@parseenv
      #1..\relax\@tracklang@end@parseenv\@tracklang@result
%    \end{macrocode}
% Parse language and territory.
%    \begin{macrocode}
    \ifx\@tracklang@result\empty
    \else
      \expandafter\@tracklang@split@underscoreorhyp\expandafter
       {\@tracklang@result}%
      \let\@TrackLangEnvLang\@tracklang@split@pre
      \let\@TrackLangEnvTerritory\@tracklang@split@post
    \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@split@underscoreorhyp}
%\changes{1.3}{2016-10-07}{new}
%Split on either an underscore or a hyphen and store the results in
%\cs{@tracklang@split@pre} and \cs{@tracklang@split@post}
%    \begin{macrocode}
\def\@tracklang@split@underscoreorhyp#1{%
%    \end{macrocode}
%First try to split on an underscore.
%    \begin{macrocode}
  \@tracklang@split@underscore{#1}%
%    \end{macrocode}
%If the post part was empty, try to split on hyphen instead.
%    \begin{macrocode}
  \ifx\@tracklang@split@post\empty
    \@tracklang@split@hyphen{#1}%
%    \end{macrocode}
%If the post part was empty, maybe the underscore has had its
%category code changed to 12.
%    \begin{macrocode}
    \ifx\@tracklang@split@post\empty
      \@tracklang@split@otherunderscore{#1}%
    \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@split@underscore}
%\changes{1.3}{2016-10-07}{new}
%Split on an underscore and store the results in
%\cs{@tracklang@split@pre} and \cs{@tracklang@split@post}. First
%make sure that the underscore has its normal subscript category code.
%    \begin{macrocode}
{
  \catcode`\_8\relax
  \gdef\@tracklang@split@underscore#1{%
    \@@tracklang@split@underscore#1__\relax\@tracklang@end@split@underscore
  }
  \gdef\@@tracklang@split@underscore#1_#2_#3\@tracklang@end@split@underscore{%
    \def\@tracklang@split@pre{#1}%
    \ifx\relax#3\relax
      \def\@tracklang@split@post{#2}%
    \else
      \@tracklang@split@underscore@remainder#2_#3%
    \fi
  }
  \gdef\@tracklang@split@underscore@remainder#1__\relax{%
    \def\@tracklang@split@post{#1}%
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@split@otherunderscore}
%\changes{1.3}{2016-10-07}{new}
%As above but where underscore has catcode 12.
%    \begin{macrocode}
{
  \catcode`\_12\relax
  \gdef\@tracklang@split@otherunderscore#1{%
    \@@tracklang@split@otherunderscore#1__\relax\@tracklang@end@split@underscore
  }
  \gdef\@@tracklang@split@otherunderscore#1_#2_#3\@tracklang@end@split@underscore{%
    \def\@tracklang@split@pre{#1}%
    \ifx\relax#3\relax
      \def\@tracklang@split@post{#2}%
    \else
      \@tracklang@split@otherunderscore@remainder#2_#3%
    \fi
  }
  \gdef\@tracklang@split@otherunderscore@remainder#1__\relax{%
    \def\@tracklang@split@post{#1}%
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@split@hyphen}
%\changes{1.3}{2016-10-07}{new}
%Split on a hyphen and store the results in
%\cs{@tracklang@split@pre} and \cs{@tracklang@split@post}
%    \begin{macrocode}
{
  \catcode`\-12\relax
  \gdef\@tracklang@split@hyphen#1{%
    \@@tracklang@split@hyphen#1--\relax\@tracklang@end@split@hyphen
  }
  \gdef\@@tracklang@split@hyphen#1-#2-#3\@tracklang@end@split@hyphen{%
    \def\@tracklang@split@pre{#1}%
    \ifx\relax#3\relax
      \def\@tracklang@split@post{#2}%
    \else
      \@tracklang@split@hyphen@remainder#2-#3%
    \fi
  }
  \gdef\@tracklang@split@hyphen@remainder#1--\relax{%
    \def\@tracklang@split@post{#1}%
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@parseenv}
%\changes{1.3}{2016-10-07}{new}
%Parse for the codeset. The first argument will be the
%language and (optionally) the territory. So the final argument is the control
%sequence to use to store the first argument, which can then be
%split.
%    \begin{macrocode}
\gdef\@tracklang@parseenv#1.#2.#3\@tracklang@end@parseenv#4{%
  \def\@TrackLangEnvCodeSet{#2}%
  \def#4{#1}%
  \ifx\@TrackLangEnvCodeSet\empty
    \tracklangparsemod#4%
  \else
    \tracklangparsemod\@TrackLangEnvCodeSet
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\tracklangparsemod}
% Extract the modifier from the code set.
% The \texttt{@} is rather awkward as we need to change its category
% code as it's likely to be set to 12 within \cs{TrackLangEnv}.
% So change the category code of \texttt{@} to 12, but this means we
% can't use it in the command name, so although these are private
% internal commands they don't look like internal commands.)
%    \begin{macrocode}
{\catcode`\@=12\relax
  \gdef\tracklangparsemod#1{
    \expandafter\tracklangparseenvatmod#1@@\relax\tracklangendparseenvatmod
    \let#1\tracklangtmp
  }%
  \gdef\tracklangparseenvatmod#1@#2@#3\tracklangendparseenvatmod{%
    \def\tracklangtmp{#1}%
%    \end{macrocode}
%Need to use \cs{csname} here as can't use internal commands.
%    \begin{macrocode}
    \expandafter\def\csname @TrackLangEnvModifier\endcsname{#2}%
%    \end{macrocode}
%Sanitize in case it contains any special characters.
%    \begin{macrocode}
    \csname @tracklang@sanitize\expandafter\endcsname
      \csname @TrackLangEnvModifier\endcsname
  }
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Internal Lists}
%
%\begin{macro}{\@tracklang@languages}
% Provide a list to keep track of all the languages.
%    \begin{macrocode}
\def\@tracklang@languages{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@dialects}
% Provide a list to keep track of all the dialects. Here the
% \qt{dialect} isn't necessarily an actual dialect but may be a
% root language or a synonym. It will usually correspond to the
% language name as specified by the user in the package option.
%    \begin{macrocode}
\def\@tracklang@dialects{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifinlist}
%\begin{definition}
%\cs{@tracklang@ifinlist}\marg{item}\marg{list}\marg{true
%part}\marg{false part}
%\end{definition}
%Checks if \meta{item} is in \meta{list}. (Performs a one-level
%expansion on \meta{list} but no expansion on \meta{item}.)
%    \begin{macrocode}
\def\@tracklang@ifinlist#1#2#3#4{%
  \def\@tracklang@doifinlist##1,#1,##2\end@tracklang@doifinlist{%
     \def\@before{##1}%
     \def\@after{##2}%
  }%
  \expandafter\@tracklang@doifinlist\expandafter,#2,#1,\@nil
    \end@tracklang@doifinlist
  \ifx\@after\@tracklang@nnil
%    \end{macrocode}
% not found
%    \begin{macrocode}
    #4%
  \else
%    \end{macrocode}
% found
%    \begin{macrocode}
    #3%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add}
%\begin{definition}
%\cs{@tracklang@add}\marg{item}\marg{list cs}
%\end{definition}
% Adds an item to the list given by \meta{list cs}. Does nothing if
% \meta{item} is empty or is already in the list. The \meta{item} is
% fully expanded before being added.
%    \begin{macrocode}
\def\@tracklang@add#1#2{%
%    \end{macrocode}
% First find out if the item is empty.
%    \begin{macrocode}
  \edef\@tracklang@element{#1}%
  \ifx\@tracklang@element\empty
%    \end{macrocode}
% Item is empty, so do nothing.
%    \begin{macrocode}
  \else
    \expandafter\@tracklang@ifinlist\expandafter{\@tracklang@element}#2%
    {%
%    \end{macrocode}
% Already in list, so do nothing.
%    \begin{macrocode}
    }%
    {%
%    \end{macrocode}
% Not in list, so add.
%    \begin{macrocode}
     \ifx\empty#2\relax
       \let#2\@tracklang@element
     \else
       \edef#2{#2,\@tracklang@element}%
     \fi
    }%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\AddTrackedDialect}
%\begin{definition}
%\cs{AddTrackedDialect}\marg{dialect name}\marg{language name}
%\end{definition}
% Add a dialect. (v1.3 switched from unexpanded to expanded def.
% All labels should be expandable.)
%    \begin{macrocode}
\def\AddTrackedDialect#1#2{%
 \@tracklang@add{#1}{\@tracklang@dialects}%
 \@tracklang@add{#2}{\@tracklang@languages}%
 \@tracklang@enamedef{@tracklang@fromdialect@#1}{#2}%
 \@tracklang@ifundef{@tracklang@todialect@#2}%
 {\@tracklang@enamedef{@tracklang@todialect@#2}{#1}}%
 {%
   \def\@tracklang@lang{#1}%
   \expandafter\@tracklang@add\expandafter\@tracklang@lang
     \csname @tracklang@todialect@#2\endcsname
 }%
%    \end{macrocode}
% Provide a convenient way of referencing the last dialect to be
% tracked.
%    \begin{macrocode}
 \edef\TrackLangLastTrackedDialect{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\AddTrackedLanguage}
%\begin{definition}
%\cs{AddTrackedLanguage}\marg{language name}
%\end{definition}
% Add a dialect.
%    \begin{macrocode}
\def\AddTrackedLanguage#1{%
  \AddTrackedDialect{#1}{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Known Languages}
%\label{sec:code:knownlangs}
%
%\begin{macro}{\@tracklang@known@langs}
%\changes{1.3}{2016-10-07}{new}
%List of known (root) languages (that may or may not be tracked).
%    \begin{macrocode}
\def\@tracklang@known@langs{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangNewLanguage}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\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}
%Identifies a new language that may be tracked. The code
%arguments may be empty if not available.
%(v1.3 switched from unexpanded to expanded def.
%All labels should be expandable.) Most
%root languages don't have an associated country code as they're
%spoken in multiple regions. The \meta{default script} is the
%default script identified with the ISO 15924 alpha script code.
%To reduce overheads, only define 639-3 if there's no 639-1 or 639-2
%code.
%    \begin{macrocode}
\def\TrackLangNewLanguage#1#2#3#4#5#6#7{%
 \@tracklang@add{#1}{\@tracklang@known@langs}%
 \edef\@tracklang@tmp{#2}%
 \ifx\@tracklang@tmp\empty
 \else
   \@tracklang@enamedef{@tracklang@knownisolang@#2}{#1}%
   \@tracklang@enamedef{@tracklang@knowniso@639@1@#1}{#2}%
 \fi
 \edef\@tracklang@tmp{#3}%
 \ifx\@tracklang@tmp\empty
 \else
   \@tracklang@enamedef{@tracklang@knownisolang@#3}{#1}%
   \@tracklang@enamedef{@tracklang@knowniso@639@2@#1}{#3}%
 \fi
 \edef\@tracklang@tmp{#4}%
 \ifx\@tracklang@tmp\empty
 \else
   \@tracklang@enamedef{@tracklang@knowniso@639@2B@#1}{#4}%
 \fi
 \edef\@tracklang@tmp{#5}%
 \ifx\@tracklang@tmp\empty
 \else
   \@tracklang@enamedef{@tracklang@knownisolang@#5}{#1}%
   \@tracklang@enamedef{@tracklang@knowniso@639@3@#1}{#5}%
 \fi
 \edef\@tracklang@tmp{#6}%
 \ifx\@tracklang@tmp\empty
 \else
   \@tracklang@enamedef{@tracklang@knowniso@3166@#1}{#6}%
 \fi
 \edef\@tracklang@tmp{#7}%
 \ifx\@tracklang@tmp\empty
 \else
   \@tracklang@enamedef{@tracklang@knowniso@script@#1}{#7}%
 \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfKnownLang}\marg{language}\marg{true}\marg{false}
%\end{definition}
%Tests if \meta{language} is known (but not necessarily tracked).
%    \begin{macrocode}
\def\TrackLangIfKnownLang#1#2#3{%
  \expandafter\@tracklang@ifinlist\expandafter{#1}{\@tracklang@known@langs}%
  {#2}%
  {#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownIsoTwoLetterLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfKnownIsoTwoLetterLang}\marg{language}\marg{true}\marg{false}
%\end{definition}
%Checks if the given language has an ISO 639-1 language code 
%(but is not necessarily tracked).
%    \begin{macrocode}
\def\TrackLangIfKnownIsoTwoLetterLang#1#2#3{%
  \@tracklang@ifundef{@tracklang@knowniso@639@1@#1}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangGetKnownIsoTwoLetterLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangGetKnownIsoTwoLetterLang}\marg{language}
%\end{definition}
%Gets the ISO 639-1 language code for the given language.
%    \begin{macrocode}
\def\TrackLangGetKnownIsoTwoLetterLang#1{%
  \@tracklang@nameuse{@tracklang@knowniso@639@1@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownIsoThreeLetterLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfKnownIsoThreeLetterLang}\marg{language}\marg{true}\marg{false}
%\end{definition}
%Checks if the given language has an ISO 639-2 language code 
%(but is not necessarily tracked).
%    \begin{macrocode}
\def\TrackLangIfKnownIsoThreeLetterLang#1#2#3{%
  \@tracklang@ifundef{@tracklang@knowniso@639@2@#1}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangGetKnownIsoThreeLetterLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangGetKnownIsoThreeLetterLang}\marg{language}
%\end{definition}
%Gets the ISO 639-2 language code.
%    \begin{macrocode}
\def\TrackLangGetKnownIsoThreeLetterLang#1{%
  \@tracklang@nameuse{@tracklang@knowniso@639@2@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownIsoThreeLetterLangB}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfKnownIsoThreeLetterLangB}\marg{language}\marg{true}\marg{false}
%\end{definition}
%Checks if the given language has an ISO 639-2 (B) language code 
%(but is not necessarily tracked).
%    \begin{macrocode}
\def\TrackLangIfKnownIsoThreeLetterLangB#1#2#3{%
  \@tracklang@ifundef{@tracklang@knowniso@639@2B@#1}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangGetKnownIsoThreeLetterLangB}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangGetKnownIsoThreeLetterLangB}\marg{language}
%\end{definition}
%Gets the ISO 639-2 (B) language code.
%    \begin{macrocode}
\def\TrackLangGetKnownIsoThreeLetterLangB#1{%
  \@tracklang@nameuse{@tracklang@knowniso@639@2B@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownLangFromIso}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfKnownLangFromIso}\marg{ISO code}\marg{true}\marg{false}
%\end{definition}
%Checks if the given ISO language code (639-1 or 639-2 or 639-3) is
%recognised (but not necessarily tracked).
%    \begin{macrocode}
\def\TrackLangIfKnownLangFromIso#1#2#3{%
  \@tracklang@ifundef{@tracklang@knownisolang@#1}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangGetKnownLangFromIso}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangGetKnownLangFromIso}\marg{ISO code}
%\end{definition}
%Gets the root language label from the given ISO code (639-1 or
%639-2).
%    \begin{macrocode}
\def\TrackLangGetKnownLangFromIso#1{%
  \@tracklang@nameuse{@tracklang@knownisolang@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfHasKnownCountry}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfHasKnownCountry}\marg{language}\marg{true}\marg{false}
%\end{definition}
%Checks if the given language has an ISO 3166-1 country code 
%(but is not necessarily tracked).
%    \begin{macrocode}
\def\TrackLangIfHasKnownCountry#1#2#3{%
  \@tracklang@ifundef{@tracklang@knowniso@3166@#1}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangGetKnownCountry}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangGetKnownCountry}\marg{language}
%\end{definition}
%Fetches the ISO 3166-1 country code for the given language.
%    \begin{macrocode}
\def\TrackLangGetKnownCountry#1{%
  \@tracklang@nameuse{@tracklang@knowniso@3166@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangGetDefaultScript}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangGetDefaultScript}\marg{language}
%\end{definition}
% Gets the default script for the given root language label.
%    \begin{macrocode}
\def\TrackLangGetDefaultScript#1{%
  \@tracklang@nameuse{@tracklang@knowniso@script@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfHasDefaultScript}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfHasDefaultScript}\marg{language}\marg{true}\marg{false}
%\end{definition}
%If there's a default script for \meta{language}, do \meta{true} otherwise
%do \meta{false}.
%    \begin{macrocode}
\def\TrackLangIfHasDefaultScript#1#2#3{%
  \@tracklang@ifundef{@tracklang@knowniso@script@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Mappings}
%\label{sec:code:mappings}
%
%\begin{macro}{\AddTrackedIsoLanguage}
%\begin{definition}
%\cs{AddTrackedIsoLanguage}\marg{code type}\marg{code}\marg{language}
%\end{definition}
% Adds a~mapping between the given ISO code and language
% name. There may be multiple mappings from an ISO code to a
% language name, but only one mapping from a language name to an ISO
% code. (v1.3 switched from unexpanded to expanded def.
% All labels should be expandable.)
%    \begin{macrocode}
\def\AddTrackedIsoLanguage#1#2#3{%
  \@tracklang@enamedef{@tracklang@#1@isofromlang@#3}{#2}%
  \@tracklang@ifundef{@tracklang@#1@isotolang@#2}%
  {\@tracklang@enamedef{@tracklang@#1@isotolang@#2}{#3}}%
  {%
    \def\@tracklang@lang{#3}%
    \expandafter\@tracklang@add\expandafter\@tracklang@lang
      \csname @tracklang@#1@isotolang@#2\endcsname
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackedLanguageFromIsoCode}
%\begin{definition}
%\cs{TrackedLanguageFromIsoCode}\marg{code type}\marg{code}
%\end{definition}
% Fetches the language label (or labels) associated with the given code.
%    \begin{macrocode}
\def\TrackedLanguageFromIsoCode#1#2{%
  \@tracklang@nameuse{@tracklang@#1@isotolang@#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackedIsoCodeFromLanguage}
%\begin{definition}
%\cs{TrackedIsoCodeFromLanguage}\marg{code type}\marg{language}
%\end{definition}
% Fetches the code associated with the given language or dialect.
%    \begin{macrocode}
\def\TrackedIsoCodeFromLanguage#1#2{%
  \@tracklang@nameuse{@tracklang@#1@isofromlang@#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackedLanguageFromDialect}
%\begin{definition}
%\cs{TrackedLanguageFromDialect}\marg{dialect}
%\end{definition}
% Fetches the language name from the given dialect.
%    \begin{macrocode}
\def\TrackedLanguageFromDialect#1{%
 \@tracklang@nameuse{@tracklang@fromdialect@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackedDialectsFromLanguage}
%\begin{definition}
%\cs{TrackedDialectsFromLanguage}\marg{root language label}
%\end{definition}
% Fetches the tracked dialects whose language is given by \meta{root
% language label}.
%    \begin{macrocode}
\def\TrackedDialectsFromLanguage#1{%
 \@tracklang@nameuse{@tracklang@todialect@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TwoLetterIsoCountryCode}
%    \begin{macrocode}
\def\TwoLetterIsoCountryCode{3166-1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TwoLetterIsoLanguageCode}
%    \begin{macrocode}
\def\TwoLetterIsoLanguageCode{639-1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ThreeLetterIsoLanguageCode}
%    \begin{macrocode}
\def\ThreeLetterIsoLanguageCode{639-2}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ThreeLetterExtIsoLanguageCode}
%    \begin{macrocode}
\def\ThreeLetterExtIsoLanguageCode{639-3}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetTrackedDialectModifier}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{SetTrackedDialectModifier}\marg{dialect}\marg{value}
%\end{definition}
%Set the modifier for \meta{dialect}. (For example, old or new.)
%Arguments are expanded.
%    \begin{macrocode}
\def\SetTrackedDialectModifier#1#2{%
  \@tracklang@enamedef{@tracklang@modifier@#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectModifier}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectModifier}\marg{dialect}
%\end{definition}
%Get the modifier for \meta{dialect}.
%    \begin{macrocode}
\def\GetTrackedDialectModifier#1{%
  \@tracklang@nameuse{@tracklang@modifier@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfHasTrackedDialectModifier}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{IfHasTrackedDialectModifier}\marg{dialect}\marg{true}\marg{false}
%\end{definition}
%If there's a modifier for \meta{dialect}, do \meta{true} otherwise
%do \meta{false}.
%    \begin{macrocode}
\def\IfHasTrackedDialectModifier#1#2#3{%
  \@tracklang@ifundef{@tracklang@modifier@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetTrackedDialectScript}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{SetTrackedDialectScript}\marg{dialect}\marg{value}
%\end{definition}
%Set the script for \meta{dialect}. (For example, Latn or Cyrl.)
%Arguments are expanded.
%    \begin{macrocode}
\def\SetTrackedDialectScript#1#2{%
  \@tracklang@enamedef{@tracklang@script@#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectScript}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectScript}\marg{dialect}
%\end{definition}
%Get the script for \meta{dialect}.
%    \begin{macrocode}
\def\GetTrackedDialectScript#1{%
  \@tracklang@nameuse{@tracklang@script@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfHasTrackedDialectScript}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{IfHasTrackedDialectScript}\marg{dialect}\marg{true}\marg{false}
%\end{definition}
%If there's a script for \meta{dialect}, do \meta{true} otherwise
%do \meta{false}.
%    \begin{macrocode}
\def\IfHasTrackedDialectScript#1#2#3{%
  \@tracklang@ifundef{@tracklang@script@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfTrackedDialectIsScriptCs}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{IfTrackedDialectIsScriptCs}\marg{dialect}\marg{cs}\marg{true}\marg{false}
%\end{definition}
%If the given tracked dialect has an associated script and that
%script code matches the replacement text for the control sequence
%\meta{cs} then do \meta{true} otherwise to \meta{false}. If the
%tracked dialect doesn't have an associated script then the default
%script for the root language is tested. The use of
%a control sequence allows \cs{ifx} for the test, which means that
%this command can expand. The supplementary package
%\sty{tracklang-script} provides control sequences for known ISO
%15924 codes.
%    \begin{macrocode}
\def\IfTrackedDialectIsScriptCs#1#2#3#4{%
  \IfHasTrackedDialectScript{#1}%
  {%
    \expandafter\ifx\expandafter#2\csname @tracklang@script@#1\endcsname
      #3%
    \else
      #4%
    \fi
  }%
  {%
    \TrackLangIfHasDefaultScript{\TrackedLanguageFromDialect{#1}}%
    {%
      \expandafter\ifx\expandafter
        #2\csname @tracklang@knowniso@script@\TrackedLanguageFromDialect{#1}\endcsname
         #3%
      \else
         #4%
      \fi
    }%
    {#4}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetTrackedDialectVariant}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{SetTrackedDialectVariant}\marg{dialect}\marg{value}
%\end{definition}
%Set the modifier for \meta{dialect}. (For example, old or new.)
%Arguments are expanded.
%    \begin{macrocode}
\def\SetTrackedDialectVariant#1#2{%
  \@tracklang@enamedef{@tracklang@variant@#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectVariant}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectVariant}\marg{dialect}
%\end{definition}
%Get the modifier for \meta{dialect}.
%    \begin{macrocode}
\def\GetTrackedDialectVariant#1{%
  \@tracklang@nameuse{@tracklang@variant@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfHasTrackedDialectVariant}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{IfHasTrackedDialectVariant}\marg{dialect}\marg{true}\marg{false}
%\end{definition}
%If there's a modifier for \meta{dialect}, do \meta{true} otherwise
%do \meta{false}.
%    \begin{macrocode}
\def\IfHasTrackedDialectVariant#1#2#3{%
  \@tracklang@ifundef{@tracklang@variant@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetTrackedDialectSubLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{SetTrackedDialectSubLang}\marg{dialect}\marg{value}
%\end{definition}
%Set the sublang for \meta{dialect}.
%Arguments are expanded.
%    \begin{macrocode}
\def\SetTrackedDialectSubLang#1#2{%
  \@tracklang@enamedef{@tracklang@sublang@#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectSubLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectSubLang}\marg{dialect}
%\end{definition}
%Get the sublang for \meta{dialect}.
%    \begin{macrocode}
\def\GetTrackedDialectSubLang#1{%
  \@tracklang@nameuse{@tracklang@sublang@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfHasTrackedDialectSubLang}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{IfHasTrackedDialectSubLang}\marg{dialect}\marg{true}\marg{false}
%\end{definition}
%If there's a sublang for \meta{dialect}, do \meta{true} otherwise
%do \meta{false}.
%    \begin{macrocode}
\def\IfHasTrackedDialectSubLang#1#2#3{%
  \@tracklang@ifundef{@tracklang@sublang@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetTrackedDialectAdditional}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{SetTrackedDialectAdditional}\marg{dialect}\marg{value}
%\end{definition}
%Set the extra for \meta{dialect}.
%Arguments are expanded.
%    \begin{macrocode}
\def\SetTrackedDialectAdditional#1#2{%
  \@tracklang@enamedef{@tracklang@extra@#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectAdditional}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectAdditional}\marg{dialect}
%\end{definition}
%Get the extra for \meta{dialect}.
%    \begin{macrocode}
\def\GetTrackedDialectAdditional#1{%
  \@tracklang@nameuse{@tracklang@extra@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfHasTrackedDialectAdditional}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{IfHasTrackedDialectAdditional}\marg{dialect}\marg{true}\marg{false}
%\end{definition}
%If there's extra info for \meta{dialect}, do \meta{true} otherwise
%do \meta{false}.
%    \begin{macrocode}
\def\IfHasTrackedDialectAdditional#1#2#3{%
  \@tracklang@ifundef{@tracklang@extra@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedLanguageTag}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedLanguageTag}\marg{dialect}
%\end{definition}
%Get the language tag for \meta{dialect}.
%    \begin{macrocode}
\def\GetTrackedLanguageTag#1{%
  \IfTrackedLanguageHasIsoCode{639-1}{\TrackedLanguageFromDialect{#1}}%
  {\TrackedIsoCodeFromLanguage{639-1}{\TrackedLanguageFromDialect{#1}}}%
  {%
    \IfTrackedLanguageHasIsoCode{639-2}{\TrackedLanguageFromDialect{#1}}%
    {\TrackedIsoCodeFromLanguage{639-2}{\TrackedLanguageFromDialect{#1}}}%
    {%
      \IfTrackedLanguageHasIsoCode{639-3}{\TrackedLanguageFromDialect{#1}}%
      {\TrackedIsoCodeFromLanguage{639-3}{\TrackedLanguageFromDialect{#1}}}%
      {und}% undefined
    }%
  }%
  \@tracklang@ifundef{@tracklang@sublang@#1}%
  {}%
  {-\csname @tracklang@sublang@#1\endcsname}%
  \@tracklang@ifundef{@tracklang@script@#1}%
  {}%
  {-\csname @tracklang@script@#1\endcsname}%
  \IfTrackedLanguageHasIsoCode{3166-1}{#1}%
  {-\TrackedIsoCodeFromLanguage{3166-1}{#1}}%
  {}%
  \@tracklang@ifundef{@tracklang@variant@#1}%
  {}%
  {-\csname @tracklang@variant@#1\endcsname}%
  \@tracklang@ifundef{@tracklang@extra@#1}%
  {}%
  {-\csname @tracklang@extra@#1\endcsname}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetCurrentTrackedDialect}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{SetCurrentTrackedDialect}\marg{dialect}
%\end{definition}
%Provided for use by language hooks to establish the current tracked
%dialect. This command doesn't change \cs{languagename} or
%hyphenation patterns etc. It just provides convenient commands that
%can be accessed. The argument may be a \styfmt{tracklang} dialect
%label or the language hook label from which a \styfmt{tracklang}
%dialect label can be obtained or the root language label.
%\changes{1.3.3}{2016-11-03}{fixed mapping}
%    \begin{macrocode}
\def\SetCurrentTrackedDialect#1{%
  \edef\CurrentTrackedDialect{#1}%
  \@tracklang@verbose{Setting current tracked dialect `\CurrentTrackedDialect'}%
  \IfTrackedDialect{\CurrentTrackedDialect}%
  {}%
  {%
    \@tracklang@verbose{Not a recognised tracklang label}%
%    \end{macrocode}
% Has a mapping from this dialect to a tracklang dialect been supplied?
%    \begin{macrocode}
    \IfHookHasMappingFromTrackedDialect{\CurrentTrackedDialect}%
    {%
      \IfTrackedDialect{\GetTrackedDialectFromMapping\CurrentTrackedDialect}%
      {%
        \edef\CurrentTrackedDialect{\GetTrackedDialectFromMapping
          {\CurrentTrackedDialect}}%
        \@tracklang@verbose{Mapping found to tracklang label `\CurrentTrackedDialect'}%
      }%
      {%
%    \end{macrocode}
% Has the root language name been supplied?
%    \begin{macrocode}
        \IfTrackedLanguage{#1}%
        {%
          \@tracklang@verbose{Supplied label is a root language.
             Finding last tracked dialect for language `#1'}%
%    \end{macrocode}
% Get the last dialect to be tracked with this language.
%    \begin{macrocode}
          \edef\@tracklang@dialects{\TrackedDialectsFromLanguage{#1}}%
          \@tracklang@for\@tracklang@dialect:=\@tracklang@dialects\do{%
            \let\CurrentTrackedDialect\@tracklang@dialect
          }%
        }%
        {%
          \@tracklang@verbose{No tracklang dialect found for label `#1'}%
        }%
      }%
    }%
    {%
      \@tracklang@verbose{No mapping found}%
%    \end{macrocode}
% Has the root language name been supplied?
%    \begin{macrocode}
      \IfTrackedLanguage{#1}%
      {%
        \@tracklang@verbose{Supplied label is a root language.
           Finding last tracked dialect for language `#1'}%
%    \end{macrocode}
% Get the last dialect to be tracked with this language.
%    \begin{macrocode}
        \edef\@tracklang@dialects{\TrackedDialectsFromLanguage{#1}}%
        \@tracklang@for\@tracklang@dialect:=\@tracklang@dialects\do{%
          \let\CurrentTrackedDialect\@tracklang@dialect
        }%
      }%
      {%
        \@tracklang@verbose{No tracklang dialect found for label `#1'}%
      }%
    }%
  }%
  \IfTrackedDialect{\CurrentTrackedDialect}%
  {%
    \edef\CurrentTrackedLanguage{%
      \TrackedLanguageFromDialect{\CurrentTrackedDialect}}%
    \edef\CurrentTrackedDialectModifier{%
      \GetTrackedDialectModifier{\CurrentTrackedDialect}}%
    \edef\CurrentTrackedDialectVariant{%
      \GetTrackedDialectVariant{\CurrentTrackedDialect}}%
%    \end{macrocode}
% Get the default script if not set.
%    \begin{macrocode}
    \IfHasTrackedDialectScript{\CurrentTrackedDialect}%
    {%
      \edef\CurrentTrackedDialectScript{%
        \GetTrackedDialectScript{\CurrentTrackedDialect}}%
    }%
    {%
      \edef\CurrentTrackedDialectScript{%
        \TrackLangGetDefaultScript\CurrentTrackedLanguage}%
    }%
    \edef\CurrentTrackedDialectSubLang{%
      \GetTrackedDialectSubLang{\CurrentTrackedDialect}}%
    \edef\CurrentTrackedDialectAdditional{%
      \GetTrackedDialectAdditional{\CurrentTrackedDialect}}%
    \edef\CurrentTrackedLanguageTag{%
      \GetTrackedLanguageTag{\CurrentTrackedDialect}}%
%    \end{macrocode}
%Region code.
%    \begin{macrocode}
    \IfTrackedLanguageHasIsoCode{3166-1}{\CurrentTrackedDialect}%
    {%
      \edef\CurrentTrackedRegion{%
       \TrackedIsoCodeFromLanguage{3166-1}{\CurrentTrackedDialect}}%
    }%
    {\def\CurrentTrackedRegion{}}%
%    \end{macrocode}
%Language code.
%    \begin{macrocode}
    \IfTrackedLanguageHasIsoCode{639-1}{\CurrentTrackedLanguage}%
    {%
      \edef\CurrentTrackedIsoCode{%
       \TrackedIsoCodeFromLanguage{639-1}{\CurrentTrackedLanguage}}%
    }%
    {%
      \IfTrackedLanguageHasIsoCode{639-2}{\CurrentTrackedLanguage}%
      {%
        \edef\CurrentTrackedIsoCode{%
         \TrackedIsoCodeFromLanguage{639-2}{\CurrentTrackedLanguage}}%
      }%
      {%
        \IfTrackedLanguageHasIsoCode{639-3}{\CurrentTrackedLanguage}%
        {%
          \edef\CurrentTrackedIsoCode{%
           \TrackedIsoCodeFromLanguage{639-3}{\CurrentTrackedLanguage}}%
        }%
        {%
          \def\CurrentTrackedIsoCode{}%
        }%
      }%
    }%
   \@tracklang@verbose{Current tracked dialect: `\CurrentTrackedDialect'.\MessageBreak
     Language: `\CurrentTrackedLanguage'.\MessageBreak
     ISO code: `\CurrentTrackedIsoCode'.\MessageBreak
     Sub-lang: `\CurrentTrackedDialectSubLang'.\MessageBreak
     Modifier: `\CurrentTrackedDialectModifier'.\MessageBreak
     Variant: `\CurrentTrackedDialectVariant'.\MessageBreak
     Script: `\CurrentTrackedDialectScript'.\MessageBreak
     Region: `\CurrentTrackedRegion'.\MessageBreak
     Additional: `\CurrentTrackedDialectAdditional'.\MessageBreak
     Tag: `\CurrentTrackedLanguageTag'.
    }%
  }%
  {%
    \@tracklang@warn{Unknown dialect label `#1' passed to 
      \string\SetCurrentTrackedDialect}%
    \edef\CurrentTrackedLanguage{\languagename}%
    \def\CurrentTrackedDialectModifier{}%
    \def\CurrentTrackedDialectVariant{}%
    \def\CurrentTrackedDialectScript{}%
    \def\CurrentTrackedDialectSubLang{}%
    \def\CurrentTrackedDialectAdditional{}%
    \def\CurrentTrackedIsoCode{}%
    \def\CurrentTrackedRegion{}%
    \def\CurrentTrackedLanguageTag{und}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\AddTrackedLanguageIsoCodes}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{AddTrackedLanguageIsoCodes}\marg{language}
%\end{definition}
%Adds the ISO 639-1, 639-2 and 639-3 ISO codes for the given language,
%which must have previously been declared using
%\cs{TrackLangNewLanguage}.
%    \begin{macrocode}
\def\AddTrackedLanguageIsoCodes#1{%
  \@tracklang@ifundef{@tracklang@knowniso@639@1@#1}%
  {}%
  {%
    \AddTrackedIsoLanguage\TwoLetterIsoLanguageCode
      {\csname @tracklang@knowniso@639@1@#1\endcsname}{#1}%
  }%
  \@tracklang@ifundef{@tracklang@knowniso@639@2@#1}%
  {}%
  {%
    \AddTrackedIsoLanguage\ThreeLetterIsoLanguageCode
       {\csname @tracklang@knowniso@639@2@#1\endcsname}{#1}%
%    \end{macrocode}
% Does it have a different 639-2 (B) code?
%    \begin{macrocode}
    \@tracklang@ifundef{@tracklang@knowniso@639@2B@#1}%
    {}%
    {%
      \AddTrackedIsoLanguage{\ThreeLetterIsoLanguageCode-T}%
         {\csname @tracklang@knowniso@639@2@#1\endcsname}{#1}%
      \AddTrackedIsoLanguage{\ThreeLetterIsoLanguageCode-B}%
         {\csname @tracklang@knowniso@639@2B@#1\endcsname}{#1}%
    }%
  }%
  \@tracklang@ifundef{@tracklang@knowniso@639@3@#1}%
  {}%
  {%
    \AddTrackedIsoLanguage\ThreeLetterExtIsoLanguageCode
      {\csname @tracklang@knowniso@639@3@#1\endcsname}{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\AddTrackedCountryIsoCode}
%\changes{1.3}{2016-10-07}{new}
%As above but adds the 3166-1 country code if provided. Most
%root languages don't have an associated country code as they're
%spoken in multiple regions. Some of those that do have an
%associated region code may also be spoken as a minority language
%elsewhere, so this is separate from the previous command. If a
%regionless setting is required, use \cs{TrackLocale} instead of 
%\cs{TrackPredefinedDialect}.
%    \begin{macrocode}
\def\AddTrackedCountryIsoCode#1{%
  \@tracklang@ifundef{@tracklang@knowniso@3166@#1}%
  {}%
  {%
    \AddTrackedIsoLanguage{3166-1}%
      {\csname @tracklang@knowniso@3166@#1\endcsname}{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Tracking Languages and Dialects}\label{sec:tracking}
%
% The commands here are provided to indicate that a language or dialect
% is active (tracked) in the document.
%
%\begin{macro}{\TrackPredefinedDialect}
%\begin{definition}
%\cs{TrackPredefinedDialect}\marg{dialect label}
%\end{definition}
% Track a predefined language or dialect.
%    \begin{macrocode}
\def\TrackPredefinedDialect#1{%
  \@tracklang@ifundef{@tracklang@add@#1}%
  {%
    \@tracklang@err{Dialect or language `#1' is not predefined}{}%
  }%
  {\@tracklang@nameuse{@tracklang@add@#1}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@hassecondchar}
%\changes{1.3}{2016-10-07}{new}
%Check if second argument is present (non-empty and not \cs{relax}).
%    \begin{macrocode}
\def\@tracklang@hassecondchar#1#2\@end@tracklang@hassecondchar#3#4{%
  \ifx\relax#2\relax
    #4%
  \else
    #3%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@hasthirdchar}
%\changes{1.3}{2016-10-07}{new}
%Check if third argument is present (non-empty and not \cs{relax}).
%    \begin{macrocode}
\def\@tracklang@hasthirdchar#1#2#3\@end@tracklang@hasthirdchar#4#5{%
  \ifx\relax#3\relax
    #5%
  \else
    #4%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@hasfourthchar}
%\changes{1.3}{2016-10-07}{new}
%Check if fourth argument is present (non-empty and not \cs{relax}).
%    \begin{macrocode}
\def\@tracklang@hasfourthchar#1#2#3#4\@end@tracklang@hasfourthchar#5#6{%
  \ifx\relax#4\relax
    #6%
  \else
    #5%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@hasfifthchar}
%\changes{1.3}{2016-10-07}{new}
%Check if fifth argument is present (non-empty and not \cs{relax}).
%    \begin{macrocode}
\def\@tracklang@hasfifthchar#1#2#3#4#5\@end@tracklang@hasfifthchar#6#7{%
  \ifx\relax#5\relax
    #7%
  \else
    #6%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@hasninthchar}
%\changes{1.3}{2016-10-07}{new}
%Check if ninth argument is present (non-empty and not \cs{relax}).
%    \begin{macrocode}
\def\@tracklang@hasninthchar#1#2#3#4#5#6#7#8#9\@end@tracklang@hasninthchar{%
  \ifx\relax#9\relax
    \expandafter\@tracklang@secondoftwo
  \else
    \expandafter\@tracklang@firstoftwo
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifalpha}
%\changes{1.3}{2016-10-07}{new}
%Check if argument a, \ldots, z or A, \ldots, Z.
%    \begin{macrocode}
\def\@tracklang@ifalpha#1#2#3{%
  \ifx\relax#1\relax
%    \end{macrocode}
%First argument empty or \cs{relax}.
%    \begin{macrocode}
    #3%
  \else
   \ifnum\lccode`#1<`a\relax
     #3%
   \else
     \ifnum\lccode`#1>`z\relax
      #3%
     \else
%    \end{macrocode}
% Is alpha.
%    \begin{macrocode}
       #2%
     \fi
   \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifdigit}
%\changes{1.3}{2016-10-07}{new}
%Check if argument is digit (0,\ldots,9).
%    \begin{macrocode}
\def\@tracklang@ifdigit#1#2#3{%
  \ifx\relax#1\relax
%    \end{macrocode}
%First argument empty or \cs{relax}.
%    \begin{macrocode}
    #3%
  \else
   \ifnum`#1<`0\relax
     #3%
   \else
     \ifnum`#1>`9\relax
      #3%
     \else
%    \end{macrocode}
% Is digit.
%    \begin{macrocode}
       #2%
     \fi
   \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifalldigits}
%\changes{1.3}{2016-10-07}{new}
%Check if the argument only consists of digits (no sign).
%    \begin{macrocode}
\def\@tracklang@ifalldigits#1{%
 \expandafter\ifx\relax#1\relax
   \expandafter\@tracklang@secondoftwo
 \else
   \expandafter\@@tracklang@ifalldigits#1\@tracklang@nnil
 \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@tracklang@ifalldigits}
%    \begin{macrocode}
\def\@@tracklang@ifalldigits#1{%
  \ifx#1\@tracklang@nnil
   \def\@tracklang@next{\expandafter\@tracklang@firstoftwo}%
  \else
    \@tracklang@ifdigit{#1}%
    {%
      \let\@tracklang@next\@@tracklang@ifalldigits
    }%
    {%
      \def\@tracklang@next##1\@tracklang@nnil{%
        \expandafter\@tracklang@secondoftwo}%
    }%
  \fi
  \@tracklang@next
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifalphanumeric}
%\changes{1.3}{2016-10-07}{new}
%Check if argument is an alphanumeric (0,\ldots,9) or (a,\ldots,z)
%or (A,\ldots,Z).
%    \begin{macrocode}
\def\@tracklang@ifalphanumeric#1#2#3{%
  \@tracklang@ifalpha{#1}%
  {#2}%
  {%
    \@tracklang@ifdigit{#1}{#2}{#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfAlphaNumericChar}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfAlphaNumericChar}\marg{tag}\marg{true}\marg{false}
%\end{definition}
%Check if the argument is a single alphanumeric character.
%    \begin{macrocode}
\def\TrackLangIfAlphaNumericChar#1#2#3{%
  \expandafter\ifx\expandafter\relax#1\relax
%    \end{macrocode}
% Tag empty or \cs{relax}.
%    \begin{macrocode}
    #3%
  \else
    \expandafter\@tracklang@hassecondchar#1\relax\relax
      \@end@tracklang@hassecondchar
    {#3}%
    {\expandafter\@tracklang@ifalphanumeric#1{#2}{#3}}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfLanguageTag}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfLanguageTag}\marg{tag}\marg{true}\marg{false}
%\end{definition}
%Check if the argument is a language tag (two or three letter
%lower case).
%    \begin{macrocode}
\def\TrackLangIfLanguageTag#1#2#3{%
  \expandafter\@tracklang@hasthirdchar#1\relax\relax\relax
    \@end@tracklang@hasthirdchar
  {%
%    \end{macrocode}
% Has 3 or more characters.
%    \begin{macrocode}
    \expandafter\@tracklang@hasfourthchar#1\relax\@end@tracklang@hasfourthchar
    {#3}%
    {%
%    \end{macrocode}
% Has 3 characters. Are they all lower case?
%    \begin{macrocode}
     \expandafter\@tracklang@iflanguage@iii@tag#1{#2}{#3}%
    }%
  }%
  {%
%    \end{macrocode}
% Has less than 3 characters.
%    \begin{macrocode}
    \expandafter\@tracklang@hassecondchar#1\relax\relax
      \@end@tracklang@hassecondchar
    {%
%    \end{macrocode}
%Has two characters. Are they both lower case?
%    \begin{macrocode}
     \expandafter\@tracklang@iflanguage@ii@tag#1{#2}{#3}%
    }%
    {#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@iflanguage@ii@tag}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@iflanguage@ii@tag#1#2#3#4{%
  \ifnum\lccode`#1=`#1\relax
    \ifnum\lccode`#2=`#2\relax
      #3%
    \else
      #4%
    \fi
  \else
    #4%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@iflanguage@iii@tag}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@iflanguage@iii@tag#1#2#3#4#5{%
  \ifnum\lccode`#1=`#1\relax
    \ifnum\lccode`#2=`#2\relax
      \ifnum\lccode`#3=`#3\relax
        #4%
      \else
        #5%
      \fi
    \else
      #5%
    \fi
  \else
    #5%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfRegionTag}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfRegionTag}\marg{tag}\marg{true}\marg{false}
%\end{definition}
%Check if the argument is a region tag (two letter
%upper case or three digit numeric).
%    \begin{macrocode}
\def\TrackLangIfRegionTag#1#2#3{%
  \expandafter\@tracklang@hasthirdchar#1\relax\relax\relax
    \@end@tracklang@hasthirdchar
  {%
%    \end{macrocode}
% Has 3 or more characters. Is it a three digit numeric code?
%    \begin{macrocode}
    \expandafter\@tracklang@hasfourthchar#1\relax\@end@tracklang@hasfourthchar
    {%
%    \end{macrocode}
% Has 4 or more characters.
%    \begin{macrocode}
      #3%
    }%
    {%
%    \end{macrocode}
% Has 3 characters. Are they all digits?
%    \begin{macrocode}
      \@tracklang@ifalldigits{#1}{#2}{#3}%
    }%
  }%
  {%
%    \end{macrocode}
% Has less than 3 characters.
%    \begin{macrocode}
    \expandafter\@tracklang@hassecondchar#1\relax\relax
      \@end@tracklang@hassecondchar
    {%
%    \end{macrocode}
%Has two characters. Are they both upper case?
%    \begin{macrocode}
     \expandafter\@tracklang@ifregion@ii@tag#1{#2}{#3}%
    }%
    {#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifregion@ii@tag}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@ifregion@ii@tag#1#2#3#4{%
  \ifnum\uccode`#1=`#1\relax
    \ifnum\uccode`#2=`#2\relax
      #3%
    \else
      #4%
    \fi
  \else
    #4%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifregion@iii@tag}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@ifregion@iii@tag#1#2#3#4#5{%
  \ifnum\uccode`#1=`#1\relax
    \ifnum\uccode`#2=`#2\relax
      \ifnum\uccode`#3=`#3\relax
        #4%
      \else
        #5%
      \fi
    \else
      #5%
    \fi
  \else
    #5%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfScriptTag}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfScriptTag}\marg{tag}\marg{true}\marg{false}
%\end{definition}
%Check if the argument is a script tag (four letter
%title case).
%    \begin{macrocode}
\def\TrackLangIfScriptTag#1#2#3{%
  \expandafter\@tracklang@hasfifthchar#1\relax\relax\relax\relax\relax
    \@end@tracklang@hasfifthchar
  {#3}%
  {%
%    \end{macrocode}
% Has less than 5 characters.
%    \begin{macrocode}
    \expandafter\@tracklang@hasfourthchar#1\relax\relax\relax\relax
      \@end@tracklang@hasfourthchar
    {%
%    \end{macrocode}
%Has four characters. Are they title case? (First letter upper case,
%others lower case.)
%    \begin{macrocode}
     \expandafter\@tracklang@ifscripttag#1{#2}{#3}%
    }%
    {#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifscripttag}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@ifscripttag#1#2#3#4#5#6{%
  \ifnum\uccode`#1=`#1\relax
    \ifnum\lccode`#2=`#2\relax
      \ifnum\lccode`#3=`#3\relax
        \ifnum\lccode`#4=`#4\relax
          #5%
        \else
          #6%
        \fi
      \else
        #6%
      \fi
    \else
      #6%
    \fi
  \else
    #6%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfVariantTag}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangIfVariantTag}\marg{tag}\marg{true}\marg{false}
%\end{definition}
%Check if the argument is a variant tag.
%    \begin{macrocode}
\def\TrackLangIfVariantTag#1#2#3{%
  \expandafter\@tracklang@hasfifthchar#1\relax\relax\relax\relax\relax
    \@end@tracklang@hasfifthchar
  {%
%    \end{macrocode}
% Has at least 5 characters. Does it have a maximum of 8?
%    \begin{macrocode}
    \expandafter\@tracklang@hasninthchar#1\relax\relax\relax\relax\relax
      \relax\relax\relax\relax
      \@end@tracklang@hasninthchar
    {#3}%
    {#2}%
  }%
  {%
%    \end{macrocode}
%Less than 5 characters.
%    \begin{macrocode}
    \expandafter\@tracklang@hasfourthchar#1\relax\relax\relax\relax
      \@end@tracklang@hasfourthchar
    {%
%    \end{macrocode}
%Has 4 characters.
%    \begin{macrocode}
      \expandafter\@tracklang@ifvariant@iv@tag#1{#2}{#3}%
    }%
    {#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@ifvariant@iv@tag}
%\changes{1.3}{2016-10-07}{new}
%four character variant starting with a digit.
%    \begin{macrocode}
\def\@tracklang@ifvariant@iv@tag#1#2#3#4#5#6{%
  \@tracklang@ifdigit{#1}%
  {#5}
  {#6}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@parse@extlang}
%\cs{@TrackLangEnvSubLang}, \cs{@tracklang@split@pre} and
%\cs{\@tracklang@split@post} should be initialised before use.
%This assumes the tag is well formed.
%    \begin{macrocode}
\def\@tracklang@parse@extlang{%
   \TrackLangIfLanguageTag{\@tracklang@split@pre}
   {%
     \ifx\@TrackLangEnvSubLang\empty
       \let\@TrackLangEnvSubLang\@tracklang@split@pre
       \let\@TrackLangEnvFirstSubLang\@TrackLangEnvSubLang
     \else
       \edef\@TrackLangEnvSubLang{\@TrackLangEnvSubLang-\@tracklang@split@pre}%
     \fi
%    \end{macrocode}
%Split again if there's more.
%    \begin{macrocode}
     \ifx\@tracklang@split@post\empty
     \else
       \expandafter\@tracklang@split@underscoreorhyp\expandafter
         {\@tracklang@split@post}%
       \ifx\@tracklang@split@pre\empty
       \else
         \@tracklang@parse@extlang
       \fi
     \fi
   }%
   {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@parse@variant}
%\cs{@TrackLangEnvVariant}, \cs{@tracklang@split@pre} and
%\cs{\@tracklang@split@post} should be initialised before use.
%    \begin{macrocode}
\def\@tracklang@parse@variant{%
   \TrackLangIfVariantTag{\@tracklang@split@pre}
   {%
     \ifx\@TrackLangEnvVariant\empty
       \let\@TrackLangEnvVariant\@tracklang@split@pre
     \else
       \edef\@TrackLangEnvVariant{\@TrackLangEnvVariant
         -\@tracklang@split@pre}%
     \fi
%    \end{macrocode}
%Split again if there's more.
%    \begin{macrocode}
     \ifx\@tracklang@split@post\empty
     \else
       \expandafter\@tracklang@split@underscoreorhyp\expandafter
         {\@tracklang@split@post}%
       \ifx\@tracklang@split@pre\empty
       \else
         \@tracklang@parse@variant
       \fi
     \fi
   }%
   {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLanguageTag}
%\begin{definition}
%\cs{TrackLanguageTag}\marg{tag}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%Parse RFC 5646 language tag (assumes regular and well-formed).
%See also \url{https://tools.ietf.org/html/rfc5646}.
%Ensure \meta{tag} is fully-expanded. Warn if argument is
%empty.
%    \begin{macrocode}
\def\TrackLanguageTag#1{%
  \edef\@tracklang@tag{#1}%
  \ifx\@tracklang@tag\empty
    \@tracklang@warn{Empty tag in \string\TrackLanguageTag}% 
  \else
    \expandafter\@TrackLanguageTag\expandafter{\@tracklang@tag}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@TrackLanguageTag}
%Argument must be expanded.
%    \begin{macrocode}
\def\@TrackLanguageTag#1{%
%    \end{macrocode}
%First check if it's predefined.
%    \begin{macrocode}
  \@tracklang@ifundef{@tracklang@add@#1}%
  {%
%    \end{macrocode}
%Parse language tag.
%    \begin{macrocode}
     \@tracklang@parselangtag{#1}%
%    \end{macrocode}
%Track this information.
%    \begin{macrocode}
     \@tracklang@track@locale
  }%
  {%
%    \end{macrocode}
%Predefined tag.
%    \begin{macrocode}
    \@tracklang@nameuse{@tracklang@add@#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackIfKnownLanguage}
%\begin{definition}
%\cs{TrackIfKnownLanguage}\marg{tag}\meta{success code}\marg{fail code}
%\end{definition}
%Like \cs{TrackLanguageTag} but does \meta{fail code} if the tag
%doesn't contain a valid language code. If successful, does
%\meta{success code} after tracking the language.
%\changes{1.3.9}{2019-11-11}{new}
%    \begin{macrocode}
\def\TrackIfKnownLanguage#1#2#3{%
  \edef\@tracklang@tag{#1}%
  \ifx\@tracklang@tag\empty
    #3%
  \else
    \expandafter\@TrackIfKnownLanguage\expandafter{\@tracklang@tag}{#2}{#3}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@TrackIfKnownLanguage}
%Argument must be expanded.
%\changes{1.3.9}{2019-11-11}{new}
%    \begin{macrocode}
\def\@TrackIfKnownLanguage#1#2#3{%
%    \end{macrocode}
%First check if it's predefined.
%    \begin{macrocode}
  \@tracklang@ifundef{@tracklang@add@#1}%
  {%
%    \end{macrocode}
%Parse language tag.
%    \begin{macrocode}
     \@tracklang@parselangtag{#1}%
%    \end{macrocode}
%Track this information if \cs{@TrackLangEnvLang} is a known ISO
%language code.
%    \begin{macrocode}
     \TrackLangIfKnownLangFromIso{\@TrackLangEnvLang}%
     {\@tracklang@track@locale#2}{#3}%
  }%
  {%
%    \end{macrocode}
%Predefined tag.
%    \begin{macrocode}
    \@tracklang@nameuse{@tracklang@add@#1}%
    #2%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@parse@langtag}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@parselangtag#1{%
%    \end{macrocode}
%Initialise.
%    \begin{macrocode}
  \def\@TrackLangEnvLang{}%
  \def\@TrackLangEnvSubLang{}%
  \def\@TrackLangEnvFirstSubLang{}%
  \def\@TrackLangEnvTerritory{}%
  \def\@TrackLangEnvCodeSet{}%
  \def\@TrackLangEnvVariant{}%
  \def\@TrackLangEnvModifier{}%
  \def\@TrackLangEnvScript{}%
  \def\@TrackLangEnvAdditional{}%
%    \end{macrocode}
%First split to determine language code.
%    \begin{macrocode}
  \@tracklang@split@underscoreorhyp{#1}%
%    \end{macrocode}
%Save the result.
%    \begin{macrocode}
  \let\@TrackLangEnvLang\@tracklang@split@pre
%    \end{macrocode}
%Is there anything else?
%    \begin{macrocode}
  \ifx\@tracklang@split@post\empty
%    \end{macrocode}
%That's it.
%    \begin{macrocode}
  \else
%    \end{macrocode}
%Split again.
%    \begin{macrocode}
     \expandafter\@tracklang@split@underscoreorhyp\expandafter
       {\@tracklang@split@post}%
%    \end{macrocode}
%Is this an extension to the language tag?
%    \begin{macrocode}
     \@tracklang@parse@extlang
%    \end{macrocode}
%Does this fit the format for a script?
%    \begin{macrocode}
     \TrackLangIfScriptTag{\@tracklang@split@pre}%
     {%
%    \end{macrocode}
%Found script.
%    \begin{macrocode}
       \let\@TrackLangEnvScript\@tracklang@split@pre
%    \end{macrocode}
%Split again if there's more.
%    \begin{macrocode}
       \ifx\@tracklang@split@post\empty
       \else
         \expandafter\@tracklang@split@underscoreorhyp\expandafter
           {\@tracklang@split@post}%
       \fi
     }%
     {}%
%    \end{macrocode}
%Does this fit the format for a region?
%    \begin{macrocode}
     \TrackLangIfRegionTag{\@tracklang@split@pre}%
     {%
%    \end{macrocode}
%Found region. Is it a 2 letter alpha or a 3 digit numeric code?
%    \begin{macrocode}
       \expandafter\@tracklang@hasthirdchar\@tracklang@split@pre
          \relax\relax\relax
          \@end@tracklang@hasthirdchar
       {%
%    \end{macrocode}
% Is three digit numeric code. We need the mappings. Has
% \texttt{tracklang-region-codes.tex} been loaded?
%    \begin{macrocode}
         \ifx\TrackLangIfKnownNumericRegion\undefined
           \@tracklang@input tracklang-region-codes.tex
         \fi
         \TrackLangIfKnownNumericRegion{\@tracklang@split@pre}%
         {%
           \edef\@TrackLangEnvTerritory{%
             \TrackLangNumericToAlphaIIRegion{\@tracklang@split@pre}%
           }%
         }%
         {%
           \let\@TrackLangEnvTerritory\@tracklang@split@pre
           \@tracklang@warn{Unrecognised numeric region code 
             `\@tracklang@split@pre'}%
         }%
       }%
       {%
%    \end{macrocode}
% Is two letter alpha code.
%    \begin{macrocode}
         \let\@TrackLangEnvTerritory\@tracklang@split@pre
       }%
     \expandafter\@tracklang@split@underscoreorhyp\expandafter
         {\@tracklang@split@post}%
     }%
     {}%
%    \end{macrocode}
%Parse for variant.
%    \begin{macrocode}
     \@tracklang@parse@variant
%    \end{macrocode}
%Anything left can go in additional.
%    \begin{macrocode}
     \let\@TrackLangEnvAdditional\@tracklang@split@post
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@input@extra@region@filelist}
%\changes{1.4}{2019-11-30}{new}
%    \begin{macrocode}
\def\@tracklang@extra@region@filelist{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangAddExtraRegionFile}
%\changes{1.4}{2019-11-30}{new}
% Add a file name to the list of extra region code files that should
% be input by tracklang-regions-codes.tex
%    \begin{macrocode}
\def\TrackLangAddExtraRegionFile#1{% 
 \ifx\TrackLangRegionMap\undefined
 \else
%    \end{macrocode}
% tracklang-region-codes.tex has already been loaded so input the file
% now.
%    \begin{macrocode}
    \@tracklang@input #1\relax
 \fi
 \@tracklang@add{#1}{\@tracklang@extra@region@filelist}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@input@extra@region@files}
%\changes{1.4}{2019-11-30}{new}
% Iterate through list of extra region files to allow other packages
% to define new regions.
%    \begin{macrocode}
\def\@tracklang@input@extra@region@files{%
  \@tracklang@for\@tracklang@currfile:=\@tracklang@extra@region@filelist\do
  {%
    \@tracklang@input\@tracklang@currfile
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@input@extra@script@filelist}
%\changes{1.4}{2019-11-30}{new}
%    \begin{macrocode}
\def\@tracklang@extra@script@filelist{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangAddExtraScriptFile}
%\changes{1.4}{2019-11-30}{new}
% Add the given file name to the list of files that should be
% automatically loaded by tracklang-scripts.tex
%    \begin{macrocode}
\def\TrackLangAddExtraScriptFile#1{% 
 \ifx\TrackLangScriptMap\undefined
 \else
%    \end{macrocode}
% tracklang-scripts.tex has already been loaded so input the file
% now.
%    \begin{macrocode}
    \@tracklang@input #1\relax
 \fi
 \@tracklang@add{#1}{\@tracklang@extra@script@filelist}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@input@extra@script@files}
%\changes{1.4}{2019-11-30}{new}
% Iterate through list of extra script files to allow other packages
% to define new scripts.
%    \begin{macrocode}
\def\@tracklang@input@extra@script@files{%
  \@tracklang@for\@tracklang@currfile:=\@tracklang@extra@script@filelist\do
  {%
    \@tracklang@input\@tracklang@currfile
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectFromLanguageTag}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectFromLanguageTag}\marg{tag}\marg{cs}
%\end{definition}
%Find the tracked dialect that matches the given language tag and
%stores the dialect label in \meta{cs}. If no match found, \meta{cs}
%will be empty. Just tests the root language, script, variant, 
%sub-language and region. Doesn't check the additional information. 
%As from v1.3.6, this sets \cs{TrackedDialectClosestSubMatch} to the
%closest sub-match.
%    \begin{macrocode}
\def\GetTrackedDialectFromLanguageTag#1#2{%
%    \end{macrocode}
%Initialise default values (in case of no match).
%\changes{1.3.6}{2018-05-13}{added \cs{TrackedDialectClosestSubMatch}}
%    \begin{macrocode}
  \def#2{}%
  \def\TrackedDialectClosestSubMatch{}%
  \@tracklang@parselangtag{#1}%
  \edef\@tracklang@dialect{%
   \@TrackLangEnvLang
   \@TrackLangEnvSubLang
   \@TrackLangEnvScript
   \@TrackLangEnvTerritory
   \@TrackLangEnvModifier
   \@TrackLangEnvVariant}%
%    \end{macrocode}
% Has this dialect label been tracked?
%    \begin{macrocode}
  \IfTrackedDialect{\@tracklang@dialect}%
  {%
%    \end{macrocode}
% Found it. All done.
%    \begin{macrocode}
      \let#2\@tracklang@dialect
  }%
  {%
%    \end{macrocode}
% Get the root language label.
%    \begin{macrocode}
      \edef\@tracklang@lang{\TrackLangGetKnownLangFromIso\@TrackLangEnvLang}%
%    \end{macrocode}
% Get the default script for this language.
%    \begin{macrocode}
      \edef\@tracklang@defscript{\TrackLangGetDefaultScript\@tracklang@lang}%
%    \end{macrocode}
% Keep track of best match.
%    \begin{macrocode}
     \def\@tracklang@bestmatch{0}%
%    \end{macrocode}
% Get the list of tracked dialects for this language.
%    \begin{macrocode}
      \edef\@tracklang@dialects{\TrackedDialectsFromLanguage\@tracklang@lang}%
%    \end{macrocode}
% For each dialect in this list, check if it matches. 
%    \begin{macrocode}
      \@tracklang@for\@tracklang@dialect:=\@tracklang@dialects\do{%
%    \end{macrocode}
% Does the script match? (Initialise to no.)
%    \begin{macrocode}
        \def\@tracklang@currentmatch{0}%
        \edef\@tracklang@tmp{%
          \GetTrackedDialectScript{\@tracklang@dialect}}%
        \ifx\@tracklang@tmp\@TrackLangEnvScript
%    \end{macrocode}
% Script matches.
%    \begin{macrocode}
          \def\@tracklang@currentmatch{1}%
        \else
%    \end{macrocode}
% Script doesn't match. If no script has been provided, does this
% dialect's script match the default for this language? 
%    \begin{macrocode}
          \ifx\@TrackLangEnvScript\empty
            \ifx\@tracklang@tmp\@tracklang@defscript
%    \end{macrocode}
% Default script matches. 
%    \begin{macrocode}
              \def\@tracklang@currentmatch{1}%
            \fi
          \fi
        \fi
%    \end{macrocode}
% Does the sub-language match?
%    \begin{macrocode}
        \edef\@tracklang@tmp{%
          \GetTrackedDialectSubLang{\@tracklang@dialect}}%
        \ifx\@tracklang@tmp\@TrackLangEnvSubLang
%    \end{macrocode}
% Sub-language matches. 
%    \begin{macrocode}
          \edef\@tracklang@currentmatch{\@tracklang@currentmatch 1}%
        \else
%    \end{macrocode}
% Sub-language doesn't match. 
%    \begin{macrocode}
          \edef\@tracklang@currentmatch{\@tracklang@currentmatch 0}%
        \fi
%    \end{macrocode}
% Does the variant match?
%    \begin{macrocode}
        \edef\@tracklang@tmp{%
          \GetTrackedDialectVariant{\@tracklang@dialect}}%
        \ifx\@tracklang@tmp\@TrackLangEnvVariant
%    \end{macrocode}
% Variant matches. 
%    \begin{macrocode}
          \edef\@tracklang@currentmatch{\@tracklang@currentmatch 1}%
        \else
%    \end{macrocode}
% Variant doesn't match. 
%    \begin{macrocode}
          \edef\@tracklang@currentmatch{\@tracklang@currentmatch 0}%
        \fi
%    \end{macrocode}
% Does the region match?
%    \begin{macrocode}
        \edef\@tracklang@tmp{%
          \TrackedIsoCodeFromLanguage{3166-1}{\@tracklang@dialect}}%
        \ifx\@tracklang@tmp\@TrackLangEnvTerritory
%    \end{macrocode}
% Region matches. 
%    \begin{macrocode}
          \edef\@tracklang@currentmatch{\@tracklang@currentmatch 1}%
        \else
%    \end{macrocode}
% Region doesn't match. 
%    \begin{macrocode}
          \edef\@tracklang@currentmatch{\@tracklang@currentmatch 0}%
        \fi
%    \end{macrocode}
% Do all four match? 
%    \begin{macrocode}
        \ifx\@tracklang@currentmatch\@tracklang@fullmatch
%    \end{macrocode}
% Found it. 
%    \begin{macrocode}
          \let#2\@tracklang@dialect
        \else
%    \end{macrocode}
% Not a complete match. Is this the best match so far? 
%    \begin{macrocode}
          \ifnum\@tracklang@currentmatch>\@tracklang@bestmatch\relax
            \let\TrackedDialectClosestSubMatch\@tracklang@dialect
            \let\@tracklang@bestmatch\@tracklang@currentmatch
          \fi
        \fi
     }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@fullmatch}
%\changes{1.3.6}{2018-05-13}{new}
%(Used to identify a full match for script, sub-language, variant
%and region.)
%    \begin{macrocode}
\def\@tracklang@fullmatch{1111}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangFromEnv}
%\changes{1.3}{2016-10-07}{new}
% This command performs the following steps:
% query environment variable (if \cs{TrackLangEnv} not already set),
% parse \cs{TrackLangEnv} (if it has been set), and add the dialect
% (if recognised).
%
% Note that this works slightly differently from just using
% \cs{TrackLangQueryEnv} followed by \cs{TrackLangParseFromEnv}
% and \cs{TrackPredefinedDialect}. 
%    \begin{macrocode}
\def\TrackLangFromEnv{%
%    \end{macrocode}
%Initialise.
%    \begin{macrocode}
 \def\TrackLangEnvLang{}%
 \def\TrackLangEnvTerritory{}%
 \def\TrackLangEnvCodeSet{}%
 \def\TrackLangEnvModifier{}%
%    \end{macrocode}
%If \cs{TrackQueryEnv} is empty, assume \cs{TrackQueryEnv} has already
%been attempted but failed, so don't bother retrying.
%    \begin{macrocode}
  \ifx\TrackLangEnv\undefined
    \TrackLangQueryEnv
  \fi
  \ifx\TrackLangEnv\empty
     \@tracklang@warn{\string\TrackLangFromEnv\space
     non-operational as \string\TrackLangEnv\space is empty}%
  \else
%    \end{macrocode}
% At this point \cs{TrackLangEnv} shouldn't be undefined (if
% \cs{TrackLangQueryEnv} fails it should define \cs{TrackLangEnv} to
% be empty), but check in case something unexpected has happened.
%    \begin{macrocode}
    \ifx\TrackLangEnv\undefined
       \@tracklang@warn{\string\TrackLangFromEnv\space
       non-operational as \string\TrackLangEnv\space hasn't been
       defined}%
    \else
%    \end{macrocode}
% Parse and track.
%    \begin{macrocode}
       \@tracklang@parse@track@locale{\TrackLangEnv}%
       \let\TrackLangEnvLang\@TrackLangEnvLang
       \let\TrackLangEnvTerritory\@TrackLangEnvTerritory
       \let\TrackLangEnvCodeSet\@TrackLangEnvCodeSet
       \let\TrackLangEnvModifier\@TrackLangEnvModifier
    \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLocale}
%\begin{definition}
%\cs{TrackLocale}\marg{locale}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%Track the dialect identified by the given locale. The argument may
%either be a predefined language\slash dialect or in the same format as
%\cs{TrackLangEnv}.
%    \begin{macrocode}
\def\TrackLocale#1{%
%    \end{macrocode}
% Is the argument a recognised dialect?
%    \begin{macrocode}
  \@tracklang@ifundef{@tracklang@add@#1}%
  {%
    \@tracklang@parse@track@locale{#1}%
  }%
  {%
    \@tracklang@nameuse{@tracklang@add@#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@parse@track@locale}
%\changes{1.3}{2016-10-07}{new}
%Parse localisation format and track.
%    \begin{macrocode}
\def\@tracklang@parse@track@locale#1{%
  \@tracklang@parse@locale{#1}%
  \@tracklang@track@locale
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@track@locale}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\@tracklang@track@locale{%
%    \end{macrocode}
% Is the language code known?
%    \begin{macrocode}
  \TrackLangIfKnownLangFromIso{\@TrackLangEnvLang}
  {%
    \edef\@tracklang@lang{\TrackLangGetKnownLangFromIso\@TrackLangEnvLang}%
    \let\@tracklang@dialect\@TrackLangEnvLang
    \ifx\@TrackLangEnvSubLang\empty
    \else
      \edef\@tracklang@dialect{\@tracklang@dialect-\@TrackLangEnvSubLang}%
    \fi
    \ifx\@TrackLangEnvScript\empty
    \else
      \edef\@tracklang@dialect{\@tracklang@dialect-\@TrackLangEnvScript}%
    \fi
    \ifx\@TrackLangEnvTerritory\empty
    \else
      \edef\@tracklang@dialect{\@tracklang@dialect-\@TrackLangEnvTerritory}%
    \fi
    \ifx\@TrackLangEnvModifier\empty
    \else
      \edef\@tracklang@dialect{\@tracklang@dialect-\@TrackLangEnvModifier}%
    \fi
    \ifx\@TrackLangEnvVariant\empty
    \else
      \edef\@tracklang@dialect{\@tracklang@dialect-\@TrackLangEnvVariant}%
    \fi
%    \end{macrocode}
% Language code is recognised. Is the dialect label recognised?
%    \begin{macrocode}
    \@tracklang@ifundef{@tracklang@add@\@tracklang@dialect}%
    {%
%    \end{macrocode}
% Not a recognised dialect.
% Form new dialect name (without hyphen).
%    \begin{macrocode}
       \edef\@tracklang@dialect{%
         \@TrackLangEnvLang
         \@TrackLangEnvSubLang
         \@TrackLangEnvScript
         \@TrackLangEnvTerritory
         \@TrackLangEnvModifier
         \@TrackLangEnvVariant}%
%    \end{macrocode}
% Add this new dialect.
%    \begin{macrocode}
       \AddTrackedDialect{\@tracklang@dialect}{\@tracklang@lang}%
       \AddTrackedLanguageIsoCodes{\@tracklang@lang}%
%    \end{macrocode}
% Is there a sub-language tag?
%    \begin{macrocode}
       \ifx\@TrackLangEnvFirstSubLang\empty
       \else
         \expandafter\AddTrackedIsoLanguage
           \expandafter\ThreeLetterExtIsoLanguageCode
           \expandafter{\@TrackLangEnvFirstSubLang}%
           {\@tracklang@dialect}%
       \fi
    }%
    {%
%    \end{macrocode}
% Dialect is recognised.
%    \begin{macrocode}
      \csname @tracklang@add@\@tracklang@dialect\endcsname
    }%
  }%
  {%
%    \end{macrocode}
% Unknown language code.
%    \begin{macrocode}
    \@tracklang@warn{Unknown language code `\@TrackLangEnvLang'}%
    \edef\@tracklang@dialect{%
      \@TrackLangEnvLang
      \@TrackLangEnvSubLang
      \@TrackLangEnvScript
      \@TrackLangEnvTerritory
      \@TrackLangEnvModifier
      \@TrackLangEnvVariant}%
    \AddTrackedDialect{\@tracklang@dialect}{\@TrackLangEnvLang}%
%    \end{macrocode}
% Determine if the language code is a two or three letter code.
%    \begin{macrocode}
    \expandafter\@tracklang@hasthirdchar
       \@TrackLangEnvLang\relax\relax\relax\@end@tracklang@hasthirdchar
     {%
%    \end{macrocode}
% 639-2 code. Track it.
%    \begin{macrocode}
       \AddTrackedIsoLanguage{639-2}{\@TrackLangEnvLang}{\@tracklang@lang}%
     }%
     {%
%    \end{macrocode}
% 639-1 code. Track it.
%    \begin{macrocode}
         \AddTrackedIsoLanguage{639-1}{\@TrackLangEnvLang}{\@tracklang@lang}%
     }%
  }%
%    \end{macrocode}
% Add the territory if provided. (The territory may not have been
% defined by the dialect option.)
%    \begin{macrocode}
  \ifx\@TrackLangEnvTerritory\empty
  \else
    \AddTrackedIsoLanguage{3166-1}{\@TrackLangEnvTerritory}%
     {\@tracklang@dialect}%
  \fi
%    \end{macrocode}
% If a modifier was provided, add that.
%    \begin{macrocode}
  \ifx\@TrackLangEnvModifier\empty
  \else
    \SetTrackedDialectModifier{\@tracklang@dialect}{\@TrackLangEnvModifier}%
  \fi
%    \end{macrocode}
% If a variant was provided, add that.
%    \begin{macrocode}
  \ifx\@TrackLangEnvVariant\empty
  \else
    \SetTrackedDialectVariant{\@tracklang@dialect}{\@TrackLangEnvVariant}%
  \fi
%    \end{macrocode}
% If a script was provided, add that.
%    \begin{macrocode}
  \ifx\@TrackLangEnvScript\empty
  \else
    \SetTrackedDialectScript{\@tracklang@dialect}{\@TrackLangEnvScript}%
  \fi
%    \end{macrocode}
% If a language extension was provided, add that.
%    \begin{macrocode}
  \ifx\@TrackLangEnvSubLang\empty
  \else
    \SetTrackedDialectSubLang{\@tracklang@dialect}{\@TrackLangEnvSubLang}%
  \fi
%    \end{macrocode}
% If additional information was provided, add that.
%    \begin{macrocode}
  \ifx\@TrackLangEnvAdditional\empty
  \else
    \SetTrackedDialectAdditional{\@tracklang@dialect}{\@TrackLangEnvAdditional}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%
%\subsection{Predefined Root Languages}\label{sec:predefinedlang}
%
% The ISO 639-1 and 639-2 codes are used to map the root language name to the
% ISO language code. The 3166-1 codes are used to map the
% dialect\slash variant to the ISO country code. The country code is
% omitted if ambiguous (for example, the language is spoken in
% multiple countries). Languages that have a country code may be
% spoken as a minority language in another region. In this case,
% \cs{TrackLocale} should be used instead to set the country code as
% appropriate. Some \qt{dialects} are just synonyms for a
% language name, such as \qt{francais} or \qt{frenchb}. These are
% defined in \sectionref{sec:predefined}.  Some of the
% languages have two ISO 639-2 codes designated as \qt{B}
% (bibliographic) or \qt{T} (terminology). In these cases the
% terminology code is used as the primary 639-2 code. The extra
% \qt{B} and \qt{T} codes are only provided if they are different.
%
%\begin{macro}{\@tracklang@declareoption}
%\changes{1.1}{2014-11-21}{new}
% Provide a hook to declare a predefined setting as a package
% option. This is defined by tracklang.sty before loading
% tracklang.tex but if this file isn't loaded through tracklang.sty
% provide a definition that ignores its argument if not already
% defined.
%    \begin{macrocode}
\ifx\@tracklang@declareoption\undefined
  \def\@tracklang@declareoption#1{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangProvidePredefinedLanguage}
%\changes{1.4}{2019-11-30}{new}
% Set up a language label for use with \cs{TrackPredefinedDialect}.
% Note that this doesn't check if already defined.
%    \begin{macrocode}
\def\TrackLangProvidePredefinedLanguage#1{%
  \@tracklang@namedef{@tracklang@add@#1}{%
    \AddTrackedLanguage{#1}%
    \AddTrackedLanguageIsoCodes{#1}%
    \AddTrackedCountryIsoCode{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangDeclareLanguageOption}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangDeclareLanguageOption}\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}
%Define a new root language that's declared as an option.
%The language name must be expanded before use. The default script
%is the ISO 15924 alpha script code. (Some languages may be written
%in multiple scripts. Leave empty if not obvious default.)
%    \begin{macrocode}
\def\TrackLangDeclareLanguageOption#1#2#3#4#5#6#7{%
  \@tracklang@ifundef{@tracklang@add@#1}%
  {%
    \TrackLangNewLanguage{#1}{#2}{#3}{#4}{#5}{#6}{#7}%
    \TrackLangProvidePredefinedLanguage{#1}%
    \@tracklang@declareoption{#1}%
  }%
  {%
    \@tracklang@err{language option `#1' has already been defined}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@abkhaz}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{abkhaz}{ab}{abk}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@afar}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{afar}{aa}{aar}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@afrikaans}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{afrikaans}{af}{afr}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@akan}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{akan}{ak}{aka}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@albanian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{albanian}{sq}{sqi}{alb}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@amharic}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{amharic}{am}{amh}{}{}{ET}{Ethi}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@anglosaxon}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{anglosaxon}{}{ang}{}{}{}{Runr}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@apache}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{apache}{}{apa}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@arabic}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{arabic}{ar}{ara}{}{}{}{Arab}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@aragonese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{aragonese}{an}{arg}{}{}{ES}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@armenian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{armenian}{hy}{hye}{arm}{}{}{Armn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@assamese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{assamese}{as}{asm}{}{}{}{Beng}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@asturian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{asturian}{}{ast}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@avaric}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{avaric}{av}{ava}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@avestan}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{avestan}{ae}{ave}{}{}{}{Avst}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@aymara}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{aymara}{ay}{aym}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@azerbaijani}
%\changes{1.3}{2016-10-07}{new}
%The default script is dependent on the region, but this is a
%regionless definition so using Latin as the default here as
%Azerbaijani alphabet is a Latin alphabet. Other countries may be 
%using a different script, such as Cyrillic in Russia.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{azerbaijani}{az}{aze}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bahasai}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bahasai}{id}{ind}{}{}{IN}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bahasam}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bahasam}{ms}{msa}{may}{}{MY}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bambara}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bambara}{bm}{bam}{}{}{ML}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bashkir}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bashkir}{ba}{bak}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@basque}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{basque}{eu}{eus}{baq}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@belarusian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{belarusian}{be}{bel}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bengali}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bengali}{bn}{ben}{}{}{}{Beng}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@berber}
%\changes{1.3}{2016-10-07}{new}
%No default. Could be Tifinagh, Latin or Arabic.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{berber}{}{ber}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bihari}
%\changes{1.3}{2016-10-07}{new}
%No clear default.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bihari}{bh}{bih}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bislama}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bislama}{bi}{bis}{}{}{VU}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bokmal}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bokmal}{nb}{nob}{}{}{NO}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bosnian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bosnian}{bs}{bos}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@breton}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{breton}{br}{bre}{}{}{FR}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bulgarian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{bulgarian}{bg}{bul}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@burmese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{burmese}{my}{mya}{bur}{}{}{Mymr}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@catalan}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{catalan}{ca}{cat}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@chamorro}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{chamorro}{ch}{cha}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@chechen}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{chechen}{ce}{che}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@chichewa}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{chichewa}{ny}{nya}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@chinese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{chinese}{zh}{zho}{chi}{}{}{Hans}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@churchslavonic}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{churchslavonic}{cu}{chu}{}{}{}{Glag}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@chuvash}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{chuvash}{cv}{chv}{}{}{RU}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@coptic}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{coptic}{}{cop}{}{}{}{Copt}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@cornish}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{cornish}{kw}{cor}{}{}{GB}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@corsican}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{corsican}{co}{cos}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@cree}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{cree}{cr}{cre}{}{}{}{Cans}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@croatian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{croatian}{hr}{hrv}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@czech}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{czech}{cs}{ces}{cze}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@danish}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{danish}{da}{dan}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@divehi}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{divehi}{dv}{div}{}{}{MV}{Thaa}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@dutch}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{dutch}{nl}{nld}{dut}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@dzongkha}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{dzongkha}{dz}{dzo}{}{}{BT}{Tibt}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@easternpunjabi}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{easternpunjabi}{pa}{pan}{}{}{IN}{Guru}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@english}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{english}{en}{eng}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@esperanto}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{esperanto}{eo}{epo}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@estonian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{estonian}{et}{est}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ewe}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{ewe}{ee}{ewe}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@faroese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{faroese}{fo}{fao}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@farsi}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{farsi}{fa}{fas}{per}{}{}{Arab}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@fijian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{fijian}{fj}{fij}{}{}{FJ}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@finnish}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{finnish}{fi}{fin}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@french}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{french}{fr}{fra}{fre}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@friulan}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{friulan}{}{fur}{}{}{IT}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@fula}
%\changes{1.3}{2016-10-07}{new}
%No default. Could be Latin or Arabic.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{fula}{ff}{ful}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@galician}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{galician}{gl}{glg}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ganda}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{ganda}{lg}{lug}{}{}{UG}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@georgian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{georgian}{ka}{kat}{geo}{}{}{Geor}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@german}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{german}{de}{deu}{ger}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@greek}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{greek}{el}{ell}{gre}{}{}{Grek}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@guarani}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{guarani}{gn}{grn}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@guiarati}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{gujarati}{gu}{guj}{}{}{}{Gujr}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@haitian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{haitian}{ht}{hat}{}{}{HT}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@hausa}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{hausa}{ha}{hau}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@hebrew}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{hebrew}{he}{heb}{}{}{}{Hebr}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@herero}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{herero}{hz}{her}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@hindi}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{hindi}{hi}{hin}{}{}{}{Deva}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@hirimotu}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{hirimotu}{ho}{hmo}{}{}{PG}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@icelandic}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{icelandic}{is}{isl}{ice}{}{IS}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ido}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{ido}{io}{ido}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@igbo}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{igbo}{ig}{ibo}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@interlingua}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{interlingua}{ia}{ina}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@interlingue}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{interlingue}{ie}{ile}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@inuktitut}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{inuktitut}{iu}{iku}{}{}{}{Cans}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@inupiaq}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{inupiaq}{ik}{ipk}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@irish}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{irish}{ga}{gle}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@italian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{italian}{it}{ita}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@japanese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{japanese}{ja}{jpn}{}{}{}{Hani}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@javanese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{javanese}{jv}{jav}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kalaallisut}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kalaallisut}{kl}{kal}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kannada}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kannada}{kn}{kan}{}{}{IN}{Knda}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kanuri}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kanuri}{kr}{kau}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kashmiri}
%\changes{1.3}{2016-10-07}{new}
%No default script. Could be Arabic or Devanagari.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kashmiri}{ks}{kas}{}{}{IN}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kazakh}
%\changes{1.3}{2016-10-07}{new}
%Default script varies according to region.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kazakh}{kk}{kaz}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@khmer}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{khmer}{km}{khm}{}{}{}{Khmr}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kikuyu}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kikuyu}{ki}{kik}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kinyarwanda}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kinyarwanda}{rw}{kin}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kirundi}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kirundi}{rn}{run}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@komi}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{komi}{kv}{kom}{}{}{RU}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kongo}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kongo}{kg}{kon}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@korean}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{korean}{ko}{kor}{}{}{}{Hang}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kurdish}
%\changes{1.3}{2016-10-07}{new}
% Script varies according to region.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kurdish}{ku}{kur}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kwanyama}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kwanyama}{kj}{kua}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kyrgyz}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{kyrgyz}{ky}{kir}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@lao}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{lao}{lo}{lao}{}{}{}{Laoo}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@latin}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{latin}{la}{lat}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@latvian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{latvian}{lv}{lav}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@limburgish}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{limburgish}{li}{lim}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@lingala}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{lingala}{ln}{lin}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@lithuanian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{lithuanian}{lt}{lit}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@lsorbian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{lsorbian}{}{dsb}{}{}{DE}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@lubakatanga}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{lubakatanga}{lu}{lub}{}{}{CD}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@luxembourgish}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{luxembourgish}{lb}{ltz}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@macedonian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{macedonian}{mk}{mkd}{mac}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@magyar}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{magyar}{hu}{hun}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@malagasy}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{malagasy}{mg}{mlg}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@malayalam}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{malayalam}{ml}{mal}{}{}{IN}{Mlym}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@maltese}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{maltese}{mt}{mlt}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@manx}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{manx}{gv}{glv}{}{}{IM}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@maori}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{maori}{mi}{mri}{mao}{}{NZ}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@marathi}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{marathi}{mr}{mar}{}{}{IN}{Deva}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@marshallese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{marshallese}{mh}{mah}{}{}{MH}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@mongolian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{mongolian}{mn}{mon}{}{}{}{Mong}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nauruan}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{nauruan}{na}{nau}{}{}{NR}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@navajo}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{navajo}{nv}{nav}{}{}{US}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ndonga}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{ndonga}{ng}{ndo}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nepali}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{nepali}{ne}{nep}{}{}{}{Deva}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nko}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{nko}{}{nqo}{}{}{}{Nkoo}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@northernndebele}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{northernndebele}{nd}{nde}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nynorsk}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{nynorsk}{nn}{nno}{}{}{NO}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@norsk}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{norsk}{no}{nor}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@northernsotho}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{northernsotho}{}{nso}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nuosu}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{nuosu}{ii}{iii}{}{}{CN}{Yiii}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@occitan}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{occitan}{oc}{oci}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ojibwe}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{ojibwe}{oj}{oji}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@oromo}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{oromo}{om}{orm}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@oriya}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{oriya}{or}{ori}{}{}{}{Orya}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ossetian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{ossetian}{os}{oss}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@pali}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{pali}{pi}{pli}{}{}{}{Brah}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@pashto}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{pashto}{ps}{pus}{}{}{}{Arab}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@piedmontese}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{piedmontese}{}{}{}{pms}{IT}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@polish}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{polish}{pl}{pol}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@portuges}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{portuges}{pt}{por}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@quechua}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{quechua}{qu}{que}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@romanian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{romanian}{ro}{ron}{rum}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@romansh}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{romansh}{rm}{roh}{}{}{CH}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@russian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{russian}{ru}{rus}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@samin}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{samin}{se}{sme}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sanskrit}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{sanskrit}{sa}{san}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@samoan}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{samoan}{sm}{smo}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sango}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{sango}{sg}{sag}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sardinian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{sardinian}{sc}{srd}{}{}{IT}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@scottish}
%Also spoken in Canada, so no region.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{scottish}{gd}{gla}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@serbian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{serbian}{sr}{srp}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@shona}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{shona}{sn}{sna}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sindhi}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{sindhi}{sd}{snd}{}{}{}{Sind}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sinhalese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{sinhalese}{si}{sin}{}{}{LK}{Sinh}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@slovak}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{slovak}{sk}{slk}{slo}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@slovene}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{slovene}{sl}{slv}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@somali}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{somali}{so}{som}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@southernndebele}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{southernndebele}{nr}{nbl}{}{}{ZA}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@southernsotho}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{southernsotho}{st}{sot}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@spanish}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{spanish}{es}{spa}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sudanese}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{sudanese}{su}{sun}{}{}{}{Sund}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@swahili}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{swahili}{sw}{swa}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@swati}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{swati}{ss}{ssw}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@swedish}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{swedish}{sv}{swe}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@syriac}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{syriac}{}{syr}{}{}{}{Syrc}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tagalog}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tagalog}{tl}{tgl}{}{}{PH}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tahitian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tahitian}{ty}{tah}{}{}{PF}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tai}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tai}{}{tai}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tajik}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tajik}{tg}{tgk}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tamil}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tamil}{ta}{tam}{}{}{}{Taml}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tatar}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tatar}{tt}{tat}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@telugu}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{telugu}{te}{tel}{}{}{IN}{Telu}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@thai}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{thai}{th}{tha}{}{}{TH}{Thai}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tibetan}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tibetan}{bo}{bod}{tib}{}{}{Tibt}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tigrinya}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tigrinya}{ti}{tir}{}{}{}{Ethi}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tonga}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tonga}{to}{ton}{}{}{TO}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tsonga}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tsonga}{ts}{tso}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@tswana}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{tswana}{tn}{tsn}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@turkish}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{turkish}{tr}{tur}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@turkmen}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{turkmen}{tk}{tuk}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@twi}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{twi}{tw}{twi}{}{}{GH}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ukrainian}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{ukrainian}{uk}{ukr}{}{}{UA}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@undetermined}
%\changes{1.3.8}{2019-10-06}{new}
%Undetermined language (ISO~636-2 code `und') for unknown languages.
%There's no ISO 639-1 language code for this language.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{undetermined}{}{und}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@urdu}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{urdu}{ur}{urd}{}{}{}{Arab}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@usorbian}
%\changes{1.3}{2016-10-07}{corrected ISO 639-1 code}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{usorbian}{}{hsb}{}{}{DE}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@uyghur}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{uyghur}{ug}{uig}{}{}{CN}{Arab}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@uzbek}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{uzbek}{uz}{uzb}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@venda}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{venda}{ve}{ven}{}{}{ZA}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@vietnamese}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{vietnamese}{vi}{vie}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@volapuk}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{volapuk}{vo}{vol}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@walloon}
% No country code as Walloon is spoken in multiple regions
% (Wallonia in Belgium, some villages in Northern France and north-east of
% Wisconsin.) Not the same as Belgian French.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{walloon}{wa}{wln}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@welsh}
%Also spoken in Argentina, so no region.
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{welsh}{cy}{cym}{wel}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@westernfrisian}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{westernfrisian}{fy}{fry}{}{}{NL}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@wolof}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{wolof}{wo}{wol}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@xhosa}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{xhosa}{xh}{xho}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@yiddish}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{yiddish}{yi}{yid}{}{}{}{Hebr}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@yoruba}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{yoruba}{yo}{yor}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@zhuang}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{zhuang}{za}{zha}{}{}{CN}{Hani}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@zulu}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareLanguageOption{zulu}{zu}{zul}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%
%\subsection{Predefined Dialects}\label{sec:predefined}
%
% Provide some predefined dialects.
%\begin{macro}{\TrackLangProvidePredefinedDialect}
%\changes{1.4}{2019-11-30}{new}
%\begin{definition}
%\cs{TrackLangProvidePredefinedDialect}\marg{dialect}\marg{root
%language}\marg{3166-1
%code}\marg{modifier}\marg{variant}\marg{map}\marg{script}
%\end{definition}
%This defines a predefined dialect label that can be used
%by \cs{TrackPredefinedDialect}. The arguments
%must be expanded before use. The final argument \meta{map} is the
%mapping from \meta{dialect} to the closest \styfmt{babel} dialect
%label.
%    \begin{macrocode}
\def\TrackLangProvidePredefinedDialect#1#2#3#4#5#6#7{
    \ifx\relax#3\relax
%    \end{macrocode}
% No region.
%    \begin{macrocode}
     \ifx\relax#4\relax
%    \end{macrocode}
% No modifier.
%    \begin{macrocode}
      \ifx\relax#5\relax
%    \end{macrocode}
% No variant.
%    \begin{macrocode}
        \@tracklang@namedef{@tracklang@add@#1}{%
          \AddTrackedDialect{#1}{#2}%
          \AddTrackedLanguageIsoCodes{#2}%
%    \end{macrocode}
% Make it easier for the parser to pick up the dialect label.
% Note that this should be the same as
% \cs{TrackLangLastTrackedDialect} but the parser references
% \cs{@tracklang@dialect}.
%    \begin{macrocode}
          \def\@tracklang@dialect{#1}%
        }%
      \else
%    \end{macrocode}
% Has variant but no modifier.
%    \begin{macrocode}
        \@tracklang@namedef{@tracklang@add@#1}{%
          \AddTrackedDialect{#1}{#2}%
          \AddTrackedLanguageIsoCodes{#2}%
          \SetTrackedDialectVariant{#1}{#5}%
          \def\@tracklang@dialect{#1}%
        }%
      \fi
     \else
%    \end{macrocode}
% Has modifier.
%    \begin{macrocode}
       \ifx\relax#5\relax
%    \end{macrocode}
% No variant.
%    \begin{macrocode}
         \@tracklang@namedef{@tracklang@add@#1}{%
           \AddTrackedDialect{#1}{#2}%
           \AddTrackedLanguageIsoCodes{#2}%
           \SetTrackedDialectModifier{#1}{#4}%
           \def\@tracklang@dialect{#1}%
         }%
       \else
%    \end{macrocode}
% Variant and modifier.
%    \begin{macrocode}
         \@tracklang@namedef{@tracklang@add@#1}{%
           \AddTrackedDialect{#1}{#2}%
           \AddTrackedLanguageIsoCodes{#2}%
           \SetTrackedDialectModifier{#1}{#4}%
           \SetTrackedDialectVariant{#1}{#5}%
           \def\@tracklang@dialect{#1}%
         }%
       \fi
     \fi
    \else
%    \end{macrocode}
% Has a region.
%    \begin{macrocode}
     \ifx\relax#4\relax
%    \end{macrocode}
% No modifier.
%    \begin{macrocode}
       \ifx\relax#5\relax
%    \end{macrocode}
% No variant.
%    \begin{macrocode}
          \@tracklang@namedef{@tracklang@add@#1}{%
            \AddTrackedDialect{#1}{#2}%
            \AddTrackedLanguageIsoCodes{#2}%
            \AddTrackedIsoLanguage{3166-1}{#3}{#1}%
            \def\@tracklang@dialect{#1}%
          }%
       \else
%    \end{macrocode}
% Variant no modifier.
%    \begin{macrocode}
          \@tracklang@namedef{@tracklang@add@#1}{%
            \AddTrackedDialect{#1}{#2}%
            \AddTrackedLanguageIsoCodes{#2}%
            \AddTrackedIsoLanguage{3166-1}{#3}{#1}%
            \SetTrackedDialectVariant{#1}{#5}%
            \def\@tracklang@dialect{#1}%
          }%
       \fi
     \else
%    \end{macrocode}
% Has modifier.
%    \begin{macrocode}
       \ifx\relax#5\relax
%    \end{macrocode}
% No variant.
%    \begin{macrocode}
          \@tracklang@namedef{@tracklang@add@#1}{%
            \AddTrackedDialect{#1}{#2}%
            \AddTrackedLanguageIsoCodes{#2}%
            \AddTrackedIsoLanguage{3166-1}{#3}{#1}%
            \SetTrackedDialectModifier{#1}{#4}%
            \def\@tracklang@dialect{#1}%
          }%
       \else
%    \end{macrocode}
% Variant and modifier.
%    \begin{macrocode}
          \@tracklang@namedef{@tracklang@add@#1}{%
            \AddTrackedDialect{#1}{#2}%
            \AddTrackedLanguageIsoCodes{#2}%
            \AddTrackedIsoLanguage{3166-1}{#3}{#1}%
            \SetTrackedDialectModifier{#1}{#4}%
            \SetTrackedDialectVariant{#1}{#5}%
            \def\@tracklang@dialect{#1}%
          }%
       \fi
     \fi
    \fi
%    \end{macrocode}
% Add the mapping if provided.
%    \begin{macrocode}
    \ifx\relax#6\relax
    \else
      \expandafter
       \let\expandafter\@tracklang@tmp\csname @tracklang@add@#1\endcsname
      \expandafter\def\csname @tracklang@add@#1\expandafter\endcsname
%    \end{macrocode}
%\changes{1.3.3}{2016-11-03}{fixed mapping order}
%    \begin{macrocode}
        \expandafter{\@tracklang@tmp\SetTrackedDialectLabelMap{#1}{#6}}%
    \fi
%    \end{macrocode}
% Add the script if provided.
%    \begin{macrocode}
    \ifx\relax#7\relax
    \else
      \expandafter
       \let\expandafter\@tracklang@tmp\csname @tracklang@add@#1\endcsname
      \expandafter\def\csname @tracklang@add@#1\expandafter\endcsname
        \expandafter{\@tracklang@tmp\SetTrackedDialectScript{#1}{#7}}%
    \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangDeclareDialectOption}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangDeclareDialectOption}\marg{dialect}\marg{root
%language}\marg{3166-1
%code}\marg{modifier}\marg{variant}\marg{map}\marg{script}
%\end{definition}
%The option name is the same as the dialect name. The arguments
%must be expanded before use. The final argument \meta{map} is the
%mapping from \meta{dialect} to the closest \styfmt{babel} dialect
%label. May be empty if no relevant mapping.
%    \begin{macrocode}
\def\TrackLangDeclareDialectOption#1#2#3#4#5#6#7{%
  \@tracklang@ifundef{@tracklang@add@#1}%
  {%
    \TrackLangProvidePredefinedDialect{#1}{#2}{#3}{#4}{#5}{#6}{#7}%
    \@tracklang@declareoption{#1}%
  }%
  {%
    \@tracklang@err{dialect option `#1' has already been defined}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@acadian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{acadian}{french}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@american}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{american}{english}{US}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@australian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{australian}{english}{AU}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@austrian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{austrian}{german}{AT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@naustrian}
%\changes{1.3}{2016-10-07}{added modifier}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{naustrian}{german}{AT}{new}{1996}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bahasa}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{bahasa}{bahasai}{IN}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@brazil}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{brazil}{portuges}{BR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@brazilian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{brazilian}{portuges}{BR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@british}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{british}{english}{GB}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@canadian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{canadian}{english}{CA}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@canadien}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{canadien}{french}{CA}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@croatia}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{croatia}{croatian}{HR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@istriacountycroatian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{istriacountycroatian}{croatian}{HR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@istriacountyitalian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{istriacountyitalian}{italian}{HR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@netherlands}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{netherlands}{dutch}{NL}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@persian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{persian}{farsi}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@flemish}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{flemish}{dutch}{BE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@francais}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{francais}{french}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@frenchb}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{frenchb}{french}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@france}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{france}{french}{FR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@belgique}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{belgique}{french}{BE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@belgiangerman}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{belgiangerman}{german}{BE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nbelgiangerman}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{nbelgiangerman}{german}{BE}{new}{1996}{ngerman}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@friulian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{friulian}{friulan}{IT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@friulano}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{friulano}{friulan}{IT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@furlan}
%\changes{1.3.4}{2017-03-25}{new}
%Added since it's a babel alias for friulan.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{furlan}{friulan}{IT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@kurmanji}
%\changes{1.3.4}{2017-03-25}{new}
%Added since it's a babel label.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{kurmanji}{kurdish}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@galicien}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{galicien}{galician}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@deutsch}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{deutsch}{german}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ngerman}
%\changes{1.3}{2016-10-07}{added modifier}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{ngerman}{german}{}{new}{1996}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ngermanb}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{ngermanb}{german}{}{new}{1996}{ngerman}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@germanb}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{germanb}{german}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ngermanDE}
%\changes{1.1}{2014-11-21}{new}
%\changes{1.3}{2016-10-07}{added modifier}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{ngermanDE}{german}{DE}{new}{1996}{ngerman}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@germanDE}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{germanDE}{german}{DE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@hungarian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{hungarian}{magyar}{HU}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@indon}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{indon}{bahasai}{IN}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@indonesian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{indonesian}{bahasai}{IN}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@gaeilge}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{gaeilge}{irish}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@IEirish}
%\changes{1.2}{2015-03-23}{new}
% Irish spoken in Republic of Ireland
%    \begin{macrocode}
\TrackLangDeclareDialectOption{IEirish}{irish}{IE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@GBirish}
%\changes{1.2}{2015-03-23}{new}
% Irish spoken in the United Kingdom of Great Britain and Northern Ireland
%    \begin{macrocode}
\TrackLangDeclareDialectOption{GBirish}{irish}{GB}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@IEenglish}
%\changes{1.2}{2015-03-23}{new}
%English spoken in the Republic of Ireland.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{IEenglish}{english}{IE}{}{}{british}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@italy}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{italy}{italian}{IT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@vatican}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{vatican}{italian}{VA}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sanmarino}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{sanmarino}{italian}{SM}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sloveneistriaitalian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{sloveneistriaitalian}{italian}{SI}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@jerseyenglish}
%\changes{1.1}{2014-11-21}{new}
%Allow it to hook to pick up \cs{captionsbritish} as well as
%\cs{captionsenglish} since the date format closely matches
%\texttt{british}.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{jerseyenglish}{english}{JE}{}{}{british}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@jerseyfrench}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{jerseyfrench}{french}{JE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@guernseyenglish}
%\changes{1.1}{2014-11-21}{new}
%Allow it to hook to pick up \cs{captionsbritish} as well as
%\cs{captionsenglish} since the date format closely matches
%\texttt{british}.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{guernseyenglish}{english}{GG}{}{}{british}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@guernseyfrench}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{guernseyfrench}{french}{GG}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@latein}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{latein}{latin}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@lowersorbian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{lowersorbian}{lsorbian}{DE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@malay}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{malay}{bahasam}{MY}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@meyalu}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{meyalu}{bahasam}{MY}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@maltamaltese}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{maltamaltese}{maltese}{MT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@maltaenglish}
%\changes{1.1}{2014-11-21}{new}
%Allow it to hook to pick up \cs{captionsbritish} as well as
%\cs{captionsenglish} since the date format closely matches
%\texttt{british}.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{maltaenglish}{english}{MT}{}{}{british}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@newzealand}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{newzealand}{english}{NZ}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@isleofmanenglish}
%\changes{1.1}{2014-11-21}{new}
%Allow it to hook to pick up \cs{captionsbritish} as well as
%\cs{captionsenglish} since the date format closely matches
%\texttt{british}.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{isleofmanenglish}{english}{IM}{}{}{british}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@norwegian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{norwegian}{norsk}{NO}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@piemonteis}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{piemonteis}{piedmontese}{IT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@polutonikogreek}
%\changes{1.3}{2016-10-07}{added modifier}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{polutonikogreek}{greek}{}{polyton}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@polutoniko}
%\changes{1.3}{2016-10-07}{added modifier}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{polutoniko}{greek}{}{polyton}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@portuguese}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{portuguese}{portuges}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@portugal}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{portugal}{portuges}{PT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@romansch}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{romansch}{romansh}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@rumantsch}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{rumantsch}{romansh}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@romanche}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{romanche}{romansh}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@russianb}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{russianb}{russian}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@gaelic}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{gaelic}{scottish}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@GBscottish}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{GBscottish}{scottish}{GB}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@serbianc}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{serbianc}{serbian}{}{}{}{}{Cyrl}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@serbianl}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{serbianl}{serbian}{}{}{}{}{Latn}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@slovenian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{slovenian}{slovene}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@slovenia}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{slovenia}{slovene}{SI}{}{}{slovenian}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@sloveneistriaslovenian}
%\changes{1.3}{2016-10-07}{fixed root language name}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{sloveneistriaslovenian}{slovene}{SI}{}{}{slovenian}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@spainspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{spainspanish}{spanish}{ES}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@argentinespanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{argentinespanish}{spanish}{AR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@bolivianspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{bolivianspanish}{spanish}{BO}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@chilianspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{chilianspanish}{spanish}{CL}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@columbianspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{columbianspanish}{spanish}{CO}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@costaricanspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{costaricanspanish}{spanish}{CR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@cubanspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{cubanspanish}{spanish}{CU}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@dominicanspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{dominicanspanish}{spanish}{DO}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ecudorianspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{ecudorianspanish}{spanish}{EC}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@elsalvadorspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{elsalvadorspanish}{spanish}{SV}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@guatemalanspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{guatemalanspanish}{spanish}{GT}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@honduranspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{honduranspanish}{spanish}{HN}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@mexicanspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{mexicanspanish}{spanish}{MX}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nicaraguanspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{nicaraguanspanish}{spanish}{NI}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@panamaspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{panamaspanish}{spanish}{PA}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@paraguayspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{paraguayspanish}{spanish}{PY}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@peruvianspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{peruvianspanish}{spanish}{PE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@puertoricospanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{puertoricospanish}{spanish}{PR}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@uruguayspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{uruguayspanish}{spanish}{UY}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@venezuelanspanish}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{venezuelanspanish}{spanish}{VE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@swissgerman}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{swissgerman}{german}{CH}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@nswissgerman}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{nswissgerman}{german}{CH}{new}{1996}{ngerman}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@swissfrench}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{swissfrench}{french}{CH}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@swissitalian}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{swissitalian}{italian}{CH}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@swissromansh}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{swissromansh}{romansh}{CH}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@UKenglish}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{UKenglish}{english}{GB}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ukraineb}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{ukraineb}{ukrainian}{UA}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@ukraine}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{ukraine}{ukrainian}{UA}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@uppersorbian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{uppersorbian}{usorbian}{DE}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@USenglish}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{USenglish}{english}{US}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@valencian}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{valencian}{catalan}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@valencien}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{valencien}{catalan}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@cymraeg}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{cymraeg}{welsh}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@add@GBwelsh}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\TrackLangDeclareDialectOption{GBwelsh}{welsh}{GB}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@nil}
%\changes{1.3.8}{2019-10-06}{new}
%Add \sty{babel}'s \texttt{nil} as a dialect of undetermined
%language.
%    \begin{macrocode}
\TrackLangDeclareDialectOption{nil}{undetermined}{}{}{}{}{}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Dialect Option Synonyms}
%\label{sec:dialectsyns}
% Add some dialect synonyms:
%\begin{macro}{\LetTrackLangSynonym}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\LetTrackLangSynonym#1#2{%
  \expandafter\let\csname @tracklang@add@#1\expandafter\endcsname
    \csname @tracklang@add@#2\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\LetTrackLangOption}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\def\LetTrackLangOption#1#2{%
  \LetTrackLangSynonym{#1}{#2}%
  \@tracklang@declareoption{#1}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-US}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-US}{american}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-GB}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-GB}{british}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-AU}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-AU}{australian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-NZ}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-NZ}{newzealand}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-CA}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-CA}{canadian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@fr-CA}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{fr-CA}{canadien}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@fr-BE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{fr-BE}{belgique}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@pt-BR}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{pt-BR}{brazilian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@it-HR}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{it-HR}{istriacountyitalian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@nl-BE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{nl-BE}{flemish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@fr-FR}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{fr-FR}{france}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@de-DE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{de-DE}{germanDE}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@de-BE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{de-BE}{belgiangerman}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-GG}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-GG}{guernseyenglish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@fr-GG}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{fr-GG}{guernseyfrench}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@it-IT}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{it-IT}{italy}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@mt-MT}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{mt-MT}{maltamaltese}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-MT}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-MT}{maltaenglish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-IM}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-IM}{isleofmanenglish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-JE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{en-JE}{jerseyenglish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@fr-JE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{fr-JE}{jerseyfrench}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@nl-NL}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{nl-NL}{netherlands}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@pt-PT}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{pt-PT}{portugal}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@it-SM}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{it-SM}{sanmarino}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@sl-SI}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{sl-SI}{slovenia}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@it-SI}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{it-SI}{sloveneistriaitalian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-ES}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-ES}{spainspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-AR}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-AR}{argentinespanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-BO}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-BO}{bolivianspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-CL}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-CL}{chilianspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-CO}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-CO}{columbianspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-CR}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-CR}{costaricanspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-CU}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-CU}{cubanspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-DO}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-DO}{dominicanspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-EC}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-EC}{ecudorianspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-SV}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-SV}{elsalvadorspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-GT}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-GT}{guatemalanspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-HN}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-HN}{honduranspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-MX}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-MX}{mexicanspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-NI}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-NI}{nicaraguanspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-PA}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-PA}{panamaspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-PY}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-PY}{paraguayspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-PE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-PE}{peruvianspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-PR}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-PR}{puertoricospanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-UY}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-UY}{uruguayspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@es-VE}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{es-VE}{venezuelanspanish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@de-CH}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{de-CH}{swissgerman}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@fr-CH}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{fr-CH}{swissfrench}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@it-CH}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{it-CH}{swissitalian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@rm-CH}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{rm-CH}{swissromansh}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@it-VA}
%\changes{1.1}{2014-11-21}{new}
%    \begin{macrocode}
\LetTrackLangOption{it-VA}{vatican}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@ga-IE}
%\changes{1.2}{2015-03-23}{new}
% Irish Gaelic in Republic of Ireland.
%    \begin{macrocode}
\LetTrackLangOption{ga-IE}{IEirish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@ga-GB}
%\changes{1.2}{2015-03-23}{new}
% Irish Gaelic in Northern Ireland.
%    \begin{macrocode}
\LetTrackLangOption{ga-GB}{GBirish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@en-IE}
%\changes{1.2}{2015-03-23}{new}
% English spoken in Republic of Ireland.
%    \begin{macrocode}
\LetTrackLangOption{en-IE}{IEenglish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@de-AT-1996}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{de-AT-1996}{naustrian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@de-AT}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{de-AT}{austrian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@id-IN}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{id-IN}{bahasa}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@ms-MY}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{ms-MY}{malay}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@hr-HR}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{hr-HR}{croatia}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@de-DE-1996}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{de-DE-1996}{ngermanDE}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@de-CH-1996}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{de-CH-1996}{nswissgerman}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@hu-HU}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{hu-HU}{hungarian}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@gd-GB}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{gd-GB}{GBscottish}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@tracklang@add@cy-GB}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\LetTrackLangOption{cy-GB}{GBwelsh}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Conditionals and Loops}
%
%\begin{macro}{\IfTrackedLanguage}
%\begin{definition}
%\cs{IfTrackedLanguage}\marg{language}\marg{true part}\marg{false
%part}
%\end{definition}
%    \begin{macrocode}
\long\def\IfTrackedLanguage#1#2#3{%
%    \end{macrocode}
% First find out if the language name is empty.
%    \begin{macrocode}
  \edef\@tracklang@element{#1}%
  \ifx\@tracklang@element\empty
%    \end{macrocode}
% Language is empty, so do false part.
%    \begin{macrocode}
    #3%
  \else
    \expandafter\@tracklang@ifinlist\expandafter{\@tracklang@element}%
      \@tracklang@languages
    {%
%    \end{macrocode}
% In list, so do true part.
%    \begin{macrocode}
      #2%
    }%
    {%
%    \end{macrocode}
% Not in list, so do false part.
%    \begin{macrocode}
      #3%
    }%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfTrackedDialect}
%\begin{definition}
%\cs{IfTrackedDialect}\marg{dialect}\marg{true part}\marg{false
%part}
%\end{definition}
%    \begin{macrocode}
\long\def\IfTrackedDialect#1#2#3{%
  \@tracklang@ifundef{@tracklang@fromdialect@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfTrackedIsoCode}
%\begin{definition}
%\cs{IfTrackedIsoCode}\marg{code type}\marg{code}\marg{true part}\marg{false
%part}
%\end{definition}
%    \begin{macrocode}
\long\def\IfTrackedIsoCode#1#2#3#4{%
  \@tracklang@ifundef{@tracklang@#1@isotolang@#2}{#4}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfTrackedLanguageHasIsoCode}
%\begin{definition}
%\cs{IfTrackedLanguageHasIsoCode}\marg{code type}\marg{language}\marg{true part}\marg{false
%part}
%\end{definition}
%    \begin{macrocode}
\long\def\IfTrackedLanguageHasIsoCode#1#2#3#4{%
  \@tracklang@ifundef{@tracklang@#1@isofromlang@#2}{#4}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ForEachTrackedLanguage}
%\begin{definition}
%\cs{ForEachTrackedLanguage}\marg{cs}\marg{body}
%\end{definition}
% Iterates through the list of tracked languages. On each iteration
% \meta{cs} is set to the language tag and \meta{body} is performed.
%    \begin{macrocode}
\long\def\ForEachTrackedLanguage#1#2{%
  \@tracklang@for#1:=\@tracklang@languages\do{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ForEachTrackedDialect}
%\begin{definition}
%\cs{ForEachTrackedDialect}\marg{cs}\marg{body}
%\end{definition}
% Iterates through the list of tracked dialects. On each iteration
% \meta{cs} is set to the dialect tag and \meta{body} is performed.
%    \begin{macrocode}
\long\def\ForEachTrackedDialect#1#2{%
  \@tracklang@for#1:=\@tracklang@dialects\do{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\AnyTrackedLanguages}
%    \begin{macrocode}
\long\def\AnyTrackedLanguages#1#2{%
  \ifx\@tracklang@languages\empty
    #2%
  \else
    #1%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfTrackedLanguageFileExists}
%\begin{definition}
%\cs{IfTrackedLanguageFileExists}\marg{dialect}\marg{prefix}\marg{suffix}\marg{true
%part}\marg{false part}
%\end{definition}
% Determines if the file \meta{prefix}\meta{tag}\meta{suffix}
% exists, where \meta{tag} is an ISO code or ISO codes or label identifying
% the language. If \meta{dialect} hasn't been identified
% as a tracked dialect, this just does \meta{false part},
% otherwise this tries various different combinations for \meta{tag}.
% If the file \meta{prefix}\meta{tag}\meta{suffix} exists, 
% \cs{CurrentTrackedTag} is set to \meta{tag} and \meta{true part}
% is performed, otherwise \meta{false part} is performed.
% The order of priority has changed with version 1.4 and now
% includes a check for variations that include the script. If the
% original ordering is specifically required, the old behaviour can
% be obtained with \cs{IfTrackedLanguageFileExists@orig}.
%    \begin{macrocode}
\long\def\IfTrackedLanguageFileExists#1#2#3#4#5{%
   \@tracklang@verbose{Finding file for dialect `#1'}%
%    \end{macrocode}
%Initialise.
%    \begin{macrocode}
   \def\CurrentTrackedTag{}%
%    \end{macrocode}
%Select this dialect.
%    \begin{macrocode}
   \SetCurrentTrackedDialect{#1}%
   \IfTrackedDialect{#1}%
   {%
%    \end{macrocode}
% Save the three types of language codes to for reference.
%    \begin{macrocode}
     \edef\CurrentTrackedIsoCodeI{\TrackedIsoCodeFromLanguage
         {639-1}{\CurrentTrackedLanguage}}%
     \edef\CurrentTrackedIsoCodeII{\TrackedIsoCodeFromLanguage
         {639-2}{\CurrentTrackedLanguage}}%
     \edef\CurrentTrackedIsoCodeIII{\TrackedIsoCodeFromLanguage
         {639-3}{\CurrentTrackedLanguage}}%
%    \end{macrocode}
%\changes{1.4}{2019-11-30}{added check for scripts}
% Earlier versions of this had too many nested conditionals, which
% was confusing and hard to follow. This is a rewrite that removes
% the nesting and adds extra checks for dialect scripts.
%    \begin{macrocode}
     \@tracklang@test@if@file@exists@for@tag{#1}{#2}{#3}%
     \@tracklang@if@file@exists{#4}{#5}%
   }%
   {#5}% unknown dialect
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@noop}
%\changes{1.4}{2019-11-30}{new}
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@noop#1#2#3{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@tag}
%\changes{1.4}{2019-11-30}{new}
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@tag#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedLanguageTag
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \let\@tracklang@if@file@exists\@tracklang@secondoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@dialect
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@dialect}
%\changes{1.4}{2019-11-30}{new}
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@dialect#1#2#3{%
  \edef\CurrentTrackedTag{#1}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \IfTrackedLanguageHasIsoCode{639-1}{\CurrentTrackedLanguage}%
    {%
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIscriptregion
    }%
    {%
      \IfTrackedLanguageHasIsoCode{639-2}{\CurrentTrackedLanguage}%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscriptregion
      }%
      {%
        \IfTrackedLanguageHasIsoCode{639-3}{\CurrentTrackedLanguage}%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptregion
        }%
        {%
          \let\CurrentTrackedIsoCode\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@scriptregion
        }%
      }%
    }%
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIscriptregion}
%\changes{1.4}{2019-11-30}{new}
% Test \meta{639-1}-\meta{sublang}-\meta{script}-\meta{region} combination.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIscriptregion#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeI
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \ifx\CurrentTrackedDialectScript\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \fi
  \ifx\CurrentTrackedRegion\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedRegion}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedRegion\empty
      \ifx\CurrentTrackedDialectScript\empty
%    \end{macrocode}
%No script or region set. If there's a sub-language code then try
%again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langII
        \else
          \let\CurrentTrackedTag\CurrentTrackedIsoCode
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langII
          }%
        \fi
      \else
%    \end{macrocode}
%No region set. If there's a sub-language code then try
%again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipscript
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipscript
          }%
        \fi
      \fi
    \else
      \ifx\CurrentTrackedDialectScript\empty
%    \end{macrocode}
% Region is set but no script. If there's a sub-language code
% then try again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipregion
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedRegion}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipregion
          }%
        \fi
      \else
%    \end{macrocode}
% Region and script set. If there's a sub-language code
% then try again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipscriptregion
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript
            -\CurrentTrackedRegion}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipscriptregion
          }%
        \fi
      \fi
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIscriptregion}
%\changes{1.4}{2019-11-30}{new}
% Test \meta{639-2}-\meta{sublang}-\meta{script}-\meta{region} combination.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIscriptregion#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \ifx\CurrentTrackedDialectScript\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \fi
  \ifx\CurrentTrackedRegion\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedRegion}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedRegion\empty
      \ifx\CurrentTrackedDialectScript\empty
%    \end{macrocode}
%No script or region set. If there's a sub-language code then try
%again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIII
        \else
          \let\CurrentTrackedTag\CurrentTrackedIsoCode
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIII
          }%
        \fi
      \else
%    \end{macrocode}
%No region set. If there's a sub-language code then try
%again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscript
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscript
          }%
        \fi
      \fi
    \else
      \ifx\CurrentTrackedDialectScript\empty
%    \end{macrocode}
% Region is set but no script. If there's a sub-language code
% then try again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipregion
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedRegion}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipregion
          }%
        \fi
      \else
%    \end{macrocode}
% Both region and script are set. If there's a sub-language code
% then try again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscriptregion
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript
            -\CurrentTrackedRegion}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscriptregion
          }%
        \fi
      \fi
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIscriptregion}
%\changes{1.4}{2019-11-30}{new}
% Test \meta{639-3}-\meta{sublang}-\meta{script}-\meta{region} combination.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIscriptregion#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \ifx\CurrentTrackedDialectScript\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \fi
  \ifx\CurrentTrackedRegion\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedRegion}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedRegion\empty
      \ifx\CurrentTrackedDialectScript\empty
%    \end{macrocode}
%No script or region set. If there's a sub-language code then try
%again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
        \else
          \let\CurrentTrackedTag\CurrentTrackedIsoCode
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
          }%
        \fi
      \else
%    \end{macrocode}
%No region set. If there's a sub-language code then try
%again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscript
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscript
          }%
        \fi
      \fi
    \else
      \ifx\CurrentTrackedDialectScript\empty
%    \end{macrocode}
% Region is set but no script. If there's a sub-language code
% then try again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipregion
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedRegion}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipregion
          }%
        \fi
      \else
%    \end{macrocode}
% Both region and script are set. If there's a sub-language code
% then try again without it.
%    \begin{macrocode}
        \ifx\CurrentTrackedDialectSubLang\empty
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscriptregion
        \else
          \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript
            -\CurrentTrackedRegion}%
          \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
          \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
          {%
            \let\@tracklang@if@file@exists\@tracklang@firstoftwo
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscriptregion
          }%
        \fi
      \fi
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIskipscript}
%\changes{1.4}{2019-11-30}{new}
%No region. Has a script but already tested with 639-1 and script.
%Just test language code alone.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIskipscript#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \IfTrackedLanguageHasIsoCode
      {639-2}{\CurrentTrackedLanguage}
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscript
      }%
      {%
        \IfTrackedLanguageHasIsoCode
        {639-3}{\CurrentTrackedLanguage}
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscript
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
        }%
      }%
    \else
%    \end{macrocode}
% Try without sub-language code.
%    \begin{macrocode}
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \IfTrackedLanguageHasIsoCode
        {639-2}{\CurrentTrackedLanguage}
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscript
        }%
        {%
          \IfTrackedLanguageHasIsoCode
          {639-3}{\CurrentTrackedLanguage}
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscript
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
          }%
        }%
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIscript}
%\changes{1.4}{2019-11-30}{new}
%No region but has a script.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIscript#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscript
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscript
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIskipscript}
%\changes{1.4}{2019-11-30}{new}
%No region. Has a script but already checked.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIskipscript#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \IfTrackedLanguageHasIsoCode
      {639-3}{\CurrentTrackedLanguage}
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscript
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
      }%
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \IfTrackedLanguageHasIsoCode
        {639-3}{\CurrentTrackedLanguage}
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscript
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
        }%
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIscript}
%\changes{1.4}{2019-11-30}{new}
%No region but has a script.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIscript#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscript
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscript
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIskipscript}
%\changes{1.4}{2019-11-30}{new}
%No region. Has a script but already checked.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIskipscript#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIskipregion}
%\changes{1.4}{2019-11-30}{new}
%No script. Has a region but already tested with 639-1 and script.
%Just test language code alone.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \IfTrackedLanguageHasIsoCode
      {639-2}{\CurrentTrackedLanguage}
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIregion
      }%
      {%
        \IfTrackedLanguageHasIsoCode
        {639-3}{\CurrentTrackedLanguage}
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIregion
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
        }%
      }%
    \else
%    \end{macrocode}
% Try without sub-language code.
%    \begin{macrocode}
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \IfTrackedLanguageHasIsoCode
        {639-2}{\CurrentTrackedLanguage}
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIregion
        }%
        {%
          \IfTrackedLanguageHasIsoCode
          {639-3}{\CurrentTrackedLanguage}
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIregion
          }%
          {%
            \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
          }%
        }%
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIregion}
%\changes{1.4}{2019-11-30}{new}
%No script but has a region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIregion#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipregion
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipregion
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIskipregion}
%\changes{1.4}{2019-11-30}{new}
%No script. Has a region but already tested with 639-2 and region.
%Just test language code alone.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \IfTrackedLanguageHasIsoCode
      {639-3}{\CurrentTrackedLanguage}
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIregion
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
      }%
    \else
%    \end{macrocode}
% Try without sub-language code.
%    \begin{macrocode}
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \IfTrackedLanguageHasIsoCode
        {639-3}{\CurrentTrackedLanguage}
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIregion
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
        }%
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIregion}
%\changes{1.4}{2019-11-30}{new}
%No script but has a region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIregion#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipregion
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipregion
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIskipregion}
%\changes{1.4}{2019-11-30}{new}
%No script. Has a region but already tested with 639-3 and region.
%Just test language code alone.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
    \else
%    \end{macrocode}
% Try without sub-language code.
%    \begin{macrocode}
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIregion}
%\changes{1.4}{2019-11-30}{new}
%No script but has a region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIregion#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipregion
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipregion
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIskipscriptregion}
%\changes{1.4}{2019-11-30}{new}
%Already tested script and region. Test without script if the script
%is the default then without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIskipscriptregion#1#2#3{%
%    \end{macrocode}
% Is the script the default for this dialect?
%    \begin{macrocode}
  \@tracklang@ifcseqcsname\CurrentTrackedDialectScript
     {@tracklang@knowniso@script@\CurrentTrackedLanguage}%
  {%
%    \end{macrocode}
% Try just language code and region.
%    \begin{macrocode}
    \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \ifx\CurrentTrackedDialectSubLang\empty
    \else
      \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
    \fi
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedRegion}%
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
      \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try just language code and script.
%    \begin{macrocode}
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIscriptskipregion
      \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedRegion}%
        \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
        \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
        {%
          \let\@tracklang@if@file@exists\@tracklang@firstoftwo
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIscriptskipregion
        }%
      \fi
    }%
  }%
  {%
%    \end{macrocode}
% Script isn't the default.
%    \begin{macrocode}
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIscriptskipregion
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIscriptskipregion}
%\changes{1.4}{2019-11-30}{new}
%Test with script and without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIscriptskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try just language code.
%    \begin{macrocode}
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipscriptskipregion
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIskipscriptskipregion
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIskipscriptskipregion}
%\changes{1.4}{2019-11-30}{new}
%Test without script and without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIskipscriptskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try other language codes with script and region.
%    \begin{macrocode}
      \IfTrackedLanguageHasIsoCode
      {639-2}{\CurrentTrackedLanguage}
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscriptregion
      }%
      {%
         \IfTrackedLanguageHasIsoCode
         {639-3}{\CurrentTrackedLanguage}
         {%
           \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
           \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptregion
         }%
         {%
%    \end{macrocode}
% No other language codes. Try just the region.
%    \begin{macrocode}
           \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@region
         }%
      }%
    \else
%    \end{macrocode}
% Try just language code.
%    \begin{macrocode}
    \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
%    \end{macrocode}
% Try other language codes with script and region.
%    \begin{macrocode}
      \IfTrackedLanguageHasIsoCode
      {639-2}{\CurrentTrackedLanguage}
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscriptregion
      }%
      {%
         \IfTrackedLanguageHasIsoCode
         {639-3}{\CurrentTrackedLanguage}
         {%
           \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
           \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptregion
         }%
         {%
%    \end{macrocode}
% No other language codes. Try just the region.
%    \begin{macrocode}
           \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@region
         }%
      }%
    }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIskipscriptregion}
%\changes{1.4}{2019-11-30}{new}
%Already tested script and region. Test without script if the script
%is the default then without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIskipscriptregion#1#2#3{%
%    \end{macrocode}
% Is the script the default for this dialect?
%    \begin{macrocode}
  \@tracklang@ifcseqcsname\CurrentTrackedDialectScript
     {@tracklang@knowniso@script@\CurrentTrackedLanguage}%
  {%
%    \end{macrocode}
% Try just language code and region.
%    \begin{macrocode}
    \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \ifx\CurrentTrackedDialectSubLang\empty
    \else
      \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
    \fi
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedRegion}%
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
      \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try just language code and script.
%    \begin{macrocode}
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscriptskipregion
      \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedRegion}%
        \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
        \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
        {%
          \let\@tracklang@if@file@exists\@tracklang@firstoftwo
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscriptskipregion
        }%
      \fi
    }%
  }%
  {%
%    \end{macrocode}
% Script isn't the default.
%    \begin{macrocode}
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIscriptskipregion
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIscriptskipregion}
%\changes{1.4}{2019-11-30}{new}
%Test with script and without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIscriptskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try just language code.
%    \begin{macrocode}
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscriptskipregion
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIskipscriptskipregion
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIskipscriptskipregion}
%\changes{1.4}{2019-11-30}{new}
%Test without script and without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIskipscriptskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try other language code with script and region.
%    \begin{macrocode}
      \IfTrackedLanguageHasIsoCode
      {639-3}{\CurrentTrackedLanguage}
      {%
        \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptregion
      }%
      {%
%    \end{macrocode}
% No other language codes. Try just the region.
%    \begin{macrocode}
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@region
      }%
    \else
%    \end{macrocode}
% Try just language code.
%    \begin{macrocode}
    \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
%    \end{macrocode}
% Try other language codes with script and region.
%    \begin{macrocode}
       \IfTrackedLanguageHasIsoCode
       {639-3}{\CurrentTrackedLanguage}
       {%
         \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
         \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptregion
       }%
       {%
%    \end{macrocode}
% No other language codes. Try just the region.
%    \begin{macrocode}
         \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@region
       }%
    }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIskipscriptregion}
%\changes{1.4}{2019-11-30}{new}
%Already tested script and region. Test without script if the script
%is the default then without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIskipscriptregion#1#2#3{%
%    \end{macrocode}
% Is the script the default for this dialect?
%    \begin{macrocode}
  \@tracklang@ifcseqcsname\CurrentTrackedDialectScript
     {@tracklang@knowniso@script@\CurrentTrackedLanguage}%
  {%
%    \end{macrocode}
% Try just language code and region.
%    \begin{macrocode}
    \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \ifx\CurrentTrackedDialectSubLang\empty
    \else
      \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
    \fi
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedRegion}%
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
      \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try just language code and script.
%    \begin{macrocode}
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptskipregion
      \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedRegion}%
        \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
        \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
        {%
          \let\@tracklang@if@file@exists\@tracklang@firstoftwo
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptskipregion
        }%
      \fi
    }%
  }%
  {%
%    \end{macrocode}
% Script isn't the default.
%    \begin{macrocode}
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIscriptskipregion
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIscriptskipregion}
%\changes{1.4}{2019-11-30}{new}
%Test with script and without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIscriptskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectScript}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% Try just language code.
%    \begin{macrocode}
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscriptskipregion
    \else
%    \end{macrocode}
% Try without sub-language.
%    \begin{macrocode}
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectScript}%
      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
      {%
        \let\@tracklang@if@file@exists\@tracklang@firstoftwo
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
      }%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIskipscriptskipregion
      }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIskipscriptskipregion}
%\changes{1.4}{2019-11-30}{new}
%Test without script and without region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIskipscriptskipregion#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \ifx\CurrentTrackedDialectSubLang\empty
%    \end{macrocode}
% No other language codes. Try just the region.
%    \begin{macrocode}
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@region
    \else
%    \end{macrocode}
% Try just language code.
%    \begin{macrocode}
    \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
%    \end{macrocode}
% No other language codes. Try just the region.
%    \begin{macrocode}
       \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@region
    }%
    \fi
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langII}
%\changes{1.4}{2019-11-30}{new}
%No region or script.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langII#1#2#3{%
  \IfTrackedLanguageHasIsoCode{639-2}{\CurrentTrackedLanguage}%
  {%
    \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeII
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \else
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectSubLang}%
    \fi
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
      \ifx\CurrentTrackedDialectSubLang\empty
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIII
      \else
        \let\CurrentTrackedTag\CurrentTrackedIsoCode
        \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
        \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
        {%
          \let\@tracklang@if@file@exists\@tracklang@firstoftwo
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIII
        }%
      \fi
    }%
    {%
      \fi
    }%
  }%
  {%
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIII
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIII}
%\changes{1.4}{2019-11-30}{new}
%No region or script.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIII#1#2#3{%
  \IfTrackedLanguageHasIsoCode{639-3}{\CurrentTrackedLanguage}%
  {%
    \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
    \ifx\CurrentTrackedDialectSubLang\empty
      \let\CurrentTrackedTag\CurrentTrackedIsoCode
    \else
      \edef\CurrentTrackedTag{\CurrentTrackedIsoCode-\CurrentTrackedDialectSubLang}%
    \fi
    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
    {%
      \let\@tracklang@if@file@exists\@tracklang@firstoftwo
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
    }%
    {%
      \ifx\CurrentTrackedDialectSubLang\empty
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
      \else
        \let\CurrentTrackedTag\CurrentTrackedIsoCode
        \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
        \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
        {%
          \let\@tracklang@if@file@exists\@tracklang@firstoftwo
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
        }%
      \fi
    }%
  }%
  {%
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@region}
%\changes{1.4}{2019-11-30}{new}
%Test just the region.
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@region#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedRegion
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langvariant
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langvariant}
%\changes{1.4}{2019-11-30}{new}
%Test language code and variant
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langvariant#1#2#3{%
  \ifx\CurrentTrackedDialectVariant\empty
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@rootlang
  \else
    \IfTrackedLanguageHasIsoCode{639-1}{\CurrentTrackedLanguage}%
    {%
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIvariant
    }%
    {%
      \IfTrackedLanguageHasIsoCode{639-2}{\CurrentTrackedLanguage}%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIvariant
      }%
      {%
        \IfTrackedLanguageHasIsoCode{639-3}{\CurrentTrackedLanguage}%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIvariant
        }%
        {%
          \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@rootlang
        }%
      }%
    }%
  \fi
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIvariant}
%\changes{1.4}{2019-11-30}{new}
%Test 639-1 code and variant
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIvariant#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeI
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectVariant}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \IfTrackedLanguageHasIsoCode{639-2}{\CurrentTrackedLanguage}%
    {%
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIvariant
    }
    {%
      \IfTrackedLanguageHasIsoCode{639-3}{\CurrentTrackedLanguage}%
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIvariant
      }
      {%
        \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@rootlang
      }%
    }%
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIvariant}
%\changes{1.4}{2019-11-30}{new}
%Test 639-2 code and variant
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIvariant#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectVariant}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \IfTrackedLanguageHasIsoCode{639-3}{\CurrentTrackedLanguage}%
    {%
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@langIIIvariant
    }
    {%
      \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@rootlang
    }%
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@langIIIvariant}
%\changes{1.4}{2019-11-30}{new}
%Test 639-3 code and variant
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@langIIIvariant#1#2#3{%
  \let\CurrentTrackedIsoCode\CurrentTrackedIsoCodeIII
  \let\CurrentTrackedTag\CurrentTrackedIsoCode
  \ifx\CurrentTrackedDialectSubLang\empty
  \else
    \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectSubLang}%
  \fi
  \edef\CurrentTrackedTag{\CurrentTrackedTag-\CurrentTrackedDialectVariant}%
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@noop
  }%
  {%
    \let\@tracklang@test@if@file@exists@next\@tracklang@test@if@file@exists@for@rootlang
  }%
  \@tracklang@test@if@file@exists@next{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@test@if@file@exists@for@rootlang}
%\changes{1.4}{2019-11-30}{new}
%Test the root language label. (Final test.)
%    \begin{macrocode}
\def\@tracklang@test@if@file@exists@for@rootlang#1#2#3{%
  \let\CurrentTrackedTag\CurrentTrackedLanguage
  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
  {%
    \let\@tracklang@if@file@exists\@tracklang@firstoftwo
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfTrackedLanguageFileExists@orig}
%\changes{1.4}{2019-11-30}{new}
%The new definition of \cs{IfTrackedLanguageFileExists} has a
%different order of priority. If the original behaviour is
%specifically required, this has the pre version 1.4 definition.
%    \begin{macrocode}
\long\def\IfTrackedLanguageFileExists@orig#1#2#3#4#5{%
   \def\CurrentTrackedTag{}%
   \SetCurrentTrackedDialect{#1}%
   \IfTrackedDialect{#1}%
   {%
     \edef\CurrentTrackedTag{#1}%
     \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
     {#4}%
     {%
       \IfTrackedLanguageHasIsoCode
         {639-1}{\CurrentTrackedLanguage}
       {%
          \edef\CurrentTrackedIsoCode{%
             \TrackedIsoCodeFromLanguage
               {639-1}{\CurrentTrackedLanguage}}%
          \ifx\CurrentTrackedRegion\empty
            \let\CurrentTrackedTag\CurrentTrackedIsoCode
            \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
            {#4}
            {%
              \IfTrackedLanguageHasIsoCode
                {639-2}{\CurrentTrackedLanguage}
              {%
                 \edef\CurrentTrackedIsoCode{%
                    \TrackedIsoCodeFromLanguage
                      {639-2}{\CurrentTrackedLanguage}}%
                 \let\CurrentTrackedTag\CurrentTrackedIsoCode
                 \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                 {#4}%
                 {%
                   \let\CurrentTrackedTag\CurrentTrackedLanguage
                   \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
                 }%
              }%
              {%
               \let\CurrentTrackedTag\CurrentTrackedLanguage
               \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
              }%
            }%
          \else
            \edef\CurrentTrackedTag{%
              \CurrentTrackedIsoCode-\CurrentTrackedRegion}%
            \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
            {#4}
            {%
              \IfTrackedLanguageHasIsoCode
              {639-2}{\CurrentTrackedLanguage}
              {%
                \let\org@currenttrackedisocode\CurrentTrackedIsoCode
                \edef\CurrentTrackedIsoCode{%
                  \TrackedIsoCodeFromLanguage
                  {639-2}{\CurrentTrackedLanguage}}%
                \edef\CurrentTrackedTag{%
                  \CurrentTrackedIsoCode-\CurrentTrackedRegion}%
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                {#4}%
                {%
                  \let\CurrentTrackedTag\org@currenttrackedisocode
                  \let\org@currenttrackedisocode\CurrentTrackedIsoCode
                  \let\CurrentTrackedIsoCode\CurrentTrackedTag
                  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                  {#4}
                  {%
                    \let\CurrentTrackedIsoCode\org@currenttrackedisocode
                    \let\CurrentTrackedTag\CurrentTrackedIsoCode
                    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                    {#4}%
                    {%
                      \let\CurrentTrackedTag\CurrentTrackedRegion
                      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                      {#4}%
                      {%
                        \let\CurrentTrackedTag\CurrentTrackedLanguage
                        \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
                      }%
                    }%
                  }%
                }%
              }%
              {%
                \let\CurrentTrackedTag\CurrentTrackedIsoCode
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                {#4}%
                {%
                  \let\CurrentTrackedTag\CurrentTrackedRegion
                  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                  {#4}%
                  {%
                    \let\CurrentTrackedTag\CurrentTrackedLanguage
                    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
                  }%
                }%
              }%
            }%
          \fi
       }%
       {%
         \IfTrackedLanguageHasIsoCode
           {639-2}{\CurrentTrackedLanguage}
         {%
            \edef\CurrentTrackedIsoCode{%
               \TrackedIsoCodeFromLanguage
               {639-2}{\CurrentTrackedLanguage}}%
         }%
         {%
           \IfTrackedLanguageHasIsoCode
             {639-3}{\CurrentTrackedLanguage}
           {%
              \edef\CurrentTrackedIsoCode{%
                 \TrackedIsoCodeFromLanguage
                 {639-3}{\CurrentTrackedLanguage}}%
           }%
           {%
              \let\CurrentTrackedIsoCode\empty
           }%
         }%
         \ifx\CurrentTrackedIsoCode\empty
           \ifx\CurrentTrackedRegion\empty
             \let\CurrentTrackedTag\CurrentTrackedLanguage
             \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
           \else
             \let\CurrentTrackedTag\CurrentTrackedRegion
             \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
             {#4}%
             {%
               \let\CurrentTrackedTag\CurrentTrackedLanguage
               \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
             }%
           \fi
         \else
            \ifx\CurrentTrackedRegion\empty
              \let\CurrentTrackedTag\CurrentTrackedIsoCode
              \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
              {#4}%
              {%
                \let\CurrentTrackedTag\CurrentTrackedLanguage
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
              }%
            \else
              \edef\CurrentTrackedTag{%
                \CurrentTrackedIsoCode-\CurrentTrackedRegion}%
              \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
              {#4}%
              {%
                \let\CurrentTrackedTag\CurrentTrackedIsoCode
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                {#4}%
                {%
                  \let\CurrentTrackedTag\CurrentTrackedRegion
                  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                  {#4}%
                  {%
                    \let\CurrentTrackedTag\CurrentTrackedLanguage
                    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
                  }%
                }%
              }%
            \fi
         \fi
       }%
     }%
   }%
   {#5}% unknown dialect
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Resources}
%Provide some commands to make it easier for package authors to
%integrate the package code with \styfmt{tracklang}. In the
%command definition describes below, \meta{pkgname} indicates the
%initial part of the resource files that follow the naming
%convention, \meta{pkgname}\texttt{-}\meta{tag}\texttt{.ldf}.
%Typically this will match the base name of the package that uses
%those resource files, but this isn't compulsory.
% The argument \meta{tag} is the current tracked tag obtained from
% \cs{IfTrackedLanguageFileExists}.
%
%\begin{macro}{\TrackLangProvidesResource}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangProvidesResource}\marg{tag}\oarg{version}
%\end{definition}
%If \cs{ProvidesFile} exists, we can use that, otherwise we need to
%provide a generic version.
%    \begin{macrocode}
\ifx\ProvidesFile\undefined
%    \end{macrocode}
%Generic code uses simplistic method to grab the version
%details in the final optional argument. Since we're not using
%\LaTeX\ we don't have commands like \cs{@ifnextchar} available.
%    \begin{macrocode}
  \long\def\TrackLangProvidesResource#1#2{%
    \ifx\TrackLangRequireDialectPrefix\undefined
      \@tracklang@err{Resources files using 
        \string\TrackLangProvidesResource\space
        must be loaded with \string\TrackLangRequireDialect}%
    \fi
    \ifx#2[\relax
      \def\@tracklang@next{%
        \@tracklang@providesresource{\TrackLangRequireDialectPrefix-#1.ldf}#2%
      }
    \else
      \expandafter\xdef\csname ver@\TrackLangRequireDialectPrefix
        -#1.ldf\endcsname{}%
      {%
        \newlinechar=`\^^J
        \def\MessageBreak{^^J}%
        \message{^^JFile: \TrackLangRequireDialectPrefix-#1.ldf^^J}%
      }%
      \long\def\@tracklang@next{#2}%
    \fi
    \@tracklang@next
  }
  \def\@tracklang@providesresource#1[#2]{%
    \expandafter\xdef\csname ver@#1\endcsname{#2}%
     {%
       \newlinechar=`\^^J
       \def\MessageBreak{^^J}%
       \message{^^JFile: #1 #2^^J}%
     }%
  }
\else
%    \end{macrocode}
%\LaTeX\ code can simply use \cs{ProvidesFile}.
%    \begin{macrocode}
  \def\TrackLangProvidesResource#1{%
    \ifx\TrackLangRequireDialectPrefix\undefined
      \@tracklang@err{Resources files using 
        \string\TrackLangProvidesResource\space
        must be loaded with \string\TrackLangRequireDialect}%
    \fi
    \ProvidesFile{\TrackLangRequireDialectPrefix-#1.ldf}%
  }
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangAddToHook}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangAddToHook}\marg{code}\marg{type}
%\end{definition}
%Within the resource files, a check is required for the language
%hook, where the hook type is given by \meta{type}.
% For example, if \meta{type} is \texttt{captions}, the for \sty{babel},
%this is \cs{captions\meta{dialect}} (dialect
%obtained through \cs{CurrentTrackedDialect}) and
%for \sty{polyglossia}, this is \cs{captions\meta{language}}
%(language obtained through \cs{CurrentTrackedLanguage}).
%This command is not permitted outside resource files.
%    \begin{macrocode}
\def\TrackLangAddToHook{\noop@TrackLangAddToHook}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\noop@TrackLangAddToHook}
%    \begin{macrocode}
\def\noop@TrackLangAddToHook#1#2{%
  \@tracklang@err{\string\TrackLangAddToHook\space
  only permitted within resource files}
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@TrackLangAddToHook}
%    \begin{macrocode}
\def\@TrackLangAddToHook#1#2{%
%    \end{macrocode}
% \sty{babel} check first.
%    \begin{macrocode}
  \@tracklang@ifundef{#2\CurrentTrackedDialect}%
  {%
%    \end{macrocode}
% Does the dialect label have a mapping?
%    \begin{macrocode}
    \IfTrackedDialectHasMapping{\CurrentTrackedDialect}%
    {%
%    \end{macrocode}
% Try the mapping label next.
%    \begin{macrocode}
      \edef\@tracklang@tmp{%
        \csname @tracklang@dialectmap@tohook@\CurrentTrackedDialect\endcsname}%
      \@tracklang@ifundef{#2\@tracklang@tmp}%
      {%
%    \end{macrocode}
% No captions hook. Try \sty{polyglossia}.
%    \begin{macrocode}
        \@tracklang@ifundef{#2\CurrentTrackedLanguage}%
        {%
%    \end{macrocode}
% No captions hook. Do the code now.
%    \begin{macrocode}
          #1%
        }%
        {%
          \@tracklang@addtohook{#2}{\CurrentTrackedLanguage}{#1}%
        }%
      }%
      {%
        \@tracklang@addtohook{#2}{\@tracklang@tmp}{#1}%
      }%
    }%
    {%
%    \end{macrocode}
% \sty{polyglossia} check next.
%    \begin{macrocode}
      \@tracklang@ifundef{#2\CurrentTrackedLanguage}%
      {%
%    \end{macrocode}
% No captions hook.
%    \begin{macrocode}
      }%
      {%
        \@tracklang@addtohook{#2}{\CurrentTrackedLanguage}{#1}%
      }%
    }%
  }%
  {%
     \@tracklang@addtohook{#2}{\CurrentTrackedDialect}{#1}%
  }%
%    \end{macrocode}
% Do the code now. (This is needed for cases such as the \sty{ngerman}
% which defines \cs{captionsngerman} but calls it immediately rather
% than at the start of the document.)
%    \begin{macrocode}
  #1%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@addtohook}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{@tracklang@addtohook}\marg{type}\marg{label}\marg{code}
%\end{definition}
%    \begin{macrocode}
\def\@tracklang@addtohook#1#2#3{%
 \expandafter\let\expandafter\@tracklang@hook\csname #1#2\endcsname
 \expandafter
  \gdef\csname#1#2\expandafter\endcsname\expandafter{\@tracklang@hook#3}%
}
%    \end{macrocode}
%\end{macro}
%
%Since the captions hook is the most common, provide a shortcut.
%\begin{macro}{\TrackLangAddToCaptions}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangAddToCaptions}\marg{code}
%\end{definition}
%    \begin{macrocode}
\def\TrackLangAddToCaptions#1{\TrackLangAddToHook{#1}{captions}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangRedefHook}
%\changes{1.4}{2019-11-30}{new}
%\begin{definition}
%\cs{TrackLangRedefHook}\marg{code}\marg{type}
%\end{definition}
% Similar to \cs{TrackLangAddToHook} but redefines the hook rather
% than appending to it.
% This command is not permitted outside resource files.
%    \begin{macrocode}
\def\TrackLangRedefHook{\noop@TrackLangRedefHook}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\noop@TrackLangRedefHook}
%    \begin{macrocode}
\def\noop@TrackLangRedefHook#1#2{%
  \@tracklang@err{\string\TrackLangRedefHook\space
  only permitted within resource files}
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@TrackLangRedefHook}
%    \begin{macrocode}
\def\@TrackLangRedefHook#1#2{%
%    \end{macrocode}
% \sty{babel} check first.
%    \begin{macrocode}
  \@tracklang@ifundef{#2\CurrentTrackedDialect}%
  {%
%    \end{macrocode}
% Does the dialect label have a mapping?
%    \begin{macrocode}
    \IfTrackedDialectHasMapping{\CurrentTrackedDialect}%
    {%
%    \end{macrocode}
% Try the mapping label next.
%    \begin{macrocode}
      \edef\@tracklang@tmp{%
        \csname @tracklang@dialectmap@tohook@\CurrentTrackedDialect\endcsname}%
      \@tracklang@ifundef{#2\@tracklang@tmp}%
      {%
%    \end{macrocode}
% No captions hook. Try \sty{polyglossia}.
%    \begin{macrocode}
        \@tracklang@ifundef{#2\CurrentTrackedLanguage}%
        {%
%    \end{macrocode}
% No captions hook. Do the code now.
%    \begin{macrocode}
          #1%
        }%
        {%
          \@tracklang@redefhook{#2}{\CurrentTrackedLanguage}{#1}%
        }%
      }%
      {%
        \@tracklang@redefhook{#2}{\@tracklang@tmp}{#1}%
      }%
    }%
    {%
%    \end{macrocode}
% \sty{polyglossia} check next.
%    \begin{macrocode}
      \@tracklang@ifundef{#2\CurrentTrackedLanguage}%
      {%
%    \end{macrocode}
% No captions hook.
%    \begin{macrocode}
      }%
      {%
        \@tracklang@redefhook{#2}{\CurrentTrackedLanguage}{#1}%
      }%
    }%
  }%
  {%
     \@tracklang@redefhook{#2}{\CurrentTrackedDialect}{#1}%
  }%
%    \end{macrocode}
% Do the code now in case the hook has already been used.
%    \begin{macrocode}
  #1%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@tracklang@redefhook}
%\changes{1.4}{2019-11-30}{new}
%\begin{definition}
%\cs{@tracklang@redefhook}\marg{type}\marg{label}\marg{code}
%\end{definition}
%    \begin{macrocode}
\def\@tracklang@redefhook#1#2#3{%
 \expandafter\gdef\csname#1#2\endcsname{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetTrackedDialectLabelMap}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{SetTrackedDialectLabelMap}\marg{tracklang-label}\marg{hook-label}
%\end{definition}
%Define a mapping between a \styfmt{tracklang} dialect label and the
%corresponding label used by the language hook. For example,
%\texttt{ngermanDE} is a recognised \styfmt{tracklang} dialect
%label, but the closest \sty{babel} equivalent is \texttt{ngerman},
%so \texttt{ngermanDE} would need to be mapped to \texttt{ngerman}
%for the language hooks. The arguments are \meta{tracklang-label} (the
%\styfmt{tracklang} dialect label) and \meta{hook-label} (the \sty{babel},
%\sty{polyglossia} etc label).
%    \begin{macrocode}
\def\SetTrackedDialectLabelMap#1#2{%
%    \end{macrocode}
% Store the mapping that can obtain the hook label from the
% tracklang label (tracklang to hook).
%    \begin{macrocode}
  \@tracklang@enamedef{@tracklang@dialectmap@tohook@#1}{#2}%
%    \end{macrocode}
% Store the mapping that can obtain the tracklang label from the
% hook label.
%    \begin{macrocode}
  \@tracklang@enamedef{@tracklang@dialectmap@fromhook@#2}{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfTrackedDialectHasMapping}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{IfTrackedDialectHasMapping}\marg{tracklang label}\marg{true}\marg{false}
%\end{definition}
%Test if the \styfmt{tracklang} dialect label has been assigned a
%mapping to a language hook.
%    \begin{macrocode}
\def\IfTrackedDialectHasMapping#1#2#3{%
  \@tracklang@ifundef{@tracklang@dialectmap@tohook@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\IfHookHasMappingFromTrackedDialect}
%\changes{1.3.3}{2016-11-03}{new}
%\begin{definition}
%\cs{IfHookHasMappingFromTrackedDialect}\marg{hook label}\marg{true}\marg{false}
%\end{definition}
%Tests if the language hook label has been assigned a mapping from a
%\styfmt{tracklang} dialect label.
%    \begin{macrocode}
\def\IfHookHasMappingFromTrackedDialect#1#2#3{%
  \@tracklang@ifundef{@tracklang@dialectmap@fromhook@#1}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectToMapping}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectToMapping}\marg{tracklang label}
%\end{definition}
%Gets the mapping for the given \styfmt{tracklang} dialect label to a
%language hook label or the \meta{label} itself if no mapping has been defined.
%    \begin{macrocode}
\def\GetTrackedDialectToMapping#1{%
  \@tracklang@ifundef{@tracklang@dialectmap@tohook@#1}{#1}%
  {\csname @tracklang@dialectmap@tohook@#1\endcsname}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GetTrackedDialectFromMapping}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{GetTrackedDialectFromMapping}\marg{language hook}
%\end{definition}
%Gets the reverse mapping from the given language hook to the
%\styfmt{tracklang} label.
%    \begin{macrocode}
\def\GetTrackedDialectFromMapping#1{%
  \@tracklang@ifundef{@tracklang@dialectmap@fromhook@#1}{#1}%
  {\csname @tracklang@dialectmap@fromhook@#1\endcsname}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangRequireResource}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangRequireResource}\marg{tag}
%\end{definition}
%    \begin{macrocode}
\def\TrackLangRequireResource{\noop@TrackLangRequireResource}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\noop@TrackLangRequireResource}
%\changes{1.3}{2016-10-07}{new}
%Default behaviour outside of resources files: generate an
%error and ignore arguments.
%    \begin{macrocode}
\def\noop@TrackLangRequireResource#1{%
  \@tracklang@err{\string\TrackLangRequireResource\space
  only permitted within resource files}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@TrackLangRequireResource}
%\changes{1.3}{2016-10-07}{new}
%Actual behaviour.
%    \begin{macrocode}
\def\@TrackLangRequireResource#1{%
  \@tracklang@ifundef{ver@\TrackLangRequireDialectPrefix-#1.ldf}%
  {%
    \@tracklang@IfFileExists{\TrackLangRequireDialectPrefix-#1.ldf}%
    {%
      \input \TrackLangRequireDialectPrefix-#1.ldf
    }%
    {%
      \@tracklang@warn{No `\TrackLangRequireDialectPrefix' support for 
      language/region `#1'\MessageBreak
      (resource file `\TrackLangRequireDialectPrefix-#1.ldf' not found)}%
    }%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangRequireResourceOrDo}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangRequireResourceOrDo}\marg{tag}\marg{resource
%loaded code}\marg{resource already loaded code}
%\end{definition}
%Like \cs{TrackLangRequireResource} but also does \meta{resource
%loaded code} if the resource file is loaded or \meta{resource
%already loaded code} if the resource file has already been loaded.
%    \begin{macrocode}
\def\TrackLangRequireResourceOrDo{%
  \noop@TrackLangRequireResourceOrDo
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\noop@TrackLangRequireResourceOrDo}
%\changes{1.3}{2016-10-07}{new}
%Default behaviour outside of resources files: generate an
%error and ignore arguments.
%    \begin{macrocode}
\def\noop@TrackLangRequireResourceOrDo#1#2#3{%
  \@tracklang@err{\string\TrackLangRequireResourceOrDo\space
  only permitted within resource files}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@TrackLangRequireResourceOrDo}
%\changes{1.3}{2016-10-07}{new}
%Actual behaviour.
%    \begin{macrocode}
\def\@TrackLangRequireResourceOrDo#1#2#3{%
  \@tracklang@ifundef{ver@\TrackLangRequireDialectPrefix-#1.ldf}%
  {%
    \@tracklang@IfFileExists{\TrackLangRequireDialectPrefix-#1.ldf}%
    {%
      \input \TrackLangRequireDialectPrefix-#1.ldf
      #2%
    }%
    {%
      \@tracklang@warn{No `\TrackLangRequireDialectPrefix' support for 
      language/region `#1'\MessageBreak
      (resource file `\TrackLangRequireDialectPrefix-#1.ldf' not found)}%
    }%
  }%
  {#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangRequestResource}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangRequestResource}\marg{tag}\marg{not found code}
%\end{definition}
%Like \cs{TrackLangRequireResource} but does \meta{not found code}
%if the file doesn't exist.
%    \begin{macrocode}
\def\TrackLangRequestResource{\noop@TrackLangRequestResource}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\noop@TrackLangRequestResource}
%\changes{1.3}{2016-10-07}{new}
%Default behaviour outside of resources files: generate an
%error and ignore arguments.
%    \begin{macrocode}
\def\noop@TrackLangRequestResource#1#2{%
  \@tracklang@err{\string\TrackLangRequestResource\space
  only permitted within resource files}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@TrackLangRequestResource}
%\changes{1.3}{2016-10-07}{new}
%Actual behaviour.
%    \begin{macrocode}
\def\@TrackLangRequestResource#1#2{%
  \@tracklang@ifundef{ver@\TrackLangRequireDialectPrefix-#1.ldf}%
  {%
    \@tracklang@IfFileExists{\TrackLangRequireDialectPrefix-#1.ldf}%
    {%
      \input \TrackLangRequireDialectPrefix-#1.ldf
    }%
    {#2}%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangRequireDialect}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangRequireDialect}\oarg{load code}\marg{pkgname}\marg{dialect}
%\end{definition}
%    \begin{macrocode}
\def\TrackLangRequireDialect{\@TrackLangRequireDialect}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\noop@TrackLangRequireDialect}
%\changes{1.3}{2016-10-07}{new}
%No-op code.
%    \begin{macrocode}
\def\noop@TrackLangRequireDialect#1{%
  \ifx[#1\relax
    \def\@tracklang@next{\@noop@TrackLangRequireDialect[}%
  \else
    \def\@tracklang@next{\@noop@TrackLangRequireDialect[]{#1}}%
  \fi
  \@tracklang@next
}
\def\@noop@TrackLangRequireDialect[#1]#2#3{%
  \@tracklang@err{\string\TrackLangRequireDialect\space
  only permitted within resource files}
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@TrackLangRequireDialect}
%\changes{1.3}{2016-10-07}{new}
%Actual code.
%    \begin{macrocode}
\def\@TrackLangRequireDialect#1{%
  \ifx[#1\relax
    \def\@tracklang@next{\@@TrackLangRequireDialect[}%
  \else
    \def\@tracklang@next{%
      \@@TrackLangRequireDialect
        [\TrackLangRequireResource{\CurrentTrackedTag}]{#1}}%
  \fi
  \@tracklang@next
}
\def\@@TrackLangRequireDialect[#1]#2#3{%
   \def\TrackLangRequireDialectPrefix{#2}%
   \IfTrackedLanguageFileExists{#3}%
   {#2-}% prefix
   {.ldf}% suffix
   {%
%    \end{macrocode}
%Enable \cs{TrackLangRequireResource} etc so that they can only be used in
%resource files.
%    \begin{macrocode}
     \let\TrackLangRequireResource\@TrackLangRequireResource
     \let\TrackLangRequireResourceOrDo\@TrackLangRequireResourceOrDo
     \let\TrackLangRequestResource\@TrackLangRequestResource
%    \end{macrocode}
%Disable \cs{TrackLangRequireDialect} so that it can't be used in
%resource files.
%    \begin{macrocode}
     \let\TrackLangRequireDialect\noop@TrackLangRequireDialect
%    \end{macrocode}
%Enable \cs{TrackLangAddToHook}.
%    \begin{macrocode}
     \let\TrackLangAddToHook\@TrackLangAddToHook
%    \end{macrocode}
%Load resource file using the code provided in the first argument.
%    \begin{macrocode}
     #1%
%    \end{macrocode}
%Disable \cs{TrackLangRequireResource} etc.
%    \begin{macrocode}
     \let\TrackLangRequireResource\noop@TrackLangRequireResource
     \let\TrackLangRequireResourceOrDo\noop@TrackLangRequireResourceOrDo
     \let\TrackLangRequestResource\noop@TrackLangRequestResource
%    \end{macrocode}
%Enable \cs{TrackLangRequireDialect}.
%    \begin{macrocode}
     \let\TrackLangRequireDialect\@TrackLangRequireDialect
%    \end{macrocode}
%Disable \cs{TrackLangAddToHook}.
%    \begin{macrocode}
     \let\TrackLangAddToHook\noop@TrackLangAddToHook
   }%
   {%
     \@tracklang@warn{No `#2' support for dialect `#3'}%
   }%
}
%    \end{macrocode}
%\end{macro}
%
%Restore category code for \texttt{@} if necessary.
%    \begin{macrocode}
\@tracklang@restore@at
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</tracklang.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*tracklang-region-codes.tex>
%    \end{macrocode}
%\fi
%\section{Regions Generic Code (\texttt{tracklang-region-codes.tex})}
%This is only loaded if a mapping is required between 
%numeric and alphabetic region codes. (It would slow down the
%package loading to automatically load if not required.)
%Since this is loaded on the fly, we need to be careful about
%spurious spaces.
%\changes{1.3}{2016-10-07}{added tracklang-region-codes.tex}
%    \begin{macrocode}
\ifnum\catcode`\@=11\relax
  \def\@tracklang@regions@restore@at{}%
\else
  \expandafter\edef\csname @tracklang@regions@restore@at\endcsname{%
    \noexpand\catcode`\noexpand\@=\number\catcode`\@\relax
  }%
 \catcode`\@=11\relax
\fi
%    \end{macrocode}
% Check if this file has already been loaded:
%    \begin{macrocode}
\ifx\TrackLangRegionMap\undefined
\else
  \@tracklang@regions@restore@at
  \expandafter\endinput
\fi
%    \end{macrocode}
% Version info.
%    \begin{macrocode}
\expandafter\def\csname ver@tracklang-region-codes.tex\endcsname{%
 2019/11/30 v1.4 (NLCT) Track Languages Regions}%
%    \end{macrocode}
%
%\begin{macro}{\TrackLangRegionMap}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangRegionMap}\marg{numeric code}\marg{alpha-2
%code}\marg{alpha-3 code}
%\end{definition}
%Define mapping.
%    \begin{macrocode}
\def\TrackLangRegionMap#1#2#3{%
  \@tracklang@enamedef{@tracklang@region@numtoalphaii@#1}{#2}%
  \@tracklang@enamedef{@tracklang@region@numtoalphaiii@#1}{#3}%
  \@tracklang@enamedef{@tracklang@region@alphaiitonum@#2}{#1}%
  \@tracklang@enamedef{@tracklang@region@alphaiiitonum@#3}{#1}%
  \@tracklang@enamedef{@tracklang@region@alphaiitoalphaiii@#2}{#3}%
  \@tracklang@enamedef{@tracklang@region@alphaiiitoalphaii@#3}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangAlphaIIToNumericRegion}
%\begin{definition}
%\cs{TrackLangAlphaIIToNumericRegion}\marg{alpha-2 code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangAlphaIIToNumericRegion#1{%
  \@tracklang@nameuse{@tracklang@region@alphaiitonum@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangNumericToAlphaIIRegion}
%\begin{definition}
%\cs{TrackLangNumericToAlphaIIRegion}\marg{numeric code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangNumericToAlphaIIRegion#1{%
  \@tracklang@nameuse{@tracklang@region@numtoalphaii@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownAlphaIIRegion}
%\begin{definition}
%\cs{TrackLangIfKnownAlphaIIRegion}\marg{alpha-2
%code}\marg{true}\marg{false}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangIfKnownAlphaIIRegion#1#2#3{%
  \@tracklang@ifundef{@tracklang@region@alphaiitonum@#1}%
  {#3}%
  {#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownNumericRegion}
%\begin{definition}
%\cs{TrackLangIfKnownNumericRegion}\marg{numeric
%code}\marg{true}\marg{false}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangIfKnownNumericRegion#1#2#3{%
  \@tracklang@ifundef{@tracklang@region@numtoalphaii@#1}%
  {#3}%
  {#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangAlphaIIIToNumericRegion}
%\begin{definition}
%\cs{TrackLangAlphaIIIToNumericRegion}\marg{alpha-3 code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangAlphaIIIToNumericRegion#1{%
  \@tracklang@nameuse{@tracklang@region@alphaiiitonum@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangNumericToAlphaIIIRegion}
%\begin{definition}
%\cs{TrackLangNumericToAlphaIIIRegion}\marg{numeric code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangNumericToAlphaIIIRegion#1{%
  \@tracklang@nameuse{@tracklang@region@numtoalphaiii@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangIfKnownAlphaIIIRegion}
%\begin{definition}
%\cs{TrackLangIfKnownAlphaIIIRegion}\marg{alpha-3
%code}\marg{true}\marg{false}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangIfKnownAlphaIIIRegion#1#2#3{%
  \@tracklang@ifundef{@tracklang@region@alphaiiitonum@#1}%
  {#3}%
  {#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%Define mappings.
%    \begin{macrocode}
\TrackLangRegionMap{004}{AF}{AFG}%
\TrackLangRegionMap{248}{AX}{ALA}%
\TrackLangRegionMap{008}{AL}{ALB}%
\TrackLangRegionMap{012}{DZ}{DZA}%
\TrackLangRegionMap{016}{AS}{ASM}%
\TrackLangRegionMap{020}{AD}{AND}%
\TrackLangRegionMap{024}{AO}{AGO}%
\TrackLangRegionMap{660}{AI}{AIA}%
\TrackLangRegionMap{010}{AQ}{ATA}%
\TrackLangRegionMap{028}{AG}{ATG}%
\TrackLangRegionMap{032}{AR}{ARG}%
\TrackLangRegionMap{051}{AM}{ARM}%
\TrackLangRegionMap{533}{AW}{ABW}%
\TrackLangRegionMap{036}{AU}{AUS}%
\TrackLangRegionMap{040}{AT}{AUT}%
\TrackLangRegionMap{031}{AZ}{AZE}%
\TrackLangRegionMap{044}{BS}{BHS}%
\TrackLangRegionMap{048}{BH}{BHR}%
\TrackLangRegionMap{050}{BD}{BGD}%
\TrackLangRegionMap{052}{BB}{BRB}%
\TrackLangRegionMap{112}{BY}{BLR}%
\TrackLangRegionMap{056}{BE}{BEL}%
\TrackLangRegionMap{084}{BZ}{BLZ}%
\TrackLangRegionMap{204}{BJ}{BEN}%
\TrackLangRegionMap{060}{BM}{BMU}%
\TrackLangRegionMap{064}{BT}{BTN}%
\TrackLangRegionMap{068}{BO}{BOL}%
\TrackLangRegionMap{535}{BQ}{BES}%
\TrackLangRegionMap{070}{BA}{BIH}%
\TrackLangRegionMap{072}{BW}{BWA}%
\TrackLangRegionMap{074}{BV}{BVT}%
\TrackLangRegionMap{076}{BR}{BRA}%
\TrackLangRegionMap{086}{IO}{IOT}%
\TrackLangRegionMap{096}{BN}{BRN}%
\TrackLangRegionMap{100}{BG}{BGR}%
\TrackLangRegionMap{854}{BF}{BFA}%
\TrackLangRegionMap{108}{BI}{BDI}%
\TrackLangRegionMap{132}{CV}{CPV}%
\TrackLangRegionMap{116}{KH}{KHM}%
\TrackLangRegionMap{120}{CM}{CMR}%
\TrackLangRegionMap{124}{CA}{CAN}%
\TrackLangRegionMap{136}{KY}{CYM}%
\TrackLangRegionMap{140}{CF}{CAF}%
\TrackLangRegionMap{148}{TD}{TCD}%
\TrackLangRegionMap{152}{CL}{CHL}%
\TrackLangRegionMap{156}{CN}{CHN}%
\TrackLangRegionMap{162}{CX}{CXR}%
\TrackLangRegionMap{166}{CC}{CCK}%
\TrackLangRegionMap{170}{CO}{COL}%
\TrackLangRegionMap{174}{KM}{COM}%
\TrackLangRegionMap{180}{CD}{COD}%
\TrackLangRegionMap{178}{CG}{COG}%
\TrackLangRegionMap{184}{CK}{COK}%
\TrackLangRegionMap{188}{CR}{CRI}%
\TrackLangRegionMap{384}{CI}{CIV}%
\TrackLangRegionMap{191}{HR}{HRV}%
\TrackLangRegionMap{192}{CU}{CUB}%
\TrackLangRegionMap{531}{CW}{CUW}%
\TrackLangRegionMap{196}{CY}{CYP}%
\TrackLangRegionMap{203}{CZ}{CZE}%
\TrackLangRegionMap{208}{DK}{DNK}%
\TrackLangRegionMap{262}{DJ}{DJI}%
\TrackLangRegionMap{212}{DM}{DMA}%
\TrackLangRegionMap{214}{DO}{DOM}%
\TrackLangRegionMap{218}{EC}{ECU}%
\TrackLangRegionMap{818}{EG}{EGY}%
\TrackLangRegionMap{222}{SV}{SLV}%
\TrackLangRegionMap{226}{GQ}{GNQ}%
\TrackLangRegionMap{232}{ER}{ERI}%
\TrackLangRegionMap{233}{EE}{EST}%
\TrackLangRegionMap{231}{ET}{ETH}%
\TrackLangRegionMap{238}{FK}{FLK}%
\TrackLangRegionMap{234}{FO}{FRO}%
\TrackLangRegionMap{242}{FJ}{FJI}%
\TrackLangRegionMap{246}{FI}{FIN}%
\TrackLangRegionMap{250}{FR}{FRA}%
\TrackLangRegionMap{254}{GF}{GUF}%
\TrackLangRegionMap{258}{PF}{PYF}%
\TrackLangRegionMap{260}{TF}{ATF}%
\TrackLangRegionMap{266}{GA}{GAB}%
\TrackLangRegionMap{270}{GM}{GMB}%
\TrackLangRegionMap{268}{GE}{GEO}%
\TrackLangRegionMap{276}{DE}{DEU}%
\TrackLangRegionMap{288}{GH}{GHA}%
\TrackLangRegionMap{292}{GI}{GIB}%
\TrackLangRegionMap{300}{GR}{GRC}%
\TrackLangRegionMap{304}{GL}{GRL}%
\TrackLangRegionMap{308}{GD}{GRD}%
\TrackLangRegionMap{312}{GP}{GLP}%
\TrackLangRegionMap{316}{GU}{GUM}%
\TrackLangRegionMap{320}{GT}{GTM}%
\TrackLangRegionMap{831}{GG}{GGY}%
\TrackLangRegionMap{324}{GN}{GIN}%
\TrackLangRegionMap{624}{GW}{GNB}%
\TrackLangRegionMap{328}{GY}{GUY}%
\TrackLangRegionMap{332}{HT}{HTI}%
\TrackLangRegionMap{334}{HM}{HMD}%
\TrackLangRegionMap{336}{VA}{VAT}%
\TrackLangRegionMap{340}{HN}{HND}%
\TrackLangRegionMap{344}{HK}{HKG}%
\TrackLangRegionMap{348}{HU}{HUN}%
\TrackLangRegionMap{352}{IS}{ISL}%
\TrackLangRegionMap{356}{IN}{IND}%
\TrackLangRegionMap{360}{ID}{IDN}%
\TrackLangRegionMap{364}{IR}{IRN}%
\TrackLangRegionMap{368}{IQ}{IRQ}%
\TrackLangRegionMap{372}{IE}{IRL}%
\TrackLangRegionMap{833}{IM}{IMN}%
\TrackLangRegionMap{376}{IL}{ISR}%
\TrackLangRegionMap{380}{IT}{ITA}%
\TrackLangRegionMap{388}{JM}{JAM}%
\TrackLangRegionMap{392}{JP}{JPN}%
\TrackLangRegionMap{832}{JE}{JEY}%
\TrackLangRegionMap{400}{JO}{JOR}%
\TrackLangRegionMap{398}{KZ}{KAZ}%
\TrackLangRegionMap{404}{KE}{KEN}%
\TrackLangRegionMap{296}{KI}{KIR}%
\TrackLangRegionMap{408}{KP}{PRK}%
\TrackLangRegionMap{410}{KR}{KOR}%
\TrackLangRegionMap{414}{KW}{KWT}%
\TrackLangRegionMap{417}{KG}{KGZ}%
\TrackLangRegionMap{418}{LA}{LAO}%
\TrackLangRegionMap{428}{LV}{LVA}%
\TrackLangRegionMap{422}{LB}{LBN}%
\TrackLangRegionMap{426}{LS}{LSO}%
\TrackLangRegionMap{430}{LR}{LBR}%
\TrackLangRegionMap{434}{LY}{LBY}%
\TrackLangRegionMap{438}{LI}{LIE}%
\TrackLangRegionMap{440}{LT}{LTU}%
\TrackLangRegionMap{442}{LU}{LUX}%
\TrackLangRegionMap{446}{MO}{MAC}%
\TrackLangRegionMap{807}{MK}{MKD}%
\TrackLangRegionMap{450}{MG}{MDG}%
\TrackLangRegionMap{454}{MW}{MWI}%
\TrackLangRegionMap{458}{MY}{MYS}%
\TrackLangRegionMap{462}{MV}{MDV}%
\TrackLangRegionMap{466}{ML}{MLI}%
\TrackLangRegionMap{470}{MT}{MLT}%
\TrackLangRegionMap{584}{MH}{MHL}%
\TrackLangRegionMap{474}{MQ}{MTQ}%
\TrackLangRegionMap{478}{MR}{MRT}%
\TrackLangRegionMap{480}{MU}{MUS}%
\TrackLangRegionMap{175}{YT}{MYT}%
\TrackLangRegionMap{484}{MX}{MEX}%
\TrackLangRegionMap{583}{FM}{FSM}%
\TrackLangRegionMap{498}{MD}{MDA}%
\TrackLangRegionMap{492}{MC}{MCO}%
\TrackLangRegionMap{496}{MN}{MNG}%
\TrackLangRegionMap{499}{ME}{MNE}%
\TrackLangRegionMap{500}{MS}{MSR}%
\TrackLangRegionMap{504}{MA}{MAR}%
\TrackLangRegionMap{508}{MZ}{MOZ}%
\TrackLangRegionMap{104}{MM}{MMR}%
\TrackLangRegionMap{516}{NA}{NAM}%
\TrackLangRegionMap{520}{NR}{NRU}%
\TrackLangRegionMap{524}{NP}{NPL}%
\TrackLangRegionMap{528}{NL}{NLD}%
\TrackLangRegionMap{540}{NC}{NCL}%
\TrackLangRegionMap{554}{NZ}{NZL}%
\TrackLangRegionMap{558}{NI}{NIC}%
\TrackLangRegionMap{562}{NE}{NER}%
\TrackLangRegionMap{566}{NG}{NGA}%
\TrackLangRegionMap{570}{NU}{NIU}%
\TrackLangRegionMap{574}{NF}{NFK}%
\TrackLangRegionMap{580}{MP}{MNP}%
\TrackLangRegionMap{578}{NO}{NOR}%
\TrackLangRegionMap{512}{OM}{OMN}%
\TrackLangRegionMap{586}{PK}{PAK}%
\TrackLangRegionMap{585}{PW}{PLW}%
\TrackLangRegionMap{275}{PS}{PSE}%
\TrackLangRegionMap{591}{PA}{PAN}%
\TrackLangRegionMap{598}{PG}{PNG}%
\TrackLangRegionMap{600}{PY}{PRY}%
\TrackLangRegionMap{604}{PE}{PER}%
\TrackLangRegionMap{608}{PH}{PHL}%
\TrackLangRegionMap{612}{PN}{PCN}%
\TrackLangRegionMap{616}{PL}{POL}%
\TrackLangRegionMap{620}{PT}{PRT}%
\TrackLangRegionMap{630}{PR}{PRI}%
\TrackLangRegionMap{634}{QA}{QAT}%
\TrackLangRegionMap{638}{RE}{REU}%
\TrackLangRegionMap{642}{RO}{ROU}%
\TrackLangRegionMap{643}{RU}{RUS}%
\TrackLangRegionMap{646}{RW}{RWA}%
\TrackLangRegionMap{652}{BL}{BLM}%
\TrackLangRegionMap{654}{SH}{SHN}%
\TrackLangRegionMap{659}{KN}{KNA}%
\TrackLangRegionMap{662}{LC}{LCA}%
\TrackLangRegionMap{663}{MF}{MAF}%
\TrackLangRegionMap{666}{PM}{SPM}%
\TrackLangRegionMap{670}{VC}{VCT}%
\TrackLangRegionMap{882}{WS}{WSM}%
\TrackLangRegionMap{674}{SM}{SMR}%
\TrackLangRegionMap{678}{ST}{STP}%
\TrackLangRegionMap{682}{SA}{SAU}%
\TrackLangRegionMap{686}{SN}{SEN}%
\TrackLangRegionMap{688}{RS}{SRB}%
\TrackLangRegionMap{690}{SC}{SYC}%
\TrackLangRegionMap{694}{SL}{SLE}%
\TrackLangRegionMap{702}{SG}{SGP}%
\TrackLangRegionMap{534}{SX}{SXM}%
\TrackLangRegionMap{703}{SK}{SVK}%
\TrackLangRegionMap{705}{SI}{SVN}%
\TrackLangRegionMap{090}{SB}{SLB}%
\TrackLangRegionMap{706}{SO}{SOM}%
\TrackLangRegionMap{710}{ZA}{ZAF}%
\TrackLangRegionMap{239}{GS}{SGS}%
\TrackLangRegionMap{728}{SS}{SSD}%
\TrackLangRegionMap{724}{ES}{ESP}%
\TrackLangRegionMap{144}{LK}{LKA}%
\TrackLangRegionMap{729}{SD}{SDN}%
\TrackLangRegionMap{740}{SR}{SUR}%
\TrackLangRegionMap{744}{SJ}{SJM}%
\TrackLangRegionMap{748}{SZ}{SWZ}%
\TrackLangRegionMap{752}{SE}{SWE}%
\TrackLangRegionMap{756}{CH}{CHE}%
\TrackLangRegionMap{760}{SY}{SYR}%
\TrackLangRegionMap{158}{TW}{TWN}%
\TrackLangRegionMap{762}{TJ}{TJK}%
\TrackLangRegionMap{834}{TZ}{TZA}%
\TrackLangRegionMap{764}{TH}{THA}%
\TrackLangRegionMap{626}{TL}{TLS}%
\TrackLangRegionMap{768}{TG}{TGO}%
\TrackLangRegionMap{772}{TK}{TKL}%
\TrackLangRegionMap{776}{TO}{TON}%
\TrackLangRegionMap{780}{TT}{TTO}%
\TrackLangRegionMap{788}{TN}{TUN}%
\TrackLangRegionMap{792}{TR}{TUR}%
\TrackLangRegionMap{795}{TM}{TKM}%
\TrackLangRegionMap{796}{TC}{TCA}%
\TrackLangRegionMap{798}{TV}{TUV}%
\TrackLangRegionMap{800}{UG}{UGA}%
\TrackLangRegionMap{804}{UA}{UKR}%
\TrackLangRegionMap{784}{AE}{ARE}%
\TrackLangRegionMap{826}{GB}{GBR}%
\TrackLangRegionMap{581}{UM}{UMI}%
\TrackLangRegionMap{840}{US}{USA}%
\TrackLangRegionMap{858}{UY}{URY}%
\TrackLangRegionMap{860}{UZ}{UZB}%
\TrackLangRegionMap{548}{VU}{VUT}%
\TrackLangRegionMap{862}{VE}{VEN}%
\TrackLangRegionMap{704}{VN}{VNM}%
\TrackLangRegionMap{092}{VG}{VGB}%
\TrackLangRegionMap{850}{VI}{VIR}%
\TrackLangRegionMap{876}{WF}{WLF}%
\TrackLangRegionMap{732}{EH}{ESH}%
\TrackLangRegionMap{887}{YE}{YEM}%
\TrackLangRegionMap{894}{ZM}{ZMB}%
\TrackLangRegionMap{716}{ZW}{ZWE}%
%    \end{macrocode}
%\changes{1.4}{2019-11-30}{input extra regions if provided}
%    \begin{macrocode}
\@tracklang@input@extra@region@files
%    \end{macrocode}
%
%Restore category code of \texttt{@}.
%    \begin{macrocode}
\@tracklang@regions@restore@at
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</tracklang-region-codes.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*tracklang-scripts.sty>
%    \end{macrocode}
%\fi
%\section{ISO 15924 Scripts \LaTeX\ Package
%(\texttt{tracklang-scripts.sty})}
%This is just a \LaTeX\ package wrapper for the generic code in
%\texttt{tracklang-scripts.tex}.
%\changes{1.3}{2016-10-07}{added tracklang-scripts.sty}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tracklang-scripts}[2019/11/30 v1.4 (NLCT) Track
Language Scripts (LaTeX)]
\RequirePackage{tracklang}
\input{tracklang-scripts}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</tracklang-scripts.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*tracklang-scripts.tex>
%    \end{macrocode}
%\fi
%\section{ISO 15924 Scripts Generic Code
%(\texttt{tracklang-scripts.tex})}
%\label{sec:tracklang-scripts.tex}
%Provides information about ISO 15924 scripts. Not automatically
%loaded.
%\changes{1.3}{2016-10-07}{added tracklang-scripts.tex}
%    \begin{macrocode}
\ifnum\catcode`\@=11\relax
  \def\@tracklang@scripts@restore@at{}%
\else
  \expandafter\edef\csname @tracklang@scripts@restore@at\endcsname{%
    \noexpand\catcode`\noexpand\@=\number\catcode`\@\relax
  }%
 \catcode`\@=11\relax
\fi
%    \end{macrocode}
% Check if this file has already been loaded:
%    \begin{macrocode}
\ifx\TrackLangScriptMap\undefined
\else
  \@tracklang@scripts@restore@at
  \expandafter\endinput
\fi
%    \end{macrocode}
% Version info.
%    \begin{macrocode}
\expandafter\def\csname ver@tracklang-scripts.tex\endcsname{%
 2019/11/30 v1.4 (NLCT) Track Languages Scripts (Generic)}%
%    \end{macrocode}
%
%\begin{macro}{\TrackLangScriptsMap}
%\changes{1.3}{2016-10-07}{new}
%\begin{definition}
%\cs{TrackLangScriptMap}\marg{letter
%code}\marg{number}\marg{name}\marg{direction}\marg{parent}
%\end{definition}
%Define mapping. To avoid problems with encodings, only use ASCII
%characters in the arguments. The first argument is the four-letter
%ISO 15924 code. The second argument is the numeric code. The third
%argument is just intended for informational purposes. The fourth
%argument indicates the direction. This may be \texttt{LR}
%(left-to-right), \texttt{RL} (right-to-left), \texttt{TB}
%(top-to-bottom), \texttt{varies} or \texttt{inherited}.
%The \meta{parent} argument is for the parent writing system, which
%may be left blank. (Currently, this is blank for all the mappings
%provided here, but the syntax has five arguments in case of future
%development.)
%    \begin{macrocode}
\def\TrackLangScriptMap#1#2#3#4#5{%
%    \end{macrocode}
%This user command is provided to make it easier to test the script
%using \cs{ifx}.
%    \begin{macrocode}
  \@tracklang@enamedef{TrackLangScript#1}{#1}%
  \@tracklang@enamedef{@tracklang@script@numtoalpha@#2}{#1}%
  \@tracklang@enamedef{@tracklang@script@alphatonum@#1}{#2}%
  \@tracklang@enamedef{@tracklang@script@alphatoname@#1}{#3}%
  \@tracklang@enamedef{@tracklang@script@alphatodir@#1}{#4}%
  \ifx\relax#5\relax
  \else
    \@tracklang@enamedef{@tracklang@script@parent@#1}{#5}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptAlphaToNumeric}
%\begin{definition}
%\cs{TrackLangScriptAlphaToNumeric}\marg{alpha code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptAlphaToNumeric#1{%
  \@tracklang@nameuse{@tracklang@script@alphatonum@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptIfKnownAlpha}
%\begin{definition}
%\cs{TrackLangScriptIfKnownAlpha}\marg{alpha
%code}\marg{true}\marg{false}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptIfKnownAlpha#1#2#3{%
  \@tracklang@ifundef{@tracklang@script@alphatonum@#1}%
  {#3}%
  {#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptNumericToAlpha}
%\begin{definition}
%\cs{TrackLangScriptNumericToAlpha}\marg{numeric code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptNumericToAlpha#1{%
  \@tracklang@nameuse{@tracklang@script@numtoalpha@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptIfKnownNumeric}
%\begin{definition}
%\cs{TrackLangScriptIfKnownNumeric}\marg{numeric
%code}\marg{true}\marg{false}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptIfKnownNumeric#1#2#3{%
  \@tracklang@ifundef{@tracklang@script@numtoalpha@#1}%
  {#3}%
  {#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptAlphaToName}
%\begin{definition}
%\cs{TrackLangScriptAlphaToName}\marg{alpha code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptAlphaToName#1{%
  \@tracklang@nameuse{@tracklang@script@alphatoname@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptAlphaToDir}
%\begin{definition}
%\cs{TrackLangScriptAlphaToDir}\marg{alpha code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptAlphaToDir#1{%
  \@tracklang@nameuse{@tracklang@script@alphatodir@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%I wasn't sure whether or not to implement a parent, but it's here
%if required. Unlike the other elements above, there's also a
%command to set this field.
%\begin{macro}{\TrackLangScriptSetParent}
%\begin{definition}
%\cs{TrackLangScriptSetParent}\marg{alpha code}\marg{parent alpha
%code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptSetParent#1#2{%
  \@tracklang@enamedef{@tracklang@script@parent@#1}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptGetParent}
%\begin{definition}
%\cs{TrackLangScriptGetParent}\marg{alpha code}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptGetParent#1{%
  \@tracklang@nameuse{@tracklang@script@parent@#1}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\TrackLangScriptIfHasParent}
%\begin{definition}
%\cs{TrackLangScriptIfHasParent}\marg{alpha
%code}\marg{true}\marg{false}
%\end{definition}
%\changes{1.3}{2016-10-07}{new}
%    \begin{macrocode}
\def\TrackLangScriptIfHasParent#1#2#3{%
  \@tracklang@ifundef{@tracklang@script@parent@#1}%
  {#3}%
  {#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%Define mappings. The parent information is currently missing.
%\changes{1.4}{2019-11-30}{removed some spurious empty braces and commented
%out EOL}
%    \begin{macrocode}
\TrackLangScriptMap{Adlm}{166}{Adlam}{RL}{}%
\TrackLangScriptMap{Afak}{439}{Afaka}{varies}{}%
\TrackLangScriptMap{Aghb}{239}{Caucasian Albanian}{LR}{}%
\TrackLangScriptMap{Ahom}{338}{Ahom, Tai Ahom}{LR}{}%
\TrackLangScriptMap{Arab}{160}{Arabic}{RL}{}%
\TrackLangScriptMap{Aran}{161}{Arabic (Nastaliq variant)}{RL}{}%
\TrackLangScriptMap{Armi}{124}{Imperial Aramaic}{RL}{}%
\TrackLangScriptMap{Armn}{230}{Armenian}{LR}{}%
\TrackLangScriptMap{Avst}{134}{Avestan}{RL}{}%
\TrackLangScriptMap{Bali}{360}{Balinese}{LR}{}%
\TrackLangScriptMap{Bamu}{435}{Bamum}{LR}{}%
\TrackLangScriptMap{Bass}{259}{Bassa Vah}{LR}{}%
\TrackLangScriptMap{Batk}{365}{Batak}{LR}{}%
\TrackLangScriptMap{Beng}{334}{Bhaiksuki}{LR}{}%
\TrackLangScriptMap{Blis}{550}{Blissymbols}{varies}{}%
\TrackLangScriptMap{Bopo}{285}{Bopomofo}{LR}{}%
\TrackLangScriptMap{Brah}{300}{Brahmi}{LR}{}%
\TrackLangScriptMap{Brai}{570}{Braille}{LR}{}%
\TrackLangScriptMap{Bugi}{367}{Buginese}{LR}{}%
\TrackLangScriptMap{Buhd}{372}{Buhid}{LR}{}%
\TrackLangScriptMap{Cakm}{349}{Chakma}{LR}{}%
\TrackLangScriptMap{Cans}{440}{Unified Canadian Aboriginal Syllabics}{LR}{}%
\TrackLangScriptMap{Cari}{201}{Carian}{LR}{}%
\TrackLangScriptMap{Cham}{358}{Cham}{LR}{}%
\TrackLangScriptMap{Cher}{445}{Cherokee}{LR}{}%
\TrackLangScriptMap{Cirt}{291}{Cirth}{varies}{}%
\TrackLangScriptMap{Copt}{204}{Coptic}{LR}{}%
\TrackLangScriptMap{Cprt}{403}{Cypriot}{RL}{}%
\TrackLangScriptMap{Cyrl}{220}{Cyrillic}{LR}{}%
\TrackLangScriptMap{Cyrs}{221}{Cyrillic (Old Church Slavonic variant)}{varies}{}%
\TrackLangScriptMap{Deva}{315}{Devanagari (Nagari)}{LR}{}%
\TrackLangScriptMap{Dsrt}{250}{Deseret (Mormon)}{LR}{}%
\TrackLangScriptMap{Dupl}{755}{Duployan shorthand, Duployan stenography}{LR}{}%
\TrackLangScriptMap{Egyd}{070}{Egyptian demotic}{RL}{}%
\TrackLangScriptMap{Egyh}{060}{Egyptian hieratic}{RL}{}%
\TrackLangScriptMap{Egyp}{050}{Egyptian hieroglyphs}{LR}{}%
\TrackLangScriptMap{Elba}{226}{Elbasan}{LR}{}%
\TrackLangScriptMap{Ethi}{430}{Ethiopic (Ge'ez)}{LR}{}%
\TrackLangScriptMap{Geok}{241}{Khutsuri (Asomtavruli and Nuskhuri)}{LR}{}%
\TrackLangScriptMap{Geor}{240}{Georgian (Mkhedruli)}{LR}{}%
\TrackLangScriptMap{Glag}{225}{Glagolitic}{LR}{}%
\TrackLangScriptMap{Goth}{206}{Gothic}{LR}{}%
\TrackLangScriptMap{Gran}{343}{Grantha}{LR}{}%
\TrackLangScriptMap{Grek}{200}{Greek}{LR}{}%
\TrackLangScriptMap{Gujr}{320}{Gujarati}{LR}{}%
\TrackLangScriptMap{Guru}{310}{Gurmukhi}{LR}{}%
\TrackLangScriptMap{Hanb}{503}{Han with Bopomofo (alias for Han + Bopomofo)}{LR}{}%
\TrackLangScriptMap{Hang}{286}{Hangul}{LR}{}%
\TrackLangScriptMap{Hani}{500}{Han (Hanzi, Kanji, Hanja)}{LR}{}%
\TrackLangScriptMap{Hano}{371}{Hanunoo}{LR}{}%
\TrackLangScriptMap{Hans}{501}{Han (Simplified variant)}{varies}{}%
\TrackLangScriptMap{Hant}{502}{Han (Traditional variant)}{varies}{}%
\TrackLangScriptMap{Hatr}{127}{Hatran}{RL}{}%
\TrackLangScriptMap{Hebr}{125}{Hebrew}{RL}{}%
\TrackLangScriptMap{Hira}{410}{Hiragana}{LR}{}%
\TrackLangScriptMap{Hluw}{080}{Anatolian Hieroglyphs (Luwian Hieroglyphs, Hittite Hieroglyphs)}{LR}{}%
\TrackLangScriptMap{Hmng}{450}{Pahawh Hmong}{LR}{}%
\TrackLangScriptMap{Hrkt}{412}{Japanese syllabaries (alias for Hiragana + Katakana)}{varies}{}%
\TrackLangScriptMap{Hung}{176}{Old Hungarian (Hungarian Runic)}{RL}{}%
\TrackLangScriptMap{Inds}{610}{Indus (Harappan)}{RL}{}%
\TrackLangScriptMap{Ital}{210}{Old Italic (Etruscan, Oscan, etc.)}{LR}{}%
\TrackLangScriptMap{Jamo}{284}{Jamo (alias for Jamo subset of Hangul)}{LR}{}%
\TrackLangScriptMap{Java}{361}{Javanese}{LR}{}%
\TrackLangScriptMap{Jpan}{413}{Japanese (alias for Han + Hiragana + Katakana)}{varies}{}%
\TrackLangScriptMap{Jurc}{510}{Jurchen}{LR}{}%
\TrackLangScriptMap{Kali}{357}{Kayah Li}{LR}{}%
\TrackLangScriptMap{Kana}{411}{Katakana}{LR}{}%
\TrackLangScriptMap{Khar}{305}{Kharoshthi}{RL}{}%
\TrackLangScriptMap{Khmr}{355}{Khmer}{LR}{}%
\TrackLangScriptMap{Khoj}{322}{Khojki}{LR}{}%
\TrackLangScriptMap{Kitl}{505}{Khitan large script}{LR}{}%
\TrackLangScriptMap{Kits}{288}{Khitan small script}{TB}{}%
\TrackLangScriptMap{Knda}{345}{Kannada}{LR}{}%
\TrackLangScriptMap{Kore}{287}{Korean (alias for Hangul + Han)}{LR}{}%
\TrackLangScriptMap{Kpel}{436}{Kpelle}{LR}{}%
\TrackLangScriptMap{Kthi}{317}{Kaithi}{LR}{}%
\TrackLangScriptMap{Lana}{351}{Tai Tham (Lanna)}{LR}{}%
\TrackLangScriptMap{Laoo}{356}{Lao}{LR}{}%
\TrackLangScriptMap{Latf}{217}{Latin (Fraktur variant)}{varies}{}%
\TrackLangScriptMap{Latg}{216}{Latin (Gaelic variant)}{LR}{}%
\TrackLangScriptMap{Latn}{215}{Latin}{LR}{}%
\TrackLangScriptMap{Leke}{364}{Leke}{LR}{}%
\TrackLangScriptMap{Lepc}{335}{Lepcha}{LR}{}%
\TrackLangScriptMap{Limb}{336}{Limbu}{LR}{}%
\TrackLangScriptMap{Lina}{400}{Linear A}{LR}{}%
\TrackLangScriptMap{Linb}{401}{Linear B}{LR}{}%
\TrackLangScriptMap{Lisu}{399}{Lisu (Fraser)}{LR}{}%
\TrackLangScriptMap{Loma}{437}{Loma}{LR}{}%
\TrackLangScriptMap{Lyci}{202}{Lycian}{LR}{}%
\TrackLangScriptMap{Lydi}{116}{Lydian}{RL}{}%
\TrackLangScriptMap{Mahj}{314}{Mahajani}{LR}{}%
\TrackLangScriptMap{Mand}{140}{Mandaic, Mandaean}{RL}{}%
\TrackLangScriptMap{Mani}{139}{Manichaean}{RL}{}%
\TrackLangScriptMap{Marc}{332}{Marchen}{LR}{}%
\TrackLangScriptMap{Maya}{090}{Mayan hieroglyphs}{varies}{}%
\TrackLangScriptMap{Mend}{438}{Mende Kikakui}{RL}{}%
\TrackLangScriptMap{Merc}{101}{Meroitic Cursive}{RL}{}%
\TrackLangScriptMap{Mero}{100}{Meroitic Hieroglyphs}{RL}{}%
\TrackLangScriptMap{Mlym}{347}{Malayalam}{LR}{}%
\TrackLangScriptMap{Modi}{324}{Modi}{LR}{}%
\TrackLangScriptMap{Mong}{145}{Mongolian}{TB}{}%
\TrackLangScriptMap{Moon}{218}{Moon (Moon code, Moon script, Moon type)}{varies}{}%
\TrackLangScriptMap{Mroo}{199}{Mro, Mru}{LR}{}%
\TrackLangScriptMap{Mtei}{337}{Meitei Mayek (Meithei, Meetei)}{LR}{}%
\TrackLangScriptMap{Mult}{323}{Multani}{LR}{}%
\TrackLangScriptMap{Mymr}{350}{Myanmar (Burmese)}{LR}{}%
\TrackLangScriptMap{Narb}{106}{Old North Arabian (Ancient North Arabian)}{RL}{}%
\TrackLangScriptMap{Nbat}{159}{Nabataean}{RL}{}%
\TrackLangScriptMap{Newa}{333}{Newa, Newar, Newari}{LR}{}%
\TrackLangScriptMap{Nkgb}{420}{Nakhi Geba}{LR}{}%
\TrackLangScriptMap{Nkoo}{165}{N'Ko}{RL}{}%
\TrackLangScriptMap{Nshu}{499}{Nushu}{LR}{}%
\TrackLangScriptMap{Ogam}{212}{Ogham}{varies}{}%
\TrackLangScriptMap{Olck}{261}{Ol Chiki}{LR}{}%
\TrackLangScriptMap{Orkh}{175}{Old Turkic, Orkhon Runic}{RL}{}%
\TrackLangScriptMap{Orya}{327}{Oriya}{LR}{}%
\TrackLangScriptMap{Osge}{219}{Osage}{LR}{}%
\TrackLangScriptMap{Osma}{260}{Osmanya}{LR}{}%
\TrackLangScriptMap{Palm}{126}{Palmyrene}{RL}{}%
\TrackLangScriptMap{Pauc}{263}{Pau Cin Hau}{LR}{}%
\TrackLangScriptMap{Perm}{227}{Old Permic}{LR}{}%
\TrackLangScriptMap{Phag}{331}{Phags-pa}{TB}{}%
\TrackLangScriptMap{Phli}{131}{Inscriptional Pahlavi}{RL}{}%
\TrackLangScriptMap{Phlp}{132}{Psalter Pahlavi}{RL}{}%
\TrackLangScriptMap{Phlv}{133}{Book Pahlavi}{RL}{}%
\TrackLangScriptMap{Phnx}{115}{Phoenician}{RL}{}%
\TrackLangScriptMap{Piqd}{293}{Klingon (KLI plqaD)}{LR}{}%
\TrackLangScriptMap{Plrd}{282}{Miao (Pollard)}{LR}{}%
\TrackLangScriptMap{Prti}{130}{Inscriptional Parthian}{RL}{}%
\TrackLangScriptMap{Qaaa}{900}{Reserved for private use (start)}{varies}{}%
\TrackLangScriptMap{Qaai}{908}{Private use}{varies}{}%
\TrackLangScriptMap{Qabx}{949}{Reserved for private use (end)}{varies}{}%
\TrackLangScriptMap{Rjng}{363}{Rejang (Redjang, Kaganga)}{LR}{}%
\TrackLangScriptMap{Roro}{620}{Rongorongo}{varies}{}%
\TrackLangScriptMap{Runr}{211}{Runic}{LR}{}%
\TrackLangScriptMap{Samr}{123}{Samaritan}{RL}{}%
\TrackLangScriptMap{Sara}{292}{Sarati}{varies}{}%
\TrackLangScriptMap{Sarb}{105}{Old South Arabian}{RL}{}%
\TrackLangScriptMap{Saur}{344}{Saurashtra}{LR}{}%
\TrackLangScriptMap{Sgnw}{095}{SignWriting}{TB}{}%
\TrackLangScriptMap{Shaw}{281}{Shavian (Shaw)}{LR}{}%
\TrackLangScriptMap{Shrd}{319}{Sharada}{LR}{}%
\TrackLangScriptMap{Sidd}{302}{Siddham}{LR}{}%
\TrackLangScriptMap{Sind}{318}{Khudawadi, Sindhi}{LR}{}%
\TrackLangScriptMap{Sinh}{348}{Sinhala}{LR}{}%
\TrackLangScriptMap{Sora}{398}{Sora Sompeng}{LR}{}%
\TrackLangScriptMap{Sund}{362}{Sundanese}{LR}{}%
\TrackLangScriptMap{Sylo}{316}{Syloti Nagri}{LR}{}%
\TrackLangScriptMap{Syrc}{135}{Syriac}{RL}{}%
\TrackLangScriptMap{Syre}{138}{Syriac (Estrangelo variant)}{RL}{}%
\TrackLangScriptMap{Syrj}{137}{Syriac (Western variant)}{RL}{}%
\TrackLangScriptMap{Syrn}{136}{Syriac (Eastern variant)}{RL}{}%
\TrackLangScriptMap{Tagb}{373}{Tagbanwa}{LR}{}%
\TrackLangScriptMap{Takr}{321}{Takri}{LR}{}%
\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}{}%
\TrackLangScriptMap{Teng}{290}{Tengwar}{LR}{}%
\TrackLangScriptMap{Tfng}{120}{Tifinagh (Berber)}{LR}{}%
\TrackLangScriptMap{Tglg}{370}{Tagalog (Baybayin, Alibata)}{LR}{}%
\TrackLangScriptMap{Thaa}{170}{Thaana}{RL}{}%
\TrackLangScriptMap{Thai}{352}{Thai}{LR}{}%
\TrackLangScriptMap{Tibt}{330}{Tibetan}{LR}{}%
\TrackLangScriptMap{Tirh}{326}{Tirhuta}{LR}{}%
\TrackLangScriptMap{Ugar}{040}{Ugaritic}{LR}{}%
\TrackLangScriptMap{Vaii}{470}{Vai}{LR}{}%
\TrackLangScriptMap{Visp}{280}{Visible Speech}{LR}{}%
\TrackLangScriptMap{Wara}{262}{Warang Citi (Varang Kshiti)}{LR}{}%
\TrackLangScriptMap{Wole}{480}{Woleai}{RL}{}%
\TrackLangScriptMap{Xpeo}{030}{Old Persian}{LR}{}%
\TrackLangScriptMap{Xsux}{020}{Cuneiform, Sumero-Akkadian}{LR}{}%
\TrackLangScriptMap{Yiii}{460}{Yi}{LR}{}%
\TrackLangScriptMap{Zinh}{994}{Inherited script}{inherited}{}%
\TrackLangScriptMap{Zmth}{995}{Mathematical notation}{LR}{}%
\TrackLangScriptMap{Zsym}{996}{Symbols}{varies}{}%
\TrackLangScriptMap{Zsye}{993}{Symbols (emoji variant)}{varies}{}%
\TrackLangScriptMap{Zxxx}{997}{Unwritten documents}{varies}{}%
\TrackLangScriptMap{Zyyy}{998}{Undetermined script}{varies}{}%
\TrackLangScriptMap{Zzzz}{999}{Uncoded script}{varies}{}%
%    \end{macrocode}
%\changes{1.4}{2019-11-30}{new}
%Load additional script files.
%    \begin{macrocode}
\@tracklang@input@extra@script@files
%    \end{macrocode}
%
%Restore category code of \texttt{@}.
%    \begin{macrocode}
\@tracklang@scripts@restore@at
%    \end{macrocode}

%\iffalse
%    \begin{macrocode}
%</tracklang-scripts.tex>
%    \end{macrocode}
%\fi
%\Finale
\endinput
