%%
%% `numspell-german.sty' German language package for 'numspell.sty'
%%
%% Copyright 2017-2026 by Tibor Tómács
%%
%% 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 Tibor Tómács.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{numspell-german}[2026/02/02 v1.1 German language package for numspell]

%% GROUP NAMES
\def\numspell@group@ii@de@name{\numspell@{tausend}}
\def\numspell@group@iii@de@name{\numspell@{Million}}
\def\numspell@group@iv@de@name{\numspell@{Milliarde}}
\def\numspell@group@v@de@name{\numspell@{Billion}}
\def\numspell@group@vi@de@name{\numspell@{Billiarde}}
\def\numspell@group@vii@de@name{\numspell@{Trillion}}
\def\numspell@group@viii@de@name{\numspell@{Trilliarde}}
\def\numspell@group@ix@de@name{\numspell@{Quadrillion}}
\def\numspell@group@x@de@name{\numspell@{Quadrilliarde}}
\def\numspell@group@xi@de@name{\numspell@{Quintillion}}
\def\numspell@group@xii@de@name{\numspell@{Quintilliarde}}
\def\numspell@group@xiii@de@name{\numspell@{Sextillion}}
\def\numspell@group@xiv@de@name{\numspell@{Sextilliarde}}
\def\numspell@group@xv@de@name{\numspell@{Septillion}}
\def\numspell@group@xvi@de@name{\numspell@{Septilliarde}}
\def\numspell@group@xvii@de@name{\numspell@{Oktillion}}
\def\numspell@group@xviii@de@name{\numspell@{Oktilliarde}}
\def\numspell@group@xix@de@name{\numspell@{Nonillion}}
\def\numspell@group@xx@de@name{\numspell@{Nonilliarde}}
\def\numspell@group@xxi@de@name{\numspell@{Dezillion}}
\def\numspell@group@xxii@de@name{\numspell@{Dezilliarde}}

%% ORDINAL GROUP NAMES
\def\numspell@ordgroup@iii@de@name{\numspell@{millionste}}
\def\numspell@ordgroup@iv@de@name{\numspell@{milliardste}}
\def\numspell@ordgroup@v@de@name{\numspell@{billionste}}
\def\numspell@ordgroup@vi@de@name{\numspell@{billiardste}}
\def\numspell@ordgroup@vii@de@name{\numspell@{trillionste}}
\def\numspell@ordgroup@viii@de@name{\numspell@{trilliardste}}
\def\numspell@ordgroup@ix@de@name{\numspell@{quadrillionste}}
\def\numspell@ordgroup@x@de@name{\numspell@{quadrilliardste}}
\def\numspell@ordgroup@xi@de@name{\numspell@{quintillionste}}
\def\numspell@ordgroup@xii@de@name{\numspell@{quintilliardste}}
\def\numspell@ordgroup@xiii@de@name{\numspell@{sextillionste}}
\def\numspell@ordgroup@xiv@de@name{\numspell@{sextilliardste}}
\def\numspell@ordgroup@xv@de@name{\numspell@{septillionste}}
\def\numspell@ordgroup@xvi@de@name{\numspell@{septilliardste}}
\def\numspell@ordgroup@xvii@de@name{\numspell@{oktillionste}}
\def\numspell@ordgroup@xviii@de@name{\numspell@{oktilliardste}}
\def\numspell@ordgroup@xix@de@name{\numspell@{nonillionste}}
\def\numspell@ordgroup@xx@de@name{\numspell@{nonilliardste}}
\def\numspell@ordgroup@xxi@de@name{\numspell@{dezillionste}}
\def\numspell@ordgroup@xxii@de@name{\numspell@{dezilliardste}}

%% SPELLING CARDINAL NUMBER GROUP
%% ---------------------------------
%% \numspell@group@spell@de{<group>} (<group>=000,001,...,999)
%% ---------------------------------
%% \numspell@group@digits{<group>}
%% Adding the <group> spelling to \thenumspell
%%
\def\numspell@group@spell@de#1{%
    \numspell@group@digits{#1}%
    \ifcase\numspell@group@digit@i%
        \or\numspell@{ein}\or\numspell@{zwei}\or\numspell@{drei}\or\numspell@{vier}\or\numspell@{f\"{u}nf}%
        \or\numspell@{sechs}\or\numspell@{sieben}\or\numspell@{acht}\or\numspell@{neun}%
    \fi%
    \ifnum\numspell@group@digit@i>0%
        \numspell@{hundert}%
    \fi%
    \ifnum\number\numexpr100*\numspell@group@digit@i+10*\numspell@group@digit@ii+\numspell@group@digit@iii>1%
        \ifcase\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii%
            \or\numspell@{eins}\or\numspell@{zwei}\or\numspell@{drei}\or\numspell@{vier}\or\numspell@{f\"{u}nf}%
            \or\numspell@{sechs}\or\numspell@{sieben}\or\numspell@{acht}\or\numspell@{neun}%
            \or\numspell@{zehn}\or\numspell@{elf}\or\numspell@{zw\"{o}lf}\or\numspell@{dreizehn}%
            \or\numspell@{vierzehn}\or\numspell@{f\"{u}nfzehn}\or\numspell@{sechzehn}\or\numspell@{siebzehn}%
            \or\numspell@{achtzehn}\or\numspell@{neunzehn}%
        \fi%
    \fi%
    \ifnum\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii>19%
        \ifcase\numspell@group@digit@iii%
            \or\numspell@{ein}\or\numspell@{zwei}\or\numspell@{drei}\or\numspell@{vier}\or\numspell@{f\"{u}nf}%
            \or\numspell@{sechs}\or\numspell@{sieben}\or\numspell@{acht}\or\numspell@{neun}%
        \fi%
    \fi%
    \ifnum\number\numexpr\numspell@group@digit@ii*\numspell@group@digit@iii>0%
        \ifnum\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii>20%
            \numspell@{und}%
        \fi%
    \fi%
    \ifnum\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii>19%
        \ifcase\numspell@group@digit@ii%
            \or\or\numspell@{zwanzig}\or\numspell@{drei\ss{}ig}\or\numspell@{vierzig}\or\numspell@{f\"{u}nfzig}%
            \or\numspell@{sechzig}\or\numspell@{siebzig}\or\numspell@{achtzig}\or\numspell@{neunzig}%
        \fi%
    \fi%
}

%% SPELLING ORDINAL NUMBER GROUP
%% ------------------------------------
%% \numspell@ordgroup@spell@de{<group>} (<group>=000,001,...,999)
%% ------------------------------------
%% \numspell@group@digits{<group>}
%% Adding the <group> ordinal spelling to \thenumspell
%%
\def\numspell@ordgroup@spell@de#1{%
    \numspell@group@digits{#1}%
    \ifcase\numspell@group@digit@i%
        \or\numspell@{ein}\or\numspell@{zwei}\or\numspell@{drei}\or\numspell@{vier}\or\numspell@{f\"{u}nf}%
        \or\numspell@{sechs}\or\numspell@{sieben}\or\numspell@{acht}\or\numspell@{neun}%
    \fi%
    \ifnum\numspell@group@digit@i>0%
        \ifnum\number\numexpr\numspell@group@digit@ii+\numspell@group@digit@iii=0%
            \numspell@{hundertste}%
        \else%
            \numspell@{hundert}%
        \fi%
    \fi%
    \ifnum\number\numexpr100*\numspell@group@digit@i+10*\numspell@group@digit@ii+\numspell@group@digit@iii>1%
        \ifcase\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii%
            \or\numspell@{erste}\or\numspell@{zweite}\or\numspell@{dritte}\or\numspell@{vierte}\or\numspell@{f\"{u}nfte}%
            \or\numspell@{sechste}\or\numspell@{siebte}\or\numspell@{achte}\or\numspell@{neunte}%
            \or\numspell@{zehnte}\or\numspell@{elfte}\or\numspell@{zw\"{o}lfte}\or\numspell@{dreizehnte}%
            \or\numspell@{vierzehnte}\or\numspell@{f\"{u}nfzehnte}\or\numspell@{sechzehnte}\or\numspell@{siebzehnte}%
            \or\numspell@{achtzehnte}\or\numspell@{neunzehnte}%
        \fi%
    \fi%
    \ifnum\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii>19%
        \ifcase\numspell@group@digit@iii%
            \or\numspell@{ein}\or\numspell@{zwei}\or\numspell@{drei}\or\numspell@{vier}\or\numspell@{f\"{u}nf}%
            \or\numspell@{sechs}\or\numspell@{sieben}\or\numspell@{acht}\or\numspell@{neun}%
        \fi%
    \fi%
    \ifnum\number\numexpr\numspell@group@digit@ii*\numspell@group@digit@iii>0%
        \ifnum\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii>20%
            \numspell@{und}%
        \fi%
    \fi%
    \ifnum\number\numexpr10*\numspell@group@digit@ii+\numspell@group@digit@iii>19%
        \ifcase\numspell@group@digit@ii%
            \or\or\numspell@{zwanzigste}\or\numspell@{drei\ss{}igste}\or\numspell@{vierzigste}\or\numspell@{f\"{u}nfzigste}%
            \or\numspell@{sechzigste}\or\numspell@{siebzigste}\or\numspell@{achtzigste}\or\numspell@{neunzigste}%
        \fi%
    \fi%
}

%% SPELLING CARDINAL NUMBER
%% --------------------------------------
%% \numspell@num@spell@de{<num1>}{<num2>}
%% --------------------------------------
%% \numspell@groups{<num1>}{<num2>}
%% Adding the \numspell@num spelling to \thenumspell
%%
\def\numspell@num@spell@de#1#2{%
    \gdef\thenumspell{}%
    \numspell@groups{#1}{#2}%
    \setcounter{numspell@groupcount}{22}%
    \@whilenum\value{numspell@groupcount}>2%
    \do{%
        \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{0}{}{%
            \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{1}{\numspell@{eine}}{}%
            \numspell@group@spell@de{\csname numspell@group@\roman{numspell@groupcount}\endcsname}%
            \numspell@{ }%
            \csname numspell@group@\roman{numspell@groupcount}@de@name\endcsname%
            \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{1}{}{\ifodd\value{numspell@groupcount}\numspell@{e}\fi}%
            \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{1}{}{\numspell@{n}}%
            \ifnum\csname numspell@group@\roman{numspell@groupcount}@before\endcsname>0\numspell@{ }\fi%
        }%
        \addtocounter{numspell@groupcount}{-1}%
    }%
    \IfEq{\numspell@group@ii}{0}{}{%
        \IfEq{\numspell@group@ii}{1}{\numspell@{ein}}{}%
        \numspell@group@spell@de{\numspell@group@ii}%
        \numspell@group@ii@de@name%
    }%
    \IfEq{\numspell@group@i}{0}{}{%
        \IfEq{\numspell@group@i}{1}{\numspell@{eins}}{}%
        \numspell@group@spell@de{\numspell@group@i}%
    }%
    \ifnum\numspell@group@max=0\numspell@{null}\fi%
}

%% SPELLING ORDINAL NUMBER
%% -----------------------------------------
%% \numspell@ordnum@spell@de{<num1>}{<num2>}
%% -----------------------------------------
%% \numspell@groups{<num1>}{<num2>}
%% Adding the \numspell@num ordinal spelling to \thenumspell
%%
\def\numspell@ordnum@spell@de#1#2{%
    \gdef\thenumspell{}%
    \numspell@groups{#1}{#2}%
    \setcounter{numspell@groupcount}{22}%
    \@whilenum\value{numspell@groupcount}>2%
    \do{%
        \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{0}{}{%
            \ifnum\csname numspell@group@\roman{numspell@groupcount}@before\endcsname>0%
                \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{1}{\numspell@{eine}}{}%
                \numspell@group@spell@de{\csname numspell@group@\roman{numspell@groupcount}\endcsname}%
                \numspell@{ }%
                \csname numspell@group@\roman{numspell@groupcount}@de@name\endcsname%
                \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{1}{}{\ifodd\value{numspell@groupcount}\numspell@{e}\fi}%
                \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{1}{}{\numspell@{n}}\numspell@{ }%
            \else%
                \IfEq{\csname numspell@group@\roman{numspell@groupcount}\endcsname}{1}{\numspell@{ein}}{}%
                \numspell@group@spell@de{\csname numspell@group@\roman{numspell@groupcount}\endcsname}%
                \csname numspell@ordgroup@\roman{numspell@groupcount}@de@name\endcsname%
            \fi%
        }%
        \addtocounter{numspell@groupcount}{-1}%
    }%
    \IfEq{\numspell@group@ii}{0}{}{%
        \IfEq{\numspell@group@ii}{1}{\numspell@{ein}}{}%
        \numspell@group@spell@de{\numspell@group@ii}%
        \numspell@group@ii@de@name%
        \ifnum\numspell@group@ii@before=0\numspell@{ste}\fi%
    }%
    \IfEq{\numspell@group@i}{0}{}{%
        \IfEq{\numspell@group@i}{1}{\numspell@{erste}}{}%
        \numspell@ordgroup@spell@de{\numspell@group@i}%
    }%
    \ifnum\numspell@group@max=0\numspell@{nullte}\fi%
}

%% ----------------------
%% \numspell@uppercase@de
%% ----------------------
%% E.g. \def\thenumspell{ein}\numspell@uppercase\thenumspell --> 'Ein'
%% \MakeUppercase does not work on pdf bookmark (see hyperref), so using another effective macro.
%%
\def\numspell@uppercase@de{%
    \fullexpandarg%
    \StrChar{\thenumspell}{1}[\numspell@firstletter]%
    \expandarg%
    \StrGobbleLeft{\thenumspell}{1}[\numspell@trunc]%
    \fullexpandarg%
    \def\numspell@the{}%
    \IfStrEq{\numspell@firstletter}{e}{\g@addto@macro\numspell@the{E}}{}% ein
    \IfStrEq{\numspell@firstletter}{z}{\g@addto@macro\numspell@the{Z}}{}% zwei
    \IfStrEq{\numspell@firstletter}{d}{\g@addto@macro\numspell@the{D}}{}% drei
    \IfStrEq{\numspell@firstletter}{v}{\g@addto@macro\numspell@the{V}}{}% vier
    \IfStrEq{\numspell@firstletter}{f}{\g@addto@macro\numspell@the{F}}{}% f\"{u}nf
    \IfStrEq{\numspell@firstletter}{s}{\g@addto@macro\numspell@the{S}}{}% sechs
    \IfStrEq{\numspell@firstletter}{a}{\g@addto@macro\numspell@the{A}}{}% acht
    \IfStrEq{\numspell@firstletter}{n}{\g@addto@macro\numspell@the{N}}{}% neun
    \ifx\numspell@the\@empty\@latexerr{'numspell.sty' error! There is not '\numspell@firstletter' in uppercase!}{}\fi%
    \expandafter\g@addto@macro\expandafter\numspell@the\expandafter{\numspell@trunc}%
    \global\let\thenumspell\numspell@the%
}

\endinput