% Language definition file (part of polyglossia v2.10 -- 2026/04/18)
%
\ProvidesFile{gloss-dutch.ldf}[polyglossia: module for Dutch]
\PolyglossiaSetup{dutch}{
  bcp47=nl,
  bcp47-language=nl,
  bcp47-script=Latn,
  hyphennames={dutch},
  hyphenmins={2,2},
  langtag=NLD,
  frenchspacing=true,
 }

% BCP-47 compliant aliases
\setlanguagealias*{dutch}{nl}

\DeclareKeys[polyglossia/gloss/dutch]
  {
    babelshorthands.if = dutch@babelshorthands,
    babelshorthands.default:n = true,
    tremahyphenation.if = dutch@tremahyphenation,
    tremahyphenation.default:n = true
  }

\ifsystem@babelshorthands
  \SetGlossOptions{dutch}{babelshorthands=true}
  % Register default options
  \InitializeGlossOptions{dutch}{babelshorthands=true,tremahyphenation=true}
\else
  \SetGlossOptions{dutch}{babelshorthands=false}
  % Register default options
  \InitializeGlossOptions{dutch}{babelshorthands=false,tremahyphenation=true}
\fi

\InitializeBabelShorthands

\def\xpg@trema#1{\allowhyphens\discretionary{-}{#1}{\"{#1}}\allowhyphens}

