%%
%% This is file `tex-locale.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tex-locale.dtx  (with options: `tex-locale.tex,package')
%% 
%%  tex-locale.dtx
%%  Copyright 2018 Nicola Talbot
%% 
%%  This work may be distributed and/or modified under the
%%  conditions of the LaTeX Project Public License, either version 1.3
%%  of this license or (at your option) any later version.
%%  The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%%  and version 1.3 or later is part of all distributions of LaTeX
%%  version 2005/12/01 or later.
%% 
%%  This work has the LPPL maintenance status `maintained'.
%% 
%%  The Current Maintainer of this work is Nicola Talbot.
%% 
%%  This work consists of the files tex-locale.dtx and tex-locale.ins and the derived files tex-locale.sty, tex-locale.tex, tex-locale-scripts-enc.def, tex-locale-encodings.def, tex-locale-support.def.
%% 
%% \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         \~}
%% arara: xetex: {shell: on}
%% arara: xetex: {shell: on}
\ifnum\catcode`\@=11\relax
  \def\@locale@restore@at{}%
\else
  \expandafter\edef\csname @locale@restore@at\endcsname{%
    \noexpand\catcode`\noexpand\@=\number\catcode`\@\relax
  }%
 \catcode`\@=11\relax
\fi
\ifx\@locale@parse@query\undefined
\else
  \@locale@restore@at
  \expandafter\endinput
\fi
\expandafter\def\csname ver@tex-locale.tex\endcsname{2018/08/26 v1.0
(NLCT) localisation support}
\input tracklang
\input texosquery
\ifx\PackageError\undefined
  \def\@locale@err#1#2{%
    \errhelp{#2}%
    \errmessage{tex-locale: #1}}
\else
  \def\@locale@err#1#2{\PackageError{tex-locale}{#1}{#2}}
\fi
\def\@locale@warn{\@tracklang@pkgwarn{tex-locale}}
\ifx\PackageInfo\undefined
  \def\@locale@info#1{%
    {%
      \newlinechar=`\^^J
      \def\MessageBreak{^^J}%
      \message{^^Jtex-locale Info: #1^^J}%
    }%
  }
\else
  \def\@locale@info#1{\PackageInfo{tex-locale}{#1}}
\fi
\ifx\@tracklang@pkgwarn\undefined
  \@locale@err{tracklang version is too old. At least v1.3.4 required}
   {You need to update tracklang to at least v1.3.4}%
\fi
\ifx\@texosquery@argquote\undefined
  \@locale@err{texosquery version is too old. At least v1.4 required}
   {You need to update texosquery to at least v1.4}%
\fi
\ifx\LocaleMain\undefined
  \def\LocaleMain{locale}
\fi
\@tracklang@sanitize\LocaleMain
\ifx\LocaleOther\undefined
  \def\LocaleOther{}
\else
  \@tracklang@sanitize\LocaleOther
\fi
\def\@locale@os@tag{}
\def\@locale@os@default{locale}
\@tracklang@sanitize\@locale@os@default
\def\@locale@unknown@currency{XXX}
\def\@locale@os@region{}
\def\@locale@os@groupsep{}
\def\@locale@os@decsep{}
\def\@locale@os@cursep{}
\def\@locale@os@exp{}
\def\@locale@os@usesgroup{}
\def\@locale@os@currencycode{XXX}
\def\@locale@os@regionalcurrencycode{XXX}
\def\@locale@os@currencysym{}
\def\@locale@os@currencytex{}
\ifx\LocaleMainFile\undefined
  \edef\LocaleMainFile{\expandafter\texosquerystripquotes{\jobname}.tex}
\fi
\ifx\LocaleIfDateTimePatternsSupported\undefined
 \def\LocaleIfDateTimePatternsSupported#1#2{#2}
\fi
\def\localedatetimefmt#1{#1}
\ifx\LocaleQueryCodesetParam\undefined
  \edef\LocaleQueryCodesetParam{\string-C}
\fi
\edef\@locale@query@params{%
  \string-o \string-r \string-a
  \string-n
  \string-N
  \LocaleQueryCodesetParam\space
}
\LocaleIfDateTimePatternsSupported
{%
  \edef\@locale@query@params{\@locale@query@params \string-M }
}
{}
\ifx\LocaleMainFile\empty
\else
 \edef\@locale@query@params{\@locale@query@params
   \string-d \@texosquery@argquote{\LocaleMainFile}
 }
\fi
\ifx\LocaleMain\@locale@os@default
 \LocaleIfDateTimePatternsSupported
 {%
   \edef\@locale@query@params{\@locale@query@params
     \string-D \string-Z
   }
 }
 {
   \edef\@locale@query@params{\@locale@query@params
     \string-D
   }
 }
\else
 \LocaleIfDateTimePatternsSupported
 {%
   \edef\@locale@query@params{\@locale@query@params
     \string-D \LocaleMain\space\string-Z \LocaleMain\space
   }
 }
 {
   \edef\@locale@query@params{\@locale@query@params
     \string-D \LocaleMain\space
   }
 }
\fi
\@tracklang@for\@locale@tag:=\LocaleOther\do{%
  \ifx\@locale@tag\@locale@os@default
   \LocaleIfDateTimePatternsSupported
   {%
     \edef\@locale@query@params{\@locale@query@params
       \string-D \string-Z
     }
   }
   {%
     \edef\@locale@query@params{\@locale@query@params
       \string-D
     }
   }
  \else
   \LocaleIfDateTimePatternsSupported
   {%
     \edef\@locale@query@params{\@locale@query@params
       \string-D \@locale@tag\space\string-Z \@locale@tag\space
     }
   }
   {%
     \edef\@locale@query@params{\@locale@query@params
       \string-D \@locale@tag\space
     }
   }
  \fi
}
\csname localeprequery\endcsname
\ifx\LocaleQueryFile\undefined
  \TeXOSQuery{\@locale@result}{\@locale@query@params}
