% Language definition file (part of polyglossia v2.10 -- 2026/04/18)
%
\ProvidesFile{gloss-czech.ldf}[polyglossia: module for Czech]

\PolyglossiaSetup{czech}{
  bcp47=cz,
  bcp47-language=cz,
  bcp47-region=CZ,
  bcp47-script=Latn,
  hyphennames={czech},
  hyphenmins={2,2},
  langtag=CSY,
  frenchspacing=true,
 }

% BCP-47 compliant aliases
\setlanguagealias*{czech}{cz}

\ifluatex
  \RequirePackage{luavlna}
\fi

\DeclareKeys[polyglossia/gloss/czech]
  {
    babelshorthands.if = czech@babelshorthands,
    babelshorthands.default:n = true,
    splithyphens.if = czech@splithyphens,
    splithyphens.default:n = true,
    vlna.if = czech@vlna,
    vlna.default:n = true
  }

\ifsystem@babelshorthands
  \SetGlossOptions{czech}{babelshorthands=true}
  % Register default options
  \InitializeGlossOptions{czech}{babelshorthands=true,splithyphens=true,vlna=true}
\else
  \SetGlossOptions{czech}{babelshorthands=false}
  % Register default options
  \InitializeGlossOptions{czech}{babelshorthands=false,splithyphens=true,vlna=true}
\fi

\InitializeBabelShorthands

\def\czech@@splithyphen#1{%
  \def\czech@sh@tmp{%
       \if\czech@sh@next-#1%
       \else\expandafter\czech@@@splithyphen{#1}\fi%
     }%
     \futurelet\czech@sh@next\czech@sh@tmp%
}

\def\czech@@@splithyphen#1{%
  \ifnum\hyphenchar \font>0%
    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
    \nobreak\hskip\z@%
  \else%
    #1%
  \fi%
}

\def\czech@splithyphen{%
  \czech@@splithyphen{-}%
}