\def\xpg@itrema{%
  \textormath{\allowhyphens\discretionary{-}{i}{\"{\i}}\allowhyphens}%
                {\ddot \imath}%
}

\def\xpg@imtrema{%
  \textormath{\allowhyphens\discretionary{-}{I}{\"{I}}\allowhyphens}%
                {\ddot I}%
}

\def\dutch@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{dutch}%
  \declare@shorthand{dutch}{"a}{\textormath{\xpg@trema{a}}{\ddot a}}%
  \declare@shorthand{dutch}{"e}{\textormath{\xpg@trema{e}}{\ddot e}}%
  \declare@shorthand{dutch}{"i}{\xpg@itrema}%
  \declare@shorthand{dutch}{"o}{\textormath{\xpg@trema{o}}{\ddot o}}%
  \declare@shorthand{dutch}{"u}{\textormath{\xpg@trema{u}}{\ddot u}}%
  \declare@shorthand{dutch}{"A}{\textormath{\xpg@trema{A}}{\ddot A}}%
  \declare@shorthand{dutch}{"E}{\textormath{\xpg@trema{E}}{\ddot E}}%
  \declare@shorthand{dutch}{"I}{\xpg@imtrema}%
  \declare@shorthand{dutch}{"O}{\textormath{\xpg@trema{O}}{\ddot O}}%
  \declare@shorthand{dutch}{"U}{\textormath{\xpg@trema{U}}{\ddot U}}%
  \declare@shorthand{dutch}{"y}{\textormath{\ij{}}{\ddot y}}%
  \declare@shorthand{dutch}{"Y}{\textormath{\IJ{}}{\ddot Y}}%
  \declare@shorthand{dutch}{"-}{\xpg@breakable@hyphen}%
  \declare@shorthand{dutch}{"~}{\xpg@nobreak@hyphen}%
  \declare@shorthand{dutch}{"|}{\xpg@ligature@break}%
  \declare@shorthand{dutch}{""}{\xpg@invisible@break}%
  \declare@shorthand{dutch}{"/}{\xpg@breakable@slash}%
  \def\-{\xpg@allowhyphenationbefore\discretionary{-}{}{}\xpg@allowhyphenationafter}%
}

\def\nodutch@shorthands{%
  \xpg@deactivate@shorthands%
  \def\-{\discretionary{-}{}{}}% << original def in latex.ltx
}

%
% Support proper hyphenation of tremata: after hyphenation,
% the trema is omitted, e.g. geëxecuteerd > ge-executeerd
% We support this by making the respective letters active.
%
% Save catcodes of trema characters for later restorage
\chardef\xpg@saved@auml@catcode\catcode`ä
\chardef\xpg@saved@euml@catcode\catcode`ë
\chardef\xpg@saved@iuml@catcode\catcode`ï
\chardef\xpg@saved@ouml@catcode\catcode`ö
\chardef\xpg@saved@uuml@catcode\catcode`ü
\chardef\xpg@saved@Auml@catcode\catcode`Ä
\chardef\xpg@saved@Euml@catcode\catcode`Ë
\chardef\xpg@saved@Iuml@catcode\catcode`Ï
\chardef\xpg@saved@Ouml@catcode\catcode`Ö
\chardef\xpg@saved@Uuml@catcode\catcode`Ü

% activate trema characters
\def\dutch@@tremahyph{%
    \catcode`ä = \active
    \catcode`ë = \active
    \catcode`ï = \active
    \catcode`ö = \active
    \catcode`ü = \active
    \catcode`Ä = \active
    \catcode`Ë = \active
    \catcode`Ï = \active
    \catcode`Ö = \active
    \catcode`Ü = \active
}

% restore previous catcode of trema characters
\def\nodutch@@tremahyph{%
    \catcode`ä = \xpg@saved@auml@catcode
    \catcode`ë = \xpg@saved@euml@catcode
    \catcode`ï = \xpg@saved@iuml@catcode
    \catcode`ö = \xpg@saved@ouml@catcode
    \catcode`ü = \xpg@saved@uuml@catcode
    \catcode`Ä = \xpg@saved@Auml@catcode
    \catcode`Ë = \xpg@saved@Euml@catcode
    \catcode`Ï = \xpg@saved@Iuml@catcode
    \catcode`Ö = \xpg@saved@Ouml@catcode
    \catcode`Ü = \xpg@saved@Uuml@catcode
}

\bgroup
\dutch@@tremahyph
\gdef\dutch@tremahyph{%
    \dutch@@tremahyph%
    \def ä{\textormath{\xpg@trema{a}}{\ddot a}}%
    \def ë{\textormath{\xpg@trema{e}}{\ddot e}}%
    \def ï{\textormath{\xpg@trema{i}}{\ddot i}}%
    \def ö{\textormath{\xpg@trema{o}}{\ddot o}}%
    \def ü{\textormath{\xpg@trema{u}}{\ddot u}}%
    \def Ä{\textormath{\xpg@trema{A}}{\ddot A}}%
    \def Ë{\textormath{\xpg@trema{E}}{\ddot E}}%
    \def Ï{\textormath{\xpg@trema{I}}{\ddot I}}%
    \def Ö{\textormath{\xpg@trema{O}}{\ddot O}}%
    \def Ü{\textormath{\xpg@trema{U}}{\ddot U}}%
}

\gdef\nodutch@tremahyph{%
    \let ä\relax%
    \let ë\relax%
    \let ï\relax%
    \let ö\relax%
    \let ü\relax%
    \let Ä\relax%
    \let Ë\relax%
    \let Ï\relax%
    \let Ö\relax%
    \let Ü\relax%
    \nodutch@@tremahyph%
}
\egroup

\def\captionsdutch{%
    \def\prefacename{Voorwoord}%
    \def\refname{Referenties}%
    \def\abstractname{Samenvatting}%
    \def\bibname{Bibliografie}%
    \def\chaptername{Hoofdstuk}%
    \def\appendixname{Bijlage}%
    \def\contentsname{Inhoudsopgave}%
    \def\listfigurename{Lijst van figuren}%
    \def\listtablename{Lijst van tabellen}%
    \def\indexname{Index}%
    \def\figurename{Figuur}%
    \def\tablename{Tabel}%
    \def\partname{Deel}%
    \def\enclname{Bijlage(n)}%
    \def\ccname{cc}%
    \def\headtoname{Aan}%
    \def\pagename{Pagina}%
    \def\seename{zie}%
    \def\alsoname{zie ook}%
    \def\proofname{Bewijs}%
    \def\glossaryname{Verklarende woordenlijst}%
}

\def\datedutch{%
    \def\today{\number\day~\ifcase\month%
      \or januari\or februari\or maart\or april\or mei\or juni\or
      juli\or augustus\or september\or oktober\or november\or
      december\fi
      \space \number\year}%
}

\def\noextras@dutch{%
  \ifdutch@babelshorthands\nodutch@shorthands\fi%
  \ifdutch@tremahyphenation\nodutch@tremahyph\fi%
}

\def\blockextras@dutch{%
  \ifdutch@babelshorthands\dutch@shorthands\else\nodutch@shorthands\fi%
  \ifdutch@tremahyphenation\dutch@tremahyph\else\nodutch@tremahyph\fi%
}

\def\inlineextras@dutch{%
  \ifdutch@babelshorthands\dutch@shorthands\else\nodutch@shorthands\fi%
  \ifdutch@tremahyphenation\dutch@tremahyph\else\nodutch@tremahyph\fi%
}

\endinput