\else
  \ifx\LocaleQueryFile\empty
    \TeXOSQuery{\@locale@result}{\@locale@query@params}
  \else
    \ifx\TeXOSQueryFromFile\undefined
      \@locale@err{texosquery too old to support
      \string\LocaleQueryFile. At least v1.4 required}
      {You need to update your version of texosquery}
      \def\@locale@result{}
    \else
      \@locale@info{Fetching query results from `\LocaleQueryFile'}%
      \TeXOSQueryFromFile{\@locale@result}{\LocaleQueryFile}
    \fi
  \fi
\fi
\global\let\@locale@result\@locale@result
\csname localepostquery\endcsname
\def\LocaleSetAttribute#1#2#3{%
  \expandafter\def\csname locale@#2@#1\endcsname{#3}%
}
\def\LocaleAppToAttribute#1#2#3{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \expandafter\expandafter\expandafter\def
      \expandafter\expandafter\csname locale@#2@#1\expandafter\endcsname
      \expandafter\expandafter\expandafter{\csname locale@#2@#1\endcsname#3}%
  }%
  {\expandafter\def\csname locale@#2@#1\endcsname{#3}}%
}
\def\LocaleXpAppToAttribute#1#2#3{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \expandafter\expandafter\expandafter\def
      \expandafter\expandafter\csname locale@#2@#1\expandafter\endcsname
      \expandafter\expandafter\expandafter{%
        \csname locale@#2@#1\expandafter\endcsname#3}%
  }%
  {%
   \expandafter\def\csname locale@#2@#1\expandafter\endcsname\expandafter{#3}%
  }%
}
\def\LocaleAddToAttributeList#1#2#3{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \LocaleIfInAttributeList{#1}{#2}{#3}%
    {}%
    {\LocaleAppToAttribute{#1}{#2}{,#3}}%
  }%
  {\LocaleSetAttribute{#1}{#2}{#3}}%
}
\def\LocaleXpAddToAttributeList#1#2#3{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \LocaleIfXpInAttributeList{#1}{#2}{#3}%
    {}%
    {\LocaleXpAppToAttribute{#1}{#2}{\expandafter,#3}}%
  }%
  {\expandafter\def\csname locale@#2@#1\expandafter\endcsname\expandafter{#3}}%
}
\def\localeshowattribute#1#2{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \expandafter\show\csname locale@#2@#1\endcsname
  }%
  {\@locale@err{Attribute `#2' not defined for `#1'}%
  {\string\localeshowattribute\space was asked to show this
   attribute for the given attribute type, but the
   associated command hasn't been defined}}%
}
\def\LocaleProvideAttribute#1#2#3{%
  \LocaleIfHasAttribute{#1}{#2}%
  {}%
  {\LocaleSetAttribute{#1}{#2}{#3}}%
}
\def\LocaleLetAttribute#1#2#3{%
  \expandafter\let\csname locale@#2@#1\endcsname#3%
}
\def\LocaleGetAttributeOrDefValue#1#2#3{%
  \@tracklang@ifundef{locale@#2@#1}%
  {#3\@locale@undef@action{#1}{#2}}%
  {\csname locale@#2@#1\endcsname}%
}
\def\LocaleGetAttribute#1#2{%
 \LocaleGetAttributeOrDefValue{#1}{#2}{}%
}
\def\@locale@undef@action#1#2{}
\def\LocaleIfHasAttribute#1#2#3#4{%
  \@tracklang@ifundef{locale@#2@#1}%
  {#4}%
  {#3}%
}
\def\LocaleForEachInAttributeList#1#2#3#4{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \expandafter\@tracklang@for\expandafter#3\expandafter:\expandafter
      =\csname locale@#2@#1\endcsname\do{#4}%
  }%
  {}%
}
\def\LocaleIfInAttributeList#1#2#3#4#5{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \expandafter\let\expandafter\@locale@attrlist\csname locale@#2@#1\endcsname
    \@tracklang@ifinlist{#3}{\@locale@attrlist}{#4}{#5}%
  }%
  {#5}%
}
\def\LocaleIfXpInAttributeList#1#2#3#4#5{%
  \LocaleIfHasAttribute{#1}{#2}%
  {%
    \expandafter\let\expandafter\@locale@attrlist\csname locale@#2@#1\endcsname
    \expandafter\@tracklang@ifinlist\expandafter{#3}{\@locale@attrlist}{#4}{#5}%
  }%
  {#5}%
}
\def\LocaleIfHasNonEmptyAttribute#1#2#3#4{%
  \@tracklang@ifundef{locale@#2@#1}%
  {#4}%
  {%
    \expandafter\ifx\csname locale@#2@#1\endcsname\empty
      #4%
    \else
      #3%
    \fi
  }%
}
\def\LocaleIfAttributeEqCs#1#2#3#4#5{%
  \expandafter\ifx\csname locale@#2@#1\endcsname#3%
    #4%
  \else
    #5%
  \fi
}
\def\LocaleIfAttributeEqCsName#1#2#3#4#5{%
  \expandafter\ifx
    \csname locale@#2@#1\expandafter\endcsname
    \csname #3\endcsname
    #4%
  \else
    #5%
  \fi
}
\def\LocaleIfAttributeEqNum#1#2#3#4#5{%
  \LocaleIfHasNonEmptyAttribute{#1}{#2}%
  {%
    \expandafter\ifnum\csname locale@#2@#1\endcsname=#3
      #4%
    \else
      #5%
    \fi
  }%
  {#5}%
}
\def\LocaleIfSameAttributeValues#1#2#3#4#5{%
  \expandafter\ifx
    \csname locale@#2@#1\expandafter\endcsname
    \csname locale@#3@#1\endcsname
    #4%
  \else
    #5%
  \fi
}
\def\localeshowdialectattribute#1#2{%
  \localeshowattribute{#1}{dialect@#2}%
}
\def\LocaleSetDialectAttribute#1#2#3{%
  \LocaleSetAttribute{#1}{dialect@#2}{#3}%
}
\def\LocaleProvideDialectAttribute#1#2#3{%
  \LocaleProvideAttribute{#1}{dialect@#2}{#3}%
}
\def\LocaleLetDialectAttribute#1#2#3{%
  \LocaleLetAttribute{#1}{dialect@#2}{#3}%
}
\def\LocaleAppToDialectAttribute#1#2#3{%
  \LocaleAppToAttribute{#1}{dialect@#2}{#3}%
}
\def\LocaleXpAppToDialectAttribute#1#2#3{%
  \LocaleXpAppToAttribute{#1}{dialect@#2}{#3}%
}
\def\LocaleAddToDialectAttributeList#1#2{%
  \LocaleAddToAttributeList{#1}{dialect@#2}%
}
\def\LocaleXpAddToDialectAttributeList#1#2{%
  \LocaleXpAddToAttributeList{#1}{dialect@#2}%
}
\def\LocaleGetDialectAttribute#1#2{%
   \LocaleGetAttribute{#1}{dialect@#2}%
}
\def\LocaleGetDialectAttributeOrDefValue#1#2{%
   \LocaleGetAttributeOrDefValue{#1}{dialect@#2}%
}
\def\LocaleIfHasDialectAttribute#1#2{%
  \LocaleIfHasAttribute{#1}{dialect@#2}%
}
\def\LocaleForEachInDialectAttributeList#1#2{%
  \LocaleForEachInAttributeList{#1}{dialect@#2}%
}
\def\LocaleIfInDialectAttributeList#1#2{%
  \LocaleIfInAttributeList{#1}{dialect@#2}%
}
\def\LocaleIfXpInDialectAttributeList#1#2{%
  \LocaleIfXpInAttributeList{#1}{dialect@#2}%
}
\def\LocaleIfHasDialectNonEmptyAttribute#1#2{%
  \LocaleIfHasNonEmptyAttribute{#1}{dialect@#2}%
}
\def\LocaleIfDialectAttributeEqCs#1#2#3{%
  \LocaleIfAttributeEqCs{#1}{dialect@#2}{#3}%
}
\def\LocaleIfDialectAttributeEqCsName#1#2#3{%
  \LocaleIfAttributeEqCsName{#1}{dialect@#2}{#3}%
}
\def\LocaleIfDialectAttributeEqNum#1#2#3{%
  \LocaleIfAttributeEqNum{#1}{dialect@#2}{#3}%
}
\def\LocaleIfSameDialectAttributeValues#1#2#3{%
  \LocaleIfSameAttributeValues{#1}{dialect@#2}{dialect@#3}%
}
\def\localeshowregionattribute#1#2{%
  \localeshowattribute{#1}{region@#2}%
}
\def\LocaleSetRegionAttribute#1#2#3{%
  \LocaleSetAttribute{#1}{region@#2}{#3}%
}
\def\LocaleProvideRegionAttribute#1#2#3{%
  \LocaleProvideAttribute{#1}{region@#2}{#3}%
}
\def\LocaleLetRegionAttribute#1#2#3{%
  \LocaleLetAttribute{#1}{region@#2}{#3}%
}
\def\LocaleAppToRegionAttribute#1#2#3{%
  \LocaleAppToAttribute{#1}{region@#2}{#3}%
}
\def\LocaleXpAppToRegionAttribute#1#2#3{%
  \LocaleXpAppToAttribute{#1}{region@#2}{#3}%
}
\def\LocaleAddToRegionAttributeList#1#2{%
  \LocaleAddToAttributeList{#1}{region@#2}%
}
\def\LocaleXpAddToRegionAttributeList#1#2{%
  \LocaleXpAddToAttributeList{#1}{region@#2}%
}
\def\LocaleGetRegionAttribute#1#2{%
   \LocaleGetAttribute{#1}{region@#2}%
}
\def\LocaleGetRegionAttributeOrDefValue#1#2{%
   \LocaleGetAttributeOrDefValue{#1}{region@#2}%
}
\def\LocaleIfHasRegionAttribute#1#2{%
  \LocaleIfHasAttribute{#1}{region@#2}%
}
\def\LocaleForEachInRegionAttributeList#1#2{%
  \LocaleForEachInAttributeList{#1}{region@#2}%
}
\def\LocaleIfInRegionAttributeList#1#2{%
  \LocaleIfInAttributeList{#1}{region@#2}%
}
\def\LocaleIfXpInRegionAttributeList#1#2{%
  \LocaleIfXpInAttributeList{#1}{region@#2}%
}
\def\LocaleIfHasRegionNonEmptyAttribute#1#2{%
  \LocaleIfHasNonEmptyAttribute{#1}{region@#2}%
}
\def\LocaleIfRegionAttributeEqCs#1#2#3{%
  \LocaleIfAttributeEqCs{#1}{region@#2}{#3}%
}
\def\LocaleIfRegionAttributeEqCsName#1#2#3{%
  \LocaleIfAttributeEqCsName{#1}{region@#2}{#3}%
}
\def\LocaleIfRegionAttributeEqNum#1#2#3{%
  \LocaleIfAttributeEqNum{#1}{region@#2}{#3}%
}
\def\LocaleIfSameRegionAttributeValues#1#2#3{%
  \LocaleIfSameAttributeValues{#1}{region@#2}{region@#3}%
}
\def\localeshowcurrencyattribute#1#2{%
  \localeshowattribute{#1}{currency@#2}%
}
\def\LocaleSetCurrencyAttribute#1#2#3{%
  \LocaleSetAttribute{#1}{currency@#2}{#3}%
}
\def\LocaleProvideCurrencyAttribute#1#2#3{%
  \LocaleProvideAttribute{#1}{currency@#2}{#3}%
}
\def\LocaleLetCurrencyAttribute#1#2#3{%
  \LocaleLetAttribute{#1}{currency@#2}{#3}%
}
\def\LocaleAppToCurrencyAttribute#1#2#3{%
  \LocaleAppToAttribute{#1}{currency@#2}{#3}%
}
\def\LocaleXpAppToCurrencyAttribute#1#2#3{%
  \LocaleXpAppToAttribute{#1}{currency@#2}{#3}%
}
\def\LocaleAddToCurrencyAttributeList#1#2{%
  \LocaleAddToAttributeList{#1}{currency@#2}%
}
\def\LocaleXpAddToCurrencyAttributeList#1#2{%
  \LocaleXpAddToAttributeList{#1}{currency@#2}%
}
\def\LocaleGetCurrencyAttribute#1#2{%
   \LocaleGetAttribute{#1}{currency@#2}%
}
\def\LocaleGetCurrencyAttributeOrDefValue#1#2{%
   \LocaleGetAttributeOrDefValue{#1}{currency@#2}%
}
\def\LocaleIfHasCurrencyAttribute#1#2{%
  \LocaleIfHasAttribute{#1}{currency@#2}%
}
\def\LocaleForEachInCurrencyAttributeList#1#2{%
  \LocaleForEachInAttributeList{#1}{currency@#2}%
}
\def\LocaleIfInCurrencyAttributeList#1#2{%
  \LocaleIfInAttributeList{#1}{currency@#2}%
}
\def\LocaleIfXpInCurrencyAttributeList#1#2{%
  \LocaleIfXpInAttributeList{#1}{currency@#2}%
}
\def\LocaleIfHasCurrencyNonEmptyAttribute#1#2{%
  \LocaleIfHasNonEmptyAttribute{#1}{currency@#2}%
}
\def\LocaleIfCurrencyAttributeEqCs#1#2#3{%
  \LocaleIfAttributeEqCs{#1}{currency@#2}{#3}%
}
\def\LocaleIfCurrencyAttributeEqCsName#1#2#3{%
  \LocaleIfAttributeEqCsName{#1}{currency@#2}{#3}%
}
\def\LocaleIfCurrencyAttributeEqNum#1#2#3{%
  \LocaleIfAttributeEqNum{#1}{currency@#2}{#3}%
}
\def\LocaleIfSameCurrencyAttributeValues#1#2#3{%
  \LocaleIfSameAttributeValues{#1}{currency@#2}{currency@#3}%
}
\def\@locale@parse@result#1#2#3#4#5#6{%
  \def\LocaleOSname{#1}%
  \def\LocaleOSversion{#2}%
  \def\LocaleOSarch{#3}%
  \def\LocaleNowStamp{#4}%
  \@locale@parse@default#5% remove outer group
  \def\LocaleOScodeset{#6}%
 \LocaleIfDateTimePatternsSupported
 {%
    \let\@locale@next\@locale@parse@datetimeinfo
 }%
 {%
    \def\LocaleDateTimeInfo{}%
    \ifx\LocaleMainFile\empty
      \def\LocaleFileMod{}%
      \let\@locale@next\@locale@parse@maindata
    \else
      \let\@locale@next\@locale@parse@filemod
    \fi
  }%
  \@locale@next
}
\def\@locale@parse@datetimeinfo#1{%
  \def\LocaleDateTimeInfo{#1}%
  \ifx\LocaleMainFile\empty
    \def\LocaleFileMod{}%
    \let\@locale@next\@locale@parse@maindata
  \else
    \let\@locale@next\@locale@parse@filemod
  \fi
  \@locale@next
}
\def\@locale@parse@default#1#2#3#4#5#6#7#8#9{%
  \def\LocaleOStag{#1}%
  \@tracklang@parselangtag{#1}%
  \let\@locale@os@region\@TrackLangEnvTerritory
  \def\@locale@os@groupsep{#2}%
  \def\@locale@os@decsep{#3}%
  \def\@locale@os@exp{#4}%
  \def\@locale@os@usesgroup{#5}%
  \def\@locale@os@currencycode{#6}%
  \def\@locale@os@regionalcurrencycode{#7}%
  \def\@locale@os@currencysym{#8}%
  \def\@locale@os@currencytex{#9}%
  \LocaleSetRegionAttribute{\@locale@os@region}{currency}{#7}%
  \LocaleProvideCurrencyAttribute{#7}{official}{#6}%
  \LocaleProvideCurrencyAttribute{#7}{sym}{#8}%
  \LocaleProvideCurrencyAttribute{#7}{tex}{#9}%
  \@locale@parse@default@cursep
}
\def\@locale@parse@default@cursep#1{%
  \def\@locale@os@cursep{#1}%
}
\def\@locale@parse@filemod#1{%
  \def\LocaleFileMod{#1}%
  \@locale@parse@maindata
}
\def\@locale@parse@maindata#1{%
  \@locale@parse@maindatablock#1% remove outer group
}
\def\@locale@parse@maindatablock#1{%
  \@locale@parse@maindatalocaleblock#1% remove outer group
  \@locale@parse@dateblock
}
\def\@locale@parse@maindatalocaleblock#1#2#3#4#5#6#7{%
  \def\LocaleMain{#1}%
  \TrackLanguageTag{#1}%
  \let\LocaleMainDialect\TrackLangLastTrackedDialect
  \let\@locale@dialect\TrackLangLastTrackedDialect
  \IfTrackedLanguageHasIsoCode{3166-1}{\@locale@dialect}%
  {%
    \edef\@locale@region{%
     \TrackedIsoCodeFromLanguage{3166-1}{\@locale@dialect}}%
  }%
  {\def\@locale@region{}}%
  \let\LocaleMainRegion\@locale@region
  \ifx\LocaleMainRegion\empty
  \else
    \LocaleLetRegionAttribute{\LocaleMainRegion}{dialect}{\@locale@dialect}%
  \fi
  \LocaleSetDialectAttribute{\@locale@dialect}{langtag}{#1}%
  \LocaleLetAttribute{#1}{tagtodialect}{\@locale@dialect}%
  \LocaleSetDialectAttribute{\@locale@dialect}{langname}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{nativelangname}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{regionname}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{nativeregionname}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{variantname}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{nativevariantname}{#7}%
}
\def\@locale@parse@otherdatalocaleblock#1#2#3#4#5#6#7{%
  \TrackLanguageTag{#1}%
  \let\@locale@dialect\TrackLangLastTrackedDialect
  \IfTrackedLanguageHasIsoCode{3166-1}{\@locale@dialect}%
  {%
    \edef\@locale@region{%
     \TrackedIsoCodeFromLanguage{3166-1}{\@locale@dialect}}%
     \ifx\@locale@region\empty
     \else
       \LocaleXpAddToRegionAttributeList
         {\@locale@region}{dialect}{\@locale@dialect}%
     \fi
  }%
  {\def\@locale@region{}}%
  \LocaleSetDialectAttribute{\@locale@dialect}{langtag}{#1}%
  \LocaleLetAttribute{#1}{tagtodialect}{\@locale@dialect}%
  \LocaleSetDialectAttribute{\@locale@dialect}{langname}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{nativelangname}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{regionname}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{nativeregionname}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{variantname}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{nativevariantname}{#7}%
}
\def\@locale@parse@dateblock#1{%
  \@locale@parse@dates#1% remove outer group
  \@locale@parse@datefmtblock
}
\def\@locale@parse@dates#1#2#3#4#5{%
  \LocaleSetDialectAttribute{\@locale@dialect}{fulldate}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{longdate}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{meddate}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortdate}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{firstday}{#5}%
}
\def\@locale@parse@datefmtblock#1{%
  \@locale@parse@datefmts#1% remove outer group
  \@locale@parse@timeblock
}
\def\@locale@parse@datefmts#1#2#3#4{%
  \LocaleSetDialectAttribute{\@locale@dialect}{fulldatefmt}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{longdatefmt}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{meddatefmt}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortdatefmt}{#4}%
}
\def\@locale@parse@timeblock#1{%
  \@locale@parse@times#1% remove outer group
  \@locale@parse@timefmtblock
}
\def\@locale@parse@times#1#2#3#4{%
  \LocaleSetDialectAttribute{\@locale@dialect}{fulltime}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{longtime}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{medtime}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shorttime}{#4}%
}
\def\@locale@parse@timefmtblock#1{%
  \@locale@parse@timefmts#1% remove outer group
  \@locale@parse@datetimeblock
}
\def\@locale@parse@timefmts#1#2#3#4{%
  \LocaleSetDialectAttribute{\@locale@dialect}{fulltimefmt}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{longtimefmt}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{medtimefmt}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shorttimefmt}{#3}%
}
\def\@locale@parse@datetimeblock#1{%
  \@locale@parse@datetimes#1% remove outer group
  \@locale@parse@datetimefmtblock
}
\def\@locale@parse@datetimes#1#2#3#4{%
  \LocaleSetDialectAttribute{\@locale@dialect}{fulldatetime}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{longdatetime}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{meddatetime}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortdatetime}{#4}%
}
\def\@locale@parse@datetimefmtblock#1{%
  \@locale@parse@datetimefmts#1% remove outer group
  \@locale@parse@weekdayblock
}
\def\@locale@parse@datetimefmts#1#2#3#4{%
  \LocaleSetDialectAttribute{\@locale@dialect}{fulldatetimefmt}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{longdatetimefmt}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{meddatetimefmt}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortdatetimefmt}{#4}%
}
\def\@locale@parse@weekdayblock#1{%
  \@locale@parse@weekdays#1% remove outer group
  \@locale@parse@shortweekdayblock
}
\def\@locale@parse@weekdays#1#2#3#4#5#6#7{%
  \LocaleSetDialectAttribute{\@locale@dialect}{day.0}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{day.1}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{day.2}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{day.3}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{day.4}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{day.5}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{day.6}{#7}%
}
\def\@locale@parse@shortweekdayblock#1{%
  \@locale@parse@shortweekdays#1% remove outer group
  \@locale@parse@monthblock
}
\def\@locale@parse@shortweekdays#1#2#3#4#5#6#7{%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortday.0}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortday.1}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortday.2}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortday.3}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortday.4}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortday.5}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortday.6}{#7}%
}
\def\@locale@parse@monthblock#1{%
  \@locale@parse@months#1% remove outer group
  \@locale@parse@shortmonthblock
}
\def\@locale@parse@months#1#2#3#4#5#6#7#8#9{%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.1}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.2}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.3}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.4}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.5}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.6}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.7}{#7}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.8}{#8}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.9}{#9}%
  \@locale@parse@endmonths
}
\def\@locale@parse@endmonths#1#2#3{%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.10}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.11}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{month.12}{#3}%
}
\def\@locale@parse@shortmonthblock#1{%
  \@locale@parse@shortmonths#1% remove outer group
  \@locale@parse@standalone@weekdayblock
}
\def\@locale@parse@shortmonths#1#2#3#4#5#6#7#8#9{%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.1}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.2}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.3}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.4}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.5}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.6}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.7}{#7}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.8}{#8}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.9}{#9}%
  \@locale@parse@endshortmonths
}
\def\@locale@parse@endshortmonths#1#2#3{%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.10}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.11}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{shortmonth.12}{#3}%
}
\def\@locale@parse@standalone@weekdayblock#1{%
  \@locale@parse@standalone@weekdays#1% remove outer group
  \@locale@parse@standalone@shortweekdayblock
}
\def\@locale@parse@standalone@weekdays#1#2#3#4#5#6#7{%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.day.0}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.day.1}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.day.2}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.day.3}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.day.4}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.day.5}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.day.6}{#7}%
}
\def\@locale@parse@standalone@shortweekdayblock#1{%
  \@locale@parse@standalone@shortweekdays#1% remove outer group
  \@locale@parse@standalone@monthblock
}
\def\@locale@parse@standalone@shortweekdays#1#2#3#4#5#6#7{%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortday.0}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortday.1}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortday.2}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortday.3}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortday.4}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortday.5}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortday.6}{#7}%
}
\def\@locale@parse@standalone@monthblock#1{%
  \@locale@parse@standalone@months#1% remove outer group
  \@locale@parse@standalone@shortmonthblock
}
\def\@locale@parse@standalone@months#1#2#3#4#5#6#7#8#9{%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.1}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.2}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.3}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.4}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.5}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.6}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.7}{#7}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.8}{#8}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.9}{#9}%
  \@locale@parse@endstandalone@months
}
\def\@locale@parse@endstandalone@months#1#2#3{%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.10}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.11}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.month.12}{#3}%
}
\def\@locale@parse@standalone@shortmonthblock#1{%
  \@locale@parse@standalone@shortmonths#1% remove outer group
  \@locale@parse@numericblock
}
\def\@locale@parse@standalone@shortmonths#1#2#3#4#5#6#7#8#9{%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.1}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.2}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.3}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.4}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.5}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.6}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.7}{#7}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.8}{#8}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.9}{#9}%
  \@locale@parse@endstandalone@shortmonths
}
\def\@locale@parse@endstandalone@shortmonths#1#2#3{%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.10}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.11}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{standalone.shortmonth.12}{#3}%
}
\def\@locale@parse@numericblock#1{%
  \@locale@parse@numeric#1% remove outer group
  \@locale@parse@numericfmtblock
}
\def\@locale@parse@numeric#1#2#3#4#5#6#7#8#9{%
  \LocaleSetDialectAttribute{\@locale@dialect}{groupsep}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{decsep}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{exp}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{usesgroup}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{currency}{#5}%
  \LocaleSetDialectAttribute{\@locale@dialect}{regionalcurrency}{#6}%
  \LocaleSetDialectAttribute{\@locale@dialect}{currencysym}{#7}%
  \LocaleSetDialectAttribute{\@locale@dialect}{currencytex}{#8}%
  \LocaleSetDialectAttribute{\@locale@dialect}{currencysep}{#9}%
  \LocaleProvideCurrencyAttribute{#6}{official}{#5}%
  \LocaleProvideCurrencyAttribute{#6}{sym}{#7}%
  \LocaleProvideCurrencyAttribute{#6}{tex}{#8}%
  \LocaleAddToAttributeList{currencies}{official}{#5}%
  \LocaleAddToAttributeList{currencies}{regional}{#6}%
  \ifx\@locale@region\empty
  \else
    \LocaleProvideRegionAttribute{\@locale@region}{currency}{#6}%
    \LocaleXpAddToCurrencyAttributeList{#5}{region}{\@locale@region}%
    \LocaleIfSameDialectAttributeValues{\@locale@dialect}%
    {regionalcurrency}{currency}%
    {}%
    {%
      \LocaleXpAddToCurrencyAttributeList{#6}{region}{\@locale@region}%
    }%
  \fi
  \@locale@parse@persym
}
\def\@locale@parse@persym#1#2{%
  \LocaleSetDialectAttribute{\@locale@dialect}{percent}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{permill}{#2}%
}
\def\@locale@parse@numericfmtblock#1{%
  \@locale@parse@numericfmt#1% remove outer group
  \LocaleIfDateTimePatternsSupported
  {\@locale@parse@timezones}%
  {\@locale@parse@otherdata}%
}
\def\@locale@parse@numericfmt#1#2#3#4{%
  \LocaleSetDialectAttribute{\@locale@dialect}{decfmt}{#1}%
  \LocaleSetDialectAttribute{\@locale@dialect}{intfmt}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{curfmt}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{perfmt}{#4}%
}
\def\@locale@parse@timezones#1{%
  \@locale@parse@timezonemap#1\relax
  \@locale@parse@otherdata
}
\def\@locale@parse@timezonemap#1{%
  \ifx\relax#1\relax
    \let\@locale@next\relax
  \else
    \@locale@save@timezonemap#1%
    \let\@locale@next\@locale@parse@timezonemap
  \fi
  \@locale@next
}%
\def\@locale@save@timezonemap#1#2#3#4#5{%
  \LocaleSetDialectAttribute{\@locale@dialect}{timezone.#1.short}{#2}%
  \LocaleSetDialectAttribute{\@locale@dialect}{timezone.#1.long}{#3}%
  \LocaleSetDialectAttribute{\@locale@dialect}{timezone.#1.shortdst}{#4}%
  \LocaleSetDialectAttribute{\@locale@dialect}{timezone.#1.longdst}{#5}%
  \LocaleAddToAttributeList{timezone}{id}{#1}%
}
\def\@locale@endparse@result{}
\def\@locale@parse@otherdata#1{%
 \ifx\@locale@endparse@result#1\relax
  \let\@locale@next\relax
 \else
  \def\@locale@next{\@locale@parse@otherdata@localeblock#1}%
 \fi
 \@locale@next
}
\def\@locale@parse@otherdata@localeblock#1{%
  \@locale@parse@otherdatalocaleblock#1% remove outer group
  \@locale@parse@dateblock
}
\ifx\@locale@result\empty
  \ifTeXOSQueryDryRun
    \@locale@warn{Dry run mode on. No data provided by texosquery. Check
    TeX's shell escape status}%
  \else
  \@locale@warn{No data provided by texosquery. Check
    TeX's shell escape status and texosquery's setup}%
  \fi
  \def\LocaleOSname{}%
  \def\LocaleOSversion{}%
  \def\LocaleOSarch{}%
  \def\LocaleNowStamp{}%
  \def\LocaleOStag{}%
  \def\LocaleOScodeset{}%
  \def\LocaleFileMod{}%
  \def\LocaleMain{}%
  \def\LocaleMainDialect{}%
  \def\LocaleMainRegion{}%
  \def\LocaleDateTimeInfo{}%
\else
  \expandafter\@locale@parse@result\@locale@result\@locale@endparse@result
\fi
\def\LocaleLanguageTag#1{%
 \LocaleGetDialectAttribute{#1}{langtag}%
}
\def\LocaleLanguageName#1{%
 \LocaleGetDialectAttribute{#1}{langname}%
}
\def\LocaleLanguageNativeName#1{%
 \LocaleGetDialectAttribute{#1}{nativelangname}%
}
\def\LocaleRegionName#1{%
 \LocaleGetDialectAttribute{#1}{regionname}%
}
\def\LocaleRegionNativeName#1{%
 \LocaleGetDialectAttribute{#1}{nativeregionname}%
}
\def\LocaleVariantName#1{%
 \LocaleGetDialectAttribute{#1}{variantname}%
}
\def\LocaleVariantNativeName#1{%
 \LocaleGetDialectAttribute{#1}{nativevariantname}%
}
\def\LocaleFullDate#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{fulldate}}%
}
\def\LocaleLongDate#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{longdate}}%
}
\def\LocaleMediumDate#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{meddate}}%
}
\def\LocaleShortDate#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{shortdate}}%
}
\def\LocaleFirstDayIndex#1{%
 \LocaleGetDialectAttributeOrDefValue{#1}{firstday}{-1}%
}
\def\dtmMondayIndex{0}
\def\dtmTuesdayIndex{1}
\def\dtmWednesdayIndex{2}
\def\dtmThursdayIndex{3}
\def\dtmFridayIndex{4}
\def\dtmSaturdayIndex{5}
\def\dtmSundayIndex{6}
\def\LocaleDayIndexFromZeroMonToOneSun#1{%
  \ifcase#1
  2% Monday 0 -> 2
  \or
  3% Tuesday 1 -> 3
  \or
  4% Wednesday 2 -> 4
  \or
  5% Thursday 3 -> 5
  \or
  6% Friday 4 -> 6
  \or
  7% Saturday 5 -> 7
  \or
  1% Sunday 6 -> 1
  \else
  -1% invalid
  \fi
}
\def\LocaleDayIndexFromZeroMonToOneMon#1{%
  \ifcase#1
  1% Monday 0 -> 1
  \or
  2% Tuesday 1 -> 2
  \or
  3% Wednesday 2 -> 3
  \or
  4% Thursday 3 -> 4
  \or
  5% Friday 4 -> 5
  \or
  6% Saturday 5 -> 6
  \or
  7% Sunday 6 -> 7
  \else
  -1% invalid
  \fi
}
\def\LocaleDayIndexFromOneSunToZeroMon#1{%
  \ifcase#1
  % no 0
  \or
  6% Sunday 1 -> 6
  \or
  0% Monday 2 -> 0
  \or
  1% Tuesday 3 -> 1
  \or
  2% Wednesday 4 -> 2
  \or
  3% Thursday 5 -> 3
  \or
  4% Friday 6 -> 4
  \or
  5% Saturday 7 -> 5
  \else
  -1% invalid
  \fi
}
\def\LocaleDayIndexFromOneMonToZeroMon#1{%
  \ifcase#1
  % no 0
  \or
  0% Monday 1 -> 0
  \or
  1% Tuesday 2 -> 1
  \or
  2% Wednesday 3 -> 2
  \or
  3% Thursday 4 -> 3
  \or
  4% Friday 5 -> 4
  \or
  5% Saturday 6 -> 5
  \or
  6% Sunday 7 -> 6
  \else
  -1% invalid
  \fi
}
\def\LocaleDayIndexFromRegion#1#2{%
  \ifcase\LocaleFirstDayIndex{#1}
    \LocaleDayIndexFromOneMonToZeroMon{#2}%
  \or
    \ifnum#2=7 % Monday
      0%
    \else
      #2%
    \fi
  \or
    \ifcase#1
    % no 0
    \or
    2% Wednesday 1 -> 2
    \or
    3% Thursday 2 -> 3
    \or
    4% Friday 3 -> 4
    \or
    5% Saturday 4 -> 5
    \or
    6% Sunday 5 -> 6
    \or
    0% Monday 6 -> 0
    \or
    1% Tuesday 7 -> 1
    \else
    -1% invalid
    \fi
  \or
    \ifcase#1
    % no 0
    \or
    3% Thursday 1 -> 3
    \or
    4% Friday 2 -> 4
    \or
    5% Saturday 3 -> 5
    \or
    6% Sunday 4 -> 6
    \or
    0% Monday 5 -> 0
    \or
    1% Tuesday 6 -> 1
    \or
    2% Wednesday 7 -> 2
    \else
    -1% invalid
    \fi
  \or
    \ifcase#1
    % no 0
    \or
    4% Friday 1 -> 4
    \or
    5% Saturday 2 -> 5
    \or
    6% Sunday 3 -> 6
    \or
    0% Monday 4 -> 0
    \or
    1% Tuesday 5 -> 1
    \or
    2% Wednesday 6 -> 2
    \or
    3% Thursday 7 -> 3
    \else
    -1% invalid
    \fi
  \or
    \ifcase#1
    % no 0
    \or
    5% Saturday 1 -> 5
    \or
    6% Sunday 2 -> 6
    \or
    0% Monday 3 -> 0
    \or
    1% Tuesday 4 -> 1
    \or
    2% Wednesday 5 -> 2
    \or
    3% Thursday 6 -> 3
    \or
    4% Friday 7 -> 4
    \else
    -1% invalid
    \fi
  \or
    \LocaleDayIndexFromOneSunToZeroMon{#2}%
  \else
    #2%
  \fi
}
\def\LocaleDayIndexToRegion#1#2{%
  \ifcase\LocaleFirstDayIndex{#1}
    \LocaleDayIndexFromZeroMonToOneMon{#2}%
  \or
    \ifnum#2=0 % Monday
      7%
    \else
      #2%
    \fi
  \or
    \ifcase#1
     6% Monday 0 -> 6
    \or
     7% Tuesday 1 -> 7
    \or
     1% Wednesday 2 -> 1
    \or
     2% Thursday 3 -> 2
    \or
     3% Friday 4 -> 3
    \or
     4% Saturday 5 -> 4
    \or
     5% Sunday 6 -> 5
    \else
    -1% invalid
    \fi
  \or
    \ifcase#1
     5% Monday 0 -> 5
    \or
     6% Tuesday 1 -> 6
    \or
     7% Wednesday 2 -> 7
    \or
     1% Thursday 3 -> 1
    \or
     2% Friday 4 -> 2
    \or
     3% Saturday 5 -> 3
    \or
     4% Sunday 6 -> 4
    \else
    -1% invalid
    \fi
  \or
    \ifcase#1
     4% Monday 0 -> 4
    \or
     5% Tuesday 1 -> 5
    \or
     6% Wednesday 2 -> 6
    \or
     7% Thursday 3 -> 7
    \or
     1% Friday 4 -> 1
    \or
     2% Saturday 5 -> 2
    \or
     3% Sunday 6 -> 3
    \else
    -1% invalid
    \fi
  \or
    \ifcase#1
     3% Monday 0 -> 3
    \or
     4% Tuesday 1 -> 4
    \or
     5% Wednesday 2 -> 5
    \or
     6% Thursday 3 -> 6
    \or
     7% Friday 4 -> 7
    \or
     1% Saturday 5 -> 1
    \or
     2% Sunday 6 -> 2
    \else
    -1% invalid
    \fi
  \or
    \LocaleDayIndexFromZeroMonToOneSun{#2}%
  \else
    #2%
  \fi
}
\def\LocaleFullTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{fulltime}}%
}
\def\LocaleLongTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{longtime}}%
}
\def\LocaleMediumTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{medtime}}%
}
\def\LocaleShortTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{shorttime}}%
}
\def\LocaleFullDateTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{fulldatetime}}%
}
\def\LocaleLongDateTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{longdatetime}}%
}
\def\LocaleMediumDateTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{meddatetime}}%
}
\def\LocaleShortDateTime#1{%
 \localedatetimefmt{\LocaleGetDialectAttribute{#1}{shortdatetime}}%
}
\def\LocaleDayName#1#2{%
 \LocaleGetDialectAttribute{#1}{day.\number#2}%
}
\def\LocaleShortDayName#1#2{%
 \LocaleGetDialectAttribute{#1}{shortday.\number#2}%
}
\def\LocaleMonthName#1#2{%
 \LocaleGetDialectAttribute{#1}{month.\number#2}%
}
\def\LocaleShortMonthName#1#2{%
 \LocaleGetDialectAttribute{#1}{shortmonth.\number#2}%
}
\def\LocaleStandaloneDayName#1#2{%
 \LocaleGetDialectAttribute{#1}{standalone.day.\number#2}%
}
\def\LocaleStandaloneShortDayName#1#2{%
 \LocaleGetDialectAttribute{#1}{standalone.shortday.\number#2}%
}
\def\LocaleStandaloneMonthName#1#2{%
 \LocaleGetDialectAttribute{#1}{standalone.month.\number#2}%
}
\def\LocaleStandaloneShortMonthName#1#2{%
 \LocaleGetDialectAttribute{#1}{standalone.shortmonth.\number#2}%
}
\def\LocaleNumericGroupSep#1{%
 \LocaleGetDialectAttribute{#1}{groupsep}%
}
\def\LocaleNumericDecimalSep#1{%
 \LocaleGetDialectAttribute{#1}{decsep}%
}
\def\LocaleNumericMonetarySep#1{%
 \LocaleGetDialectAttribute{#1}{currencysep}%
}
\def\LocaleNumericExponent#1{%
 \LocaleGetDialectAttribute{#1}{exp}%
}
\def\LocaleCurrencyLabel#1{%
 \LocaleIfDialectAttributeEqCs{#1}{currency}{\@locale@unknown@currency}%
 {%
   \ifx\LocaleMainRegion\empty
     \@locale@os@currencycode
   \else
     \LocaleGetDialectAttributeOrDefValue{\LocaleMainDialect}{currency}%
     {\@locale@os@currencycode}%
   \fi
 }%
 {\LocaleGetDialectAttribute{#1}{currency}}%
}
\def\LocaleCurrencyRegionalLabel#1{%
 \LocaleIfDialectAttributeEqCs{#1}{regionalcurrency}%
 {\@locale@unknown@currency}%
 {%
   \ifx\LocaleMainRegion\empty
     \@locale@os@regionalcurrencycode
   \else
     \LocaleGetDialectAttributeOrDefValue{\LocaleMainDialect}{regionalcurrency}%
     {\@locale@os@regionalcurrencycode}%
   \fi
 }%
 {\LocaleGetDialectAttribute{#1}{regionalcurrency}}%
}
\def\LocaleCurrencySymbol#1{%
 \LocaleIfDialectAttributeEqCs{#1}{currency}{\@locale@unknown@currency}%
 {%
   \ifx\LocaleMainRegion\empty
     \ifx\@locale@os@currencysym\empty
       \LocaleGetDialectAttribute{#1}{currencysym}%
     \else
       \@locale@os@currencysym
     \fi
   \else
     \LocaleGetDialectAttributeOrDefValue{\LocaleMainDialect}{currencysym}%
     {\LocaleGetDialectAttribute{#1}{currencysym}}%
   \fi
 }%
 {%
   \LocaleIfSameDialectAttributeValues{#1}%
   {currency}{currencysym}%
   {%
     \LocaleGetCurrencyAttributeOrDefValue
     {\LocaleGetDialectAttribute{#1}{currency}}{sym}%
     {\LocaleGetDialectAttribute{#1}{currencysym}}%
   }%
   {%
     \LocaleGetDialectAttribute{#1}{currencysym}%
   }%
 }%
}
\def\LocaleCurrencyTeXSymbol#1{%
 \LocaleIfDialectAttributeEqCs{#1}{currency}{\@locale@unknown@currency}%
 {%
   \ifx\LocaleMainRegion\empty
     \ifx\@locale@os@currencytex\empty
       \LocaleGetDialectAttribute{#1}{currencytex}%
     \else
       \@locale@os@currencytex
     \fi
   \fi
 }%
 {%
   \LocaleIfSameDialectAttributeValues{#1}%
   {currency}{currencytex}%
   {%
     \LocaleGetCurrencyAttributeOrDefValue
     {\LocaleGetDialectAttribute{#1}{currency}}{tex}%
     {\LocaleGetDialectAttribute{#1}{currencytex}}%
   }%
   {%
     \LocaleGetDialectAttribute{#1}{currencytex}%
   }%
 }%
}
\def\LocaleNumericPercent#1{%
 \LocaleGetDialectAttribute{#1}{percent}%
}
\def\LocaleNumericPermill#1{%
 \LocaleGetDialectAttribute{#1}{permill}%
}
\def\LocaleApplyDateTimePattern#1#2#3{%
 \LocaleIfHasDialectNonEmptyAttribute{#1}{#2}%
 {%
   \ifx\empty#3\empty
     \@locale@warn{No date-time data for pattern
       (attribute `#2', dialect `#1')}%
   \else
    \localedatetimefmt
     {\expandafter\texosqueryfmtdatetime
      \csname locale@dialect@#2@#1\expandafter\endcsname#3}%
   \fi
 }%
 {%
   \@locale@warn{No date-time pattern attribute `#2' for dialect `#1'}%
 }%
}
\LocaleIfDateTimePatternsSupported
{%
  \def\texosqueryfmtpatMMM#1{%
    \CurrentLocaleShortMonthName{#1}%
  }
  \def\texosqueryfmtpatMMMM#1{%
    \CurrentLocaleMonthName{#1}%
  }
  \def\texosqueryfmtpatLLL#1{%
    \CurrentLocaleStandaloneShortMonthName{#1}%
  }
  \def\texosqueryfmtpatLLLL#1{%
    \CurrentLocaleStandaloneMonthName{#1}%
  }
  \def\texosqueryfmtpatEEE#1{%
    \CurrentLocaleShortDayName{\LocaleDayIndexFromOneMonToZeroMon{#1}}%
  }
  \def\texosqueryfmtpatEEEE#1{%
    \CurrentLocaleDayName{\LocaleDayIndexFromOneMonToZeroMon{#1}}%
  }
  \def\texosquerytimezonefmt#1{#1}
  \def\texosqueryshorttimezone#1{%
    \texosquerytimezonefmt
     {\LocaleGetDialectAttribute{\CurrentTrackedDialect}{timezone.#1.short}}%
  }
  \def\texosqueryshortdstzone#1{%
    \texosquerytimezonefmt
     {\LocaleGetDialectAttribute{\CurrentTrackedDialect}{timezone.#1.shortdst}}%
  }
  \def\texosquerylongtimezone#1{%
    \texosquerytimezonefmt
     {\LocaleGetDialectAttribute{\CurrentTrackedDialect}{timezone.#1.long}}%
  }
  \def\texosquerylongdstzone#1{%
    \texosquerytimezonefmt
     {\LocaleGetDialectAttribute{\CurrentTrackedDialect}{timezone.#1.longdst}}%
  }
}
{}
\def\texosquerypatfmtgroupsep{\CurrentLocaleNumericGroupSep}
\def\texosquerypatfmtdecsep{\CurrentLocaleDecimalSep}
\def\texosquerypatfmtcurdecsep{\CurrentLocaleMonetarySep}
\def\texosquerypatfmtexp{\CurrentLocaleExponent}
\def\texosquerypatfmtcurrencysign{\CurrentLocaleCurrency}
\def\texosquerypatfmtpercentsign{\CurrentLocalePercent}
\def\texosquerypatfmtpermillsign{\CurrentLocalePermill}
\def\LocaleIfNumericUsesGroup#1{%
 \LocaleIfDialectAttributeEqNum{#1}{usesgroup}{1}%
}
\def\LocaleIfHasLanguageName#1{%
 \LocaleIfHasDialectNonEmptyAttribute{#1}{langname}%
}
\def\LocaleIfHasRegionName#1{%
 \LocaleIfHasDialectNonEmptyAttribute{#1}{regionname}%
}
\def\LocaleIfHasVariantName#1{%
 \LocaleIfHasDialectNonEmptyAttribute{#1}{variantname}%
}
\ifx\@locale@postparse@hook\undefined
\else
  \@locale@postparse@hook
\fi
\def\CurrentLocaleLanguageName{}%
\def\CurrentLocaleLanguageNativeName{}%
\def\CurrentLocaleRegionName{}%
\def\CurrentLocaleRegionNativeName{}%
\def\CurrentLocaleVariantName{}%
\def\CurrentLocaleVariantNativeName{}%
\def\CurrentLocaleFirstDayIndex{-1}%
\def\CurrentLocaleDayIndexFromRegion{-1}%
\def\CurrentLocaleDayName{}%
\def\CurrentLocaleShortDayName{}%
\def\CurrentLocaleStandaloneDayName{}%
\def\CurrentLocaleStandaloneShortDayName{}%
\def\CurrentLocaleMonthName{}%
\def\CurrentLocaleShortMonthName{}%
\def\CurrentLocaleStandaloneMonthName{}%
\def\CurrentLocaleStandaloneShortMonthName{}%
\def\CurrentLocaleFullDate{}%
\def\CurrentLocaleLongDate{}%
\def\CurrentLocaleMediumDate{}%
\def\CurrentLocaleShortDate{}%
\def\CurrentLocaleFullTime{}%
\def\CurrentLocaleLongTime{}%
\def\CurrentLocaleMediumTime{}%
\def\CurrentLocaleShortTime{}%
\def\CurrentLocaleFullDateTime{}%
\def\CurrentLocaleLongDateTime{}%
\def\CurrentLocaleMediumDateTime{}%
\def\CurrentLocaleShortDateTime{}%
\def\CurrentLocaleDate{}%
\def\CurrentLocaleTime{}%
\def\CurrentLocaleCurrency{}%
\def\CurrentLocaleNumericGroupSep{}%
\def\CurrentLocaleIfNumericUsesGroup{}%
\def\CurrentLocaleDecimalSep{}%
\def\CurrentLocaleMonetarySep{}%
\def\CurrentLocaleExponent{}%
\def\CurrentLocalePercent{}%
\def\CurrentLocalePermill{}%
\def\CurrentLocaleIntegerPattern{}%
\def\CurrentLocaleDecimalPattern{}%
\def\CurrentLocaleCurrencyPattern{}%
\def\CurrentLocalePercentPattern{}%
\def\CurrentLocaleApplyDateTimePattern{}%
\def\CurrentTrackedDialect{}%
\def\@locale@select#1{%
  \SetCurrentTrackedDialect{#1}%
  \def\CurrentLocaleLanguageName{\LocaleLanguageName{#1}}%
  \def\CurrentLocaleLanguageNativeName{\LocaleLanguageNativeName{#1}}%
  \def\CurrentLocaleRegionName{\LocaleRegionName{#1}}%
  \def\CurrentLocaleRegionNativeName{\LocaleRegionNativeName{#1}}%
  \def\CurrentLocaleVariantName{\LocaleVariantName{#1}}%
  \def\CurrentLocaleVariantNativeName{\LocaleVariantNativeName{#1}}%
  \def\CurrentLocaleFirstDayIndex{\LocaleFirstDayIndex{#1}}%
  \def\CurrentLocaleDayIndexFromRegion{\LocaleDayIndexFromRegion{#1}}%
  \def\CurrentLocaleDayName{\LocaleDayName{#1}}%
  \def\CurrentLocaleShortDayName{\LocaleShortDayName{#1}}%
  \def\CurrentLocaleStandaloneDayName{%
    \LocaleStandaloneDayName{#1}}%
  \def\CurrentLocaleStandaloneShortDayName{%
    \LocaleStandaloneShortDayName{#1}}%
  \def\CurrentLocaleMonthName{\LocaleMonthName{#1}}%
  \def\CurrentLocaleShortMonthName{\LocaleShortMonthName{#1}}%
  \def\CurrentLocaleStandaloneMonthName{%
    \LocaleStandaloneMonthName{#1}}%
  \def\CurrentLocaleStandaloneShortMonthName{%
    \LocaleStandaloneShortMonthName{#1}}%
  \def\CurrentLocaleFullDate{\LocaleFullDate{#1}}%
  \def\CurrentLocaleLongDate{\LocaleLongDate{#1}}%
  \def\CurrentLocaleMediumDate{\LocaleMediumDate{#1}}%
  \def\CurrentLocaleShortDate{\LocaleShortDate{#1}}%
  \def\CurrentLocaleFullTime{\LocaleFullTime{#1}}%
  \def\CurrentLocaleLongTime{\LocaleLongTime{#1}}%
  \def\CurrentLocaleMediumTime{\LocaleMediumTime{#1}}%
  \def\CurrentLocaleShortTime{\LocaleShortTime{#1}}%
  \def\CurrentLocaleFullDateTime{\LocaleFullDateTime{#1}}%
  \def\CurrentLocaleLongDateTime{\LocaleLongDateTime{#1}}%
  \def\CurrentLocaleMediumDateTime{\LocaleMediumDateTime{#1}}%
  \def\CurrentLocaleShortDateTime{\LocaleShortDateTime{#1}}%
  \def\CurrentLocaleDate{%
    \localedatechoice
     {\LocaleFullDate{#1}}%
     {\LocaleLongDate{#1}}%
     {\LocaleMediumDate{#1}}%
     {\LocaleShortDate{#1}}%
  }%
  \def\CurrentLocaleTime{%
    \localetimechoice
     {\LocaleFullTime{#1}}%
     {\LocaleLongTime{#1}}%
     {\LocaleMediumTime{#1}}%
     {\LocaleShortTime{#1}}%
  }%
  \def\CurrentLocaleCurrency{%
    \localecurrchoice
     {\LocaleCurrencyLabel{#1}}%
     {\LocaleCurrencyRegionalLabel{#1}}%
     {\LocaleCurrencySymbol{#1}}%
     {\LocaleCurrencyTeXSymbol{#1}}%
  }%
  \def\CurrentLocaleNumericGroupSep{%
    \LocaleNumericGroupSep{#1}%
  }%
  \def\CurrentLocaleIfNumericUsesGroup{%
    \LocaleIfNumericUsesGroup{#1}%
  }%
  \def\CurrentLocaleDecimalSep{%
    \LocaleNumericDecimalSep{#1}%
  }%
  \def\CurrentLocaleMonetarySep{%
    \LocaleNumericMonetarySep{#1}%
  }%
  \def\CurrentLocaleExponent{%
    \LocaleNumericExponent{#1}%
  }%
  \def\CurrentLocalePercent{%
    \LocaleNumericPercent{#1}%
  }%
  \def\CurrentLocalePermill{%
    \LocaleNumericPermill{#1}%
  }%
  \def\CurrentLocaleIntegerPattern{%
    \LocaleGetDialectAttribute{#1}{intfmt}%
  }%
  \def\CurrentLocaleDecimalPattern{%
    \LocaleGetDialectAttribute{#1}{decfmt}%
  }%
  \def\CurrentLocaleCurrencyPattern{%
    \LocaleGetDialectAttribute{#1}{curfmt}%
  }%
  \def\CurrentLocalePercentPattern{%
    \LocaleGetDialectAttribute{#1}{perfmt}%
  }%
  \def\CurrentLocaleApplyDateTimePattern{%
    \LocaleApplyDateTimePattern{#1}%
  }%
}
\ifx\localedatechoice\undefined
  \def\localedatechoice#1#2#3#4{#2}
\fi
\ifx\localetimechoice\undefined
  \def\localetimechoice#1#2#3#4{#3}
\fi
\ifx\localecurrchoice\undefined
  \def\localecurrchoice#1#2#3#4{#2}
\fi
\def\CurrentLocaleDateTime{\CurrentLocaleDate\space\CurrentLocaleTime}
\def\localenumfmt#1#2{%
  \@locale@decfmt#2\empty.0E0\relax
 \ifnum\@locale@decfmt@int<0
   \let\@localenum@fmt\localenumfmtneg
 \else
   \ifnum\@locale@decfmt@int=0
     \ifnum\@locale@decfmt@frac=0
       \ifnum\@locale@decfmt@exp=0
         \let\@localenum@fmt\localenumfmtzero
       \else
         \let\@localenum@fmt\localenumfmtpos
       \fi
     \else
       \let\@localenum@fmt\localenumfmtpos
     \fi
   \else
     \let\@localenum@fmt\localenumfmtpos
   \fi
 \fi
 \@localenum@fmt
 {%
   \texosqueryfmtnumber{#1}%
   {\@locale@decfmt@int}%
   {\@locale@decfmt@frac}%
   {\@locale@decfmt@exp}%
 }%
}
\def\localenumfmtpos#1{#1}
\def\localenumfmtneg#1{#1}
\def\localenumfmtzero#1{#1}
\def\localeint#1{%
 \localenumfmt{\CurrentLocaleIntegerPattern}{#1}%
}
\def\localedec#1{%
 \localenumfmt{\CurrentLocaleDecimalPattern}{#1}%
}
\def\localecur#1{%
 \localenumfmt{\CurrentLocaleCurrencyPattern}{#1}%
}
\def\localeper#1{%
 \localenumfmt{\CurrentLocalePercentPattern}{#1}%
}
\def\@locale@decfmt#1.#2E#3\relax{%
 \@locale@decfmt@split#1E\empty\relax
 \ifx\@locale@decfmt@exp\empty
   \edef\@locale@decfmt@frac{\@locale@gobbleemptytorelax#2\empty\relax}%
   \edef\@locale@decfmt@exp{\@locale@gobbleemptytorelax#3\empty\relax}%
 \else
   \def\@locale@decfmt@frac{0}%
 \fi
}
\def\@locale@gobbleemptytorelax#1\empty#2\relax{#1}
\def\@locale@decfmt@split#1E#2\empty#3\relax{%
 \edef\@locale@decfmt@int{\@locale@gobbleemptytorelax#1\empty\relax}%
 \edef\@locale@decfmt@exp{\@locale@gobbleemptytorelax#2\empty\relax}%
}
\ForEachTrackedDialect{\locale@this@dialect}{%
  \SetCurrentTrackedDialect{\locale@this@dialect}%
  \expandafter\@TrackLangAddToHook\expandafter
   {\expandafter\@locale@select\expandafter{\locale@this@dialect}}
   {captions}%
}
\def\selectlocale#1{%
  \ifx\selectlanguage\undefined
    \IfTrackedDialect{#1}%
    {\@locale@select{#1}}%
    {%
      \LocaleIfHasAttribute{#1}{tagtodialect}
      {%
        \edef\@locale@dialect{\LocaleGetAttribute{#1}{tagtodialect}}%
        \expandafter\@locale@select\expandafter{\@locale@dialect}%
      }%
      {%
        \ifTeXOSQueryDryRun
          \@locale@warn{Unknown locale `#1'}%
        \else
          \@locale@err{Unknown locale `#1'}%
          {The argument to \string\selectlocale\space must be either a
           tracklang dialect label or a tracked dialect language tag}%
        \fi
      }%
    }%
  \else
    \IfTrackedDialect{#1}%
    {%
      \@locale@select@dialect{#1}%
    }%
    {%
      \LocaleIfHasAttribute{#1}{tagtodialect}
      {\@locale@select@dialect{\LocaleGetAttribute{#1}{tagtodialect}}}%
      {%
        \ifTeXOSQueryDryRun
          \@locale@warn{Unknown locale `#1'}%
        \else
          \@locale@err{Unknown locale `#1'}%
          {The argument to \string\selectlocale\space must be either a
           tracklang dialect label or a tracked dialect language tag}%
        \fi
      }%
    }%
  \fi
}
\def\@locale@select@dialect#1{%
  \IfTrackedDialectHasMapping{#1}%
  {\edef\@locale@dialect{\GetTrackedDialectToMapping{#1}}}%
  {\edef\@locale@dialect{#1}}%
  \@tracklang@ifundef{date\@locale@dialect}%
  {%
    \edef\@locale@dialect{\TrackedLanguageFromDialect{#1}}%
    \@tracklang@ifundef{date\@locale@dialect}%
    {%
      \@locale@warn{Can't determine correct label for
       \string\selectlanguage\space from tracklang dialect `#1'}%
      \SetCurrentTrackedDialect{#1}%
    }%
    {\expandafter\selectlanguage\expandafter{\@locale@dialect}}%
  }%
  {\expandafter\selectlanguage\expandafter{\@locale@dialect}}%
}
\ifx\LocaleMainDialect\empty
\else
  \expandafter\@locale@select\expandafter{\LocaleMainDialect}
\fi
\@locale@restore@at

\endinput
%%
%% End of file `tex-locale.tex'.
