%\iffalse
% tracklang.dtx generated using makedtx version 1.2 (c) Nicola Talbot
% Command line args:
%   -src "tracklang.sty\Z=>tracklang.sty"
%   -src "tracklang.tex\Z=>tracklang.tex"
%   -src "tracklang-region-codes.tex\Z=>tracklang-region-codes.tex"
%   -src "tracklang-scripts.sty\Z=>tracklang-scripts.sty"
%   -src "tracklang-scripts.tex\Z=>tracklang-scripts.tex"
%   -author "Nicola Talbot"
%   -doc "tracklang-codedoc.tex"
%   -codetitle "Main Package Code"
%   tracklang
% Created on 2022/12/13 11:26
%\fi
%\iffalse
%<*package>
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%</package>
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
% Copyright (C) 2022 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
\iffalse
tracklang-codedoc.tex is a stub file used by makedtx to create
tracklang.dtx
\fi

\documentclass{article}
\usepackage{doc}

\CheckSum{6246}

\RecordChanges
\PageIndex
\SetupDoc{reportchangedates}
\setcounter{IndexColumns}{2}

\usepackage[T1]{fontenc}
\usepackage{tcolorbox}

\definecolor{defbackground}{rgb}{1,1,0.75}

\newtcolorbox{definition}{halign=flush left,
 colframe=black,colback=defbackground,
 fontupper=\ttfamily,
 before upper={\frenchspacing\obeylines},
 after={\par\noindent\ignorespacesafterend}
}

\NewDocElement{Option}{option}