\def\czech@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{czech}%
  \declare@shorthand{czech}{"=}{\czech@splithyphen}%
  \declare@shorthand{czech}{"`}{„}%
  \declare@shorthand{czech}{"'}{“}%
  \declare@shorthand{czech}{"<}{«}%
  \declare@shorthand{czech}{">}{»}%
}

\def\noczech@shorthands{%
  \xpg@deactivate@shorthands%
}

\ifxetex
  % splithyphens
  \newXeTeXintercharclass\czech@hyphen % -
  % vlna
  \newXeTeXintercharclass\czech@openpunctuation
  \newXeTeXintercharclass\czech@nonsyllabicpreposition
  \ifdefined\e@alloc@intercharclass@top
    \chardef\czech@boundary=\e@alloc@intercharclass@top
  \else
    \ifdefined\XeTeXinterwordspaceshaping
      \chardef\czech@boundary=4095 %
      \def\newXeTeXintercharclass{%
        \e@alloc\XeTeXcharclass\chardef
              \xe@alloc@intercharclass\m@ne\@ucharclass@boundary}%
    \else
      \chardef\czech@boundary=255
    \fi
  \fi
\fi

\def\czech@hyphens{%
    \ifluatex
      \AfterPreamble{\enablesplithyphens{czech}}%
    \else
      \XeTeXinterchartokenstate=1
      \XeTeXcharclass `\- \czech@hyphen
      \XeTeXinterchartoks \z@ \czech@hyphen = {\czech@@splithyphen}% "-" -> "\czech@@splithyphen-"
      % necessary if used together with vlna:
      \XeTeXinterchartoks \czech@nonsyllabicpreposition \czech@hyphen = {\czech@@splithyphen}% "-" -> "\czech@@splithyphen-"
    \fi%
}

\def\noczech@hyphens{%
    \ifluatex
      \AfterPreamble{\disablesplithyphens{czech}}%
    \else
      \XeTeXcharclass `\- \z@
    \fi%
}

% Add nonbreakable space after single-letter word to
% prevent them to land at the end of a line
% vlna code taken and adapted from xevlna.sty
\ifxetex
    \def\czech@nointerchartoks{\let\czech@interchartoks\czech@PreCSpreposition}%
    \def\czech@PreCSpreposition{%
       \def\next{}%
       \ifnum\catcode`\ =10 % nothing will be done in verbatim
       \ifmmode % nothing in math
       \else
          \let\czech@interchartoks\czech@nointerchartoks
          \let\next\czech@ExamineCSpreposition
       \fi\fi
       \next%
    }%
    \def\czech@ExamineCSpreposition #1{#1\futurelet\next\czech@ProcessCSpreposition}%
    \def\czech@ProcessCSpreposition{\ifx\next\czech@XeTeXspace\nobreak\fi}%
    \futurelet\czech@XeTeXspace{ }\czech@nointerchartoks
\fi

\def\czech@vlna{%
    \ifluatex
       \preventsingleon
    \else
        % Code taken and adapted from xevlna.sty
        \XeTeXinterchartokenstate=1
        \XeTeXcharclass `\( \czech@openpunctuation
        \XeTeXcharclass `\[ \czech@openpunctuation
        \XeTeXcharclass `\„ \czech@openpunctuation
        \XeTeXcharclass `\» \czech@openpunctuation
        \XeTeXcharclass `\K \czech@nonsyllabicpreposition
        \XeTeXcharclass `\k \czech@nonsyllabicpreposition
        \XeTeXcharclass `\S \czech@nonsyllabicpreposition
        \XeTeXcharclass `\s \czech@nonsyllabicpreposition
        \XeTeXcharclass `\V \czech@nonsyllabicpreposition
        \XeTeXcharclass `\v \czech@nonsyllabicpreposition
        \XeTeXcharclass `\Z \czech@nonsyllabicpreposition
        \XeTeXcharclass `\z \czech@nonsyllabicpreposition
        \XeTeXcharclass `\O \czech@nonsyllabicpreposition
        \XeTeXcharclass `\o \czech@nonsyllabicpreposition
        \XeTeXcharclass `\U \czech@nonsyllabicpreposition
        \XeTeXcharclass `\u \czech@nonsyllabicpreposition
        \XeTeXcharclass `\A \czech@nonsyllabicpreposition
        \XeTeXcharclass `\a \czech@nonsyllabicpreposition
        \XeTeXcharclass `\I \czech@nonsyllabicpreposition
        \XeTeXcharclass `\i \czech@nonsyllabicpreposition
        \XeTeXinterchartoks \czech@boundary \czech@nonsyllabicpreposition {\czech@interchartoks}%
        \XeTeXinterchartoks \czech@openpunctuation \czech@nonsyllabicpreposition {\czech@interchartoks}%
    \fi
}

\def\noczech@vlna{%
    \ifluatex
        \preventsingleoff
    \else
        \XeTeXcharclass`\(\z@
        \XeTeXcharclass`\[\z@
        \XeTeXcharclass`\„\z@
        \XeTeXcharclass`\»\z@
        \XeTeXcharclass`\K\z@
        \XeTeXcharclass`\k\z@
        \XeTeXcharclass`\S\z@
        \XeTeXcharclass`\s\z@
        \XeTeXcharclass`\V\z@
        \XeTeXcharclass`\v\z@
        \XeTeXcharclass`\Z\z@
        \XeTeXcharclass`\z\z@
        \XeTeXcharclass`\O\z@
        \XeTeXcharclass`\o\z@
        \XeTeXcharclass`\U\z@
        \XeTeXcharclass`\u\z@
        \XeTeXcharclass`\A\z@
        \XeTeXcharclass`\a\z@
        \XeTeXcharclass`\I\z@
        \XeTeXcharclass`\i\z@
    \fi
}


\def\captionsczech{%
   \def\refname{Reference}%
   \def\abstractname{Abstrakt}%
   \def\bibname{Literatura}%
   \def\prefacename{Předmluva}%
   \def\chaptername{Kapitola}%
   \def\appendixname{Dodatek}%
   \def\contentsname{Obsah}%
   \def\listfigurename{Seznam obrázků}%
   \def\listtablename{Seznam tabulek}%
   \def\indexname{Index}%
   \def\figurename{Obrázek}%
   \def\tablename{Tabulka}%
   %\def\thepart{}%
   \def\partname{Část}%
   \def\pagename{Strana}%
   \def\seename{viz}%
   \def\alsoname{viz}%
   \def\enclname{Příloha}%
   \def\ccname{Na vědomí:}%
   \def\headtoname{Komu}%
   \def\proofname{Důkaz}%
   \def\glossaryname{Slovník}%was Glosář
}

\def\dateczech{%
   \def\today{\number\day.~\ifcase\month\or
    ledna\or února\or března\or dubna\or května\or
    června\or července\or srpna\or září\or
    října\or listopadu\or prosince\fi
    \space \number\year}%
}

\def\noextras@czech{%
  \ifczech@babelshorthands\noczech@shorthands\fi%
  \noczech@hyphens%
  \noczech@vlna%
  \ifxetex\XeTeXinterchartokenstate=0\fi%
}

\def\blockextras@czech{%
  \ifczech@babelshorthands\czech@shorthands\else\noczech@shorthands\fi%
  \ifczech@vlna\czech@vlna\else\noczech@vlna\fi%
  \ifczech@splithyphens\czech@hyphens\else\noczech@hyphens\fi%
}

\def\inlineextras@czech{%
  \ifczech@babelshorthands\czech@shorthands\else\noczech@shorthands\fi%
  \ifczech@vlna\czech@vlna\else\noczech@vlna\fi%
  \ifczech@splithyphens\czech@hyphens\else\noczech@hyphens\fi%
}

\def\nestedextras@czech{%
 \ifluatex%
  \ifczech@vlna\czech@vlna\else\noczech@vlna\fi%
  \ifczech@splithyphens\czech@hyphens\else\noczech@hyphens\fi%
 \fi%
}

\endinput