\providecommand{\sty}[1]{\styfmt{#1}}
\providecommand{\styfmt}[1]{\textsf{#1}}
\providecommand{\pkgoptfmt}[1]{\textsf{#1}}
\providecommand{\envvar}[1]{\texttt{#1}}
\providecommand{\app}[1]{\texttt{#1}}
\providecommand{\qt}[1]{``#1''}
\providecommand{\sectionref}[1]{\S\ref{#1}}

\providecommand\marg[1]{%
  \texorpdfstring{\allowbreak{\ttfamily\char`\{}\meta{#1}{\ttfamily\char`\}}}
  {\{#1\}}}
\providecommand\oarg[1]{%
  \texorpdfstring{\allowbreak{\ttfamily[}\meta{#1}{\ttfamily]}}
  {[#1]}}

\begin{document}
\DocInput{tracklang.dtx}
\end{document}
%</driver>
%\fi
%
% \title{Documented Code For tracklang v1.6.1}
% \author{Nicola L.C. Talbot\\[10pt]
%Dickimaw Books\\
%\url{http://www.dickimaw-books.com/}}
%
% \date{2022-12-13}
% \maketitle
%
%\tableofcontents
%
%\section{Introduction}
%
%This is the documented code for the \sty{tracklang} package.
%See \texttt{tracklang-manual.pdf} for the main user guide.
%
%\StopEventually{\clearpage\PrintChanges \clearpage\PrintIndex}
%
%
%
%\section{Main Package 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}[2022/12/13 v1.6.1 (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} now provides \cs{xpg@bcp@loaded}, which contains
%a comma-separated list of language tags, so use that if
%it exists.
%\changes{1.6}{2022-10-29}{added check for \cs{xpg@bcp@loaded}}
%    \begin{macrocode}
             \@ifundefined{xpg@bcp@loaded}%
             {% 
%    \end{macrocode}
% Older versions:
% \sty{polyglossia} sets \cs{\meta{lang}@loaded} for each loaded
% language, so check this for all known languages. I don't know how
% to consistently check for variants. (Conditionals such as
% \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}}%
                  }%
               }%
             }%
             {%
               \@for\this@language:=\xpg@bcp@loaded\do{%
%    \end{macrocode}
%These are language tags, which is more convenient.
%    \begin{macrocode}
                  \expandafter\TrackLanguageTag{\this@language}%
               }%
             }%
%    \end{macrocode}
%The \cs{xpg@bcp@loaded} list doesn't seem to include the main
%language until the start of the document environment but
%\cs{mainbabelname} is defined after \cs{setmainlanguage}. I'm not
%sure if \cs{mainbabelname} was provided in the same version of
%\sty{polyglossia} as \cs{xpg@bcp@loaded} or a different one, so
%have a separate conditional.
%    \begin{macrocode}
             \@ifundefined{mainbabelname}{}%
             {%
               \let\@org@tracklang@add@latex\@tracklang@add@latex
               \def\@tracklang@add@latex{%
                 \PackageWarning{tracklang}%
                   {Can't detect polyglossia main language. It may
                     not have been set yet}%
               }%
               \@ifundefined{@tracklang@add@\mainbabelname}%
               {%
                 \PackageWarning{tracklang}%
                   {Adding unknown polyglossia main babel name `\mainbabelname'}%
                 \expandafter\AddTrackedLanguage{\mainbabelname}%
               }%
               {%
                 \@nameuse{@tracklang@add@\mainbabelname}%
               }%
               \let\@tracklang@add@latex\@org@tracklang@add@latex
             }%
           }%
           {%
%    \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{%
 2022/12/13 v1.6.1 (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}
%
%\begin{macro}{\TrackLangEncodingName}
%\changes{1.6.1}{2022-12-13}{new}
%Provide a default encoding name to avoid repeated tests to determine whether or not
%\cs{inputencodingname} has been defined.
%    \begin{macrocode}
\ifx\inputencodingname\undefined
  \def\TrackLangEncodingName{utf8}
\else
  \def\TrackLangEncodingName{\inputencodingname}
\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}
%\changes{1.6}{2022-10-29}{changed \cs{x} to \cs{@tracklang@x}}
%    \begin{macrocode}
     \def\TrackLangQueryEnv{%
       \begingroup\endlinechar=-1\relax
       \everyeof{\noexpand}%
       \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\@tracklang@x
       \@tracklang@checklocale
       \ifx\TrackLangEnv\empty
         \begingroup\endlinechar=-1\relax
         \everyeof{\noexpand}%
         \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
           \@tracklang@input|"kpsewhich --var-value LANG" }}\@tracklang@x
%    \end{macrocode}
%Not sure if a path is likely to occur with \app{kpsewhich}
%but check for it just in case.
%    \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\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
         \@tracklang@input|"kpsewhich --var-value LC_ALL" }}\@tracklang@x
       \@tracklang@checklocale
       \ifx\TrackLangEnv\empty
         \begingroup\endlinechar=-1\relax
         \everyeof{\noexpand}%
         \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
           \@tracklang@input|"kpsewhich --var-value #1" }}\@tracklang@x
         \@tracklang@checklocale
         \ifx\TrackLangEnv\empty
           \begingroup\endlinechar=-1\relax
           \everyeof{\noexpand}%
           \edef\@tracklang@x{\endgroup\def\noexpand\TrackLangEnv{%
             \@tracklang@input|"kpsewhich --var-value LANG"}}\@tracklang@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}
%\changes{1.3}{2016-10-07}{new}
%    \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 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
    }%
%    \end{macrocode}
%\changes{1.5}{2020-06-30}{removed spurious code block}
%    \begin{macrocode}
  }%
  {%
    \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}
%\changes{1.5}{2020-06-30}{added verbose messages}
%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{%
   \@tracklang@verbose{Finding file for dialect `#1' (pre-v1.4)}%
   \def\CurrentTrackedTag{}%
   \SetCurrentTrackedDialect{#1}%
   \IfTrackedDialect{#1}%
   {%
     \edef\CurrentTrackedTag{#1}%
     \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
     \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
     {#4}%
     {%
       \IfTrackedLanguageHasIsoCode
         {639-1}{\CurrentTrackedLanguage}
       {%
          \edef\CurrentTrackedIsoCode{%
             \TrackedIsoCodeFromLanguage
               {639-1}{\CurrentTrackedLanguage}}%
          \ifx\CurrentTrackedRegion\empty
            \let\CurrentTrackedTag\CurrentTrackedIsoCode
            \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
            \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
            {#4}
            {%
              \IfTrackedLanguageHasIsoCode
                {639-2}{\CurrentTrackedLanguage}
              {%
                 \edef\CurrentTrackedIsoCode{%
                    \TrackedIsoCodeFromLanguage
                      {639-2}{\CurrentTrackedLanguage}}%
                 \let\CurrentTrackedTag\CurrentTrackedIsoCode
                 \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                 \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                 {#4}%
                 {%
                   \let\CurrentTrackedTag\CurrentTrackedLanguage
                   \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                   \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
                 }%
              }%
              {%
               \let\CurrentTrackedTag\CurrentTrackedLanguage
               \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
               \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
              }%
            }%
          \else
            \edef\CurrentTrackedTag{%
              \CurrentTrackedIsoCode-\CurrentTrackedRegion}%
            \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
            \@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@verbose{Testing tag `\CurrentTrackedTag'}%
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                {#4}%
                {%
                  \let\CurrentTrackedTag\org@currenttrackedisocode
                  \let\org@currenttrackedisocode\CurrentTrackedIsoCode
                  \let\CurrentTrackedIsoCode\CurrentTrackedTag
                  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                  {#4}
                  {%
                    \let\CurrentTrackedIsoCode\org@currenttrackedisocode
                    \let\CurrentTrackedTag\CurrentTrackedIsoCode
                    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                    \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                    {#4}%
                    {%
                      \let\CurrentTrackedTag\CurrentTrackedRegion
                      \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                      \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                      {#4}%
                      {%
                        \let\CurrentTrackedTag\CurrentTrackedLanguage
                        \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                        \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
                      }%
                    }%
                  }%
                }%
              }%
              {%
                \let\CurrentTrackedTag\CurrentTrackedIsoCode
                \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                {#4}%
                {%
                  \let\CurrentTrackedTag\CurrentTrackedRegion
                  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                  {#4}%
                  {%
                    \let\CurrentTrackedTag\CurrentTrackedLanguage
                    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                    \@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@verbose{Testing tag `\CurrentTrackedTag'}%
             \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
           \else
             \let\CurrentTrackedTag\CurrentTrackedRegion
             \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
             \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
             {#4}%
             {%
               \let\CurrentTrackedTag\CurrentTrackedLanguage
               \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
               \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
             }%
           \fi
         \else
            \ifx\CurrentTrackedRegion\empty
              \let\CurrentTrackedTag\CurrentTrackedIsoCode
              \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
              \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
              {#4}%
              {%
                \let\CurrentTrackedTag\CurrentTrackedLanguage
                \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}{#4}{#5}%
              }%
            \else
              \edef\CurrentTrackedTag{%
                \CurrentTrackedIsoCode-\CurrentTrackedRegion}%
              \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
              \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
              {#4}%
              {%
                \let\CurrentTrackedTag\CurrentTrackedIsoCode
                \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                {#4}%
                {%
                  \let\CurrentTrackedTag\CurrentTrackedRegion
                  \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                  \@tracklang@IfFileExists{#2\CurrentTrackedTag#3}%
                  {#4}%
                  {%
                    \let\CurrentTrackedTag\CurrentTrackedLanguage
                    \@tracklang@verbose{Testing tag `\CurrentTrackedTag'}%
                    \@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 nothing (it's possible no language package
% has been loaded).
%\changes{1.5}{2020-06-30}{removed redundant code and added verbose message}
%    \begin{macrocode}
          \@tracklang@verbose{no hook found for \CurrentTrackedDialect}%
        }%
        {%
          \@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@verbose{no hook found for \CurrentTrackedDialect}%
      }%
      {%
        \@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 nothing (it's possible no language package
% has been loaded).
%\changes{1.5}{2020-06-30}{removed redundant code and added verbose message}
%    \begin{macrocode}
          \@tracklang@verbose{no hook found for \CurrentTrackedDialect}%
        }%
        {%
          \@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@verbose{no hook found for \CurrentTrackedDialect}%
      }%
      {%
        \@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{%
 2022/12/13 v1.6.1 (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}[2022/12/13 v1.6.1 (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{%
 2022/12/13 v1.6.1 (NLCT) Track Languages Scripts (Generic)}%
%    \end{macrocode}
%
%\begin{macro}{\TrackLangScriptMap}
%\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{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
