%\iffalse
% polyglossia.dtx generated using mkpolyglossiadtx.pl
% (derived from makedtx.pl version 1.49 (c) Nicola Talbot)
% 
% To extract the files, use xetex polyglossia.dtx or luatex polyglossia.dtx
% 
%<*internal>
\iffalse
%</internal>
%<*README>
# THE POLYGLOSSIA PACKAGE v1.64
## Multilingual typesetting with XeLaTeX and LuaLaTeX

This package provides an alternative to Babel for users of XeLaTeX and LuaLaTeX.
This version includes support for over 80 different languages, some of which in
different regional or national varieties, or using a different writing system.

Polyglossia makes it possible to automate the following tasks:

* Loading the appropriate hyphenation patterns.
* Setting the script and language tags of the current font (if possible and
  available), using the package fontspec.
* Switching to a font assigned by the user to a particular script or language.
* Adjusting some typographical conventions in function of the current language
  (such as afterindent, frenchindent, spaces before or after punctuation marks,
  etc.).
* Redefining the document strings (like “chapter”, “figure”, “bibliography”).
* Adapting the formatting of dates (for non-gregorian calendars via external
  packages bundled with polyglossia: currently the Hebrew, Islamic and Farsi
  calendars are supported).
* For languages that have their own numeration system, modifying the formatting
  of numbers appropriately.
* Ensuring the proper directionality if the document contains languages
  written from right to left (via the packages bidi and luabidi, available
  separately).

# LICENCE

Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2023 Arthur Reutenauer,
Copyright (c) 2019-2023 Bastien Roucariès, 2019-2023 Jürgen Spitzmüller

Except where otherwise noted, Polyglossia is placed under the terms of the MIT licence
(https://opensource.org/licenses/MIT).

# BUGS

If you run into a bug, or suspect you do, or you have a request or comment, please
use the GitHub issue tracker: http://github.com/reutenauer/polyglossia/issues

This is more efficient than contacting the maintainer by email as it allows us
to track the issues and follow progress.
%</README>
%<*internal>
\fi
%</internal>
%
%<*internal>
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\let\MetaPrefix\relax
\preamble
  ____________________________

  The polyglossia package         
  (C) 2008–2010 François Charette    
  (C) 2011–2023 Arthur Reutenauer
  (C) 2013 Elie Roux
  (C) 2019 Bastien Roucariès
  (C) 2019–2023 Jürgen Spitzmüller
  License information appended


\endpreamble
\postamble

 Copyright (C) 2023 by Arthur Reutenauer <arthur 'dot' reutenauer 'at' normalesup 'dot' org> 

 This work may be distributed and/or modified under the
 conditions of the LaTeX Project Public License, either version 1.3
 of this license of (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 Arthur Reutenauer.


\endpostamble
\let\MetaPrefix\DoubleperCent
\askforoverwritefalse
\generate{\file{polyglossia.sty}{\from{polyglossia.dtx}{polyglossia.sty}}}
\generate{\file{farsical.sty}{\from{polyglossia.dtx}{farsical.sty}}}
\generate{\file{hebrewcal.sty}{\from{polyglossia.dtx}{hebrewcal.sty}}}
\generate{\file{hijrical.sty}{\from{polyglossia.dtx}{hijrical.sty}}}
\generate{\file{polyglossia-french.lua}{\from{polyglossia.dtx}{polyglossia-french.lua}}}
\generate{\file{polyglossia-korean.lua}{\from{polyglossia.dtx}{polyglossia-korean.lua}}}
\generate{\file{polyglossia-latin.lua}{\from{polyglossia.dtx}{polyglossia-latin.lua}}}
\generate{\file{polyglossia-punct.lua}{\from{polyglossia.dtx}{polyglossia-punct.lua}}}
\generate{\file{polyglossia-sanskrit.lua}{\from{polyglossia.dtx}{polyglossia-sanskrit.lua}}}
\generate{\file{polyglossia-tibt.lua}{\from{polyglossia.dtx}{polyglossia-tibt.lua}}}
\generate{\file{polyglossia.lua}{\from{polyglossia.dtx}{polyglossia.lua}}}
\generate{\file{babel-hebrewalph.def}{\from{polyglossia.dtx}{babel-hebrewalph.def}}}
\generate{\file{babelsh.def}{\from{polyglossia.dtx}{babelsh.def}}}
\generate{\file{cal-util.def}{\from{polyglossia.dtx}{cal-util.def}}}
\generate{\file{xgreek-fixes.def}{\from{polyglossia.dtx}{xgreek-fixes.def}}}
\generate{\file{gloss-latex.lde}{\from{polyglossia.dtx}{gloss-latex.lde}}}
\generate{\file{gloss-acadien.ldf}{\from{polyglossia.dtx}{gloss-acadien.ldf}}}
\generate{\file{gloss-aeb.ldf}{\from{polyglossia.dtx}{gloss-aeb.ldf}}}
\generate{\file{gloss-af.ldf}{\from{polyglossia.dtx}{gloss-af.ldf}}}
\generate{\file{gloss-afb.ldf}{\from{polyglossia.dtx}{gloss-afb.ldf}}}
\generate{\file{gloss-afrikaans.ldf}{\from{polyglossia.dtx}{gloss-afrikaans.ldf}}}
\generate{\file{gloss-albanian.ldf}{\from{polyglossia.dtx}{gloss-albanian.ldf}}}
\generate{\file{gloss-am.ldf}{\from{polyglossia.dtx}{gloss-am.ldf}}}
\generate{\file{gloss-american.ldf}{\from{polyglossia.dtx}{gloss-american.ldf}}}
\generate{\file{gloss-amharic.ldf}{\from{polyglossia.dtx}{gloss-amharic.ldf}}}
\generate{\file{gloss-apd.ldf}{\from{polyglossia.dtx}{gloss-apd.ldf}}}
\generate{\file{gloss-ar-IQ.ldf}{\from{polyglossia.dtx}{gloss-ar-IQ.ldf}}}
\generate{\file{gloss-ar-JO.ldf}{\from{polyglossia.dtx}{gloss-ar-JO.ldf}}}
\generate{\file{gloss-ar-LB.ldf}{\from{polyglossia.dtx}{gloss-ar-LB.ldf}}}
\generate{\file{gloss-ar-MR.ldf}{\from{polyglossia.dtx}{gloss-ar-MR.ldf}}}
\generate{\file{gloss-ar-PS.ldf}{\from{polyglossia.dtx}{gloss-ar-PS.ldf}}}
\generate{\file{gloss-ar-SY.ldf}{\from{polyglossia.dtx}{gloss-ar-SY.ldf}}}
\generate{\file{gloss-ar-YE.ldf}{\from{polyglossia.dtx}{gloss-ar-YE.ldf}}}
\generate{\file{gloss-ar.ldf}{\from{polyglossia.dtx}{gloss-ar.ldf}}}
\generate{\file{gloss-arabic.ldf}{\from{polyglossia.dtx}{gloss-arabic.ldf}}}
\generate{\file{gloss-armenian.ldf}{\from{polyglossia.dtx}{gloss-armenian.ldf}}}
\generate{\file{gloss-arq.ldf}{\from{polyglossia.dtx}{gloss-arq.ldf}}}
\generate{\file{gloss-ary.ldf}{\from{polyglossia.dtx}{gloss-ary.ldf}}}
\generate{\file{gloss-arz.ldf}{\from{polyglossia.dtx}{gloss-arz.ldf}}}
\generate{\file{gloss-ast.ldf}{\from{polyglossia.dtx}{gloss-ast.ldf}}}
\generate{\file{gloss-asturian.ldf}{\from{polyglossia.dtx}{gloss-asturian.ldf}}}
\generate{\file{gloss-australian.ldf}{\from{polyglossia.dtx}{gloss-australian.ldf}}}
\generate{\file{gloss-austrian.ldf}{\from{polyglossia.dtx}{gloss-austrian.ldf}}}
\generate{\file{gloss-ayl.ldf}{\from{polyglossia.dtx}{gloss-ayl.ldf}}}
\generate{\file{gloss-bahasa.ldf}{\from{polyglossia.dtx}{gloss-bahasa.ldf}}}
\generate{\file{gloss-bahasai.ldf}{\from{polyglossia.dtx}{gloss-bahasai.ldf}}}
\generate{\file{gloss-bahasam.ldf}{\from{polyglossia.dtx}{gloss-bahasam.ldf}}}
\generate{\file{gloss-basque.ldf}{\from{polyglossia.dtx}{gloss-basque.ldf}}}
\generate{\file{gloss-be-tarask.ldf}{\from{polyglossia.dtx}{gloss-be-tarask.ldf}}}
\generate{\file{gloss-be.ldf}{\from{polyglossia.dtx}{gloss-be.ldf}}}
\generate{\file{gloss-belarusian.ldf}{\from{polyglossia.dtx}{gloss-belarusian.ldf}}}
\generate{\file{gloss-bengali.ldf}{\from{polyglossia.dtx}{gloss-bengali.ldf}}}
\generate{\file{gloss-bg.ldf}{\from{polyglossia.dtx}{gloss-bg.ldf}}}
\generate{\file{gloss-bn.ldf}{\from{polyglossia.dtx}{gloss-bn.ldf}}}
\generate{\file{gloss-bo.ldf}{\from{polyglossia.dtx}{gloss-bo.ldf}}}
\generate{\file{gloss-bosnian.ldf}{\from{polyglossia.dtx}{gloss-bosnian.ldf}}}
\generate{\file{gloss-br.ldf}{\from{polyglossia.dtx}{gloss-br.ldf}}}
\generate{\file{gloss-brazil.ldf}{\from{polyglossia.dtx}{gloss-brazil.ldf}}}
\generate{\file{gloss-breton.ldf}{\from{polyglossia.dtx}{gloss-breton.ldf}}}
\generate{\file{gloss-british.ldf}{\from{polyglossia.dtx}{gloss-british.ldf}}}
\generate{\file{gloss-bs.ldf}{\from{polyglossia.dtx}{gloss-bs.ldf}}}
\generate{\file{gloss-bulgarian.ldf}{\from{polyglossia.dtx}{gloss-bulgarian.ldf}}}
\generate{\file{gloss-ca.ldf}{\from{polyglossia.dtx}{gloss-ca.ldf}}}
\generate{\file{gloss-canadian.ldf}{\from{polyglossia.dtx}{gloss-canadian.ldf}}}
\generate{\file{gloss-canadien.ldf}{\from{polyglossia.dtx}{gloss-canadien.ldf}}}
\generate{\file{gloss-catalan.ldf}{\from{polyglossia.dtx}{gloss-catalan.ldf}}}
\generate{\file{gloss-chinese.ldf}{\from{polyglossia.dtx}{gloss-chinese.ldf}}}
\generate{\file{gloss-ckb-Arab.ldf}{\from{polyglossia.dtx}{gloss-ckb-Arab.ldf}}}
\generate{\file{gloss-ckb-Latn.ldf}{\from{polyglossia.dtx}{gloss-ckb-Latn.ldf}}}
\generate{\file{gloss-ckb.ldf}{\from{polyglossia.dtx}{gloss-ckb.ldf}}}
\generate{\file{gloss-cop.ldf}{\from{polyglossia.dtx}{gloss-cop.ldf}}}
\generate{\file{gloss-coptic.ldf}{\from{polyglossia.dtx}{gloss-coptic.ldf}}}
\generate{\file{gloss-croatian.ldf}{\from{polyglossia.dtx}{gloss-croatian.ldf}}}
\generate{\file{gloss-cy.ldf}{\from{polyglossia.dtx}{gloss-cy.ldf}}}
\generate{\file{gloss-cz.ldf}{\from{polyglossia.dtx}{gloss-cz.ldf}}}
\generate{\file{gloss-czech.ldf}{\from{polyglossia.dtx}{gloss-czech.ldf}}}
\generate{\file{gloss-da.ldf}{\from{polyglossia.dtx}{gloss-da.ldf}}}
\generate{\file{gloss-danish.ldf}{\from{polyglossia.dtx}{gloss-danish.ldf}}}
\generate{\file{gloss-de-AT-1901.ldf}{\from{polyglossia.dtx}{gloss-de-AT-1901.ldf}}}
\generate{\file{gloss-de-AT-1996.ldf}{\from{polyglossia.dtx}{gloss-de-AT-1996.ldf}}}
\generate{\file{gloss-de-AT.ldf}{\from{polyglossia.dtx}{gloss-de-AT.ldf}}}
\generate{\file{gloss-de-CH-1901.ldf}{\from{polyglossia.dtx}{gloss-de-CH-1901.ldf}}}
\generate{\file{gloss-de-CH-1996.ldf}{\from{polyglossia.dtx}{gloss-de-CH-1996.ldf}}}
\generate{\file{gloss-de-CH.ldf}{\from{polyglossia.dtx}{gloss-de-CH.ldf}}}
\generate{\file{gloss-de-DE-1901.ldf}{\from{polyglossia.dtx}{gloss-de-DE-1901.ldf}}}
\generate{\file{gloss-de-DE-1996.ldf}{\from{polyglossia.dtx}{gloss-de-DE-1996.ldf}}}
\generate{\file{gloss-de-DE.ldf}{\from{polyglossia.dtx}{gloss-de-DE.ldf}}}
\generate{\file{gloss-de-Latf-AT-1901.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-AT-1901.ldf}}}
\generate{\file{gloss-de-Latf-AT-1996.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-AT-1996.ldf}}}
\generate{\file{gloss-de-Latf-AT.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-AT.ldf}}}
\generate{\file{gloss-de-Latf-CH-1901.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-CH-1901.ldf}}}
\generate{\file{gloss-de-Latf-CH-1996.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-CH-1996.ldf}}}
\generate{\file{gloss-de-Latf-CH.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-CH.ldf}}}
\generate{\file{gloss-de-Latf-DE-1901.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-DE-1901.ldf}}}
\generate{\file{gloss-de-Latf-DE-1996.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-DE-1996.ldf}}}
\generate{\file{gloss-de-Latf-DE.ldf}{\from{polyglossia.dtx}{gloss-de-Latf-DE.ldf}}}
\generate{\file{gloss-de-Latf.ldf}{\from{polyglossia.dtx}{gloss-de-Latf.ldf}}}
\generate{\file{gloss-de.ldf}{\from{polyglossia.dtx}{gloss-de.ldf}}}
\generate{\file{gloss-divehi.ldf}{\from{polyglossia.dtx}{gloss-divehi.ldf}}}
\generate{\file{gloss-dsb.ldf}{\from{polyglossia.dtx}{gloss-dsb.ldf}}}
\generate{\file{gloss-dutch.ldf}{\from{polyglossia.dtx}{gloss-dutch.ldf}}}
\generate{\file{gloss-dv.ldf}{\from{polyglossia.dtx}{gloss-dv.ldf}}}
\generate{\file{gloss-el-monoton.ldf}{\from{polyglossia.dtx}{gloss-el-monoton.ldf}}}
\generate{\file{gloss-el-polyton.ldf}{\from{polyglossia.dtx}{gloss-el-polyton.ldf}}}
\generate{\file{gloss-el.ldf}{\from{polyglossia.dtx}{gloss-el.ldf}}}
\generate{\file{gloss-en-AU.ldf}{\from{polyglossia.dtx}{gloss-en-AU.ldf}}}
\generate{\file{gloss-en-CA.ldf}{\from{polyglossia.dtx}{gloss-en-CA.ldf}}}
\generate{\file{gloss-en-GB.ldf}{\from{polyglossia.dtx}{gloss-en-GB.ldf}}}
\generate{\file{gloss-en-NZ.ldf}{\from{polyglossia.dtx}{gloss-en-NZ.ldf}}}
\generate{\file{gloss-en-US.ldf}{\from{polyglossia.dtx}{gloss-en-US.ldf}}}
\generate{\file{gloss-en.ldf}{\from{polyglossia.dtx}{gloss-en.ldf}}}
\generate{\file{gloss-english.ldf}{\from{polyglossia.dtx}{gloss-english.ldf}}}
\generate{\file{gloss-eo.ldf}{\from{polyglossia.dtx}{gloss-eo.ldf}}}
\generate{\file{gloss-es-ES.ldf}{\from{polyglossia.dtx}{gloss-es-ES.ldf}}}
\generate{\file{gloss-es-MX.ldf}{\from{polyglossia.dtx}{gloss-es-MX.ldf}}}
\generate{\file{gloss-es.ldf}{\from{polyglossia.dtx}{gloss-es.ldf}}}
\generate{\file{gloss-esperanto.ldf}{\from{polyglossia.dtx}{gloss-esperanto.ldf}}}
\generate{\file{gloss-estonian.ldf}{\from{polyglossia.dtx}{gloss-estonian.ldf}}}
\generate{\file{gloss-et.ldf}{\from{polyglossia.dtx}{gloss-et.ldf}}}
\generate{\file{gloss-eu.ldf}{\from{polyglossia.dtx}{gloss-eu.ldf}}}
\generate{\file{gloss-fa.ldf}{\from{polyglossia.dtx}{gloss-fa.ldf}}}
\generate{\file{gloss-farsi.ldf}{\from{polyglossia.dtx}{gloss-farsi.ldf}}}
\generate{\file{gloss-fi.ldf}{\from{polyglossia.dtx}{gloss-fi.ldf}}}
\generate{\file{gloss-finnish.ldf}{\from{polyglossia.dtx}{gloss-finnish.ldf}}}
\generate{\file{gloss-fr-CA-u-sd-canb.ldf}{\from{polyglossia.dtx}{gloss-fr-CA-u-sd-canb.ldf}}}
\generate{\file{gloss-fr-CA.ldf}{\from{polyglossia.dtx}{gloss-fr-CA.ldf}}}
\generate{\file{gloss-fr-CH.ldf}{\from{polyglossia.dtx}{gloss-fr-CH.ldf}}}
\generate{\file{gloss-fr-FR.ldf}{\from{polyglossia.dtx}{gloss-fr-FR.ldf}}}
\generate{\file{gloss-fr.ldf}{\from{polyglossia.dtx}{gloss-fr.ldf}}}
\generate{\file{gloss-french.ldf}{\from{polyglossia.dtx}{gloss-french.ldf}}}
\generate{\file{gloss-friulan.ldf}{\from{polyglossia.dtx}{gloss-friulan.ldf}}}
\generate{\file{gloss-friulian.ldf}{\from{polyglossia.dtx}{gloss-friulian.ldf}}}
\generate{\file{gloss-fur.ldf}{\from{polyglossia.dtx}{gloss-fur.ldf}}}
\generate{\file{gloss-ga.ldf}{\from{polyglossia.dtx}{gloss-ga.ldf}}}
\generate{\file{gloss-gaelic.ldf}{\from{polyglossia.dtx}{gloss-gaelic.ldf}}}
\generate{\file{gloss-galician.ldf}{\from{polyglossia.dtx}{gloss-galician.ldf}}}
\generate{\file{gloss-gd.ldf}{\from{polyglossia.dtx}{gloss-gd.ldf}}}
\generate{\file{gloss-georgian.ldf}{\from{polyglossia.dtx}{gloss-georgian.ldf}}}
\generate{\file{gloss-german.ldf}{\from{polyglossia.dtx}{gloss-german.ldf}}}
\generate{\file{gloss-germanb.ldf}{\from{polyglossia.dtx}{gloss-germanb.ldf}}}
\generate{\file{gloss-gl.ldf}{\from{polyglossia.dtx}{gloss-gl.ldf}}}
\generate{\file{gloss-grc.ldf}{\from{polyglossia.dtx}{gloss-grc.ldf}}}
\generate{\file{gloss-greek.ldf}{\from{polyglossia.dtx}{gloss-greek.ldf}}}
\generate{\file{gloss-he.ldf}{\from{polyglossia.dtx}{gloss-he.ldf}}}
\generate{\file{gloss-hebrew.ldf}{\from{polyglossia.dtx}{gloss-hebrew.ldf}}}
\generate{\file{gloss-hi.ldf}{\from{polyglossia.dtx}{gloss-hi.ldf}}}
\generate{\file{gloss-hindi.ldf}{\from{polyglossia.dtx}{gloss-hindi.ldf}}}
\generate{\file{gloss-hr.ldf}{\from{polyglossia.dtx}{gloss-hr.ldf}}}
\generate{\file{gloss-hsb.ldf}{\from{polyglossia.dtx}{gloss-hsb.ldf}}}
\generate{\file{gloss-hu.ldf}{\from{polyglossia.dtx}{gloss-hu.ldf}}}
\generate{\file{gloss-hungarian.ldf}{\from{polyglossia.dtx}{gloss-hungarian.ldf}}}
\generate{\file{gloss-hy.ldf}{\from{polyglossia.dtx}{gloss-hy.ldf}}}
\generate{\file{gloss-ia.ldf}{\from{polyglossia.dtx}{gloss-ia.ldf}}}
\generate{\file{gloss-icelandic.ldf}{\from{polyglossia.dtx}{gloss-icelandic.ldf}}}
\generate{\file{gloss-id.ldf}{\from{polyglossia.dtx}{gloss-id.ldf}}}
\generate{\file{gloss-interlingua.ldf}{\from{polyglossia.dtx}{gloss-interlingua.ldf}}}
\generate{\file{gloss-irish.ldf}{\from{polyglossia.dtx}{gloss-irish.ldf}}}
\generate{\file{gloss-is.ldf}{\from{polyglossia.dtx}{gloss-is.ldf}}}
\generate{\file{gloss-it.ldf}{\from{polyglossia.dtx}{gloss-it.ldf}}}
\generate{\file{gloss-italian.ldf}{\from{polyglossia.dtx}{gloss-italian.ldf}}}
\generate{\file{gloss-ja.ldf}{\from{polyglossia.dtx}{gloss-ja.ldf}}}
\generate{\file{gloss-japanese.ldf}{\from{polyglossia.dtx}{gloss-japanese.ldf}}}
\generate{\file{gloss-ka.ldf}{\from{polyglossia.dtx}{gloss-ka.ldf}}}
\generate{\file{gloss-kannada.ldf}{\from{polyglossia.dtx}{gloss-kannada.ldf}}}
\generate{\file{gloss-khmer.ldf}{\from{polyglossia.dtx}{gloss-khmer.ldf}}}
\generate{\file{gloss-km.ldf}{\from{polyglossia.dtx}{gloss-km.ldf}}}
\generate{\file{gloss-kmr-Arab.ldf}{\from{polyglossia.dtx}{gloss-kmr-Arab.ldf}}}
\generate{\file{gloss-kmr-Latn.ldf}{\from{polyglossia.dtx}{gloss-kmr-Latn.ldf}}}
\generate{\file{gloss-kmr.ldf}{\from{polyglossia.dtx}{gloss-kmr.ldf}}}
\generate{\file{gloss-kn.ldf}{\from{polyglossia.dtx}{gloss-kn.ldf}}}
\generate{\file{gloss-ko.ldf}{\from{polyglossia.dtx}{gloss-ko.ldf}}}
\generate{\file{gloss-korean.ldf}{\from{polyglossia.dtx}{gloss-korean.ldf}}}
\generate{\file{gloss-ku-Arab.ldf}{\from{polyglossia.dtx}{gloss-ku-Arab.ldf}}}
\generate{\file{gloss-ku-Latn.ldf}{\from{polyglossia.dtx}{gloss-ku-Latn.ldf}}}
\generate{\file{gloss-ku.ldf}{\from{polyglossia.dtx}{gloss-ku.ldf}}}
\generate{\file{gloss-kurdish.ldf}{\from{polyglossia.dtx}{gloss-kurdish.ldf}}}
\generate{\file{gloss-kurmanji.ldf}{\from{polyglossia.dtx}{gloss-kurmanji.ldf}}}
\generate{\file{gloss-la-x-classic.ldf}{\from{polyglossia.dtx}{gloss-la-x-classic.ldf}}}
\generate{\file{gloss-la-x-ecclesia.ldf}{\from{polyglossia.dtx}{gloss-la-x-ecclesia.ldf}}}
\generate{\file{gloss-la-x-medieval.ldf}{\from{polyglossia.dtx}{gloss-la-x-medieval.ldf}}}
\generate{\file{gloss-la.ldf}{\from{polyglossia.dtx}{gloss-la.ldf}}}
\generate{\file{gloss-lao.ldf}{\from{polyglossia.dtx}{gloss-lao.ldf}}}
\generate{\file{gloss-latin.ldf}{\from{polyglossia.dtx}{gloss-latin.ldf}}}
\generate{\file{gloss-latinclassic.ldf}{\from{polyglossia.dtx}{gloss-latinclassic.ldf}}}
\generate{\file{gloss-latinecclesiastic.ldf}{\from{polyglossia.dtx}{gloss-latinecclesiastic.ldf}}}
\generate{\file{gloss-latinmedieval.ldf}{\from{polyglossia.dtx}{gloss-latinmedieval.ldf}}}
\generate{\file{gloss-latvian.ldf}{\from{polyglossia.dtx}{gloss-latvian.ldf}}}
\generate{\file{gloss-lithuanian.ldf}{\from{polyglossia.dtx}{gloss-lithuanian.ldf}}}
\generate{\file{gloss-lo.ldf}{\from{polyglossia.dtx}{gloss-lo.ldf}}}
\generate{\file{gloss-lowersorbian.ldf}{\from{polyglossia.dtx}{gloss-lowersorbian.ldf}}}
\generate{\file{gloss-lsorbian.ldf}{\from{polyglossia.dtx}{gloss-lsorbian.ldf}}}
\generate{\file{gloss-lt.ldf}{\from{polyglossia.dtx}{gloss-lt.ldf}}}
\generate{\file{gloss-lv.ldf}{\from{polyglossia.dtx}{gloss-lv.ldf}}}
\generate{\file{gloss-macedonian.ldf}{\from{polyglossia.dtx}{gloss-macedonian.ldf}}}
\generate{\file{gloss-magyar.ldf}{\from{polyglossia.dtx}{gloss-magyar.ldf}}}
\generate{\file{gloss-malay.ldf}{\from{polyglossia.dtx}{gloss-malay.ldf}}}
\generate{\file{gloss-malayalam.ldf}{\from{polyglossia.dtx}{gloss-malayalam.ldf}}}
\generate{\file{gloss-marathi.ldf}{\from{polyglossia.dtx}{gloss-marathi.ldf}}}
\generate{\file{gloss-mk.ldf}{\from{polyglossia.dtx}{gloss-mk.ldf}}}
\generate{\file{gloss-ml.ldf}{\from{polyglossia.dtx}{gloss-ml.ldf}}}
\generate{\file{gloss-mn.ldf}{\from{polyglossia.dtx}{gloss-mn.ldf}}}
\generate{\file{gloss-mongolian.ldf}{\from{polyglossia.dtx}{gloss-mongolian.ldf}}}
\generate{\file{gloss-mr.ldf}{\from{polyglossia.dtx}{gloss-mr.ldf}}}
\generate{\file{gloss-naustrian.ldf}{\from{polyglossia.dtx}{gloss-naustrian.ldf}}}
\generate{\file{gloss-nb.ldf}{\from{polyglossia.dtx}{gloss-nb.ldf}}}
\generate{\file{gloss-newzealand.ldf}{\from{polyglossia.dtx}{gloss-newzealand.ldf}}}
\generate{\file{gloss-ngerman.ldf}{\from{polyglossia.dtx}{gloss-ngerman.ldf}}}
\generate{\file{gloss-nko.ldf}{\from{polyglossia.dtx}{gloss-nko.ldf}}}
\generate{\file{gloss-norsk.ldf}{\from{polyglossia.dtx}{gloss-norsk.ldf}}}
\generate{\file{gloss-norwegian.ldf}{\from{polyglossia.dtx}{gloss-norwegian.ldf}}}
\generate{\file{gloss-nswissgerman.ldf}{\from{polyglossia.dtx}{gloss-nswissgerman.ldf}}}
\generate{\file{gloss-nynorsk.ldf}{\from{polyglossia.dtx}{gloss-nynorsk.ldf}}}
\generate{\file{gloss-occitan.ldf}{\from{polyglossia.dtx}{gloss-occitan.ldf}}}
\generate{\file{gloss-pa.ldf}{\from{polyglossia.dtx}{gloss-pa.ldf}}}
\generate{\file{gloss-persian.ldf}{\from{polyglossia.dtx}{gloss-persian.ldf}}}
\generate{\file{gloss-piedmontese.ldf}{\from{polyglossia.dtx}{gloss-piedmontese.ldf}}}
\generate{\file{gloss-polish.ldf}{\from{polyglossia.dtx}{gloss-polish.ldf}}}
\generate{\file{gloss-polutonikogreek.ldf}{\from{polyglossia.dtx}{gloss-polutonikogreek.ldf}}}
\generate{\file{gloss-portuges.ldf}{\from{polyglossia.dtx}{gloss-portuges.ldf}}}
\generate{\file{gloss-portuguese.ldf}{\from{polyglossia.dtx}{gloss-portuguese.ldf}}}
\generate{\file{gloss-punjabi.ldf}{\from{polyglossia.dtx}{gloss-punjabi.ldf}}}
\generate{\file{gloss-romanian.ldf}{\from{polyglossia.dtx}{gloss-romanian.ldf}}}
\generate{\file{gloss-romansh.ldf}{\from{polyglossia.dtx}{gloss-romansh.ldf}}}
\generate{\file{gloss-russian.ldf}{\from{polyglossia.dtx}{gloss-russian.ldf}}}
\generate{\file{gloss-sami.ldf}{\from{polyglossia.dtx}{gloss-sami.ldf}}}
\generate{\file{gloss-samin.ldf}{\from{polyglossia.dtx}{gloss-samin.ldf}}}
\generate{\file{gloss-sanskrit.ldf}{\from{polyglossia.dtx}{gloss-sanskrit.ldf}}}
\generate{\file{gloss-scottish.ldf}{\from{polyglossia.dtx}{gloss-scottish.ldf}}}
\generate{\file{gloss-serbian.ldf}{\from{polyglossia.dtx}{gloss-serbian.ldf}}}
\generate{\file{gloss-serbianc.ldf}{\from{polyglossia.dtx}{gloss-serbianc.ldf}}}
\generate{\file{gloss-slovak.ldf}{\from{polyglossia.dtx}{gloss-slovak.ldf}}}
\generate{\file{gloss-slovene.ldf}{\from{polyglossia.dtx}{gloss-slovene.ldf}}}
\generate{\file{gloss-slovenian.ldf}{\from{polyglossia.dtx}{gloss-slovenian.ldf}}}
\generate{\file{gloss-sorbian.ldf}{\from{polyglossia.dtx}{gloss-sorbian.ldf}}}
\generate{\file{gloss-spanish.ldf}{\from{polyglossia.dtx}{gloss-spanish.ldf}}}
\generate{\file{gloss-spanishmx.ldf}{\from{polyglossia.dtx}{gloss-spanishmx.ldf}}}
\generate{\file{gloss-swedish.ldf}{\from{polyglossia.dtx}{gloss-swedish.ldf}}}
\generate{\file{gloss-swissgerman.ldf}{\from{polyglossia.dtx}{gloss-swissgerman.ldf}}}
\generate{\file{gloss-syriac.ldf}{\from{polyglossia.dtx}{gloss-syriac.ldf}}}
\generate{\file{gloss-tamil.ldf}{\from{polyglossia.dtx}{gloss-tamil.ldf}}}
\generate{\file{gloss-telugu.ldf}{\from{polyglossia.dtx}{gloss-telugu.ldf}}}
\generate{\file{gloss-thai.ldf}{\from{polyglossia.dtx}{gloss-thai.ldf}}}
\generate{\file{gloss-tibetan.ldf}{\from{polyglossia.dtx}{gloss-tibetan.ldf}}}
\generate{\file{gloss-turkish.ldf}{\from{polyglossia.dtx}{gloss-turkish.ldf}}}
\generate{\file{gloss-turkmen.ldf}{\from{polyglossia.dtx}{gloss-turkmen.ldf}}}
\generate{\file{gloss-ug.ldf}{\from{polyglossia.dtx}{gloss-ug.ldf}}}
\generate{\file{gloss-ukrainian.ldf}{\from{polyglossia.dtx}{gloss-ukrainian.ldf}}}
\generate{\file{gloss-uppersorbian.ldf}{\from{polyglossia.dtx}{gloss-uppersorbian.ldf}}}
\generate{\file{gloss-urdu.ldf}{\from{polyglossia.dtx}{gloss-urdu.ldf}}}
\generate{\file{gloss-usorbian.ldf}{\from{polyglossia.dtx}{gloss-usorbian.ldf}}}
\generate{\file{gloss-uyghur.ldf}{\from{polyglossia.dtx}{gloss-uyghur.ldf}}}
\generate{\file{gloss-vietnamese.ldf}{\from{polyglossia.dtx}{gloss-vietnamese.ldf}}}
\generate{\file{gloss-welsh.ldf}{\from{polyglossia.dtx}{gloss-welsh.ldf}}}
\generate{\file{gloss-zh-CN.ldf}{\from{polyglossia.dtx}{gloss-zh-CN.ldf}}}
\generate{\file{gloss-zh-TW.ldf}{\from{polyglossia.dtx}{gloss-zh-TW.ldf}}}
\generate{\file{arabicdigits.map}{\from{polyglossia.dtx}{arabicdigits.map}}}
\generate{\file{bengalidigits.map}{\from{polyglossia.dtx}{bengalidigits.map}}}
\generate{\file{devanagaridigits.map}{\from{polyglossia.dtx}{devanagaridigits.map}}}
\generate{\file{farsidigits.map}{\from{polyglossia.dtx}{farsidigits.map}}}
\generate{\file{gurmukhidigits.map}{\from{polyglossia.dtx}{gurmukhidigits.map}}}
\generate{\file{thaidigits.map}{\from{polyglossia.dtx}{thaidigits.map}}}
\def\MetaPrefix{-- }
\generate{\file{polyglossia-french.lua}{\from{polyglossia.dtx}{polyglossia-french.lua}}}
\generate{\file{polyglossia-korean.lua}{\from{polyglossia.dtx}{polyglossia-korean.lua}}}
\generate{\file{polyglossia-latin.lua}{\from{polyglossia.dtx}{polyglossia-latin.lua}}}
\generate{\file{polyglossia-punct.lua}{\from{polyglossia.dtx}{polyglossia-punct.lua}}}
\generate{\file{polyglossia-sanskrit.lua}{\from{polyglossia.dtx}{polyglossia-sanskrit.lua}}}
\generate{\file{polyglossia-tibt.lua}{\from{polyglossia.dtx}{polyglossia-tibt.lua}}}
\generate{\file{polyglossia.lua}{\from{polyglossia.dtx}{polyglossia.lua}}}
\let\MetaPrefix\DoubleperCent
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{polyglossia.ins}{\from{polyglossia.dtx}{batchfile}}}
\nopreamble\nopostamble
\generate{\file{examples.tex}{\from{polyglossia.dtx}{examples.tex}}}
\generate{\file{example-arabic.tex}{\from{polyglossia.dtx}{example-arabic.tex}}}
\generate{\file{example-thai.tex}{\from{polyglossia.dtx}{example-thai.tex}}}
\generate{\file{README.md}{\from{polyglossia.dtx}{README}}}
\endgroup
%</internal>
%
%<*driver>
% !TeX spellcheck = en_US
% !TeX TS-program = xelatex
\documentclass[11pt,nohyperref]{ltxdoc}
\usepackage{xcolor}
\usepackage{xspace,fancyvrb,longtable,booktabs}
\usepackage[neverdecrease]{paralist}
\usepackage[format=hang,labelfont=bf,labelsep=period]{caption}
\definecolor{xpgblue}{rgb}{0.02,0.04,0.48}
\definecolor{lightblue}{rgb}{0.61,.8,.8}
\definecolor{xpgred}{rgb}{0.65,0.04,0.07}
\usepackage[
    unicode=true,
    bookmarks=true,
    colorlinks=true,
    linkcolor=xpgblue,
    urlcolor=xpgblue,
    citecolor=xpgblue,
    hyperindex=false,
    hyperfootnotes=false,
    pdftitle={Polyglossia: Modern multilingual typesetting with XeLaTeX and LuaLaTeX},
    pdfauthor={F Charette, A Reutenauer, B Roucariès, J Spitzmüller},
    pdfkeywords={xetex, xelatex, luatex, lualatex, multilingual, babel, hyphenation}
    ]{hyperref}
\usepackage{array}
\usepackage{metalogo}
\let\XeTeX\undefined
\let\XeLaTeX\undefined
\usepackage[babelshorthands]{polyglossia}
\usepackage{farsical}
%
% Languages we need in the documentation. See below for fonts
\setmainlanguage[variant=british,ordinalmonthday=false]{english}
\setotherlanguages{arabic,armenian,hebrew,syriac,greek,russian,serbian,catalan,georgian,chinese}
\usepackage[protrusion,nopatch=footnote]{microtype}
\renewcommand\MacroFont{\footnotesize\color{xpgblue}\ttfamily}
% Customizable version of \DescribeMacro (e.g. if macro is too long)
\newcommand*\DescribeMacroCust[2]{%
  \let\origMacroFont\MacroFont%
  \renewcommand\MacroFont{\footnotesize\color{xpgblue}\ttfamily#1}%
  \DescribeMacro{#2}%
  \let\MacroFont\origMacroFont%
}
\newcommand*\Cmd[1]{\cmd{#1}\DescribeMacro{#1}\xspace}
\newcommand*\pkg[1]{\textsf{\color{xpgblue}#1}}
\newcommand*\file[1]{\texttt{\color{xpgblue}#1}}
\newcommand*\TR[1]{\textcolor{xpgred}{#1}}
\newcommand*\TX[1]{\hyperref[#1]{\textcolor{xpgred}{#1}}}
\newcommand*\TA[1]{\textsc{\color{xpgblue}#1}}
\newcommand*\link[1]{\href{#1}{#1}}
\renewcommand*\meta[1]{\texttt{⟨#1⟩}}
\newcommand*\TXI[1]{\href{https://github.com/reutenauer/polyglossia/issues/#1}{\textcolor{xpgred}{\##1}}}
\newcommand*\TXP[1]{\href{https://github.com/reutenauer/polyglossia/pull/#1}{\textcolor{xpgred}{\##1}}}
\def\eg{\textit{e.g.,}\xspace}
\def\ie{\textit{i.e.,}\xspace}
\def\ca{\textit{ca.}\@\xspace}
\def\Eg{\textit{E.g.,}\xspace}
\def\Ie{\textit{I.e.,}\xspace}
\def\etc{\@ifnextchar.{\textit{etc}}{\textit{etc.}\@\xspace}}

%
%% Commands for documenting options
%
\newcommand*\xpgoption[1]{\textcolor{xpgblue}{\ttfamily\bfseries #1}}
\newcommand*\xpgvalue[1]{\texttt{#1}}
\newcommand*\xpgpresetvalue[1]{\texttt{\textit{#1}}}
\newcommand*\xpgdefaultvalue[1]{\texttt{*#1}}

% arguments: #1 version number, #2 key name, #3 footnote, #4 possible values
\NewDocumentCommand\xpgchoicekey{omom}{%
	\xpgoption{#2}\IfValueT{#3}{\footnote{#3}}%
    \IfValueT{#1}{\new{#1}} \xpgvalue{=} #4\par%
}

% arguments: #1 version number, #2 key name, #3 footnote
\NewDocumentCommand\xpgboolkey{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{true} or \xpgvalue{false}}}
\NewDocumentCommand\xpgboolkeytrue{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{\xpgpresetvalue{true}} or \xpgvalue{false}}}
\NewDocumentCommand\xpgboolkeyfalse{omo}{\xpgchoicekey[#1]{#2}[#3]{\xpgdefaultvalue{true} or \xpgpresetvalue{false}}}

% arguments: #1 version number, #2 key name, #3 default code
\NewDocumentCommand\xpgcodekey{omv}{%
	\xpgoption{#2}\IfValueT{#1}{\new{#1}}
     \xpgvalue{=} \meta{code} (default value: \texttt{#3})\par%
}

% arguments: #1 version number, #2 key name, #3 value type, #4 default value
\NewDocumentCommand\xpgoptkey{ommo}{%
	\xpgoption{#2}\IfValueT{#1}{\new{#1}}
	\xpgvalue{=} \meta{#3} (default value: \texttt{#4})\par%
}

%% Sidenotes  << copied from fontspec.dtx
\newcommand\new[1]{%
  \edef\thisversion{v#1}%
  \ifhmode\unskip~\fi{\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi
  $\leftarrow$}%
  \marginpar{\centering
    \small\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi
    \textsf{v#1}}}
\newcommand\displaycmd[2]{%
  \\\DescribeMacro{#2}\centerline{\cmd{#1}}}
\renewenvironment{itemize}{\begin{compactitem}[\char"2023]}%[{\fontspec{DejaVu Sans}\char"25BB}]}%
		{\end{compactitem}}
\renewenvironment{enumerate}{\begin{compactenum}}{\end{compactenum}}
\newenvironment{shorthands}{%
	 \begin{list}{}%
	 	{\settowidth{\labelwidth}{MM}%
	 	 \setlength{\leftmargin}{\labelwidth}%
	 	 \addtolength{\leftmargin}{\labelsep}%
	     \renewcommand{\makelabel}[1]{##1\hfil}}}%
	{\end{list}}

% This is to prevent page breaks too short after subsections
\def\condbreak#1{%
	\vskip 0pt plus #1\pagebreak[3]\vskip 0pt plus -#1\relax}
\pretocmd{\subsection}{\condbreak{2\baselineskip}}{}{}

%
% Fonts
% We try to use fonts that are shipped with TeXLive
% (see #478)
%
%% fontspec declarations:
% Main font: Package libertine (Linux Libertine and Biolinum Mono)
\usepackage[osf]{libertine}
% Monospace: Package dejavu-otf
\setmonofont[Scale=MatchLowercase]{DejaVuSansMono}
% Libertine includes Hebrew, but we load it separately since
% osf is not supported with this script and we want to avoid the
% respective warnings
\newfontfamily\hebrewfont[Script=Hebrew]{Linux Libertine O}
% Package dejavu-otf
\newfontfamily\armenianfont[Script=Armenian,Scale=MatchLowercase]{DejaVuSans}
\newfontfamily\georgianfont[Scale=MatchLowercase]{DejaVuSerif}
% Package amiri
\newfontfamily\arabicfont[Script=Arabic]{Amiri-Regular}
% No Syriac otf/ttf font seems available on CTAN
% This one, from the Syriac Institute, is included on Linux
% in the x11-fonts set and can be downloaded from
% https://bethmardutho.org/meltho/ (Meltho Fonts Package)
\newfontfamily\syriacfont[Script=Syriac]{Serto Jerusalem}
% Our decorative title: package gfscomplutum
\newfontfamily\xpgtitlefont[Scale=1.4, LetterSpace=30]{GFSPolyglot.otf}
% Package noto, notoCJKsc
\newfontfamily\chinesefont{Noto Serif CJK SC}[Script=CJK]

\linespread{1.05}
\frenchspacing
\EnableCrossrefs
\CodelineIndex
\RecordChanges
% COMMENT THE NEXT LINE TO INCLUDE THE CODE
\AtBeginDocument{\OnlyDescription}


\begin{document}
\ifxetex
  \DocInput{polyglossia.dtx}
\fi
\end{document}
%</driver>
% 
% \fi
% 
% \errorcontextlines=999
% \makeatletter
% 
% \hyphenation{Kha-li-ghi Reu-ten-auer new-zea-land}
% \GetFileInfo{polyglossia.sty}
% 
% \title{{\textgreek{\xpgtitlefont\color{lightblue}\MakeUppercase{Πολυγλωσσία}}}
% \\[16pt]
% \color{xpgblue}Polyglossia: Modern multilingual typesetting with \XeLaTeX\ and \LuaLaTeX}
% \author{\TA{François Charette} \and \TA{Arthur Reutenauer}\thanks{Current maintainer}
% 	    \and \TA{Bastien Roucariès} \and \TA{Jürgen Spitzmüller}}
% \date{\filedate \qquad \fileversion\thanks{Please report bugs to \url{http://github.com/reutenauer/polyglossia/issues}}\\
% \footnotesize (\textsc{pdf} file generated on \today)}
% 
% \maketitle
% \tableofcontents
% 
% \condbreak{4\baselineskip}
% 
% 
% \DeleteShortVerb{\|}
% \MakeShortVerb{\¦}
% 
% ^^A\begin{abstract}
% ^^ABlablabla
% ^^A\end{abstract}
% 
% 
% \section{Introduction}
% 
% \pkg{Polyglossia} is a package for facilitating multilingual typesetting with
% \XeLaTeX\ and \LuaLaTeX. Basically, it
% can be used as an alternative to \pkg{babel} for performing the following
% tasks automatically:
% 
% \begin{enumerate}
% \item Loading the appropriate hyphenation patterns.
% \item Setting the script and language tags of the current font (if possible and
%       available), via the package \pkg{fontspec}.
% \item Switching to a font assigned by the user to a particular script or language.
% \item Adjusting some typographical conventions according to the current language
%       (such as afterindent, frenchindent, spaces before or after punctuation marks,
%       etc.).
% \item Redefining all document strings (like “chapter”, “figure”, “bibliography”).
% \item Adapting the formatting of dates (for non-Gregorian calendars via external
%       packages bundled with polyglossia: currently the Hebrew, Islamic and Farsi
%       calendars are supported).
% \item For languages that have their own numbering system, modifying the formatting
%       of numbers appropriately (this also includes redefining the alphabetic sequence
%       for non-Latin alphabets).\footnote{%
%         This is done by bundled sub-packages such as \pkg{arabicnumbers}.}
% \item Ensuring proper directionality if the document contains languages
%       that are written from right to left (via the package \pkg{bidi},
%       available separately).
% \end{enumerate}
% ^^A
% Several features of \pkg{babel} that do not make sense in the \XeTeX\ world (like font
% encodings, shorthands, etc.) are not supported.
% Generally speaking, \pkg{polyglossia} aims to remain as compatible as possible
% with the fundamental features of \pkg{babel} while being cleaner, light-weight,
% and modern. The package \pkg{antomega} has been very beneficial in our attempt to
% reach this objective.
% 
% \paragraph{Requirements} The current version of \pkg{polyglossia} makes use of some convenient
% macros defined in the \pkg{etoolbox} package by \TA{Philipp Lehmann} and \TA{Joseph Wright}.
% Being designed for \XeLaTeX\ and \LuaLaTeX, it obviously also relies on \pkg{fontspec} by
% \TA{Will Robertson}. For languages written from right to left, it needs the package \pkg{bidi}
% (for \XeTeX) or \pkg{luabidi} (for \LuaTeX) by \TA{Vafa Khalighi} (\textarabic{وفا خليقي}) and
% the \pkg{bidi-tex GitHub Organisation}.
% Polyglossia also bundles three packages for calendaric computations (\pkg{hebrewcal},
% \pkg{hijrical}, and \pkg{farsical}).
% 
% 
% \section{Setting up multilingual documents}
% 
% \subsection{Activating languages}
% 
% The default language of a document is specified by means of the command
% 	\displaycmd{\setdefaultlanguage\oarg{options}\marg{lang}}{\setdefaultlanguage}
% (or, equivalently, \Cmd\setmainlanguage).
% Secondary languages are specified with
% 	\displaycmd{\setotherlanguage\oarg{options}\marg{lang}.}{\setotherlanguage}
% All these commands allow you to set language-specific options.\footnote{%
% 	Section~\ref{specific} documents these options for the respective languages.}
% It is also possible to load a series of secondary languages at once (but without options)
% using
% 	\displaycmd{\setotherlanguages\marg{lang1⟩,⟨lang2⟩,⟨lang3⟩,⟨…}.}{\setotherlanguages}
% ^^A
% All language-specific options can be modified locally by means of the
% language-switching commands described in section \ref{languageswitching}.
% 
% \paragraph{Note} In general, it is advisable to activate the languages \emph{after} all
% packages have been loaded. This is particularly important if you use right-to-left scripts
% or languages with babel shorthands.
% 
% 
% \subsection{Supported languages}
% 
% Table~\ref{tab:lang} lists all languages currently supported.
% Those in \TR{red} have specific options and/or commands
% that are explained in section \ref{specific} below.
% 
% \begin{table}[ht]\centering
% \caption{\label{tab:lang}Languages currently supported in \pkg{polyglossia}}
% ^^A Produced with tools/insert-language-list.rb -- JS, 2022-11-23
% ^^A Edited by hand -- JS, 2022-11-23
% \begin{tabular}{lllll}
% 	\toprule
% 	\TX{afrikaans}	& danish		& icelandic		& nko			& \TX{spanish}	\\
% 	albanian		& divehi		& interlingua	& \TX{norwegian}& swedish		\\
% 	amharic			& \TX{dutch}	& \TX{italian}	& occitan		& \TX{syriac}	\\
% 	\TX{arabic}		& \TX{english}	& japanese		& \TX{persian}	& tamil			\\
% 	\TX{armenian}	& \TX{esperanto}& kannada		& piedmontese	& telugu		\\
% 	asturian		& estonian		& khmer			& \TX{polish}	& \TX{thai}		\\
% 	basque			& \TX{finnish}	& \TX{korean}	&\TX{portuguese}& \TX{tibetan}	\\
% 	\TX{belarusian}	& \TX{french}	& \TX{kurdish}	& \TX{punjabi}	& turkish		\\
% 	\TX{bengali}	& friulian		& \TX{lao}		& romanian		& turkmen		\\
% 	bosnian			& \TX{gaelic}	& \TX{latin}	& romansh		& \TX{ukrainian}\\
% 	breton			& galician		& latvian		& \TX{russian}	& \TX{urdu}		\\
% 	bulgarian		& \TX{georgian}	& lithuanian	& \TX{sami}		& \TX{uyghur}	\\
% 	\TX{catalan}	& \TX{german}	& macedonian	& \TX{sanskrit}	& vietnamese	\\
% 	\TX{chinese}	& \TX{greek}	& \TX{malay}	& \TX{serbian}	& \TX{welsh}	\\
% 	coptic			& \TX{hebrew}	& malayalam		& \TX{slovak}	& 				\\
% 	\TX{croatian}	& \TX{hindi}	& \TX{marathi}	& \TX{slovenian}& 				\\
% 	\TX{czech}		& \TX{hungarian}& \TX{mongolian}& \TX{sorbian}	& 				\\
% 	\bottomrule
% \end{tabular}
% \end{table}
% 
% \paragraph{Version Notes} The support for Amharic\new{1.0.1} should be considered an experimental attempt to
% port the package \pkg{ethiop}; feedback is welcome.
% Version 1.1.1\new{1.1.1} added support for Asturian, %\footnote{ Provided by Kevin Godby and Xuacu Saturio.},
% Lithuanian, %\footnote{ Provided by Kevin Godby and Paulius Sladkevičius.},
% and Urdu. %\footnote{ Provided by Kamal Abdali.}
% ^^A
% Version 1.2\new{1.2.0} introduced Armenian, Occitan, Bengali,
% Lao, Malayalam, Marathi, Tamil, Telugu, and Turkmen.\footnote{%
%   See acknowledgements at the end for due credit to the various contributors.}
% Version 1.43\new{1.43} brought basic support for Japanese (this
% is considered experimental, feedback is appreciated).
% In version 1.45\new{1.45}, support for Kurdish and Mongolian as well as some new
% variants (Canadian French and English) have been added. Furthermore, for consistency reasons, some language have
% been renamed (\emph{farsi}\textrightarrow\emph{persian}, \emph{friulan}\textrightarrow\emph{friulian},
% \emph{magyar}\textrightarrow\emph{hungarian}, \emph{portuges}\textrightarrow\emph{portuguese},
% \emph{samin}\textrightarrow\emph{sami}) or merged (\emph{bahasai}\slash\emph{bahasam}\textrightarrow\emph{malay},
% \emph{brazil}\slash\emph{portuges}\textrightarrow\emph{portuguese},
% \emph{lsorbian}\slash\emph{usorbian}\textrightarrow\emph{sorbian},
% \emph{irish}\slash\emph{scottish}\textrightarrow\emph{gaelic},
% \emph{norsk}\slash\emph{nynorsk}\textrightarrow\emph{norwegian}). The old names are still supported for backwards
% compatibility reasons.
% Version 1.46\new{1.46} introduces support for Afrikaans, Belarusian, Bosnian and Georgian.
% Version 1.52\new{1.52} introduces support for Uyghur.
% 
% 
% \subsection{Relation to and use of Babel language names}\label{sec:babelnames}
% 
% If you are familiar with the \pkg{babel} package, you will note that \pkg{polyglossia}'s language naming
% slightly differs. Whereas \pkg{babel} has a unique name for each language variety (\eg\emph{american} and \emph{british}),
% \pkg{polyglossia} differentiates language varieties via language options (\eg \emph{english}, ¦variant=american¦).
% 
% Furthermore, \pkg{babel} sometimes uses abbreviated language names (\eg\emph{bahasam} for Bahasa Malayu) as well
% as endonyms, \ie language names coming from the designated languages (such as \emph{bahasa}, \emph{canadien} or \emph{magyar}).
% As opposed to this, \pkg{polyglossia} always uses spelled-out (lower-cased) English language names.
% Please refer to table~\ref{tab:bbllang} for the differing language names in both packages.
% 
% \begin{table}
% \caption{\label{tab:bbllang}Babel-polyglossia language name matching}
% 
% \begin{minipage}[t]{1\columnwidth}
% \small\centering
% \begin{tabular}{lll}
% \toprule
% \textbf{Babel name} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\tabularnewline
% \midrule
% acadian            & french     & variant=acadian                     \\
% american           & english    & variant=american [\emph{default}]   \\
% australian         & english    & variant=australian                  \\
% austrian           & german     & variant=austrian, spelling=old      \\
% bahasa             & malay      & variant=indonesian [\emph{default}] \\
% bahasam            & malay      & variant=malaysian                   \\
% brazil             & portuguese & variant=brazilian                   \\
% british            & english    & variant=british                     \\
% canadian           & english    & variant=canadian                    \\
% canadien           & french     & variant=canadian                    \\
% classiclatin       & latin      & variant=classic                     \\
% farsi              & persian    &                                     \\
% ecclesiasticlatin  & latin      & variant=ecclesiastic                \\
% friulan            & friulian   &                                     \\
% german\footnote{Due to the name conflict only available in \pkg{polyglossia} as \emph{germanb} (which is a \pkg{babel} synonym).}
%                    & german     & spelling=old                        \\
% irish              & gaelic     & variant=irish [\emph{default}]      \\
% kurmanji           & kurdish    & variant=kurmanji                    \\
% lowersorbian       & sorbian    & variant=lower                       \\
% magyar             & hungarian  &                                     \\
% medievallatin      & latin      & variant=medieval                    \\
% naustrian          & german     & variant=austrian                    \\
% newzealand         & english    & variant=newzealand                  \\
% ngerman            & german     & variant=german [\emph{default}]     \\
% norsk              & norwegian  & variant=bokmal                      \\
% nswissgerman       & german     & variant=swiss                       \\
% nynorsk            & norwegian  & variant=nynorsk [\emph{default}]    \\
% polutonikogreek    & greek      & variant=polytonic                   \\
% portuges           & portuguese & variant=portuguese [\emph{default}] \\
% samin              & sami       &                                     \\
% scottish           & gaelic     & variant=scottish                    \\
% serbianc           & serbian    & script=Cyrillic                     \\
% slovene            & slovenian  &                                     \\
% spanishmx          & spanish    & variant=mexican                     \\
% swissgerman        & german     & variant=swiss, spelling=old         \\
% uppersorbian       & sorbian    & variant=upper [\emph{default}]      \\
% \bottomrule
% \end{tabular}
% \end{minipage}
% 
% \end{table}
% 
% For convenience reasons, \pkg{polyglossia} also supports the use of babel names\new{1.46} (for the few justified
% exceptions, please refer to the notes in table~\ref{tab:bbllang}).
% The babel names listed in table~\ref{tab:bbllang} can be used instead of the corresponding polyglossia
% name\slash options in \cmd\setdefaultlanguage\ and \cmd\setotherlanguage\ as well as in the \pkg{polyglossia} and
% \pkg{babel} language switching commands\slash environments documented in section~\ref{sec:langcmds} and
% \ref{sec:babelcmds} (\eg \cmd\textaustrian\ is synonymous to ¦\textgerman[variant=austrian,spelling=old]¦).
% However, unless you have special reasons, we strongly encourage you to use the \pkg{polyglossia} names.
% 
% 
% \subsection{Using IETF language tags}\label{sec:langtags}
% 
% \pkg{Polyglossia}\new{1.47} also supports the use of language tags that conform to the IETF BCP-47
% \emph{Best Current Practice}.\footnote{Please refer to \url{https://tools.ietf.org/html/bcp47} and
% 	\url{https://en.wikipedia.org/wiki/IETF_language_tag} for details.}
% Thus, you can use tags such as ¦en-GB¦ (for British English) or ¦de-AT-1901¦ (for Austrian German, old spelling)
% in \cmd\setdefaultlanguage\ and \cmd\setotherlanguage\ as well as in the language switching command
% \cmd{\textlang\marg{tag}}, the environment \cmd{\begin\{lang\}\marg{tag}} \ldots\ \cmd{\end\{lang\}} and the \pkg{babel}
% language switching commands\slash environments documented in section~\ref{sec:babelcmds}.
% Table~\ref{tab:BCP47-polyglossia} lists the currently supported tags.
% 
% \bgroup\small\addfontfeatures{Numbers={Monospaced,Lining}}
% \begin{longtable}[c]{ll>{\raggedright}p{6cm}}
% 	\caption{\label{tab:BCP47-polyglossia}BCP47-polyglossia language name matching}\tabularnewline
% 	\toprule
% 	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\tabularnewline
% 	\midrule
% 	\endfirsthead
% 	\caption[]{BCP47-polyglossia language name matching (\emph{continued})}\tabularnewline
% 	\toprule
% 	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\tabularnewline
% 	\midrule
% 	\endhead
% 	aeb              & arabic      & locale=tunisia                                     \tabularnewline
% 	af               & afrikaans   &                                                    \tabularnewline
% 	afb              & arabic      & locale=default                                     \tabularnewline
% 	am               & amharic     &                                                    \tabularnewline
% 	apd              & arabic      & locale=default                                     \tabularnewline
% 	ar               & arabic      &                                                    \tabularnewline
% 	ar-IQ            & arabic      & locale=mashriq                                     \tabularnewline
% 	ar-JO            & arabic      & locale=mashriq                                     \tabularnewline
% 	ar-LB            & arabic      & locale=mashriq                                     \tabularnewline
% 	ar-MR            & arabic      & locale=mauritania                                  \tabularnewline
% 	ar-PS            & arabic      & locale=mashriq                                     \tabularnewline
% 	ar-SY            & arabic      & locale=mashriq                                     \tabularnewline
% 	ar-YE            & arabic      & locale=default                                     \tabularnewline
% 	arq              & arabic      & locale=algeria                                     \tabularnewline
% 	ary              & arabic      & locale=morocco                                     \tabularnewline
% 	arz              & arabic      & locale=default                                     \tabularnewline
% 	ast              & asturian    &                                                    \tabularnewline
% 	ayl              & arabic      & locale=libya                                       \tabularnewline
% 	be               & belarusian  &                                                    \tabularnewline
% 	be-tarask        & belarusian  & spelling=classic                                   \tabularnewline
% 	bg               & bulgarian   &                                                    \tabularnewline
% 	bn               & bengali     &                                                    \tabularnewline
% 	bo               & tibetan     &                                                    \tabularnewline
% 	br               & breton      &                                                    \tabularnewline
% 	bs               & bosnian     &                                                    \tabularnewline
% 	ca               & catalan     &                                                    \tabularnewline
% 	ckb              & kurdish     & variant=sorani [\emph{default}]                    \tabularnewline
% 	ckb-Arab         & kurdish     & variant=sorani, script=Arabic [\emph{default}]     \tabularnewline
% 	ckb-Latn         & kurdish     & variant=sorani, script=Latin                       \tabularnewline
% 	cop              & coptic      &                                                    \tabularnewline
% 	cy               & welsh       &                                                    \tabularnewline
% 	cz               & czech       &                                                    \tabularnewline
% 	da               & danish      &                                                    \tabularnewline
% 	de               & german      &                                                    \tabularnewline
% 	de-AT            & german      & variant=austrian, spelling=new                     \tabularnewline
% 	de-AT-1901       & german      & variant=austrian, spelling=old                     \tabularnewline
% 	de-AT-1996       & german      & variant=austrian, spelling=new                     \tabularnewline
% 	de-CH            & german      & variant=swiss, spelling=new                        \tabularnewline
% 	de-CH-1901       & german      & variant=swiss, spelling=old                        \tabularnewline
% 	de-CH-1996       & german      & variant=swiss, spelling=new                        \tabularnewline
% 	de-DE            & german      & variant=german, spelling=new                       \tabularnewline
% 	de-DE-1901       & german      & variant=german, spelling=old                       \tabularnewline
% 	de-DE-1996       & german      & variant=german, spelling=new  [\emph{default}]     \tabularnewline
% 	de-Latf          & german      & script=blackletter                                 \tabularnewline
% 	de-Latf-AT       & german      & variant=austrian, spelling=new, script=blackletter \tabularnewline
% 	de-Latf-AT-1901  & german      & variant=austrian, spelling=old, script=blackletter \tabularnewline
% 	de-Latf-AT-1996  & german      & variant=austrian, spelling=new, script=blackletter \tabularnewline
% 	de-Latf-CH       & german      & variant=swiss, spelling=new, script=blackletter    \tabularnewline
% 	de-Latf-CH-1901  & german      & variant=swiss, spelling=old, script=blackletter    \tabularnewline
% 	de-Latf-CH-1996  & german      & variant=swiss, spelling=new, script=blackletter    \tabularnewline
% 	de-Latf-DE       & german      & variant=german, spelling=new, script=blackletter   \tabularnewline
% 	de-Latf-DE-1901  & german      & variant=german, spelling=old, script=blackletter   \tabularnewline
% 	de-Latf-DE-1996  & german      & variant=german, spelling=new, script=blackletter   \tabularnewline
% 	dsb              & sorbian     & variant=lower                                      \tabularnewline
% 	dv               & divehi      &                                                    \tabularnewline
% 	el               & greek       &                                                    \tabularnewline
% 	el-monoton       & greek       & variant=monotonic  [\emph{default}]                \tabularnewline
% 	el-polyton       & greek       & varant=polytonic                                   \tabularnewline
% 	en               & english     &                                                    \tabularnewline
% 	en-AU            & english     & variant=australian                                 \tabularnewline
% 	en-CA            & english     & variant=canadian                                   \tabularnewline
% 	en-GB            & english     & variant=british                                    \tabularnewline
% 	en-NZ            & english     & variant=newzealand                                 \tabularnewline
% 	en-US            & english     & variant=us [\emph{default}]                        \tabularnewline
% 	eo               & esperanto   &                                                    \tabularnewline
% 	es               & spanish     &                                                    \tabularnewline
% 	es-ES            & spanish     & variant=spanish [\emph{default}]                   \tabularnewline
% 	es-MX            & spanish     & variant=mexican                                    \tabularnewline
% 	et               & estonian    &                                                    \tabularnewline
% 	eu               & basque      &                                                    \tabularnewline
% 	fa               & persian     &                                                    \tabularnewline
% 	fi               & finnish     &                                                    \tabularnewline
% 	fr               & french      &                                                    \tabularnewline
% 	fr-CA            & french      & variant=canadian                                   \tabularnewline
% 	fr-CA-u-sd-canb  & french      & variant=acadian                                    \tabularnewline
% 	fr-CH            & french      & variant=swiss                                      \tabularnewline
% 	fr-FR            & french      & variant=french [\emph{default}]                    \tabularnewline
% 	fur              & friulian    &                                                    \tabularnewline
% 	ga               & gaelic      & variant=irish [\emph{default}]                     \tabularnewline
% 	gd               & gaelic      & variant=scottish                                   \tabularnewline
% 	gl               & galician    &                                                    \tabularnewline
% 	grc              & greek       & variant=ancient                                    \tabularnewline
% 	he               & hebrew      &                                                    \tabularnewline
% 	hi               & hindi       &                                                    \tabularnewline
% 	hr               & croatian    &                                                    \tabularnewline
% 	hsb              & sorbian     & variant=upper [\emph{default}]                     \tabularnewline
% 	hu               & hungarian   &                                                    \tabularnewline
% 	hy               & armenian    &                                                    \tabularnewline
% 	ia               & interlingua &                                                    \tabularnewline
% 	id               & malay       & variant=indonesian                                 \tabularnewline
% 	is               & icelandic   &                                                    \tabularnewline
% 	it               & italian     &                                                    \tabularnewline
% 	ja               & japanese    &                                                    \tabularnewline
% 	ka               & georgian    &                                                    \tabularnewline
% 	km               & khmer       &                                                    \tabularnewline
% 	kmr              & kurdish     & variant=kurmanji                                   \tabularnewline
% 	kmr-Arab         & kurdish     & variant=kurmanji, script=Arabic                    \tabularnewline
% 	kmr-Latn         & kurdish     & variant=kurmanji, script=Latin                     \tabularnewline
% 	kn               & kannada     &                                                    \tabularnewline
% 	ko               & korean      &                                                    \tabularnewline
% 	ku               & kurdish     &                                                    \tabularnewline
% 	ku-Arab          & kurdish     & script=Arabic                                      \tabularnewline
% 	ku-Latn          & kurdish     & script=Latin                                       \tabularnewline
% 	la               & latin       &                                                    \tabularnewline
% 	la-x-classic     & latin       & variant=classic                                    \tabularnewline
% 	la-x-ecclesia    & latin       & variant=ecclesiastic                               \tabularnewline
% 	la-x-medieval    & latin       & variant=medieval                                   \tabularnewline
% 	lo               & lao         &                                                    \tabularnewline
% 	lt               & lithuanian  &                                                    \tabularnewline
% 	lv               & latvian     &                                                    \tabularnewline
% 	mk               & macedonian  &                                                    \tabularnewline
% 	ml               & malayalam   &                                                    \tabularnewline
% 	mn               & mongolian   &                                                    \tabularnewline
% 	mr               & marathi     &                                                    \tabularnewline
% 	nb               & norwegian   & variant=bokmal                                     \tabularnewline
% 	nko              & nko         &                                                    \tabularnewline
% 	nl               & dutch       &                                                    \tabularnewline
% 	nn               & norwegian   & variant=nynorsk [\emph{default}]                   \tabularnewline
% 	oc               & occitan     &                                                    \tabularnewline
% 	pa               & punjabi     & numerals=gurmukhi                                  \tabularnewline
% 	pl               & polish      &                                                    \tabularnewline
% 	pms              & piedmontese &                                                    \tabularnewline
% 	pt               & portuguese  &                                                    \tabularnewline
% 	pt-BR            & portuguese  & variant=brazilian                                  \tabularnewline
% 	pt-PT            & portuguese  & variant=portuguese [\emph{default}]                \tabularnewline
% 	rm               & romansh     &                                                    \tabularnewline
% 	ro               & romanian    &                                                    \tabularnewline
% 	ru               & russian     &                                                    \tabularnewline
% 	ru-luna1918      & russian     & spelling=modern [\emph{default}]                   \tabularnewline
% 	ru-petr1708      & russian     & spelling=old                                       \tabularnewline
% 	sa               & sanskrit    &                                                    \tabularnewline
% 	sa-Beng          & sanskrit    & script=Bengali                                     \tabularnewline
% 	sa-Deva          & sanskrit    & script=Devanagari [\emph{default}]                 \tabularnewline
% 	sa-Gujr          & sanskrit    & script=Gujarati                                    \tabularnewline
% 	sa-Knda          & sanskrit    & script=Kannada                                     \tabularnewline
% 	sa-Mlym          & sanskrit    & script=Malayalam                                   \tabularnewline
% 	sa-Telu          & sanskrit    & script=Telugu                                      \tabularnewline
% 	se               & sami        &                                                    \tabularnewline
% 	sk               & slovak      &                                                    \tabularnewline
% 	sl               & slovenian   &                                                    \tabularnewline
% 	sq               & albanian    &                                                    \tabularnewline
% 	sr               & serbian     &                                                    \tabularnewline
% 	sr-Cyrl          & serbian     & script=Cyrillic                                    \tabularnewline
% 	sr-Latn          & serbian     & script=Latin [\emph{default}]                      \tabularnewline
% 	sv               & swedish     &                                                    \tabularnewline
% 	syr              & syriac      &                                                    \tabularnewline
% 	ta               & tamil       &                                                    \tabularnewline
% 	te               & telugu      &                                                    \tabularnewline
% 	th               & thai        &                                                    \tabularnewline
% 	tk               & turkmen     &                                                    \tabularnewline
% 	tr               & turkish     &                                                    \tabularnewline
% 	ug               & uyghur      &                                                    \tabularnewline
% 	uk               & ukrainian   &                                                    \tabularnewline
% 	ur               & urdu        &                                                    \tabularnewline
% 	vi               & vietnamese  &                                                    \tabularnewline
% 	zh               & chinese     &                                                    \tabularnewline
% 	zh-CN            & chinese     & variant=simplified [\emph{default}]                \tabularnewline
% 	zh-TW            & chinese     & variant=traditional                                \tabularnewline
% 	zsm              & malay       & variant=malaysian [\emph{default}]                 \tabularnewline
% 	\bottomrule
% \end{longtable}
% \egroup
% 
% \subsection{Global options}
% 
% \pkg{Polyglossia} can be loaded with the following global package options:
% 
% \begin{itemize}
% 	\item \xpgboolkeyfalse[1.1.1]{babelshorthands}
% 		Globally activates \pkg{babel} shorthands whenever available. Such shorthands are
% 		implemented currently for Afrikaans, Belarusian, Catalan, Croatian,
% 		Czech, Dutch, Finnish, Georgian, German, Italian, Latin, Mongolian,
% 		Russian, Slovak, and Ukrainian. Please refer to the respective language descriptions
% 		(sec.~\ref{specific}) for details.
% 
% 	\item \xpgboolkeyfalse{localmarks} redefines the internal \LaTeX\ macros \cmd\markboth\ and
% 		\cmd\markright\ to the effect that the header text is explicitly set in the currently
% 		active language (\ie wrapped into \cmd\foreignlanguage\{\meta{lang}\}\{\meta{\ldots}\}).
% 		
% 		In earlier versions of \pkg{polyglossia},\new{1.2.0} this
% 		option was enabled by default, but we now realize that it causes more problems
% 		than it helps (since it breaks if a package or class redefines \cmd\markboth\ or
% 		\cmd\markright), so it is now disabled by default. For backwards compatibility, the
% 		option \xpgoption{nolocalmarks} which used to switch off the previous default, and
% 		now equals the default, is still available.
% 
%     \item \xpgoptkey[1.50]{luatexrenderer}{renderer}[Harfbuzz] determines which font renderer is used
%         with \LuaTeX\ output. The correct font renderer is essential particularly for non-Latin scripts.
%         By default, \pkg{polyglossia} uses the \xpgvalue{Harfbuzz} renderer that has been introduced to
%         \LuaTeX\ in 2019 (\TeX Live 2020), as this gives the best results generally. If you want to use
%         a different renderer, you can specify this here (or individually for specific fonts via the optional
%         argument of the font selection commands). Please refer to the \pkg{fontspec} manual for supported
%         values and for details on how to change the renderer for individual fonts.\\
%         \xpgoption{luatexrenderer=none} disables \pkg{polyglossia}'s automatic renderer setting.
% 
% 	\item \xpgboolkeytrue{verbose} determines whether info messages and (some of the) warnings issued
% 		by \LaTeX, \pkg{fontspec} and \pkg{polyglossia} are output.
% \end{itemize}
% 
% \section{Language-switching commands}\label{languageswitching}
% 
% \subsection{Recommended commands}\label{sec:langcmds}
% For each activated language the command
% \cmd{\text\meta{lang}\oarg{options}\marg{…}} \DescribeMacro{\text\meta{lang}}
% (as well as the synonymous \DescribeMacro{\textlang}%
% \cmd{\textlang\oarg{options}\marg{lang}\marg{…}}\new{1.46})
% becomes available for short insertions of text in that language.
% 
% For example ¦\textrussian{\today}¦ and ¦\textlang{russian}{\today}¦ yield \textrussian{\today}
% The commands switch to the correct hyphenation patterns, they activate
% some extra features for the selected language (such as extra spacing before
% punctuation in French), and they translate the date when using \cmd\today.
% They do not, however, translate so-called \textit{caption strings}, \ie
% ``chapter'', ``figure'' etc., to the local language (these remain in the currently active `outer'
% language).
% 
% The\DescribeEnv{\meta{lang}}\ environment \meta{lang}, which is also available for any activated language
% (as well as the equivalent \DescribeMacro{lang}%
% \cmd{\begin\{lang\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{lang\}}\new{1.47}),
% is meant for longer passages of text. It behaves slightly different than the \cmd{\text\meta{lang}} and
% \cmd\textlang\ commands: It does everything the latter do, but additionally, the caption strings
% are translated as well, and the language is also passed to auxiliary files, the table of contents
% and the lists of figures/tables.
% Like the commands, the environment provides the possibility of setting language options locally.
% For instance the following allows us to quote the beginning
% of Homer’s \textit{Iliad}:
% 
% \begin{Verbatim}[formatcom=\color{xpgblue}]
%   \begin{quote}
%    \begin{greek}[variant=ancient]
%      μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος οὐλομένην, ἣ μυρί' Ἀχαιοῖς
%      ἄλγε' ἔθηκε, πολλὰς δ' ἰφθίμους ψυχὰς Ἄϊδι προί̈αψεν ἡρώων,
%      αὐτοὺς δὲ ἑλώρια τεῦχε κύνεσσιν οἰωνοῖσί τε πᾶσι, Διὸς δ'
%      ἐτελείετο βουλή, ἐξ οὗ δὴ τὰ πρῶτα διαστήτην ἐρίσαντε Ἀτρεί̈δης
%      τε ἄναξ ἀνδρῶν καὶ δῖος Ἀχιλλεύς.
%    \end{greek}
%   \end{quote}
% \end{Verbatim}
% 
% \vspace{-.5\baselineskip}
% 
% \begin{quote}
% \begin{greek}[variant=ancient]
% μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος οὐλομένην, ἣ μυρί' Ἀχαιοῖς ἄλγε' ἔθηκε,
% πολλὰς δ' ἰφθίμους ψυχὰς Ἄϊδι προί̈αψεν ἡρώων, αὐτοὺς δὲ ἑλώρια τεῦχε κύνεσσιν
% οἰωνοῖσί τε πᾶσι, Διὸς δ' ἐτελείετο βουλή, ἐξ οὗ δὴ τὰ πρῶτα διαστήτην ἐρίσαντε
% Ἀτρεί̈δης τε ἄναξ ἀνδρῶν καὶ δῖος Ἀχιλλεύς.
% \end{greek}
% \end{quote}
% 
% \noindent\DescribeEnv{Arabic} Note that for Arabic one cannot use the environment ¦arabic¦,
% as \cmd\arabic\ is defined internally by \LaTeX. In this case
% we need to use the environment ¦Arabic¦ instead.
% 
% \subsection{Babel commands}\label{sec:babelcmds}
% Some macros defined in \pkg{babel}’s \file{hyphen.cfg} (and thus usually
% compiled into the \XeLaTeX\ and \LuaLaTeX\ format) are redefined, but keep a
% similar behaviour.
% \begin{itemize}
% \item \DescribeMacro{\selectlanguage}\cmd{\selectlanguage\oarg{options}\marg{lang}}
% \item \DescribeMacro{\foreignlanguage}\cmd{\foreignlanguage\oarg{options}\marg{lang}\marg{…}}
% \item \DescribeEnv{otherlanguage}\cmd{\begin\{otherlanguage\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{otherlanguage\}}
% \item \DescribeEnv{otherlanguage*}\cmd{\begin\{otherlanguage*\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{otherlanguage*\}}
% \item \DescribeEnv{hyphenrules}\cmd{\begin\{hyphenrules\}\oarg{options}\marg{lang}} \dots{} \cmd{\end\{hyphenrules\}}\new{1.50}
% \end{itemize}
% ^^A
% \cmd\selectlanguage\marg{lang} and the ¦otherlanguage¦ environment are identical to the
% \meta{lang} environment, except that \cmd\selectlanguage\marg{lang}
% does not need to be explicitly closed. The command \cmd\foreinlanguage\marg{lang}\marg{…} and the ¦otherlanguage*¦
% environment are identical with the use of the \cmd\text\meta{lang} or \cmd\textlang\ command, with the one
% notable exception that they do not translate the date with \cmd\today.
% 
% The \meta{hyphenrules} environment only switches the hyphenation patterns to the one associated with the language \meta{lang}
% (or the language variety as specified via \meta{options}). It does no further language-specific change.
% 
% Since the \XeLaTeX\ and \LuaLaTeX\ format incorporate \pkg{babel}’s \file{hyphen.cfg},
% the low-level commands for hyphenation and language switching defined there are in principal also accessible.
% Note, however, that the availability of such low-level commands is not guaranteed, as \file{hyphen.cfg}, which is
% out of \pkg{polyglossia}'s control, is (or at least has been) subject to regular change.
% 
% \subsection{Other commands}
% The following commands are probably of lesser interest to the end user, but
% ought to be mentioned here.
% \begin{itemize}
% \item \DescribeMacro{\selectbackgroundlanguage}\cmd{\selectbackgroundlanguage\marg{lang}}:
%     this selects the global font setup and the numbering definitions for the default language.
% 
% \item \DescribeMacro{\resetdefaultlanguage}\cmd{\resetdefaultlanguage\oarg{options}\marg{lang}} (experimental):
% 	Switches the default language
% 	to another one in the middle of a document: \textit{this may have adverse effects}!
% 
% \item \Cmd\normalfontlatin: in an environment where \cmd\normalfont\ has been redefined
% 	to a non-latin script, this will reset to the font defined with \cmd\setmainfont\ etc.
% 	In a similar vein, it is possible to use \Cmd\rmfamilylatin, \Cmd\sffamilylatin,
% 	and \Cmd\ttfamilylatin.
% 
% \item \Cmd\latinalph: Representation of counter as a lower-case letter:  1 = a, 2 = b, etc.
% 
% \item \Cmd\latinAlph: Representation of counter as a upper-case letter:  1 = A, 2 = B, etc.
% \end{itemize}
% 
% 
% \subsection{Setting up alias commands}
% 
% By means of the macro\new{1.46}
% \displaycmd{\setlanguagealias\oarg{options}\marg{language}\marg{alias}}{\setlanguagealias}
% you can define alias commands for specific language (variants). \Eg
% 
% \begin{quote}
% \begin{verbatim}
% \setlanguagealias[variant=austrian]{german}{AT}
% \end{verbatim}
% \end{quote}
% ^^A
% will define a command \cmd{\textAT} as well as an environment ¦{AT}¦ which will link towards
% the command ¦\textgerman[variant=austrian]¦ and the environment ¦{german}[variant=austrian]¦,
% respectively. The aliases can also be used in the language switching commands described in
% section~\ref{sec:langcmds} and \ref{sec:babelcmds}.
% Note, though, that the usual restrictions for command names apply, so something such as
% ¦de-AT¦ or ¦de_AT¦ will not work since ¦-¦ and ¦_¦ are not allowed in command names (the same
% holds true for any non-ASCII character and for digits).
% 
% For the latter case, and for the case where an alias would clash with an existing command
% (\eg ¦\fi¦) or a \cmd{\text\meta{\ldots}} command (\eg \cmd\textit), a starred version \Cmd{\setlanguagealias*}
% is provided which does neither define a \cmd{\text\meta{alias}} command nor an \meta{alias} environment,
% but which will set up the alias for everything else, including \cmd{\textlang\marg{alias}}
% and \cmd{\begin\{lang\}\marg{alias}}.
% 
% \pkg{Polyglossia} comes with some aliases predefined, namely aliases for \pkg{babel} language names
% (see sec.~\ref{sec:babelnames}) and for IETF BCP-47 language tags (the latter via \cmd{\setlanguagealias*};
% see sec.~\ref{sec:langtags}).
% 
% \section{Font setup}
% 
% With polyglossia it is possible to associate a specific font with any script or language
% that occurs in the document. That font should always be defined as
% \cmd{\⟨script⟩font}\ or \cmd{\⟨language⟩font}.
% For instance, if the default font defined by \cmd\setmainfont\
% does not support Greek, then one can define the font used to display Greek with:\\
% \centerline{ \cmd\newfontfamily\cmd{\greekfont[Script=Greek,\meta{…}]\marg{font}}. }
% Note that polyglossia will use the font defined as is, so assure to do all necessary settings
% (please refer to the \pkg{fontspec} documentation for details).
% For instance, if \cmd\arabicfont\ is explicitly defined, then the option ¦Script=Arabic¦ should
% be included in that definition.
% 
% If a specific sans serif or monospace (`teletype') font is needed for a particular script or language,
% it can be defined by means of \new{1.2.0}
% \cmd{\⟨script⟩fontsf} or \cmd{\⟨language⟩fontsf} and \cmd{\⟨script⟩fonttt} or \cmd{\⟨language⟩fonttt}, respectively.
% 
% Whenever a new language is activated, \pkg{polyglossia} will first check whether
% a font has been defined for that language or – for languages in non-Latin scripts –
% for the script it uses. If it is not defined, it will use the currently active font
% and – in the case of OpenType fonts – will attempt to turn on the appropriate
% OpenType tags for the script and language used, in case these are available in
% the font, by means of \pkg{fontspec}’s \cmd\addfontfeature. If the current font
% does not appear to support the script of that language, an error message is
% displayed.
% 
% \section{Adapting hyphenation}
% 
% \subsection{Hyphenation exceptions}
% 
% \TeX\ provides the command \cmd\hyphenation\marg{exceptions} to globally define hyphenation exceptions
% which override the hyphenation patterns for specified words. The command takes as argument a space-separated
% list of words where hyphenation points are marked by a dash (if no dash is used, the respective word is not
% hyphenated at all):
% \begin{quote}
% \begin{minipage}{.7\textwidth}
% \begin{verbatim}
% \hyphenation{%
%   po-ly-glos-sia
%   LaTeX
% }
% \end{verbatim}
% \end{minipage}
% \end{quote}
% ^^A
% These exceptions, however, apply to all languages. In addition to this, \pkg{polyglossia} provides
% the command\new{1.45}
% \displaycmd{\pghyphenation\oarg{options}\marg{lang}\marg{exceptions}}{\pghyphenation}
% which can be used to define exceptions that only apply to a specific language or language variant,
% respectively.
% 
% \subsection{Hyphenation thresholds}
% 
% \pkg{Polyglossia} sets reasonable defaults for the hyphenation thresholds of each language,
% \ie the number of characters that must  at least be there at the beginning or end of a
% word before it is hyphenated (\cmd\lefthyphenmin\ and \cmd\righthyphenmin\ in \TeX).
% For instance, with English, this threshold is 2 at the beginning (`left') and 3 at the end (`right'),
% so a word will not be hyphenated within the first two characters at the beginning and the last three
% characters at the end.
% 
% To change this value, \pkg{polyglossia} provides the command\new{1.50}
% \displaycmd{\setlanghyphenmins\oarg{options}\marg{lang}\marg{l}\marg{r}}{\setlanghyphenmins}
% ^^A
% where \meta{lang} is to be replaced with the respective language name or alias, \meta{options}
% can be used to delimit the modification to a particular variety (\eg via \texttt{variant} or \texttt{spelling}),
% \meta{l} with the left threshold value (\eg \texttt{3}), and \meta{r} with the right
% one (\eg \verb|\setlanghyphenmins[spelling=old]{german}{4}{4}|).
% This setting can be changed repeatedly in the preamble and the document body.
% It applies to all subsequent text in the respective language (variety), but only after the
% next language switch.
% 
% \subsection{Hyphenation disabling}
% 
% In some very specific contexts (such as music score creation), \TeX\ hyphenation
% is something to avoid completely as it may cause troubles.
% \pkg{Polyglossia} provides two functions: \Cmd\disablehyphenation\ and \Cmd\enablehyphenation.
% Note that if you select a new language while hyphenation is disabled, it will remain disabled.
% If you re-enable it, the hyphenation patterns of the currently selected language
% will be activated.
% 
% \section{Language-specific options and commands}\label{specific}
% 
% This section gives a list of all languages for which options and end-user
% commands are defined. Note the following conventions:
% \begin{itemize}
% 	\item The preset value of each option (\ie the setting that applies by default,
% 	if the option is not explicitly set) is given in \xpgpresetvalue{italics}.
% 	\item If an option key may be used without a value, the value that applies
% 	for value-less keys is marked by a preceding \xpgdefaultvalue{asterisk}.
% \end{itemize}
% For instance, \texttt{babelshorthands = *true} or \texttt{\textit{false}} means that
% \xpgvalue{babelshorthands} is \xpgvalue{false} by default in the respective language,
% and that passing \xpgvalue{babelshorthands} (without value) is equivalent to passing
% \xpgvalue{babelshorthands=true}.
% 
% \subsection{afrikaans}\label{afrikaans}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse[1.1.1]{babelshorthands}
% 	If this is turned on, the following shorthands defined for fine-tuning hyphenation and
% 	micro-typography of Afrikaans words are activated:
% 	\begin{shorthands}
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		in the hyphenation patterns (as opposed to \cmd\- in default \TeX).
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 		cases where the hyphen should stick at the following syllable.
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash,
% 		hyphenation at the breakpoints preset in the hyphenation patterns is still allowed.
% 	\end{shorthands}
% \end{itemize}
% 
% \subsection{arabic}\label{arabic}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{calendar}{\xpgpresetvalue{gregorian} or \xpgvalue{islamic} (= \xpgvalue{hijri})}
% 	\item \xpgoptkey{hijricorrection}{integer}[0]
% 	    If \xpgvalue{calendar=hijri} or \xpgvalue{calendar=islamic} is selected, \cmd{\today} will output the date
% 	    according to the lunar Islamic (Hijra) calendar. This option allows to shift the day of the output with respect
% 	    to the current date. Both positive and negative integer values are allowed (negative decrease the day value).
% 	    This corresponds to the optional argument of the \cmd{\Hijritoday} command which can be used to output Hijri
% 	    dates irrespective of the \xpgvalue{calendar} option (see sec.~\ref{sec:hijrical}).
% 	\item \xpgchoicekey{locale}{\xpgpresetvalue{default}, \xpgvalue{mashriq}, \xpgvalue{libya},
% 		\xpgvalue{algeria}, \xpgvalue{tunisia}, \xpgvalue{morocco}, \xpgvalue{mauritania}}
% 		This setting influences the spelling of the month names for the Gregorian calendar,
% 		as well as the form of the numerals (unless overridden by the following option). Recommended settings are
% 		\xpgvalue{default} for Egypt, Sudan, Yemen and the Gulf states, and \xpgvalue{mashriq} for Iraq, Syria,
% 		Jordan, Lebanon and Palestine.
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{mashriq} (=~\xpgvalue{eastern}\new{1.63}) or \xpgvalue{maghrib}
% 		(=~\xpgvalue{western}\new{1.63})}
% 		Use Eastern Arabic (a.k.a.\ Indic-Arabic) numerals (\xpgvalue{mashriq} or \xpgvalue{eastern}) or Western numerals
% 		(\xpgvalue{maghrib} or \xpgvalue{western}).
% 		The latter is the default when \xpgvalue{locale=algeria}, \xpgvalue{tunisia}, or \xpgvalue{morocco}, the former
% 		is the default with all other Arabic locales.
% 	\item \xpgcodekey[1.63]{sectionsep}¦.¦
% 		This option allows to customize the separator between chapters, sections, and subsections (a dot by default),
% 		\eg \xpgoption{sectionsep=-}.
% 		This might be useful particularly with \xpgoption{numerals=mashriq} or \xpgoption{eastern}, as the dot looks
% 		too similar to the zero	in many fonts.
% 	\item \xpgboolkeyfalse[1.50]{abjadalph}
% 	     Set this to true if you want the alphabetic counters to be output using \cmd\abjadalph\ rather than \cmd\abjad.
% 	     Note that this limits the counter scope to 28 (see \cmd\abjadalph\ below).
% 	\item \xpgboolkeyfalse[1.0.3]{abjadjimnotail}
% 	    Set this to true if you want the \textit{abjad} form of the number three to be \textarabic{ج‍} – as in the manuscript
% 	    tradition – instead of the modern usage \textarabic{ج}.
% 	\end{itemize}
% \paragraph*{Commands:}
% 	\begin{itemize}
% 	\item \Cmd\abjad outputs Arabic \textit{abjad} numbers according to the Mashriq varieties.
% 	      Example: ¦\abjad{1863}¦ yields \textarabic{\abjad{1863}}.
% 	\item \Cmd\abjadmaghribi outputs Arabic \textit{abjad} numbers according to the Maghrib varieties.
% 	       Example: ¦\abjadmaghribi{1863}¦ yields \textarabic{\abjadmaghribi{1863}}.
% 	\item \Cmd\abjadalph\new{1.50} steps through the Arabic alphabet, thus it can only be used up to 28.
% 	       Example: ¦\textarabic{\abjadalph{18}}¦ yields \textarabic{\abjadalph{18}}.
%     \item \Cmd\aemph to emphasize text with \cmd\overline.\new{1.2.0}
%           ¦\textarabic{\aemph{اب}}¦ yields \textarabic{\aemph{اب}}.
%            This command is also available for Farsi, Urdu, etc.
% 	\end{itemize}
% 
% \subsection{armenian}\label{armenian}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{eastern} or \xpgpresetvalue{western}}
% 	\item \xpgchoicekey[1.45]{numerals}{\xpgvalue{armenian} or \xpgpresetvalue{arabic}}
% 	\item \xpgboolkeyfalse[1.63]{capitalyiwn}
% 		If this is set to true, \cmd{\MakeUppercase} will upcase the ligature of letters ech and yiwn to capital
% 		ech and yiwn. This conforms to the output outside Armenian language selection.
% 		By default (and with this option set to \xpgvalue{false}), \cmd{\MakeUppercase} upcases the ech and yiwn
% 		ligature to capital ech and \emph{vew}, adhering to Armenian reformed spelling regulations.
% 		Note that this feature requires	\LaTeX\ kernel 2023/06 at least.
% \end{itemize}
% 
% \subsection[belarusian]{belarusian\new{1.46}}\label{belarusian}
% 
% \paragraph*{Options:}
% \begin{itemize}
%   \item \xpgboolkeyfalse{babelshorthands}
% 	If this is turned on, the following shorthands are activated:
% 	\begin{shorthands}
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		    in the hyphenation patterns (as opposed to \cmd\-).
% 		\item[¦"=¦] adds an explicit hyphen with a breakpoint, allowing for hyphenation at the
% 		    other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 		    cases where the hyphen should stick at the following syllable.
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
% 		\item[¦"‘¦] for German left double quotes (looks like ,,).
% 		\item[¦"’¦] for German right double quotes (looks like “).
% 		\item[¦"<¦] for French left double quotes (looks like <<).
% 		\item[¦">¦] for French right double quotes (looks like >>).
% 	\end{shorthands}
% 
% 	There are also three shorthands for the Cyrillic dash (\textrussian{тире}), which is shorter than the
% 	emdash but longer than the endash (namely 0.8\,em).
% 	Note that, since it is not covered by unicode, this character is faked by telescoping two endashes:
% 	\begin{shorthands}
% 		\item[¦"---¦] Cyrillic dash for the use in normal text. This requires preceding space
% 		       in input (trailing space is optional) and prints with a non-breakable thin space before
% 	           and after the dash.
% 		\item[¦"--\textasciitilde¦] Cyrillic dash for the use in compound names (surnames).
% 		       As opposed to ¦"---¦ this removes any space before and after the dash. 
% 		\item[¦"--*¦] Cyrillic dash for denoting direct speech. This adds a larger space after
% 		       the dash. Space before the dash is output as is.
% 	\end{shorthands}
%     \item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic}, \xpgvalue{cyrillic-alph} or \xpgvalue{cyrillic-trad}}
%          Uses either Arabic numerals or Cyrillic alphanumerical numbering. The two Cyrillic variants differ as follows:
%          \begin{itemize}
% 	          \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
% 	          \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
% 	                \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
% 	                It supports numbers up to 999\,999.
%          \end{itemize}
% 	\item \xpgchoicekey{spelling}{\xpgpresetvalue{modern} or \xpgvalue{classic} (= \xpgvalue{tarask})}
% 	With ¦spelling=classic¦, captions and dates adhere to the Taraškievica (or
% 	Belarusian classical) orthography rather than the standard orthography.
% \end{itemize}
% 
% \condbreak{\baselineskip}
% \paragraph*{Commands:}
% \begin{itemize}
%      \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
%           It steps through the Cyrillic alphabet and thus it can only be used up to 30.
%           The command takes a counter as argument, \eg ¦\textbelarusian{\Asbuk{page}}¦ produces \textrussian{\Asbuk{page}}.
%      \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
%      \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
%           numbers up to 999\,999.\\
%           \Eg ¦\textbelarusian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
%      \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
% \end{itemize}
% 
% \subsection[bengali]{bengali\new{1.2.0}}\label{bengali}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	  \item \xpgchoicekey{numerals}{\xpgvalue{western}, \xpgvalue{bengali}, or \xpgpresetvalue{devanagari}}
% 		\item \xpgboolkeyfalse{changecounternumbering}
% 		Use specified numerals for headings and page numbers.
% 	\end{itemize}
% 
% \subsection{catalan}\label{catalan}
% \paragraph*{Options:}
% \begin{itemize}
%   \item \xpgboolkeyfalse[1.1.1]{babelshorthands}
%     Activates the shorthands \texttt{"l} and \texttt{"L} to type geminated l or L.
% \end{itemize}
% 
% \paragraph*{Commands:}
% \begin{itemize}
%   \item \Cmd{\l.l} and \Cmd{\L.L}\new{1.1.1} can be used to type a geminated l, as in \textit{co\l.laborar},
%         similar to \pkg{babel} (the glyph U+00B7 MIDDLE DOT is used as a geminating sign).
% \end{itemize}
% 
% \subsection[chinese]{chinese\new{1.59}}\label{chinese}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{simplified} (= \xpgvalue{cn}), or \xpgvalue{traditional} (= \xpgvalue{tw})}
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic} or \xpgvalue{chinese}}
% 		Uses either Arabic numerals or Chinese ideographic numbering.
% 	\end{itemize}
% \paragraph*{Commands:}
% 	\begin{itemize}
% 	\item \Cmd\chinesenumeral (see section \ref{abjad}).
% 	\end{itemize}
% 
% \subsection{croatian}\label{croatian}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse[1.47]{babelshorthands}
% 	If this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
% 	of Croatian words are activated.
% 	\begin{shorthands}
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[¦"=¦] for an explicit hyphen with a breakpoint, allowing for hyphenation at the
% 		            other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 		            cases where the hyphen should stick at the following syllable.
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		            in the hyphenation patterns (as opposed to \cmd\-).
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation
% 		            at the breakpoints preset in the hyphenation patterns is still allowed.
% 	\end{shorthands}
% 	Furthermore, the following shorthands generate easy access to Croatian digraphs:
% 	\begin{shorthands}
% 		\item[¦"dz¦] Generates the digraph \charifavailable{01C6}{dž}\ if the font provides it. If not,
% 		             the two consecutive glyphs are output mimicking the digraph. Also available for
% 		             ¦"Dz¦ (\charifavailable{01C5}{Dž}) and ¦"DZ¦ (\charifavailable{01C4}{DŽ}).
% 		\item[¦"lj¦] Generates the digraph \charifavailable{01C9}{lj}\ if the font provides it. If not,
% 		             the two consecutive glyphs are output mimicking the digraph. Also available for
% 		             ¦"Lj¦ (\charifavailable{01C8}{Lj}) and ¦"LJ¦ (\charifavailable{01C7}{LJ}).
% 		\item[¦"nj¦] Generates the digraph \charifavailable{01CC}{nj}\ if the font provides it. If not,
% 		             the two consecutive glyphs are output mimicking the digraph. Also available for
% 		             ¦"Nj¦ (\charifavailable{01CB}{Nj}) and ¦"NJ¦ (\charifavailable{01CA}{NJ}).
% 	\end{shorthands}
% 	
% 	Finally, there are also four shorthands for quotation marks:
% 	\begin{shorthands}
% 		\item[¦"`¦] for Croatian left double quotes („).
% 		\item[¦"'¦] for Croatian right double quotes (”).
% 		\item[¦">¦] for Croatian left guillemets (»).
% 		\item[¦"<¦] for Croatian right guillemets («).
% 	\end{shorthands}
% 	\item \xpgboolkeyfalse[1.47]{disabledigraphs}[Up to version 1.53, the option was
% 		called \xpgvalue{disableligatures}. The old option is kept for backwards compatibility,
% 		but the use is discouraged.] If this is \xpgvalue{true}, all Croatian digraphs
% 		(such as \charifavailable{01C6}{dž}) will be replaced by the two consecutive letters,
% 		which is the most common way of typesetting them in Croatian. This can be useful if
% 		the Unicode digraphs in your font are broken (if the font does not have them,
% 		they are automatically mimicked by the two consecutive glyphs).
% 	\item \xpgboolkeytrue[1.53]{localalph}
% 		If \xpgvalue{true}, alphanumeric counters will use a locally established version which excludes
% 		the characters \meta{q}, \meta{w}, \meta{x} and \meta{y} from alphabetic counting.
% 		Obviously this limits the counting range to 22.
%     \item \xpgboolkeytrue[1.51]{splithyphens}
% 	    According to Croatian typesetting conventions, if a word with a hard hyphen (such as
% 	    \emph{hrvatsko-engleski}) is hyphenated at this hyphen, a second hyphenation character is to be
% 	    inserted at the beginning of the line that follows the hyphenation (\emph{hrvatsko-/-engleski}).
% 	    By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
% 	    loaded to achieve this).
% 	    Set this option to ¦false¦ to disable the feature.
% \end{itemize}
% 
% \subsection{czech}\label{czech}
% 
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse[1.45]{babelshorthands}
% 	If this is turned on, the following shorthands for Czech are activated:
% 	\begin{shorthands}
% 		\item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
% 		            of the next line when hyphenated, as common in Czech typesetting
% 		            (only needed with ¦splithyphens=false¦).
% 		\item[¦"‘¦] for Czech left double quotes („).
% 		\item[¦"’¦] for Czech right double quotes (“).
% 		\item[¦">¦] for Czech left double guillemets (»).
% 		\item[¦"<¦] for Czech right double guillemets («).
% 	\end{shorthands}
% 	\item \xpgboolkeytrue[1.45]{splithyphens}
% 	      According to Czech typesetting conventions, if a word with a hard hyphen (such as \emph{je-li})
% 	      is hyphenated at this hyphen, a second hyphenation character is to be inserted at the beginning
% 	      of the line that follows the hyphenation (\emph{je-/-li}).
%           By default, this is done automatically\new{1.46} (if you are using \LuaTeX, the \pkg{luavlna} package is
%           loaded to achieve this).
%           Set this option to ¦false¦ to disable the feature.
% 	\item \xpgboolkeytrue[1.45]{vlna}
%          According to Czech typesetting conventions, single-letter words (non-syllable prepositions)
%          must not occur at line ends.
%          \pkg{Polyglossia} takes care of this automatically by default\new{1.46} (if you are using \LuaTeX, the
%          \pkg{luavlna} package is loaded to achieve this).
%          Set this option to ¦false¦ to disable the feature.
% \end{itemize}
% 
% \subsection{dutch}\label{dutch}
% \paragraph*{Options:}
% \begin{itemize}
%   \item \xpgboolkeytrue[1.63]{tremahyphenation}
%         Following Dutch orthography, words with tremata (such as \emph{geëxecuteerd}) lose the trema on hyphenation
%         before the trematized letter (\emph{ge-executeerd}). This is achieved by \pkg{polyglossia} by making those
%         letters active. If you set this option to false, this mechanism is deactivated (and the hyphenation wrong,
%         but you can still use the babelshorthands mentioned below).
%   \item \xpgboolkeyfalse[1.1.1]{babelshorthands}
% 		If this is turned on, the following shorthands defined for fine-tuning hyphenation and
% 		micro-typography of Dutch words are activated:
% 		\begin{shorthands}
% 		\item[¦"a¦]\new{1.63} an \meta{ä} (a with trema) which is hyphenated as \meta{-a} as required by the Dutch standards.
% 		            Also implemented for the other vowels (e, i, o, u), both lower and uppercase.
% 		\item[¦"y¦]\new{1.63} the \ij\ ligature.
% 		\item[¦"Y¦]\new{1.63} the \IJ\ ligature.
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 			        in the hyphenation patterns (as opposed to \cmd\- in default \TeX).
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 			        cases where the hyphen should stick at the following syllable.
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash,
% 		            hyphenation at the breakpoints preset in the hyphenation patterns is still allowed.
% 		\end{shorthands}
%         In addition, the macro \Cmd\- is redefined to allow hyphens in the rest of the word (equivalent to ¦"-¦).
% \end{itemize}
% 
% \subsection{english}\label{english}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{american} (= \xpgvalue{us}), \xpgvalue{usmax} (same as \xpgvalue{american} but with additional hyphenation patterns),
% 	\xpgvalue{british} (= \xpgvalue{uk}), \xpgvalue{australian}, \xpgvalue{canadian}\new{1.45}, or \xpgvalue{newzealand}}
% 	\item \xpgboolkeyfalse{ordinalmonthday}
% 		The default value is true for \xpgvalue{variant=british}.
% 	\end{itemize}
% 
% \subsection{esperanto}\label{esperanto}
% \paragraph*{Commands:}
% 	\begin{itemize}
% 	\item \Cmd\hodiau\ and \Cmd\hodiaun are special forms of \cmd\today. The former produces the date in Esperanto
% 	      preceded by the article (\emph{la}), which is the most common date format.
% 	      The latter produces the same date format in accusative case.
% 	\end{itemize}
% 
% \subsection{finnish}\label{finnish}
% \paragraph*{Options:}
% \begin{itemize}
%   \item \xpgboolkeyfalse[1.45]{babelshorthands}
% 		If this is turned on, the following shorthands for fine-tuning hyphenation
% 		and micro-typography of Finnish words are activated:
% 		\begin{shorthands}
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
%                     in the hyphenation patterns (as opposed to \cmd\-).
%         \item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
%                     cases where the hyphen should stick at the following syllable.
%         \item[¦"|¦] disables a ligature at this position.
%         \item[¦""¦] allows for a line break at this position (without hyphenation sign).
%         \item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash,
%                   hyphenation at the breakpoints preset in the hyphenation patterns is still allowed.
% 		\end{shorthands}
%   \item \xpgboolkeyfalse[1.54]{schoolhyphens}
% 	    If this is set to true, alternative (experimental) hyphenation patterns are used rather than the
% 	    default Finnish patterns. These (so-called `School') patterns allow hyphenation at
% 	    all valid points, including hyphenation points that are considered sub-optimal from an
% 	    ortho-typographic point of view (e.\,g., hyphenation between two vowels).
% 	    The default patterns try to prevent such hyphenation, with the drawback that simple words
% 	    are sometimes not being hyphenated at points where this would be valid.
% 	    See \url{https://github.com/hyphenation/basic-finnish} for details.
% \end{itemize}
% 
% \subsection{french}\label{french}
% \paragraph*{Options:}
% 	\begin{itemize}
% 		\item \xpgchoicekey{variant}{\xpgpresetvalue{french}, \xpgvalue{canadian}, \xpgvalue{acadian}\new{1.45} or \xpgvalue{swiss}\new{1.47}}
% 			Currently, the only difference between the four variants is that \xpgvalue{swiss}
% 			uses \xpgvalue{thincolonspace=true} by default since this conforms to the Swiss
% 			conventions.
% 		\item \xpgboolkeytrue{autospacing}
% 			One of the most distinct features of French typography is the addition of
% 			extra spacing around punctuation and quotation marks (guillemets). By
% 			default, polyglossia adds these spaces automatically, so you don't need
% 			to enter them. This options allows you to switch this feature off
% 			globally.
% 		\item \xpgboolkeyfalse[1.46]{thincolonspace}
% 			With \xpgvalue{variant=swiss}, the default value is \xpgvalue{true}. If \xpgvalue{false}, a full
% 			(non-breaking) interword space is inserted before a colon. If \xpgvalue{true}, a
% 			thinner space -- as before \texttt{;}, \texttt{!}, and \texttt{?} -- is
% 			used. Note that this option must be set after the ¦variant¦ option.
% 		\item \xpgboolkeytrue{autospaceguillemets}[Up to version 1.44, the option was
% 		called \xpgvalue{automaticspacesaroundguillemets}. For backwards compatibility
% 		reasons, the more verbose old option is still supported.]
% 			If you only want to disable the automatic addition of spacing after
% 			opening and before closing guillemets (and not at punctuation), set this
% 			to \textit{false}. Note that the more general option \textit{autospacing}
% 			overrides this.
% 		\item \xpgboolkeyfalse[1.45]{autospacetypewriter}[Babel's syntax \xpgvalue{OriginalTypewriter}
% 		is also supported.]
% 			By default, automatic spacing is disabled in typewriter font. If this is
% 			enabled, spacing in typewriter context is the same as with roman and sans
% 			serif font, depending on the \xpgvalue{autospacing} and
% 			\xpgvalue{autospaceguillemets} settings (note that this was the default up
% 			to v.~1.44).
% 		\item \xpgboolkeyfalse{frenchfootnote}
% 			If \xpgvalue{true}, footnotes start with a non-superscripted number
% 			followed by a dot, as common in French typography. Note that this might
% 			interfere with the specific footnote handling of classes or packages.
% 			Also note that this option is only functional (by design) if French is
% 			the main language.
% 		\item \xpgboolkeyfalse[1.46]{frenchitemlabels}
% 			If \textit{true}, itemize item labels use em-dashes throughout, as common
% 			in French typography.  Note that this option is only functional (by
% 			design) if French is the main language. Also, it might interfere with
% 			list packages such as \pkg{enumitem}.
% 		\item \xpgboolkeytrue[1.51]{frenchpart}
% 			By default, \pkg{polyglossia} modifies part headings to match French conventions
% 			(\emph{Première partie} rather than \emph{Partie I}). Next to the standard classes,
% 			specifics of \pkg{KOMA-script}, \pkg{memoir} and the \pkg{titlesec} package are
% 			taken into account. With other classes or packages, redefinition might fail if these
% 			have particular part settings.
% 			In such case, or if you don't want the redefinition, you can switch off the feature
% 			by passing \textit{false} to this option.
% 		\item \xpgcodekey[1.46]{itemlabels}¦\textemdash¦
% 			If \emph{frenchitemlabels} is true, you can customize here the used item
% 			label of all levels.
% 		\item \xpgcodekey[1.46]{itemlabeli}¦\textemdash¦
% 			If \emph{frenchitemlabels} is true, you can customize here the used item
% 			label of the first level.
% 		\item \xpgcodekey[1.46]{itemlabelii}¦\textemdash¦
% 			If \emph{frenchitemlabels} is true, you can customize here the used item
% 			label of the second level.
% 		\item \xpgcodekey[1.46]{itemlabeliii}¦\textemdash¦
% 			If \emph{frenchitemlabels} is true, you can customize here the used item
% 			label of the third level.
% 		\item \xpgcodekey[1.46]{itemlabeliv}¦\textemdash¦
% 			If \emph{frenchitemlabels} is true, you can customize here the used item
% 			label of the fourth level.
% 	\end{itemize}
% \paragraph*{Commands:}
% \begin{itemize}
% 	\item \Cmd\NoAutoSpacing\new{1.45} disables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\NoAutoSpacing foo:bar}¦
% 	\item \Cmd\AutoSpacing\new{1.45} enables automatic spacing around punctuation and quotation marks in all following text. The command can also be used locally if braces are used for grouping: ¦{\AutoSpacing regarde!}¦
% \end{itemize}
% 
% \subsection[gaelic]{gaelic\new{1.45}}\label{gaelic}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{irish} or \xpgvalue{scottish}}
% \end{itemize}
% 
% \subsection[georgian]{georgian\new{1.46}}\label{georgian}
% 
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse{babelshorthands}
% 		If this is turned on, the following shorthands are activated:
% 		\begin{shorthands}
% 			\item[¦"-¦] adds a hyphenation point that does still allow for
% 			    hyphenation at the points preset in the hyphenation patterns (as opposed to \cmd\-).
% 		    \item[¦"=¦] adds an explicit hyphen with a breakpoint, allowing for hyphenation at the
% 			    other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
% 			\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 			cases where the hyphen should stick at the following syllable.
% 			\item[¦"|¦] disables a ligature at this position.
% 			\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 			\item[¦",¦] thinspace for initials with a breakpoint in following surname.
% 			\item[¦"‘¦] for German-style left double quotes (looks like ,,).
% 			\item[¦"’¦] for German-style right double quotes (looks like “).
% 			\item[¦"<¦] for French-style left double quotes (looks like <<).
% 			\item[¦">¦] for French-style right double quotes (looks like >>).
% 	    \end{shorthands}
%     
% 		There are also three shorthands for the Cyrillic dash (\textrussian{тире}), which is shorter than the
% 		emdash but longer than the endash (namely 0.8\,em).
% 		Note that, since it is not covered by unicode, this character is faked by telescoping two endashes:
% 		\begin{shorthands}
% 			\item[¦"---¦] Cyrillic dash for the use in normal text. This requires preceding space
% 			in input (trailing space is optional) and prints with a non-breakable thin space before
% 			and after the dash.
% 			\item[¦"--\textasciitilde¦] Cyrillic dash for the use in compound names (surnames).
% 			As opposed to ¦"---¦ this removes any space before and after the dash. 
% 			\item[¦"--*¦] Cyrillic dash for denoting direct speech. This adds a larger space after
% 			the dash. Space before the dash is output as is.
% 		\end{shorthands}
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic} or \xpgvalue{georgian}}
% 		Uses either Arabic numerals or Georgian alphanumerical numbering.
% 	\item \xpgboolkeyfalse{oldmonthnames}
% 		Uses traditional Georgian month names.
% \end{itemize}
% 
% \subsection{german}\label{german}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{german}, austrian, or swiss\new{1.33.4}}
% 		Setting \xpgvalue{variant=austrian} or \xpgvalue{variant=swiss} uses some lexical variants.
% 		With \xpgvalue{spelling=old}, \xpgvalue{variant=swiss} furthermore loads specific hyphenation
% 		patterns.
% 	\item \xpgchoicekey{spelling}{\xpgpresetvalue{new} (= \xpgvalue{1996}) or \xpgvalue{old} (= \xpgvalue{1901})}
% 		Indicates whether hyphenation patterns for traditional (1901) or reformed
% 		(1996) orthography should be used. The latter is the default.
% 	\item \xpgboolkeyfalse[1.63]{capitaleszett}
% 	     If this is set to true, \cmd{\MakeUppercase} will upcase the eszett character ⟨ß⟩ to the
% 	     capital counterpart ⟨\charifavailable{1E9E}{SS}⟩ that has been introduced to Unicode in 2008 and
% 	     standardized in German regulations in 2017, rather than ⟨SS⟩. Note that this feature requires
% 	     \LaTeX\ kernel 2023/06 at least and a font that contains the respective glyph.
% 	\item \xpgchoicekey[1.2.0]{script}{\xpgpresetvalue{latin} or \xpgvalue{blackletter}\new{1.46} (= \xpgvalue{fraktur})}
% 	     Setting ¦script=blackletter¦ adapts the captions for typesetting German in blackletter type, using the `long s' ⟨ſ\kern1.5pt⟩
% 	     where appropriate.
% 	\item \xpgboolkeyfalse[1.0.3]{babelshorthands}
% 		If this is turned on, all shorthands defined in \pkg{babel}
% 		for fine-tuning hyphenation and micro-typography of German words are activated.
% 		\begin{shorthands}
% 		\item[¦"ck¦] for ¦ck¦ to be hyphenated as ¦k-k¦ (1901 spelling).
% 		\item[¦"ff¦] for ¦ff¦ to be hyphenated as ¦ff-f¦ (1901 spelling); this is also available
% 		           for the letters l, m, n, p, r and t.
% 		\item[¦"|¦] disables a ligature at this position (\eg ¦Auf"|lage¦).
% 		\item[¦"=¦] for an explicit hyphen with a breakpoint, allowing for hyphenation at the
% 		           other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 		           cases where the hyphen should stick at the following syllable, \eg ¦bergauf und "~ab¦.
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		           in the hyphenation patterns (as opposed to \cmd\-).
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign);
% 		           \eg ¦(pseudo"~)""wissenschaftlich¦.
% 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation at the breakpoints
% 		           preset in the hyphenation patterns is still allowed.
% 		\end{shorthands}
% 
% 		There are also four shorthands for quotation signs:
% 		\begin{shorthands}
% 		\item[¦"`¦] for German-style left double quotes („)
% 		\item[¦"'¦] for German-style right double quotes (“)
% 		\item[¦"<¦] for French-style left double quotes («)
% 		\item[¦">¦] for French-style right double quotes (»).
% 		\end{shorthands}
% 	\end{itemize}
% 
% \subsection{greek}\label{greek}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{monotonic} (= \xpgvalue{mono}), \xpgvalue{polytonic} (= \xpgvalue{poly}), or \xpgvalue{ancient}}
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{greek} or \xpgvalue{arabic}}
% 	\item \xpgboolkeyfalse[1.63]{capitaliota}
% 		If this is set to true, \cmd{\MakeUppercase} will upcase the \emph{ypogegrammeni} (subscript muted iota) to capital iota.
% 		By default (and with this option set to \xpgvalue{false}), \cmd{\MakeUppercase} retains the subscript versions.
% 		Note that this feature requires	\LaTeX\ kernel 2023/06 at least.
% 	\end{itemize}
% \paragraph*{Commands:}
% 	\begin{itemize}
% 	\item \Cmd\Greeknumber and \Cmd\greeknumber \ (see section \ref{abjad}).
% 	\item The command \Cmd\atticnumeral (= \Cmd\atticnum) (activated with
% 	  the option ¦attic=true¦), displays numbers using the acrophonic
%           numbering system (defined in the Unicode range
% 	  \textsf{U+10140–U+10174}).\footnote{ %
% 	  	See the documentation of the \pkg{xgreek} package for more details.}
% 	\end{itemize}
% 
% \subsection{hebrew}\label{hebrew}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{numerals}{\xpgvalue{hebrew} or \xpgpresetvalue{arabic}}
% 	\item \xpgchoicekey{calendar}{\xpgvalue{hebrew} or \xpgpresetvalue{gregorian}}
% 	\item \xpgboolkeyfalse{marcheshvan}
% 		If \xpgvalue{true}, the second month of the civil year will be output as
% 		\texthebrew{מרחשון} (Marcheshvan) rather than \texthebrew{חשון} (Heshvan),
% 		which is the default.
% 	 \item \xpgboolkeyfalse[1.57]{fullyear} causes years from the current millennium to be printed with the thousands digit
% 	      (he-tav-shin-samekh-gimel). Without this option, thousands are not printed for the current millennium.
% 	\item \xpgchoicekey[1.57]{transliteration}{\xpgvalue{academy} or \xpgpresetvalue{alt}} With value \xpgvalue{academy}, transliteration
% 	follows	the recommendations of the Hebrew Language Academy. The default (\xpgvalue{alt}) uses the received settings of
% 	\pkg{babel} (\pkg{hebcal}) and	\pkg{polyglossia} (\pkg{hebrewcal}).
% 	\end{itemize}
% \paragraph*{Commands:}
% 	\begin{itemize}
% 	\item \Cmd\hebrewnumeral\ (= \Cmd\hebrewalph) (see section \ref{abjad}).
%   \item \Cmd\aemph (see section \ref{arabic}).
% 	\end{itemize}
% 
% \subsection[hindi]{hindi\new{1.2.0}}\label{hindi}
% \paragraph*{Options:}
% 	\begin{itemize}
% 		\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgpresetvalue{devanagari}}
% 	\end{itemize}
% 
% \subsection{hungarian}\label{hungarian}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.46]{swapstrings}{\xpgdefaultvalue{\xpgpresetvalue{all}},
% 	\xpgvalue{captions}, \xpgvalue{headings}, \xpgvalue{headers}, \xpgvalue{hheaders}, or \xpgvalue{none}}
% 	       In Hungarian, some caption strings need to be in a different order than in other languages
% 	       (\eg \emph{1. fejezet} instead of \emph{Chapter 1}). By default, \pkg{polyglossia} tries hard to
% 	       provide the correct order for different classes and packages (standard classes, \pkg{KOMA-script},
% 	       \pkg{memoir}, and \pkg{titlesec} package should work, as well as \pkg{fancyhdr} and \pkg{caption}).
% 	       However, since the definition of these strings is not standardized, the redefinitions might not work
% 	       and even interfere badly if you use specific classes or packages that redefine the respective strings
% 	       themselves. In this case, you can disable some or all changes.
% 	       The possibilities are:
% 	       \begin{itemize}
% 	       	\item ¦all¦: Redefine figure and table captions, part and chapter headings, and running headers (=~default setting)
% 	       	\item ¦captions¦: Redefine figure and table captions only
% 	       	\item ¦headings¦: Redefine part and chapter headings only
% 	       	\item ¦headers¦: Redefine running headers only
% 	       	\item ¦hheaders¦: Redefine part and chapter headings as well as running headers
% 	       	\item ¦none¦: Do not redefine anything
% 	       \end{itemize}
%     \item \xpgboolkeytrue[1.58]{forceheadingpunctuation}
%         Section numbers always have a trailing punctuation in Hungarian (as in \emph{1.1.} as opposed to \emph{1.1}).
%         For compatibility reasons, the default option is \xpgvalue{false}, thus \textsf{polyglossia}
%         does not touch heading punctuation, so this will be whatever the class or a package determines.
%         Set this option to \xpgvalue{true}, 
%         and \textsf{polyglossia} appends a period after the section counters, 
%         and adjusts the header punctuation (as in \emph{1. fejezet.} as opposed to \emph{1. fejezet}).
% \end{itemize}
% \paragraph*{Commands:}
% \begin{itemize}
% 	\item \Cmd\ontoday\ (= \Cmd\ondatehungarian): special form of \cmd\today\ which produces a slightly different
% 	date format as used in prepositional phrases (such as ‘on February 10th’) in Hungarian.
% \end{itemize}
% 
% \subsection{italian}\label{italian}
% \paragraph*{Options:}
% \begin{itemize}
%   \item \xpgboolkeyfalse[1.2.0cc]{babelshorthands}% TODO: check version
%   Activates the ¦"¦ character as a switch to perform etymological
%   hyphenation when followed by a letter. Furthermore, the following shorthands are activated:
%   \begin{shorthands}
%   	\item[¦""¦] double raised open quotes (the Italian keyboard misses the backtick).
%   	\item[¦"<¦] open guillemet (looks like <<).
%   	\item[¦">¦] closing guillemet (looks like >>).
%   	\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash,
%                hyphenation at the breakpoints preset in the hyphenation patterns is still allowed.
%   	\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
%                in the hyphenation patterns (as opposed to \cmd\-).
%   \end{shorthands}
% \end{itemize}
% 
% \subsection[korean]{korean\new{1.40.0}}\label{korean}
% \paragraph*{Options:}
%   \begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgpresetvalue{plain}, \xpgvalue{classic}, or \xpgvalue{modern}}
%     These variants control spacing before/after CJK punctuations.
%       \begin{itemize}
%         \item ¦plain¦: Do nothing
%         \item ¦classic¦: Suitable for text with no interword spaces.
%           This option forces CJK punctuations to half-width, and
%           inserts half-width glue around them.
%         \item ¦modern¦: Suitable for text with interword spaces.
%           This option forces CJK punctuations to half-width, and
%           inserts small (half of interword space) glue around them.
%       \end{itemize}
% 	\item \xpgchoicekey{captions}{\xpgpresetvalue{hangul} or \xpgvalue{hanja}}
% 	\item \xpgchoicekey[1.47]{swapstrings}{\xpgdefaultvalue{\xpgpresetvalue{all}},
% 	\xpgvalue{headers}, \xpgvalue{headings}, or \xpgvalue{none}}
%     With this option, Korean-style part and chapter headings, and
%     running headers are available.
%     It is similar to Hungarian (see \ref{hungarian}) except that
%     figure and table captions are not touched.
%       \begin{itemize}
%         \item ¦all¦: Redefine part and chapter headings, and running headers
%           (=~default setting)
%         \item ¦headings¦: Redefine part and chapter headings only
%         \item ¦headers¦: Redefine running headers only
%         \item ¦none¦: Do not redefine anything
%       \end{itemize}
%   \end{itemize}
% 
% \subsection[kurdish]{kurdish\new{1.45}}\label{kurdish}
% 
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgvalue{kurmanji} or \xpgpresetvalue{sorani}}
% 	\item \xpgchoicekey{script}{\xpgvalue{arabic} or \xpgvalue{latin}}
% 		Defaults are \xpgvalue{arabic} for Sorani and \xpgvalue{latin} for Kurmanji.
% 	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgvalue{eastern}}
% 		Defaults are \xpgvalue{western} for Latin and \xpgvalue{eastern} for Arabic script, depending
% 		on the selection above.
% 	\item \xpgcodekey[1.63]{sectionsep}¦.¦
% 		This option allows to customize the separator between chapters, sections, and subsections (a dot by default),
% 		\eg \xpgoption{sectionsep=-}.
% 		This might be useful particularly with \xpgoption{numerals=eastern}, as the dot looks too similar to the zero
% 		in many fonts.
% 	\item \xpgboolkeyfalse{abjadjimnotail}
% 		Set this to true if you want the \textit{abjad} form of the number three to
% 		be \textarabic{ج‍} – as in the manuscript tradition – instead of the
% 		modern usage \textarabic{ج}.
% ^^A	\item \xpgchoicekey{locale}{} (not yet implemented)
% ^^A	\item \xpgchoicekey{calendar}{} (not yet implemented)
% \end{itemize}
% \condbreak{2\baselineskip}
% \paragraph*{Commands:}
% \begin{itemize}
% 	\item \Cmd\ontoday: special form of \cmd\today\ which produces a slightly different
% 	date format as used in prepositional phrases (as in ‘on February 10th’). Only available for Latin script.
% 	\item \Cmd\abjad (see section \ref{abjad})
% 	\item \Cmd\aemph (see section \ref{arabic})
% \end{itemize}
% 
% \subsection[lao]{lao\new{1.2.0}}\label{lao}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{numerals}{\xpgvalue{lao} or \xpgpresetvalue{arabic}}
% 	\end{itemize}
% 
% \subsection{latin}\label{latin}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{variant}{\xpgvalue{classic}, \xpgvalue{medieval}, \xpgpresetvalue{modern}, or \xpgvalue{ecclesiastic}\new{1.46}}
% 			These variants refer to different spelling conventions. The \xpgvalue{classic}
% 			and the \xpgvalue{medieval} variant do not use the letters \emph{U} and
% 			\emph{v}, but only \emph{V} and \emph{u}. This concerns predefined terms like
% 			month names as well as the behaviour of the \cmd\MakeUppercase\ and the
% 			\cmd\MakeLowercase\ command. The ¦medieval¦ and the
% 			¦ecclesiastic¦ variant use the ligatures \emph{\ae} and \emph{\oe}.
% 			See table \ref{tab:latin-spelling} for examples.
% 
% 			Furthermore, the \xpgvalue{ecclesiastic} variant takes care for a punctuation
% 			spacing similar to French, but with smaller spaces, as provided for
% 			PDF\TeX\ by the \pkg{ecclesiastic} package.
% 			\begin{table}
% 			\centering
% 			\caption{\label{tab:latin-spelling}Spelling differences between the Latin
% 				language variants.\newline The capitalization of month names and the use of
% 				\emph{i/j} may be affected by the \xpgvalue{capitalizemonth} and the
% 				\xpgvalue{usej} option.}
% 			\begin{tabular}{llll}
% 			\toprule
% 			\textbf{classic} & \textbf{medieval} & \textbf{modern} & \textbf{ecclesiastic} \\
% 			\midrule
% 			Ianuarii & Ianuarii & Ianuarii & ianuarii \\
% 			Nouembris & Nouembris & Novembris & novembris \\
% 			Praefatio & Præfatio & Praefatio & Præfatio \\
% 			\addlinespace\multicolumn{4}{@{}l}{\cmd{\MakeUppercase\{Iulius\}} yields:} \\
% 			IVLIVS & IVLIVS & IULIUS & IULIUS \\
% 			\bottomrule
% 			\end{tabular}
% 			\end{table}
% 	\item \xpgchoicekey[1.46]{hyphenation}{\xpgvalue{classic}, \xpgvalue{modern}, or \xpgvalue{liturgical}}
% 			There are three different sets of hyphenation patterns for Latin. Separate
% 			documention for them is available on the
% 			Internet.\footnote{Refer to \url{https://github.com/gregorio-project/hyphen-la/blob/master/doc/README.md\#hyphenation-styles}}
% 			Each of the four variants mentioned above has its default set of hyphenation
% 			patterns as indicated by table \ref{tab:latin-hyphenation}. Use the
% 			¦hyphenation¦ option if the default style does not fit your needs.
% 			Note that the liturgical hyphenation patterns are the default of none of the
% 			language variants. To use them, you have to say
% 			\xpgvalue{hyphenation=liturgical} in any case.
% 			\begin{table}
% 			\caption{\label{tab:latin-hyphenation}Latin default hyphenation styles}
% 			\centering
% 			\begin{tabular}{ll}
% 			\toprule
% 			\textbf{Language variant} & \textbf{Default hyphenation style} \\
% 			\midrule
% 			classic & classic \\
% 			medieval & modern \\
% 			modern & modern \\
% 			ecclesiastic & modern \\
% 			\bottomrule
% 			\end{tabular}
% 			\end{table}
% 	\item \xpgboolkeyfalse[1.46]{ecclesiasticfootnotes}
% 			Use footnotes as provided by the \pkg{ecclesiastic} package, which typesets
% 			footnotes with ordinary instead of superior numbers and without indentation.
% 			As many ecclesiastic documents and liturgical books use footnotes that are
% 			very similar to the ordinary \LaTeX\ ones, we do not use this footnote style
% 			as default even for the ¦ecclesiastic¦ variant.
% 		
% 			Note that this option is only possible if Latin is the main language of your
% 			document.
% 	\item \xpgboolkeyfalse[1.46]{usej}
% 			Use \emph{J/j} in predefined terms. The letter \emph{j} is not of ancient
% 			origin. In early modern times, it was used to distinguish the consonantic
% 			\emph{i} from the vocalic~\emph{i}. Nowadays, the use of \emph{j} has
% 			disappeared from most Latin publications. So ¦false¦ is the default
% 			value for all four language variants. Use this option if you prefer
% 			\emph{Januarii} and \emph{Maji} to \emph{Ianuarii} and \emph{Maii}.
% 	\item \xpgboolkey[1.46]{capitalizemonth}
% 			Capitalize the month name when printing dates (using the \cmd\today\
% 			command).  Traditionally, month names are capitalized. However, in recent
% 			liturgical books they are lowercase. So ¦true¦ is the default value for
% 			the variants ¦classic¦, ¦medieval¦, and ¦modern¦,
% 			whereas ¦false¦ is the default value for the ¦ecclesiastic¦
% 			variant.
% 	\item \xpgboolkeyfalse{babelshorthands}
% 			Enable the following shorthands inherited from \pkg{babel-latin} and the
% 			\pkg{ecclesiastic} package.
% 			\begin{shorthands}
% 				\item[¦"<¦] for « (left guillemet)
% 				\item[¦">¦] for » (right guillemet)
% 				\item[¦"¦] If no other shorthand applies, ¦"¦ before any letter
% 					character defines an optional break point allowing further break points
% 					within the same word (as opposed to the \cmd\- command).
% 				\item[¦"|¦] the same as ¦"¦, but also possible before non-letter
% 					characters
% 				\item[¦'a¦] for á (a with acute), also available for é, í, ó, ú, ý, ǽ, and
% 					\'œ
% 				\item[¦'A¦] for Á (A with acute), also available for É, Í, Ó, Ú, \'V, Ý, Ǽ,
% 					and \'Œ
% 			\end{shorthands}
% 			The following shorthands are only available for the ¦medieval¦ and the
% 			¦ecclesiastic¦ variant.
% 			\begin{shorthands}
% 				\item[¦"ae¦] for æ (ae ligature), also available for œ
% 				\item[¦"Ae¦] for Æ (AE ligature), also available for Œ
% 				\item[¦"AE¦] for Æ (AE ligature), also available for Œ
% 				\item[¦'ae¦] for ǽ (ae ligature with acute), also available for \'œ
% 				\item[¦'Ae¦] for Ǽ (AE ligature with acute), also available for \'Œ
% 				\item[¦'AE¦] for Ǽ (AE ligature with acute), also available for \'Œ
% 			\end{shorthands}
% 	\item \xpgboolkeyfalse[1.46]{prosodicshorthands}
% 			Enable shorthands for prosodic marks (macrons and breves) very similiar to
% 			those provided by \pkg{babel-latin} using the ¦withprosodicmarks¦
% 			modifier.
% 			Note that the active ¦=¦ character used for macrons will cause problems with
% 			commands using \texttt{key=value} interfaces, such as the command
% 			¦\includegraphics[scale=2]{...}¦. Use \cmd{\shorthandoff\{=\}} before
% 			such commands (and \cmd{\shorthandon\{=\}} thereafter) within every
% 			environment with prosodic shorthands enabled.
% 		
% 			The following shorthands are available.
% 			\begin{shorthands}
% 				\item[¦=a¦] for ā (a with macron), also available for ē, ī, ō, ū, and ȳ
% 				\item[¦=A¦] for Ā (A with macron), also available for Ē, Ī, Ō, Ū, V̄, and Ȳ.
% 					Note that a macron above the letter V is only displayed if your font
% 					supports the Unicode character ¦0304¦ (\emph{combining macron}).
% 				\item[¦=ae¦] for a͞e (ae diphthong with macron, for the ¦classic¦ and
% 					the ¦modern¦ variant) or ǣ (ae ligature with macron, for the ¦medieval¦
% 					and the ¦ecclesiastic¦ variant), respectively; also available for a͞u,
% 					e͞u, and o͞e/œ̄. Note that macrons above diphthongs are only displayed if
% 					your font supports the Unicode character ¦035E¦ (\emph{combining double
% 					macron}).
% 				\item[¦=Ae¦] for A͞e (Ae diphthong with macron, for the ¦classic¦ and
% 					the ¦modern¦ variant) or Ǣ (AE ligature with macron, for the ¦medieval¦
% 					and the ¦ecclesiastic¦ variant), respectively; also available for A͞u,
% 					E͞u, and O͞e/Œ̄.
% 				\item[¦=AE¦] for A͞E (AE diphthong with macron, for the ¦classic¦ and
% 					the ¦modern¦ variant) or Ǣ (AE ligature with macron, for the ¦medieval¦
% 					and the ¦ecclesiastic¦ variant), respectively; also available for A͞U,
% 					E͞U, and O͞E/Œ̄.
% 				\item[¦\textasciicircum a¦] for ă (a with breve), also available for ĕ, ĭ,
% 					ŏ, ŭ, and y̆. Note that a breve above the letter y is only displayed if
% 					your font supports the Unicode character ¦0306¦ (\emph{combining
% 					breve}).
% 				\item[¦\textasciicircum A¦] Ă (A with breve), also available for Ĕ, Ĭ, Ŏ,
% 					Ŭ, V̆, and Y̆. Note that breves above the letters V and Y are only displayed
% 					if your font supports the Unicode character ¦0306¦ (\emph{combining
% 					breve}).
% 			\end{shorthands}
% \end{itemize}
% 
% \subsection{malay}\label{malay}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{indonesian} or \xpgpresetvalue{malaysian}}
% \end{itemize}
% 
% \subsection{marathi}\label{marathi}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{devanagari} or \xpgvalue{western}}
% \end{itemize}
% 
% \subsection[mongolian]{mongolian\new{1.45}}\label{mongolian}
% Currently, only the Khalkha variety in Cyrillic script is supported.
% 
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse{babelshorthands}
% 	If this is turned on, the following shorthands are activated:
% 	\begin{shorthands}
%         \item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		           in the hyphenation patterns (as opposed to \cmd\-).
% 		\item[¦"=¦] adds an explicit hyphen with a breakpoint, allowing for hyphenation at the
% 		           other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 		           cases where the hyphen should stick at the following syllable.
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
% 		\item[¦"‘¦] for German-style left double quotes (looks like ,,).
% 		\item[¦"’¦] for German-style right double quotes (looks like “).
% 		\item[¦"<¦] for French-style left double quotes (looks like <<).
% 		\item[¦">¦] for French-style right double quotes (looks like >>).
%     \end{shorthands}
% 
% 	There are also three shorthands for the Cyrillic dash (\textrussian{тире}), which is shorter than the
% 	emdash but longer than the endash (namely 0.8\,em).
% 	Note that, since it is not covered by unicode, this character is faked by telescoping two endashes:
% 	\begin{shorthands}
% 		\item[¦"---¦] Cyrillic dash for the use in normal text. This requires preceding space
% 		in input (trailing space is optional) and prints with a non-breakable thin space before
% 		and after the dash.
% 		\item[¦"--\textasciitilde¦] Cyrillic dash for the use in compound names (surnames).
% 		As opposed to ¦"---¦ this removes any space before and after the dash. 
% 		\item[¦"--*¦] Cyrillic dash for denoting direct speech. This adds a larger space after
% 		the dash. Space before the dash is output as is.
% 	\end{shorthands}
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic}, \xpgvalue{cyrillic-alph} or \xpgvalue{cyrillic-trad}}
%           Uses either Arabic numerals or Cyrillic alphanumerical numbering. The two Cyrillic variants differ as follows:
%           \begin{itemize}
% 	           \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
% 	           \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
% 	                 \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
% 	                 It supports numbers up to 999\,999.
%           \end{itemize}
% \end{itemize}
% ^^A
% \paragraph*{Commands:}
% \begin{itemize}
%     \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
%           It steps through the Cyrillic alphabet and thus it can only be used up to 30.
%           The command takes a counter as argument, \eg ¦\textmongolian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
%     \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
%     \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
%           numbers up to 999\,999.\\
%           \Eg ¦\textmongolian{\AsbukTrad{section}}¦ produces \textrussian{\AsbukTrad{section}}.
%     \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
% \end{itemize}
% 
% \subsection{norwegian}\label{norwegian}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{bokmal} or \xpgpresetvalue{nynorsk}}
% \end{itemize}
% 
% \subsection{persian}\label{persian}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgpresetvalue{eastern}}
% 	\item \xpgcodekey[1.63]{sectionsep}¦.¦
% 		This option allows to customize the separator between chapters, sections, and subsections (a dot by default),
% 		\eg \xpgoption{sectionsep=-}.
% 		This might be useful particularly with \xpgoption{numerals=eastern}, as the dot looks too similar to the zero
% 		in many fonts.
% 	\item \xpgboolkeyfalse[1.0.3]{abjadjimnotail}
% 		Set this to \xpgvalue{true} if you want the \textit{abjad} form of the number three to
% 		be \textarabic{ج‍} – as in the manuscript tradition – instead of the
% 		modern usage \textarabic{ج}.
% ^^A	\item \xpgchoicekey{locale}{} (not yet implemented)
% ^^A	\item \xpgchoicekey{calendar}{} (not yet implemented)
% \end{itemize}
% \paragraph*{Commands:}
% \begin{itemize}
% 	\item \Cmd\abjad (see section \ref{abjad})
% 	\item \Cmd\aemph (see section \ref{arabic}).
% \end{itemize}
% 
% \subsection{polish}\label{polish}
% 
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse[1.55]{babelshorthands}
% 	If this is turned on, the following shorthands for Polish are activated:
% 	\begin{shorthands}
% 		\item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
% 		of the next line when hyphenated, as common in Polish typesetting
% 		(also if ¦splithyphens=false¦). Unlike  plain ¦-¦, this also allows
% 		for hyphenation at the other points preset in the hyphenation patterns.
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 		cases where the hyphen should stick at the following syllable.
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		in the hyphenation patterns (as opposed to \cmd\-).
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 		\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation at the breakpoints
% 		preset in the hyphenation patterns is still allowed.
% 		\item[¦"`¦] for Polish left double quotes (looks like ,,).
% 		\item[¦"'¦] for Polish right double quotes (looks like '').
% 		\item[¦"<¦] for French left double guillemets (looks like << -- used in Polish as second level quotes). 
% 		\item[¦">¦] for French right double guillemets (looks like >>).
% 	\end{shorthands}
% 	\item \xpgboolkeytrue[1.55]{splithyphens}
% 	According to Polish typesetting conventions, if a word with a hard hyphen (such as \emph{czerwono-złote})
% 	is hyphenated at this hyphen, a second hyphenation character is to be inserted at the beginning
% 	of the line that follows the hyphenation (\emph{czerwono-/-złote}).
% 	By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
% 	loaded to achieve this).
% 	Set this option to ¦false¦ to disable the feature.
% 	\item \xpgboolkeytrue[1.55]{vlna}
% 	According to Polish typesetting conventions, single-letter words (non-syllable prepositions)
% 	must not occur at line ends.
% 	\pkg{Polyglossia} takes care of this automatically by default (if you are using \LuaTeX, the
% 	\pkg{luavlna} package is loaded to achieve this).
% 	Set this option to ¦false¦ to disable the feature.
% \end{itemize}
% 
% \subsection{portuguese}\label{portuguese}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{brazilian} or \xpgpresetvalue{portuguese}}
% 	\item \xpgboolkeyfalse[1.54]{babelshorthands}
% 		If this is turned on, the following shorthands for fine-tuning hyphenation and micro-typography
% 		of Portuguese words are activated.
% 		\begin{shorthands}
% 			\item[¦"|¦] disables a ligature at this position.
% 			\item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
% 			of the next line when hyphenated, as common in Portuguese typesetting
% 			(also if ¦splithyphens=false¦). Unlike  plain ¦-¦, this also allows
% 			for hyphenation at the other points preset in the hyphenation patterns.
% 			\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 			cases where the hyphen should stick at the following syllable.
% 			\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 			in the hyphenation patterns (as opposed to \cmd\-).
% 			\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 			\item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation
% 			at the breakpoints preset in the hyphenation patterns is still allowed.
% 			\item[¦"<¦] for French left guillemets («).
% 			\item[¦">¦] for French right guillemets (»).
% 		\end{shorthands}
%     \item \xpgboolkeytrue[1.54]{splithyphens}
% 		According to Portuguese typesetting conventions, if a word with a hard hyphen (such as
% 		\emph{pára-brisas}) is hyphenated at this hyphen, a second hyphenation character is to be
% 		inserted at the beginning of the line that follows the hyphenation (\emph{pára-/-brisas}).
% 		By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
% 		loaded to achieve this).
% 		Set this option to ¦false¦ to disable the feature.
% \end{itemize}
% 
% \subsection[punjabi]{punjabi\new{1.59}}\label{punjabi}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgpresetvalue{gurmukhi}}
% \end{itemize}
% 
% \subsection{russian}\label{russian}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgboolkeyfalse{babelshorthands}
% 	If this is turned on, the following shorthands are activated:
% 	\begin{shorthands}
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		           in the hyphenation patterns (as opposed to \cmd\-).
% 		\item[¦"=¦] adds an explicit hyphen with a breakpoint, allowing for hyphenation at the
% 		           other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
% 		\item[\texttt{"\textasciitilde}] adds an explicit hyphen without a breakpoint. Useful for
% 		           cases where the hyphen should stick at the following syllable.
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% 	 \end{shorthands}
% 
% 	There are also three shorthands for the Cyrillic dash (\textrussian{тире}), which is shorter than the
% 	emdash but longer than the endash (namely 0.8\,em).
% 	Note that, since it is not covered by unicode, this character is faked by telescoping two endashes:
% 	\begin{shorthands}
% 		\item[¦"---¦] Cyrillic dash for the use in normal text. This requires preceding space
% 		in input (trailing space is optional) and prints with a non-breakable thin space before
% 		and after the dash.
% 		\item[¦"--\textasciitilde¦] Cyrillic dash for the use in compound names (surnames).
% 		As opposed to ¦"---¦ this removes any space before and after the dash. 
% 		\item[¦"--*¦] Cyrillic dash for denoting direct speech. This adds a larger space after
% 		the dash. Space before the dash is output as is.
% ^^A These are commented out in gloss-russian
% ^^A		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
% ^^A		\item[¦"‘¦] for German left double quotes (looks like ,,).
% ^^A		\item[¦"’¦] for German right double quotes (looks like “).
% ^^A		\item[¦"<¦] for French left double quotes (looks like <<).
% ^^A		\item[¦">¦] for French right double quotes (looks like >>).
% 	\end{shorthands}
%     \item \xpgboolkeytrue[1.50]{forceheadingpunctuation}
%         By default, chapter and section numbers always have a trailing punctuation in Russian
%         (as in \emph{1.1.} as opposed to \emph{1.1}). If this option is set to \xpgvalue{false}, \textsf{polyglossia}
%         will not touch heading punctuation, so this will be whatever the class or a package determines.
% 	\item \xpgboolkeytrue[1.46]{indentfirst}
% 		By default, all paragraphs are indented in Russian, also those after a
% 		chapter or section heading. If this option is \xpgvalue{false}, the latter paragraphs
% 		are not indented, as normal in \LaTeX.
%     \item \xpgboolkeytrue[1.52]{mathfunctions}
% 	    By default, some specific math macros are defined for Russian (see below). In order to prevent command
% 	    clashes (\eg with the \pkg{chemformula} package), you can switch these definitions off by passing \xpgvalue{false}
% 	    to this option.
% 	\item \xpgchoicekey{spelling}{\xpgpresetvalue{modern} or \xpgvalue{old}}
% 		This option is for captions and date only, not for hyphenation.
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic}, \xpgvalue{cyrillic-alph} or \xpgvalue{cyrillic-trad}}
% 		Uses either Arabic numerals or Cyrillic alphanumerical numbering. The two Cyrillic variants differ as follows:
% 		\begin{itemize}
% 			\item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
% 			\item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
% 			      \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
% 			      It supports numbers up to 999\,999.
% 		\end{itemize}
% 	\end{itemize}
% ^^A
% \paragraph*{Commands:}
% 	\begin{itemize}
% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
% 	      It steps through the Cyrillic alphabet and thus it can only be used up to 30.
% 	      The command takes a counter as argument, \eg ¦\textrussian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
% 	\item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
% 	\item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
% 	      numbers up to 999\,999.\\
% 	      \Eg ¦\textrussian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
% 	\item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
% 	\end{itemize}
%     If the \xpgoption{mathfunctions} option is \xpgvalue{true}, loading Russian defines a few macros than can be used
%     independently of the current language. These are nine macros to be used in math mode to type the names of
%     trigonometric functions common for Russian documents: \cmd\sh , \cmd\ch , \cmd\tg , \cmd\ctg , \cmd\arctg ,
%     \cmd\arcctg , \cmd\th , \cmd\cth , and \cmd\cosec . Cyrillic letters in math mode can be typed with
%     the aid of text commands such as \cmd\textbf , \cmd\textsf , \cmd\textit , \cmd\texttt , etc.
%     The macros \cmd\Prob , \cmd\Variance , \cmd\NOD , \cmd\nod , \cmd\NOK , \cmd\nok , \cmd\Proj\ print some rare
%     Russian mathematical symbols.
% 
% \subsection[sami]{sami\new{1.45}}\label{sami}
% Currently support for Sami is limited to Northern Sami.
% 
% \subsection{sanskrit}\label{sanskrit}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey[1.0.2]{script}{\xpgpresetvalue{devanagari}, \xpgvalue{gujarati},
% 	\xpgvalue{malayalam}, \xpgvalue{bengali}, \xpgvalue{kannada}, \xpgvalue{telugu}, \xpgvalue{latin}}
% 		The value is passed to \pkg{fontspec} should the respective
% 		\cmd{\⟨script⟩font} not be defined.  This can be useful if you typeset Sanskrit
% 		texts in scripts other than Devanagari.
% 	\item \xpgchoicekey[1.45]{numerals}{\xpgpresetvalue{devanagari} or \xpgvalue{western}}
% 	\end{itemize}
% 
% \subsection{serbian}\label{serbian}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey[1.63]{variant}{\xpgpresetvalue{ekavian} or \xpgvalue{ijekavian}}
% 	        With \xpgvalue{ijekavian}, the different spelling is reflected in some caption strings.
% 	\item \xpgchoicekey{script}{\xpgpresetvalue{cyrillic} or \xpgvalue{latin}}
% 	\item \xpgboolkeyfalse[1.63]{datei}
% 	        If this is \xpgvalue{true}, the sixth and seventh month of the year are written in the date
% 	        with the trailing \meta{i} or \meta{и} (\ie \emph{juni}, \emph{juli} or \emph{јуни}, \emph{јули}
% 	        rather than \emph{jun}, \emph{jul} or \emph{јун}, \emph{јул}).
% 	\item \xpgboolkeytrue[1.54]{splithyphens}
% 			According to Serbian typesetting conventions, if a word with a hard hyphen (such as
% 			\emph{калцијум-карбонат}) is hyphenated at this hyphen, a second hyphenation character is to be
% 			inserted at the beginning of the line that follows the hyphenation (\emph{калцијум-/-карбонат}).
% 			By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
% 			loaded to achieve this).
% 			Set this option to ¦false¦ to disable the feature.
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic}, \xpgvalue{cyrillic-alph} or \xpgvalue{cyrillic-trad}}
%           Uses either Arabic numerals or Cyrillic alphanumerical numbering. The two Cyrillic variants differ as follows:
%           \begin{itemize}
%                \item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
% 	           \item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
% 	                  \footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
% 	                  It supports numbers up to 999\,999.
%           \end{itemize}
% \end{itemize}
% ^^A
% \paragraph*{Commands:}
% \begin{itemize}
%     \item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
%           It steps through the Cyrillic alphabet and thus it can only be used up to 30.
%           The command takes a counter as argument, \eg ¦\textserbian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
%     \item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
%     \item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
%           numbers up to 999\,999.\\
%           \Eg ¦\textserbian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
%     \item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
%     \item \Cmd{\today*}: as opposed to the unstarred counterpart, this does not end the date with a punctuation.
%     \item \Cmd{\todayGen}: outputs the date with months in genitive inflection. This form is suggested when the date
%           is integrated into a sentence (as opposed to a standalone date statement). The starred form \Cmd{\todayGen*}
%           omits the trailing punctuation.
%     \item \Cmd{\todayArabic}: outputs the date with months in Arabic number. The starred form \Cmd{\todayArabic*} omits
%     	  the trailing punctuation.
% 	\item \Cmd{\todayRoman}: outputs the date with months in Roman number. The starred form \Cmd{\todayRoman*} omits
% 	      the trailing punctuation.
% \end{itemize}
% 
% 
% \subsection{slovak}\label{slovak}
% 
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse[1.46]{babelshorthands}
% 		If this is turned on, the following shorthands for Slovak are activated:
% 		\begin{shorthands}
%         \item[¦"=¦] for an explicit hyphen sign which is repeated at the beginning
%                     of the next line when hyphenated, as common in Slovak typesetting
% 		            (also if ¦splithyphens=false¦). Unlike  plain ¦-¦, this also allows
% 		            for hyphenation at the other points preset in the hyphenation patterns.
%         \item[¦"|¦] disables a ligature at this position.
%         \item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
%                     cases where the hyphen should stick at the following syllable.
%         \item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
%                     in the hyphenation patterns (as opposed to \cmd\-).
%         \item[¦""¦] allows for a line break at this position (without hyphenation sign).
%         \item[¦"/¦] a slash that allows for a subsequent line break. As opposed to \cmd\slash, hyphenation at the breakpoints
%                     preset in the hyphenation patterns is still allowed.
%         \item[¦"‘¦] for Slovak left double quotes (looks like ,,).
%         \item[¦"’¦] for Slovak right double quotes (looks like “).
%         \item[¦">¦] for Slovak left double guillemets (looks like >>).
%         \item[¦"<¦] for Slovak right double guillemets (looks like <<).
% 		\end{shorthands}
% 	\item \xpgboolkeytrue[1.46]{splithyphens}
% 	      According to Slovak typesetting conventions, if a word with a hard hyphen (such as \emph{je-li})
% 	      is hyphenated at this hyphen, a second hyphenation character is to be inserted at the beginning
%           of the line that follows the hyphenation (\emph{je-/-li}).
% 	      By default, this is done automatically (if you are using \LuaTeX, the \pkg{luavlna} package is
% 	      loaded to achieve this).
% 	      Set this option to ¦false¦ to disable the feature.
% 	\item \xpgboolkeytrue[1.46]{vlna}
% 	      According to Slovak typesetting conventions, single-letter words (non-syllable prepositions)
% 	      must not occur at line ends.
% 	      \pkg{Polyglossia} takes care of this automatically by default (if you are using \LuaTeX, the
% 	      \pkg{luavlna} package is loaded to achieve this).
% 	      Set this option to ¦false¦ to disable the feature.
% \end{itemize}
% 
% \subsection{slovenian}\label{slovenian}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgboolkeyfalse{localalph}
% 	      If \xpgvalue{true}, alphanumeric counters will use a localized version including characters with caron
% 	      (\emph{a, b, c, č, d, \ldots}) and excluding the characters \meta{q}, \meta{w}, \meta{x} and \meta{y}
% 	      from alphabetic counting.
% 	\end{itemize}
% 
% \subsection{sorbian}\label{sorbian}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{lower} or \xpgpresetvalue{upper}}
% 	\item \xpgboolkeyfalse[1.45]{olddate}
% 		If \xpgvalue{true}, \cmd\today\ will use traditional Sorbian month names (\ie it will be
% 		synonymous to \cmd\oldtoday\ below).
% \end{itemize}
% \paragraph*{Commands:}
% \begin{itemize}
% 	\item \Cmd\oldtoday: outputs the current date using traditional Sorbian month names, even if
% 	       \xpgvalue{olddate} is \xpgvalue{false}.
% \end{itemize}
% 
% \subsection{spanish}\label{spanish}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.46]{variant}{\xpgpresetvalue{spanish} or \xpgvalue{mexican}}
% 	\item \xpgchoicekey[1.46]{spanishoperators}{\xpgdefaultvalue{all}, \xpgvalue{accented},
% 	\xpgvalue{spaced}, \xpgvalue{none}, or \xpgpresetvalue{false}}
% 	      Determines of and how math operators are localized to Spanish.
% 	      \begin{itemize}
% 	      	\item ¦accented¦ causes some math operators to use accents where usual in Spanish (\emph{lím},
% 	      	      \emph{lím\,sup}, \emph{lím\,inf}, \emph{máx}, \emph{mín}, \emph{ínf}, \emph{mód}).
% 	      	\item ¦spaced¦ causes some math operators to use spaces where usual in Spanish (\emph{arc\,cos},
% 	      	      \emph{arc\,sen}, \emph{arc\,tg}).
% 	      	\item ¦all¦ activates ¦accented¦ and ¦spaced¦ and furthermore provides Spanish localizations of
% 	      	      \cmd\sin\ (\emph{sen}), \cmd\tan\ (\emph{tg}), \cmd\sinh\ (\emph{senh}), and \cmd\tanh\ (\emph{tgh}).
% 	      	\item ¦none¦ does no localization at all (default setting).
% 	      \end{itemize}
% \end{itemize}
% \paragraph*{\color{black}Commands:}\new{1.46}
% \begin{itemize}
% 	\item \Cmd\arcsen: alias to \cmd\arcsin\ (\pkg{babel} compatibility)
% 	\item \Cmd\arctg: alias to \cmd\arctan\ (\pkg{babel} compatibility)
% 	\item \Cmd\sen: alias to \cmd\sin\ (\pkg{babel} compatibility)
% 	\item \Cmd\senh: alias to \cmd\sinh\ (\pkg{babel} compatibility)
% 	\item \Cmd\tg: alias to \cmd\tan\ (\pkg{babel} compatibility)
% 	\item \Cmd\tgh: alias to \cmd\tanh\ (\pkg{babel} compatibility)
% 	\item \Cmd\spanishoperator: allows you to define further localized operators. For instance, ¦\spanishoperator{cotg}¦
% 	      defines a command \cmd\cotg\ that outputs \emph{cotg} in math. The optional argument of the command lets you specify the
% 	      spelling, if needed, \eg ¦\spanishoperator[arc\,ctg]{arcctg}¦.
% \end{itemize}
% 
% \subsection{syriac}\label{syriac}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey[1.0.1]{numerals}{\xpgpresetvalue{western} (\ie 1234567890), \xpgvalue{eastern}
% 		(for which the Oriental Arabic numerals are used: \textarabic{١٢٣٤٥٦٧٨٩٠}), or
% 		\xpgvalue{abjad}}
% 	\item \xpgcodekey[1.63]{sectionsep}¦.¦
% 		This option allows to customize the separator between chapters, sections, and subsections (a dot by default),
% 		\eg \xpgoption{sectionsep=-}.
% 		This might be useful particularly with \xpgoption{numerals=eastern}, as the dot looks too similar to the zero
% 		in many fonts.
% 	\end{itemize}
% \paragraph*{Commands:}
% 	\begin{itemize}
% 	\item \Cmd\abjadsyriac (see section \ref{abjad})
%   \item \Cmd\aemph (see section \ref{arabic}).
% 	\end{itemize}
% 
% \subsection{thai}\label{thai}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{numerals}{\xpgvalue{thai} or \xpgpresetvalue{arabic}}
% 	\end{itemize}
% ^^A
% To insert word breaks, you need to use an external processor.
% See the documentation to \pkg{thai-latex} and the file \file{testthai.tex}
% that comes with this package.
% 
% \subsection{tibetan}\label{tibetan}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{numerals}{\xpgvalue{tibetan} or \xpgpresetvalue{arabic}}
% \end{itemize}
% 
% \subsection{ukrainian}\label{ukrainian}
% 
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgboolkeyfalse{babelshorthands}
% 	If this is turned on, the following shorthands are activated:
% 	\begin{shorthands}
% 		\item[¦"-¦] adds a hyphenation point that does still allow for hyphenation at the points preset
% 		     in the hyphenation patterns (as opposed to \cmd\-).
% 		\item[¦"=¦] adds an explicit hyphen with a breakpoint, allowing for hyphenation at the
% 		     other points preset in the hyphenation patterns (as opposed to plain ¦-¦).
% 		\item[\texttt{"\textasciitilde}] for a hyphen sign without a breakpoint. Useful for
% 		     cases where the hyphen should stick at the following syllable.
% 		\item[¦"|¦] disables a ligature at this position.
% 		\item[¦""¦] allows for a line break at this position (without hyphenation sign).
% ^^A These are commented out in gloss-ukrainian
% ^^A		\item[¦",¦] thinspace for initials with a breakpoint in following surname.
% ^^A		\item[¦"‘¦] for German left double quotes (looks like ,,).
% ^^A		\item[¦"’¦] for German right double quotes (looks like “).
% ^^A		\item[¦"<¦] for French left double quotes (looks like <<).
% ^^A		\item[¦">¦] for French right double quotes (looks like >>).
% 	\end{shorthands}
% 
% 	There are also three shorthands for the Cyrillic dash (\textrussian{тире}), which is shorter than the
% 	emdash but longer than the endash (namely 0.8\,em).
% 	Note that, since it is not covered by unicode, this character is faked by telescoping two endashes:
% 	\begin{shorthands}
% 		\item[¦"---¦] Cyrillic dash for the use in normal text. This requires preceding space
% 		in input (trailing space is optional) and prints with a non-breakable thin space before
% 		and after the dash.
% 		\item[¦"--\textasciitilde¦] Cyrillic dash for the use in compound names (surnames).
% 		As opposed to ¦"---¦ this removes any space before and after the dash. 
% 		\item[¦"--*¦] Cyrillic dash for denoting direct speech. This adds a larger space after
% 		the dash. Space before the dash is output as is.
% 	\end{shorthands}
%     \item \xpgboolkeytrue[1.52]{mathfunctions}
% 		By default, some specific math macros are defined for Ukrainian (see below). In order to prevent command
% 		clashes (\eg with the \pkg{chemformula} package), you can switch these definitions off by passing \xpgvalue{false}
% 		to this option.
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{arabic}, \xpgvalue{cyrillic-alph} or \xpgvalue{cyrillic-trad}}
% 	      Uses either Arabic numerals or Cyrillic alphanumerical numbering. The two Cyrillic variants differ as follows:
% 	\begin{itemize}
% 		\item \xpgvalue{cyrillic-alph} steps through the Cyrillic alphabet. Thus it can only be used up to 30.
% 		\item \xpgvalue{cyrillic-trad} (= \xpgvalue{cyrillic}) uses a traditional Cyrillic alphanumeric system.%
% 		\footnote{See \url{https://en.wikipedia.org/wiki/Cyrillic_numerals}.}
% 		It supports numbers up to 999\,999.
% 	\end{itemize}
% \end{itemize}
% ^^A
% \paragraph*{Commands:}
% \begin{itemize}
% 	\item \Cmd\Asbuk: produces uppercased Cyrillic alphanumerals, for environments such as ¦enumerate¦.
% 	It steps through the Cyrillic alphabet and thus it can only be used up to 30.
% 	The command takes a counter as argument, \eg ¦\textukrainian{\Asbuk{section}}¦ produces \textrussian{\Asbuk{section}}.
% 	\item \Cmd\asbuk: same as \cmd\Asbuk\ but in lowercase.
% 	\item \Cmd\AsbukTrad: same as \cmd\Asbuk\ but using the traditional Cyrillic alphanumeric numbering which supports
% 	numbers up to 999\,999.\\
% 	\Eg ¦\textukrainian{\AsbukTrad{page}}¦ produces \textrussian{\AsbukTrad{page}}.
% 	\item \Cmd\asbukTrad: same as \cmd\AsbukTrad\ but in lowercase.
% \end{itemize}
% ^^A
% If the \xpgoption{mathfunctions} option is \xpgvalue{true}, loading Ukrainian defines a few macros than can be used
% independently of the current language. These are nine macros to be used in math mode to type the names of
% trigonometric functions common for Ukrainian documents: \cmd\sh , \cmd\ch , \cmd\tg , \cmd\ctg , \cmd\arctg ,
% \cmd\arcctg , \cmd\th , \cmd\cth , and \cmd\cosec . Cyrillic letters in math mode can be typed with
% the aid of text commands such as \cmd\textbf , \cmd\textsf , \cmd\textit , \cmd\texttt , etc.
% The macros \cmd\Prob , \cmd\Variance , \cmd\NOD , \cmd\nod , \cmd\NOK , \cmd\nok , \cmd\NSD , \cmd\nsd , \cmd\NSK ,
% \cmd\nsk , \cmd\Proj\ print some rare
% Ukrainian mathematical symbols.
% 
% \subsection{urdu}\label{urdu}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey{calendar}{\xpgpresetvalue{gregorian} or \xpgvalue{hijri}}
% 	\item \xpgoptkey{hijricorrection}{integer}[0]
% 		If \xpgvalue{calendar=hijri} is selected, \cmd{\today} will output the date
% 		according to the lunar Islamic (Hijra) calendar. This option allows to shift the day of the output with respect
% 		to the current date. Both positive and negative integer values are allowed (negative decrease the day value).
% 		This corresponds to the optional argument of the \cmd{\Hijritoday} command which can be used to output Hijri
% 		dates irrespective of the \xpgvalue{calendar} option (see sec.~\ref{sec:hijrical}).
% 	\item \xpgchoicekey{numerals}{\xpgvalue{western} or \xpgpresetvalue{eastern}}
% 	\item \xpgcodekey[1.63]{sectionsep}¦.¦
% 		This option allows to customize the separator between chapters, sections, and subsections (a dot by default),
% 		\eg \xpgoption{sectionsep=-}.
% 		This might be useful particularly with \xpgoption{numerals=eastern}, as the dot looks too similar to the zero
% 		in many fonts.
% 	\item \xpgboolkeyfalse{abjadjimnotail}
% 		Set this to \xpgvalue{true} if you want the \textit{abjad} form of the number three to
% 		be \textarabic{ج‍} – as in the manuscript tradition – instead of the
% 		modern usage \textarabic{ج}.
% \end{itemize}	
% 
% \subsection{uyghur}\label{uyghur}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.53]{chapterformat}{\xpgdefaultvalue{\xpgpresetvalue{ordinal}},
% 		\xpgvalue{roman}, \xpgvalue{arabic}}
% 	In Uyghur, chapter and part headings usually use ordinals rather than numbers. Alternatively Roman numbers
% 	are common as well. By default, \pkg{polyglossia} uses ordinals.
% 	This option allows to change this. Choices are:
% 	\begin{itemize}
% 		\item ¦ordinal¦: Use ordinals for chapter and part headings (=~default setting)
% 		\item ¦roman¦: Use Roman numbering for chapter and part heading.
% 		\item ¦arabic¦: Use Arabic numbering for chapter and part heading (=~LaTeX default).
% 	\end{itemize}
%     Note that this option only works if \xpgoption{swapstrings} is set to \xpgvalue{all}, \xpgvalue{headings} or
%     \xpgvalue{hheaders}. The caveats for that options (see below) apply.
% 	\item \xpgchoicekey[1.53]{swapstrings}{\xpgdefaultvalue{\xpgpresetvalue{all}},
% 		\xpgvalue{captions}, \xpgvalue{headings}, \xpgvalue{headers}, \xpgvalue{hheaders}, or \xpgvalue{none}}
% 	In Uyghur, table and figure caption strings need to be in a different order and format than in other languages.
% 	By default, \pkg{polyglossia} provides the correct for different classes and packages (standard classes, \pkg{KOMA-script},
% 	\pkg{memoir}, and \pkg{titlesec} package should work, as well as \pkg{fancyhdr} and \pkg{caption}).
% 	However, since the definition of these strings is not standardized, the redefinitions might not work
% 	and even interfere badly if you use specific classes or packages that redefine the respective strings
% 	themselves. In this case, you can disable some or all changes.
% 	The possibilities are:
% 	\begin{itemize}
% 		\item ¦all¦: Redefine figure and table captions, part and chapter headings, and running headers (=~default setting)
% 		\item ¦captions¦: Redefine figure and table captions only
% 		\item ¦headings¦: Redefine part and chapter headings only
% 		\item ¦headers¦: Redefine running headers only
% 		\item ¦hheaders¦: Redefine part and chapter headings as well as running headers
% 		\item ¦none¦: Do not redefine anything
% 	\end{itemize}
% \end{itemize}
% ^^A
% \paragraph*{Commands:}
% \begin{itemize}
% 	\item \Cmd\uyghurordinal: outputs Uyghur ordinals. Supported input: integer numbers in the range of 1--100.
% 	\item \Cmd\uyghurord: same as \cmd\uyghurordinal\ but with counter as input (\eg ¦\textuyghur{\uyghurord{page}}¦).
% \end{itemize}
% 
% \subsection{welsh}\label{welsh}
% \paragraph*{Options:}
% 	\begin{itemize}
% 	\item \xpgchoicekey{date}{\xpgvalue{long} or \xpgpresetvalue{short}}
% 	\end{itemize}
% 
% 
% \section{Modifying or extending captions, date formats and language settings}
% 
% \pkg{Polyglossia} uses the following macros to define language-specific captions
% (\ie strings such as ``chapter''), date formats and additional language settings
% (\meta{lang} is to be replaces with the respective language name):
% 
% \begin{itemize}
% 	\item \Cmd{\captions\meta{lang}} stores definitions of caption strings
% 	           (such as, in the case of English, ¦\def\chaptername{Chapter}¦)
% 	\item \Cmd{\date\meta{lang}} stores definitions of date formats (usually redefinitions
% 	           of \cmd\today, in some cases also definitions of additional date commands)
% 	\item \Cmd{\blockextras@\meta{lang}} stores macros that are to be executed when the language
%               \meta{lang} is activated via \cmd\selectlanguage\ command or the \meta{lang} environment
% 	\item \Cmd{\inlineextras@\meta{lang}} stores macros that are to be executed when the language
% 	          \meta{lang} is activated locally via \cmd\text\meta{lang} command
% 	\item \Cmd{\noextras@\meta{lang}} stores macros that are to be executed when the language
% 	          \meta{lang} is closed
% \end{itemize}
% ^^A
% In order to redefine internal macros, we recommend to use the command \cmd\gappto.
% For compatibility with \pkg{babel} the command \cmd\addto\ is also available
% to the same effect. For instance, to change the \cmd\chaptername\ for language ¦lingua¦,
% you can do this:
% \begin{verbatim}
% \gappto\captionslingua{\def\chaptername{Caput}}
% \end{verbatim}
% ^^A
% Note that this needs to be done after the respective language has been loaded with
% \cmd\setmainlanguage\ or \cmd\setotherlanguage.
% 
% Specifically for package authors, analogous commands are provided which are only executed
% if a specific language \emph{variety} is used. As opposed to the macros above, these refer
% to babel names. Other than that, the function is identical:
% 
% \begin{itemize}
% 	\item \Cmd{\captions@bbl@\meta{babelname}}
% 	\item \Cmd{\date@bbl@\meta{babelname}}
% 	\item \Cmd{\blockextras@bbl@\meta{babelname}}
% 	\item \Cmd{\inlineextras@bbl@\meta{babelname}}
% 	\item \Cmd{\noextras@bbl@\meta{babelname}}
% \end{itemize}
% ^^A
% By default, these macros are undefined. If they are defined (\eg by an external package),
% they will be executed after their respective \meta{lang} counterpart and thus can be used to
% overwrite definitions of the former. Again, use \cmd\gappto\ to define\slash modify these macros.
% For instance, to add a new caption \cmd\footnotename\ to the Swiss variety of German (babel name
% ¦nswissgerman¦), you can do this:
% \begin{verbatim}
% \gappto\captions@bbl@nswissgerman{\def\footnotename{Fussnote}}
% \end{verbatim}
% ^^A
% If you do this in a document preamble rather than in a package, you need to embrace the redefinition
% by \cmd\makeatletter\ and \cmd\makeatother\ due to the ¦@¦ in the macro names.
% 
% Finally, as soon as the language has been switched (either inline or as a block), \pkg{polyglossia}
% executes the (by default empty) hook
% \begin{itemize}
% 	\item \cmd{\polyglossia@language@switched}\DescribeMacroCust{\scriptsize}{\polyglossia@language@switched}
% \end{itemize}
% to which you can append arbitrary code (via \cmd\gappto) that should be executed if (a particular)
% language is being activated. This is done before any of the above
% macros are issued (so you can still alter them), but at a point where \cmd\languagename, \cmd\babelname\
% and \cmd\languageid\ are already set, so you can condition on specific languages in your code.
% This hook is particularly provided for package authors.
% 
% \section{Script-specific numbering}
% 
% Languages and scripts have specific numbering conventions. Some use decimal digits
% (\eg Arabic numerals), some use alphabetic or alphanumerical notation (\eg Roman numbering).
% In some cases, different conventions are available (\eg Mashriq or Maghrib numbering
% in Arabic script, Arabic or Hebrew [=~alphanumeric] numbering in Hebrew).
% 
% If the latter is the case, \pkg{polyglossia} provides language options which allow you to select
% or switch to the suitable convention. With the appropriate language option set, \pkg{polyglossia}
% will automatically convert the output of internal \LaTeX\ counters to their
% localized forms, for instance to display page, chapter and section numbers.
% 
% For manual input of numbers, macros are provided. These convert Arabic numeric input to the respective
% local decimal digit (see sec.~\ref{sec:decdigit}), alphanumeric representation (see sec.~\ref{abjad})
% or whatever is appropriate (see sec.~\ref{sec:localnumber}). The possibilities are described in turn.
% 
% \subsection{General localization of numbering}\label{sec:localnumber}
% 
% As of 1.45,\new{1.45} \pkg{polyglossia} provides a generic macro \Cmd\localnumeral\ which converts numbers
% to the current local form (which might be script-specific decimal digit, an alphabetic numbering or something else).
% For instance in an Arabic environment
% ¦\localnumeral{42}¦ yields \textarabic{\localnumeral{42}}, whereas in an Hebrew environment, it
% results in \texthebrew[numerals=hebrew]{\localnumeral{42}} with ¦numerals=hebrew¦, and \texthebrew{\localnumeral{42}}
% with ¦numerals=arabic¦. Note that, as opposed to the various ¦digits¦ macros (described in sec.~\ref{sec:decdigit}),
% the argument of \cmd\localnumeral\ must consist of numbers only.
% 
% For\new{1.45} the conversion of counters, the starred version \Cmd{\localnumeral*} is provided. This takes a counter as argument.
% For instance in an Arabic environment ¦\localnumeral*{page}¦ yields \textarabic{\localnumeral*{page}}.
% 
% For scripts with alphanumeric numbering, the variants \Cmd{\Localnumeral} and \Cmd{\Localnumeral*} provide the uppercased
% versions.\medskip
% 
% \noindent All these macros provide the following options:
% 
% \begin{itemize}
% 	\item \DescribeMacro{[lang=]}\xpgchoicekey{lang}{\xpgpresetvalue{local}, \xpgvalue{main},
% 	or \xpgvalue{\meta{language}}}
% 		Output number in the local form of the currently active language for
% 		¦local¦, the main language of the document for ¦main¦, and any (loaded)
% 		language for \meta{language} (\eg ¦\localnumeral[lang=arabic]{42}}¦).
% \end{itemize}
% 
% \subsection{Non-Western decimal digits}\label{sec:decdigit}
% 
% In addition\new{1.1.1} to the generic macros described above, \pkg{polyglossia} provides language-specific conversion macros
% which can be used if the generic ones do not suit the need.\footnote{%
% A third method are so-called TECKit fontmappings.
% Those can be activated with the \pkg{fontspec} ¦Mapping¦ option,
% using ¦arabicdigits¦, ¦farsidigits¦ or ¦thaidigits¦.
% For instance if \cmd\arabicfont\ is defined with the option ¦Mapping=arabicdigits¦,
% typing \cmd{\textarabic\{2010\}} results in \textarabic{٢٠١٠}. Note that this method has some drawbacks, though,
% for instance when the value of a counter has to be written and read from auxiliary files.
% So please use this with care.}
% The macros have the form \cmd{\⟨script⟩digits}. They convert Arabic numerical input and leave every other input untouched.
% In an Arabic context, for instance, ¦\arabicdigits{9182/738543-X}¦ yields \textarabic{\arabicdigits{9182/738543-X}}.
% 
% Currently, the following macros are provided:
% 
% \begin{itemize}
% 	\item \Cmd\arabicdigits
% 	\item \Cmd\bengalidigits
% 	\item \Cmd\devanagaridigits
% 	\item \Cmd\farsidigits
% 	\item \Cmd\gurmukhidigits
% 	\item \Cmd\kannadadigits
% 	\item \Cmd\khmerdigits
% 	\item \Cmd\laodigits
% 	\item \Cmd\nkodigits
% 	\item \Cmd\thaidigits
% 	\item \Cmd\tibetandigits
% \end{itemize}
% 
% 
% \subsection{Non-Latin alphabetic numbering}\label{abjad}
% 
% For languages which use special (non-Latin) alphanumerical notation\footnote{%
% 	For instance, see \url{http://en.wikipedia.org/wiki/Greek_numerals},
% 	\url{http://en.wikipedia.org/wiki/Abjad_numerals},
% 	\url{http://en.wikipedia.org/wiki/Hebrew_numerals},
% 	and \url{http://en.wikipedia.org/wiki/Syriac_alphabet}.}, dedicated macros are provided.
% 
% They work in a similar way than the \cmd{\⟨script⟩digits} macros described above: They take Arabic numerical input
% and output the respective value in the local alphabetic numbering scheme (most of these macros are equivalent
% to \cmd\localnumeral\ and \cmd\Localnumeral\ in the respective context).
% 
% The following macros are provided:
% 
% \begin{itemize}
%     \item \Cmd\abjad outputs Arabic \textit{abjad} numbers according to the Mashriq varieties.
% 			Example: ¦\abjad{1863}¦ yields \textarabic{\abjad{1863}}.
% 			
% 	\item \Cmd\abjadmaghribi outputs Arabic \textit{abjad} numbers according to the Maghrib varieties.
% 			Example: ¦\abjadmaghribi{1863}¦ yields \textarabic{\abjadmaghribi{1863}}.
% 			
% 	\item \Cmd\abjadsyriac outputs Syriac abjad numerals.\footnote{%
% 				A fine guide to numerals in Syriac can be found at \link{http://www.garzo.co.uk/documents/syriac-numerals.pdf}.}\\
% 			Example: ¦\abjadsyriac{463}¦ yields \textsyriac{\abjadsyriac{463}}.
% 	
% 	\item \Cmd\armeniannumeral produces Armenian alphabetic numbering.
% 	          Example: ¦\armeniannumeral{1863}¦ yields \textarmenian{\armeniannumeral{1863}}.
% 	          
% 	\item \Cmd\belarusiannumeral produces Belarusian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Belarusiannumeral.
% 	          Depending on the ¦numerals¦ option in the Belarusian language selection, this is either Arabic digit or Cyrillic
% 	          alphanumercial output.\\
% 	          Example: With ¦numerals=latin¦ ¦\belarusiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
% 	          with ¦numerals=cyrillic-trad¦ ¦\belarusiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
% 	          with ¦numerals=cyrillic-alph¦ ¦\belarusiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
% 
% 	\item \Cmd\chinesenumeral produces Chinese numbering which, depending on the ¦numerals¦ option in the Chinese language selection,
% 			  produces is either Arabic digit or Chinese ideographic output.\\
% 	          Example: With ¦numerals=arabic¦ ¦\chinesenumeral{753}¦ yields \textchinese[numerals=arabic]{\chinesenumeral{753}},
% 	          with ¦numerals=chinese¦ ¦\chinesenumeral{753}¦ results in \textchinese[numerals=chinese]{\chinesenumeral{753}}.
% 
% 	\item \Cmd\georgiannumeral produces Georgian alphabetic numbering.\\
%               Example: ¦\georgiannumeral{1863}¦ yields \textgeorgian{\georgiannumeral{1863}}.
% 
% 	\item \Cmd\greeknumeral produces Greek alphabetic numbering, \Cmd\Greeknumeral outputs uppercased variants.
% 			Example: ¦\greeknumeral{1863}¦ yields \textgreek{\greeknumeral{1863}},
% 			¦\Greeknumeral{1863}¦ results in \textgreek{\Greeknumeral{1863}}.
% 
% 	\item \Cmd\hebrewnumeral, \Cmd\Hebrewnumeral and \Cmd\Hebrewnumeralfinal produce variants of Hebrew alphanumeric numerals.
% 			The commands behave identical as in \pkg{babel}: \cmd\hebrewnumeral\ outputs the numbers without any decoration at all,
% 			\cmd\Hebrewnumeral\ adds \textit{gereshayim} before the last letter, and \cmd\Hebrewnumeralfinal\ uses in addition the final
% 			forms of Hebrew letters.
% 			Examples:
% 			¦\hebrewnumeral{1750}¦ yields \texthebrew{\hebrewnumeral{1750}},
% 			¦\Hebrewnumeral{1750}¦ yields \texthebrew{\Hebrewnumeral{1750}},
% 			and ¦\Hebrewnumeralfinal{1750}¦ yields \texthebrew{\Hebrewnumeralfinal{1750}}.
% 			
% 	\item \Cmd\mongoliannumeral produces Mongolian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Mongoliannumeral.
%             Depending on the ¦numerals¦ option in the Mongolian language selection, this is either Arabic digit or Cyrillic
%             alphanumercial output.\\
%             Example: With ¦numerals=latin¦ ¦\mongoliannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
%             with ¦numerals=cyrillic-trad¦ ¦\mongoliannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
%             with ¦numerals=cyrillic-alph¦ ¦\mongoliannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
%     
%     \item \Cmd\punjabinumeral produces Punjabi numbering, depending on the setting of the ¦numerals¦ option in the Punjabi language
%            selection, this is either Gurmukhi or Arabic (Western).
% 	
% 	\item \Cmd\russiannumeral produces Russian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Russiannumeral.
% 	        Depending on the ¦numerals¦ option in the Russian language selection, this is either Arabic digit or Cyrillic
% 	        alphanumercial output.\\
% 	        Example: With ¦numerals=latin¦ ¦\russiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
% 	        with ¦numerals=cyrillic-trad¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
% 	        with ¦numerals=cyrillic-alph¦ ¦\russiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
% 			
% 	\item \Cmd\serbiannumeral produces Serbian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Serbiannumeral.
% 		    Depending on the ¦numerals¦ option in the Serbian language selection, this is either Arabic digit or Cyrillic
% 		    alphanumercial output.\\
% 		    Example: With ¦numerals=latin¦ ¦\serbiannumeral{19}¦ yields \textrussian{\serbiannumeral{19}},
% 			with ¦numerals=cyrillic-trad¦ ¦\serbiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\serbiannumeral{19}},\\
% 			with ¦numerals=cyrillic-alph¦ ¦\serbiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\serbiannumeral{19}}.
% 			
% 	\item \Cmd\ukrainiannumeral produces Ukrainian numbering, with uppercased variant (for alphanumerical variant) via \Cmd\Ukrainiannumeral.
% 			Depending on the ¦numerals¦ option in the Ukrainian language selection, this is either Arabic digit or Cyrillic
% 			alphanumercial output.\\
% 			Example: With ¦numerals=latin¦ ¦\ukrainiannumeral{19}¦ yields \textrussian{\russiannumeral{19}},
% 			with ¦numerals=cyrillic-trad¦ ¦\ukrainiannumeral{19}¦ results in \textrussian[numerals=cyrillic-trad]{\russiannumeral{19}},\\
% 			with ¦numerals=cyrillic-alph¦ ¦\ukrainiannumeral{19}¦ results in \textrussian[numerals=cyrillic-alph]{\russiannumeral{19}}.
% \end{itemize}
% 
% 
% \section{Footnotes in right-to-left context}
% 
% With languages that use right-to-left scripts, footnote apparatuses are usually placed at the right side of the page bottom.
% Consequently, the footnote rule also is to be placed right. Things get more tricky, though, if right-to-left and left-to-right
% scripts are mixed. Then you might want to put the footnotes on some pages left, on some right, or even mix positions on a page.
% Thus, footnote handling in right-to-left context sometimes needs manual intervention. This is described in what follows.
% 
% \subsection{Horizontal footnote position}
% 
% When right-to-left languages are used, the \cmd\footnote\ command becomes sensitive to the text directionality. The footnote is
% always placed on the side that is currently the origin of direction: on the left side of the page in LTR paragraphs and
% on the right in RTL paragraphs.
% 
% For cases where this is not desired, two additional footnote commands are provided: \Cmd\RTLfootnote and \Cmd\LTRfootnote.
% \cmd\LTRfootnote\ always places the footnote on the left side, notwithstanding the current
% directionality. Likewise, \cmd\RTLfootnote\ always places it on the right side. Like \cmd\footnote, \cmd\RTLfootnote\
% and \cmd\LTRfootnote\ provide an optional argument to customize the number.
% 
% 
% \subsection{Footnote rule length and position}
% 
% The default placement of the footnote rule differs in \XeTeX\ and \LuaTeX\ output (this is due to differences in the \textsf{bidi}
% and \textsf{luabidi} packages). With \XeTeX, footnote rules are always placed left, which is often wrong in RTL context.
% With \LuaTeX, by contrast, the rule is placed always right if the main language is a right-to-left language, and always left
% if the main language is a left-to-right language, which is the right thing in many cases.
% 
% In both cases, you can change the default behavior as follows:
% \begin{itemize}
% 	\item Put \Cmd\leftfootnoterule in the preamble to have all rules left-aligned.
% 	\item Put \Cmd\rightfootnoterule in the preamble to have all rules right-aligned.
% 	\item Put \Cmd\autofootnoterule in the preamble to have automatic placement depending on the context (see below for elaboration).
% 	\item Put \Cmd\textwidthfootnoterule in the preamble to have a rule that spans the whole text width.
% \end{itemize}
% With \cmd\autofootnoterule, the first footnote on the current page determines the placement. Note that this automatic can fail with
% footnotes at page boundaries that differ in directionality from the first footnote on the page. You can work around such cases by switching to \cmd\rightfootnoterule\ or \cmd\leftfootnoterule\ on these pages.
% 
% Note also that the rule switches might interfere in bad ways with packages or classes that redefine footnotes themselves. This is also the reason
% why \cmd\autofootnoterule\ is not used by default.
% 
% 
% \section{Calendars}
% 
% \subsection{Hebrew calendar (hebrewcal.sty)}
% The package \file{hebrewcal.sty} is almost a verbatim copy of \file{hebcal.sty}
% that comes with \pkg{babel}.
% The command \Cmd\Hebrewtoday\ formats the current date in the Hebrew calendar
% (depending of the current writing direction this will automatically set either
% in Hebrew script or in roman transliteration).
% 
% \subsection{Islamic calendar (hijrical.sty)}\label{sec:hijrical}
% This package computes dates in the lunar Islamic (Hijra) calendar.\footnote{ %
% 	It makes use of the arithmetical algorithm in chapter 6 of
% 	Reingold \& Gershowitz, \textit{Calendrical calculation: the Millenium edition}
% 	(Cambridge University Press, 2001).\label{reingold}}
% It provides two macros for the end-user.
% The command
% 	\displaycmd{\HijriFromGregorian\marg{year}\marg{month}\marg{day}}{\HijriFromGregorian}
% sets the counters ¦Hijriday¦, ¦Hijrimonth¦ and ¦Hijriyear¦.
% \Cmd\Hijritoday\ formats the Hijri date for the current day.
% This command is now locale-aware\new{1.1.1}: its output will differ depending on the
% currently active language. Presently \pkg{polyglossia}’s language definition files
% for Arabic, Farsi, Urdu, Turkish and Malay provide a localized version of \cmd\Hijritoday.
% If the formatting macro for the current language is undefined, the Hijri date will be formatted
% in Arabic or in roman transliteration, depending of the current writing direction.
% You can define a new format or redefine one with the command
%   \displaycmd{\DefineHijriDateFormat\marg{lang}\marg{code}.}{\DefineHijriDateFormat}
% 
% The command \cmd\Hijritoday\ also accepts an optional argument to add or subtract a correction
% (in days) to the date computed by the arithmetical algorithm.\footnote{ %
% 	The Islamic calendar is indeed a purely lunar calendar based on the observation
% 	of the first visibility of the lunar crescent at the beginning of the lunar month,
% 	so there can be differences between different localities, as well as between
% 	civil and religious authorities.}
% For instance if \cmd\Hijritoday\ yields the date “7 Rajab 1429” (which is the date that was
% displayed on the front page of \href{http://www.aljazeera.net}{aljazeera.net} on
% 11th July 2008), ¦\Hijritoday[1]¦ would rather print “8 Rajab 1429” (the date
% indicated the same day on the site \href{http://www.gulfnews.com}{gulfnews.com}).
% 
% \subsection{Farsi (jalālī) calendar (farsical.sty)}
% This package is an almost verbatim copy of ¦Arabiftoday.sty¦ (in the \pkg{Arabi} package),
% itself a slight modification of ¦ftoday.sty¦ in Farsi\TeX.\footnote{ %
% 	One day we may rewrite \pkg{farsical} from scratch using the algorithm in
% 	Reingold \& Gershowitz (ref.~n.\,\ref{reingold}).}
% Here we have renamed the command \cmd\ftoday\ to
% \Cmd\Jalalitoday.
% Example: today is \Jalalitoday.
% 
% 
% \section{Auxiliary commands}
% 
% The macro\new{1.47} \displaycmd{\charifavailable\marg{char code}\marg{substitution}}{\charifavailable} checks whether
% the character with the specified \meta{char code} (\ie unicode utf-16 code without preceding ¦0x¦) exists in
% the current font. If so, the character is printed, if not, the \meta{substitution} is printed.
% 
% Example: ¦\charifavailable{1E9E}{SS}¦ prints the capital version of the German letter ⟨ß⟩ if available
% (\ie \charifavailable{1E9E}{SS}), else it prints the substitution digraph SS.
% 
% 
% \section{Accessing language information}\label{sec:langinfo}
% 
% The following is specifically relevant to package authors who need information about the languages in use
% and the details of the respective locale.
% In order to get such information, the recommended way is to use the \Cmd{\BCPdata\marg{type}}\new{1.61}
% command to get (parts of) the BCP-47 language tag. This command is used by the \LaTeX\ kernel as of 6/2023,
% and the syntax is standardized at least between \pkg{babel} and \pkg{polyglossia}.
% 
% \cmd\BCPdata\ supports the following \marg{type} arguments:
% \begin{itemize}
% 	\item \xpgoption{language} The language subtag (\eg \texttt{de})
% 	\item \xpgoption{region} The region subtag (\eg \texttt{AT})
% 	\item \xpgoption{script} The script subtag (\eg \texttt{Latn})
% 	\item \xpgoption{variant} The variant subtag (\eg \texttt{1901} for German old spelling)
% 	\item \xpgoption{extension.t} The subtag indicating transformation between languages or scripts
% 	      (\eg \texttt{ja} as in \texttt{en-t-ja}: English transformed to Japanese)
% 	\item \xpgoption{extension.u} The subtag indicating additional locale information (\eg \texttt{nu-latn} as in \texttt{ar-u-nu-latn}:
% 	      Arabic with Latin Numbering)
% 	\item \xpgoption{extension.x} The private usespace subtag (\eg \texttt{classic} as in \texttt{la-x-classic} for classic Latin)
% 	\item \xpgoption{casing} is a special semantic value which returns whatever is considered suitable
% 	           for casing commands such as \cmd\MakeUppercase. In many cases, this is identical to \texttt{language} but
% 	           it could also be something more specific such as \texttt{el-x-iota} or \texttt{ckb-Latn} if this is
% 	           needed for proper casing. Note that this information is retrieved by the \LaTeX\ kernel for casing as
% 	           of 06/2023.
% 	\item \xpgoption{tag} returns the registered full tag (identical to \cmd\languageid\ below). This however omits
% 	       certain subtags if these are considered obvious (\eg for German, only \texttt{de-DE} is returned, although
% 	       script [\texttt{Latn}] and variant [\texttt{1996}] are defined as well).
% \end{itemize}
% If a subtag is not defined for a given language, an empty string is returned.
% 
% The values above return information for the language currently in use. If you need to access information for the 
% main language of the document, prepend \xpgoption{main.} to the respective argument (\eg \xpgoption{main.language}). This works
% for all supported arguments.
% 
% Next to \cmd\BCPdata, \pkg{polyglossia} provides the following legacy macros which are partly unique to \pkg{polyglossia},
% partly re-implementations of legacy \pkg{babel} commands:
% 
% \begin{itemize}
% 	\item \Cmd\languagename\ stores the currently active (polyglossia) language name.
% 	\item \Cmd\mainlanguagename\ stores the (polyglossia) language name of the main document language.
% 	\item \Cmd\languagevariant\ stores the language variant if set. The macro is empty if no variant has been set.
% 	\item \Cmd\mainlanguagevariant\ stores the language variant of the main document language if set.
% 	       The macro is empty if no variant has been set.
% 	\item \Cmd\babelname\ stores the corresponding name of the currently active language (variant) in \pkg{babel}.
% 	      This might not only be useful if you want to support both \pkg{babel} and \pkg{polyglossia}, but also
% 	      since this name is unique for a given language variety (\eg ngerman, german, swissgerman etc.).
% 	      Note that this macro is also defined for languages that are not supported in \pkg{babel}. In that
% 	      case, they are equal to the polyglossia language name.
% 	\item \Cmd\mainbabelname\ analogously stores the name of document's main language (variant) in \pkg{babel}.
% 	\item \Cmd{\languageid\marg{type}}\new{1.47} stores the identifier tag of the current language. Currently supported \meta{types}:
% 	      \begin{itemize}
% 	      	\item ¦bcp-47¦ (alias ¦bcp47¦): IETF BCP-47 language identifier
% 	      \end{itemize}
% 	 \item \Cmd{\mainlanguageid\marg{type}}\new{1.47} stores identifier tag of the main language. Currently supported \meta{types}:
% 	      see \cmd\languageid.
% \end{itemize}
% \bigskip
% 
% \noindent If you want to have a full list of loaded languages/variants, use the following macros:
% \begin{itemize}
% 	\item \Cmd{\xpg@loaded}\ stores a comma-separated list of all loaded languages (polyglossia name)
% 	\item \Cmd{\xpg@vloaded}\ stores a comma-separated list of all loaded variants
% 	\item \Cmd{\xpg@bloaded}\ stores a comma-separated list of \pkg{babel} names of all language variants
% 	\item \Cmd{\xpg@bcp@loaded}\new{1.47}\ stores a comma-separated list of the BCP-47 IDs of all language variants
% \end{itemize}
% \bigskip
% 
% \noindent Whether a language is loaded can be tested by
% \displaycmd{\iflanguageloaded\marg{lang}\marg{true}\marg{false}}{\iflanguageloaded}
% where \texttt{\meta{lang}} is a \pkg{polyglossia} language name, by
% \displaycmd{\ifbabellanguageloaded\marg{lang}\marg{true}\marg{false}}{\ifbabellanguageloaded}
% where \texttt{\meta{lang}} is a \pkg{babel} language name (see table~\ref{tab:bbllang} on p.~\pageref{tab:bbllang}), or by\new{1.47}
% \displaycmd{\iflanguageidloaded\marg{type}\marg{id}\marg{true}\marg{false}}{\iflanguageidloaded}
% where \meta{type} is a supported language id type (such as ¦bcp-47¦) and \meta{id} is a language id
% (such as ¦en-US¦; see table~\ref{tab:BCP47-polyglossia} on p.~\pageref{tab:BCP47-polyglossia}).
% \bigskip
% 
% \noindent Finally, if you want to know whether a specific language option has been set, you can use\new{1.47}
% \displaycmd{\iflanguageoption\marg{lang}\marg{key}\marg{value}\marg{true}\marg{false}}{\iflanguageoption}
% 
% \section{Revision history}
% 
% \bgroup\footnotesize
% \subsection*{1.64 (2023/07/21)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Fix conflict of \pkg{soul} with \xpgoption{splithyphens} on \XeLaTeX\ (\TXI{600}).
% \end{itemize}
% 
% \subsection*{1.63 (2023/06/10)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Language options are now lowercased before they are handled. This fixes errors when
% 	      using the options in \cmd{\MakeUppercase} context (\eg in headings).
% 	\item Fix casing value for medieval Latin (this concerns ⟨u⟩ and ⟨V⟩ casing).
% 	\item Remove hacks in some gloss files where \cmd\MakeUppercase\ has been redefined to a no-op
% 		since the respective scripts do not have uppercasing. As \cmd\MakeUppercase\ is now locale-aware,
% 		these hacks are no longer needed. This concerns Arabic, Divehi, Hebrew, Hindi, Kurdish,
% 		Persian, Punjabi, Syriac, and Urdu.
% 	\item Fix Eastern (Mashriq) Arabic numbering direction with \LuaLaTeX\ for Arabic, Kurdish, Persian,
% 		Syriac, and Urdu (amends previous fix to \TXI{213}).
% 	\item French \xpgoption{variant=acadian} refers to the Canadian French subvariety as spoken in the Acadian
% 	     region (as opposed to Quebec French). To differentiate it we now use a dedicated subtag
% 	     which can also be used to access the language (\texttt{fr-CA-u-sd-canb}).
% 	     Note that Quebec French is currently connected with \texttt{fr-CA}, not the more specific
% 	     \texttt{fr-CA-u-sd-caqc}, although the u extension is returned if requested via \cmd\BCPdata.
% 	     In practice, the Canadian subvarieties of French are identical currently, anyway.
% 	\item Do not blindly de-activate the quote character in languages that provide shorthands if the
% 	     shorthands are not used. This allows to activate the character with other packages such as
% 	     \pkg{csquotes} (\TXI{592}).
% 	\item Do not flood the \LaTeX\ hooks with redundant French itemlabels and footnote settings (\TXI{593}).
% 	\item Fix Korean patching of part format with hyperref (\TXP{595}).
% 	\item Make Hebrew numerals expandable (\TXP{596}).
% 	\item Avoid superfluous writing of language switches to aux file (\TXI{593}).
% \end{itemize}
% 
% \subsubsection*{New features}
% \begin{itemize}
% 	\item New option \xpgoption{capitalyiwn} for Armenian.
% 	\item New option \xpgoption{capitaleszett} for German.
% 	\item New option \xpgoption{capitaliota} for Greek.
% 	\item New option \xpgoption{datei} for Serbian.
% 	\item New option \xpgoption{sectionsep} for Arabic, Kurdish, Persian,
% 		  Syriac, and Urdu (\TXI{589}).
% 	\item Add aliases \xpgvalue{eastern} (=~\xpgvalue{mashriq}) and \xpgvalue{western} (=~\xpgvalue{maghrib})
% 	      to Arabic \xpgoption{numerals}.
% 	\item New date commands \cmd{\today*}, \cmd{\todayGen}, \cmd{\todayArabic}, and \cmd{\todayRoman} (all with
% 	      starred counterparts) for Serbian (\TXI{524}).
% 	\item Implement basic support for \xpgoption{variant=ijekavian} in Serbian.
% 	\item Dutch now hyphenates properly on letters with tremata. The new option, \xpgoption{tremahyphenation},
% 		  is provided to opt-out this feature.
% 	\item Add shorthands ¦"a¦, ¦"e¦, ¦"i¦, ¦"o¦, ¦"u¦, ¦"A¦, ¦"E¦, ¦"I¦, ¦"O¦, ¦"U¦, ¦"y¦, and ¦"Y¦ to Dutch.
% \end{itemize}
% 
% \subsubsection*{Interface changes}
% \begin{itemize}
% 	\item All language options are now lowercase by default (though the mechanism is case-insensitive anyway).
% 		  Changes cover Kurdish, Sanskrit, Serbian.
% \end{itemize}
% 
% \subsection*{1.62 (2023/04/22)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item \cmd\BCPdata\ was not fully expandable as required. Now it is.
% \end{itemize}
% 
% \subsection*{1.61 (2023/04/16)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Properly reset fonts on change to Latin-script other language (\TXI{580})
% 	\item Turn ¦^¦ shorthand off in aux file for Latin (\TXI{582})
% 	\item Fix stacking of nested languages and resulting bug in TOC language assignment (\TXI{585})
% 	\item Fix ¦\greeknumeral{6}¦ (\TXI{587})
% 	\item Fix (re)setting of scripts in inline language commands.
% \end{itemize}
% 
% \subsubsection*{New features}
% \begin{itemize}
% 	\item Introduce \cmd\BCPdata, a standardized way to gather localization information
% 	(see sec.~\ref{sec:langinfo}).
% \end{itemize}
% 
% \subsection*{1.60 (2023/02/11)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Remove stray \texttt{U+FEFF} glyphs in gloss files (\TXI{574})
% 	\item Fix vertical whitespace in captions (\TXI{575})
% 	\item Fix whitespace in dutch with shorthands.
% \end{itemize}
% 
% \subsection*{1.59 (2022/11/29)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Do not error, but warn, after language change due to non-updated aux file (\TXI{565}).
% 	\item Fix catcode issue for Latin (\TXI{566}).
% 	\item Improve error message with missing fonts (\TXI{571})
% \end{itemize}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item Add support for (simplified and traditional) Chinese (\TXI{65}, provided by \TA{Takuji Tanaka}).
% \item Add support for Punjabi (\TXP{572}), provided by \TA{Arvinder Singh}.
% \end{itemize}
% 
% \subsection*{1.58 (2022/10/26)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
%     \item The option \xpgoption{forceheadingpunctuation} is introduced
%         for correct running headers in Hungarian documents (\TXI{557}).
% 	\item Fix language setting in list of figure and table if captions float to different
% 	      language areas (\TXI{542}).
% 	\item Make Croatian digraphs robust (\TXI{552}).
% 	\item Fix definition of some Finnish shorthands (\TXI{554}).
% 	\item Re-fix Hungarian patching of parts with hyperref (\TXI{555}).
% 	\item Correct running headers in Hungarian documents (\TXI{557}).
% 	\item Fix option expansion issue (\TXI{559}).
% \end{itemize}
% 
% \subsection*{1.57 (2022/07/18)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Fix passing of macros to \cmd\setmainlanguage\ and \cmd\setotherlanguage\ (\TXI{543}).
% 	\item Fix ¦otherlanguage*¦ environment with bidi text (\TXP{544}).
% 	\item Re-fix patching of French part headings with hyperref (\TXI{546}).
% 	\item Fix Latin prosodic shorthand issues (\TXI{547}, \href{https://github.com/latex3/babel/issues/126}{Babel/\#126},
% 	      \href{https://github.com/latex3/babel/issues/129}{Babel/\#129}).
% \end{itemize}
% 
% \subsubsection*{New features}
% \begin{itemize}
% 	\item New option \xpgoption{transliteration} to Hebrew and hebrewcal (\TXI{540}).
% 	\item New option \xpgoption{fullyear} to Hebrew.
% \end{itemize}
% 
% \subsection*{1.56 (2022/04/20)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Fix English setup via aliases (\TXI{539}).
% \end{itemize}
% 
% 
% \subsection*{1.55a (2022/04/10)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Fix \cmd\foreignlanguage\ command (\TXI{538}).
% \end{itemize}
% 
% \subsection*{1.55 (2022/04/09)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% 	\item New option \xpgoption{splithyphens} and \xpgoption{vlna} for Polish (\TXI{535}).
% 	\item Add \xpgoption{babelshorthands} to Polish.
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Add missing \texttt{gloss-latex.lde} file to release (\TXI{537}).
% \end{itemize}
% 
% \subsection*{1.54 (2022/03/27)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% 	\item New option \xpgoption{splithyphens} for Serbian (\TXI{496}) and Portuguese (\TXI{534}).
% 	\item Add \xpgoption{babelshorthands} to Portuguese.
% 	\item Add \xpgoption{schoolhyphens} option to Finnish (\TXI{525}).
% \end{itemize}
% 
% \subsubsection*{Interface and defaults changes}
% \begin{itemize}
% 	\item Rename \xpgoption{disableligatures} to \xpgoption{disabledigraphs} for Croatian (\TXI{497}, \TXP{500}).
% 	\item Fix output with \xpgoption{numerals=cyrillic-alph} (part of \TXI{503}).
% 	\item Standardize February and November in Indonesian according to the Great Dictionary of the Indonesian Language
% 	      of the Language Center (\emph{Kamus Besar Bahasa Indonesia}) (\TXP{526}).
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Fix robustification of font family switches (\TXI{428}).
% 	\item Preserve font family switches across languages (\TXI{519}).
% 	\item Fix \TeX\ dash ligatures with \xpgoption{splithyphens} (\TXI{502}).
% 	\item Prevent \emph{missing hyphenmins value} \LaTeX\ error with unknown languages (\TXI{513}).
% 	\item Fix global \xpgoption{babelshorthands}, \xpgoption{localmarks} and \xpgoption{verbose}
% 	      options (\TXI{515}).
% 	\item Fix Latin shorthands (\TXI{516}).
% 	\item Remove spurious space in Bosnian date (\TXP{528}).
% 	\item Fix \cmd\languagevariant\ and \cmd\mainlanguagevariant\ macros (\TXI{530}, \TXI{531}).
% 	\item Make \cmd\iflanguageloaded\ and friends work in preamble (\TXI{532}).
% 	\item Fix deactivation of shorthands (\TXI{320}).
% 	\item Fix deactivation of numerals.
% 	\item Update deprecated \LaTeX\ hooks (\TXI{523}).
% 	\item Fix \xpgoption{luatexrenderer} option which was not considered appropriately (\TXI{533}).
% 	\item Turn warning about \texttt{totalhyphenmin} to info, which is more appropriate (\TXI{111}).
% \end{itemize}
% 
% \subsubsection*{Documentation improvements}
% \begin{itemize}
% 	\item Document in this manual where to report bugs (\TXI{512}).
% \end{itemize}
% 
% 
% \subsection*{1.53 (2021/04/12)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% 	\item New option \xpgoption{localalph} for Croatian (\TXI{486}).
% 	\item Use ordinals in part and chapter headings. A new option \xpgoption{chapterformat} has been
% 	      added to disable this or change format to Roman numbering (\TXI{479}).
% 	\item New command \cmd\uyghurordinal\ and \cmd\uyghurord\ to produce Uyghur ordinals from 1--100.
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% 	\item Fix typo in Uyghur language definition file (\TXI{479}).
% 	\item Fix Uyghur date format (\TXI{479}).
% 	\item Fix Uyghur caption format and add \xpgoption{swapstrings} option (\TXI{479}).
% 	\item Add overlooked digraphs in Croatian (\TXP{484}).
% 	\item Fix typo in Serbian ¦\thepart¦ (\TXP{485}).
% 	\item Fix part modifications in Hungarian with \pkg{hyperref} (\TXI{493}).
% \end{itemize}
% 
% \subsection*{1.52 (2021/03/16)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item Adaptations to \LaTeX\ 2021/05/01 pre-release 2 for Korean (\TXI{477}).
% \item Add support for Uyghur (\TXI{475}).
% \item New option \xpgoption{mathfunctions} for Russian and Ukrainian allows to disable the definitions
%       of math macros that might clash with other packages (\TXI{465}).
% \item Support LaTeX's new NFSS hooks (\TXI{471}).
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Fix French part modifications with \pkg{hyperref} (\TXI{469}).
% \item Fix markup of French ¦\see¦ and ¦\alsoname¦ (\TXI{468}).
% \end{itemize}
% 
% \subsection*{1.51 (2020/12/08)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item New option \xpgoption{frenchpart} for French (\TXI{458}).
% \item New option \xpgoption{splithyphens} for Croatian (\TXI{454}).
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Use new LaTeX core hooks rather than \pkg{filehook} package. This fixes
%       a recent breakage of \pkg{filehook} with other external packages (\TXI{453}).
% \item Remove very old code that pretends \pkg{polyglossia} is \pkg{babel} (\TXI{455}).
% \item Fix spelling of Albanian contentsname (\TXI{456}).
% \item Fix part heading modification in French (\TXI{458}).
% \item Fix extra space in Hebrew (\TXI{459}).
% \item Register main polyglossia language earlier (\TXI{461}).
% \item Allow for hyphenations in words following opening guillemet in French with XeTeX (\TXI{462}).
% \end{itemize}
% 
% 
% \subsection*{1.50a (2020/10/15)}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Assure ¦\autodot¦ is defined with ¦\KOMAScript¦ in Russian.
% \end{itemize}
% 
% \subsection*{1.50 (2020/10/09)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item Polyglossia now uses the Harfbuzz renderer by default with LuaTeX
%       output. This brings LuaTeX on par with XeTeX for all scripts (\TXI{337}).
%       The renderer can be changed via the new global \xpgoption{luatexrenderer} option.
% \item The (previously inadvertently working) ¦hyphenrules¦ environment that ceased
%       to work after a recent \pkg{babel} update is back and now officially supported.
%       The environment now also supports language options and aliases (\TXI{427}).
% \item New command ¦\setlanghyphenmins¦ to adapt hyphenation thresholds of languages
%       and varieties.
% \item New command ¦\abjadalph¦ for Arabic with corresponding option (\TXI{431}).
% \item Replace consecutive glues around punctuation by the correct amount of space
%       with lualatex for French, ecclesiastic Latin, and Sanskrit (\TXI{437}).
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Remove warning about missing Brazil patterns (\TXI{404}).
% \item Fix incompatibility with recent \pkg{babel} release (\TXI{408}).
% \item Fixed some spellings in Marathi (\TXI{409}).
% \item Fix spacing of geminating dot in Catalan (\TXI{410}).
% \item Fix incompatibility of Marathi with \pkg{beamer}.
% \item Correct ¦\partname¦ in Hindi (\TXI{416}).
% \item Updates and improvements to Kurdish (\TXI{418}).
% \item Only activate shorthand character if \xpgoption{babelshorthands} is \xpgvalue{true} (\TXI{421}). 
% \item Fix whitespace issue in Czech and Slovak with \xpgvalue{vlna=true} (\TXI{423}).
% \item Fix whitespace issue in Danish (\TXI{424}).
% \item Fix catcode conflicts that might occur in language definition files
%       f.\,ex.\ when loaded from a LaTeX3 class (\TXI{67}, \TXI{425}).
% \item Robustify font family switches (\TXI{428}).
% \item Fix whitespace issue in Russian \xpgoption{indentfirst} option (\TXI{433}).
% \item In Russian, \xpgoption{indentfirst} is now again default (\TXI{434}).
% \item Fix LaTeX error with arabic numbering in Ukrainian (\TXI{440}).
% \item Fix directionality after Hebrew decimal numbers (\TXI{441}).
% \item Fix ¦babelname¦ of Latin Serbian (\TXI{442}).
% \item Fix recording of secondary languages in ¦\xpg@bloaded¦ and ¦\xpg@bcp@loaded¦
%       lists (\TXI{443}).
% \item Simplify and robustify section heading modification in Russian
%       and introduce option \xpgoption{forceheadingpunctuation} (\TXI{444}).
% \item Fix Cyrillic dash (via babelshorthand ¦"---¦) when TeX ligatures
%       are disabled (\TXI{445}).
% \item Fix problem with large character indices in Lua module for punctuation
%       spacing
% \end{itemize}
% 
% \subsubsection*{Interface and defaults changes}
% \begin{itemize}
% \item Polyglossia now uses the Harfbuzz renderer by default with LuaTeX
%       output. See new features section.
% \end{itemize}
% 
% \subsubsection*{Build fixes}
% \begin{itemize}
% \item Fix an embarrassing bug in the dtx build script which was the reason for an utterly
%        incomplete ¦polyglossia.dtx¦ file (\TXI{420}).
% \end{itemize}
% 
% \subsubsection*{Documentation improvements}
% \begin{itemize}
% \item Document how to change ¦\lefthyphenmin¦ and ¦\righthyphenmin¦ for a language
%       (\TXI{435}).
% \end{itemize}
% 
% 
% \subsection*{1.49 (2020/04/08)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item Add hook ¦\polyglossia@language@switched¦ to the external package interface (\TXI{398}).
% \item Real fix for \TXI{400}, that wasn’t properly taken care of in 1.48.
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Fix compilation error with some \xpgoption{swapstring} options in Hungarian (\TXI{373}).
% \item Fix whitespace problem in Greek language.
% \end{itemize}
% 
% \subsubsection*{Interface and defaults changes}
% \begin{itemize}
% \item Changed Finnish caption for ``Table of Contents'' to ``Sisällys'' (\TXI{403}).
% \end{itemize}
% 
% 
% \subsection*{1.48 (2020/03/25)}
% 
% \begin{itemize}
% \item No new features
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Fix use of Hebrew with LuaLaTeX (\TXI{389}).
% \item Do not overwrite footnote redefinitions of other packages
%       with Latin and French (\TXI{391}).
% \item Fix Serbian cyrillic numerals code (\TXI{392}).
% \item Fix \xpgoption{[no]localmarks} option, whose logic was swapped (part of \TXI{395}).
% \item Protect \xpgoption{localmarks} function against uppercased language names (part of \TXI{395}).
% \item Fix buggy redefinition of ¦\@markright¦ with option localmarks (\TXI{396}).
% \item Fix incompatibility between Latin and unicode-math (\TXI{394}).
% \item Make (undocumented) ¦\defineshorthand¦ command (imported from babel) work.
% \item Fix usage of \xpgoption{localmarks} option without value.
% \item Emergency fixes for bugs caused by updates in \pkg{babel}’s ¦switch.def¦ (\TXI{399} and \TXI{400}).
% \end{itemize}
% 
% \subsubsection*{Interface and defaults changes}
% \begin{itemize}
% \item Use private macros in keyval choice keys (\TXI{390}).
% \end{itemize}
% 
% \subsection*{1.47 (2020/01/29)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item IETF BCP-47 compliant language tags can now be used for loading and switching
%       languages alternatively to language names (\TXI{226}).
% \item New commands ¦\languageid{<type>}¦ and ¦\mainlanguageid{<type>}¦.
% \item New test ¦\iflanguageidloaded¦.
% \item New list ¦\xpg@bcp@loaded¦.
% \item New environment ¦{lang}{<lang>}¦ (this is equivalent to ¦{<lang>}¦,  but also available with
%       ¦\setlanguagealias*¦ which does not define dedicated alias environments).
% \item New gloss option ¦totalhyphenmin¦ (corresponds to LuaTeX's ¦\hyphenationmin¦) (\TXI{111}).
% \item New test ¦\iflanguageoption{<lang>}{<key>}{<val>}¦ (\TXI{364}).
% \item Restore simple alphabetic numbering for ¦\asbuk¦ and ¦\Asbuk¦ in Belarusian, Mongolian,
%       Russian, Serbian, and Ukrainian (\TXI{377}).
% \item New command ¦\AsbukTrad¦ and ¦\asbukTrad¦ for Belarusian, Mongolian, Russian, Serbian,
%       and Ukrainian which uses traditional alphanumerical numbering.
% \item New numerals option ¦cyrillic-trad¦ and ¦cyrillic-alph¦ to differentiate simple
%       alphabetic and traditional alphanumerical Cyrillic numbering.
% \item ¦\selectbackgroundlanguage¦ and ¦\resetdefaultlanguage¦ now also support language
%       aliases.
% \item New macro ¦\charifavailable{<char code>}{<substitution>}¦.
% \item Add French language variant ¦swiss¦.
% \item Implement \xpgoption{babelshorthands} for Croatian.
% \item Implement ¦\localnumeral¦ for Japanese.
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Fix font family issue in headers (\TXI{355}).
% \item Fix whitespace issues in ¦\text<lang>¦ (\TXI{356}).
% \item Fix option-less ¦\babelname¦ in multi-variant languages (\TXI{357}).
% \item Fix some spacing inconsistencies with French, Latin, and Sanskrit (\TXI{358}).
% \item Fix issues with \xpgoption{babelshorthands} and \pkg{graphics} package (\TXI{368}).
% \item Fix some captions and improve numbering in Marathi (\TXI{370}).
% \item Fix Hungarian \xpgoption{swapstrings} feature (\TXI{373}).
% \item Fix lua punctuation code problem (\TXI{374}).
% \item Fix Bengali changecounternumbering option (\TXI{381}).
% \item Fix whitespace issue in Japanese (\TXI{387}).
% \item Fix ¦\text<lang>¦ command with multiple paragraphs.
% \item Actually implement documented german spelling variant ¦1996¦ (= ¦new¦).
% \item Fix Slovenian \xpgoption{localalph} option.
% \item Fix Czech and Slovak \xpgoption{splithyphens} with typewriter fonts.
% \item ¦farsical.sty¦: fix spacing issue with some month names.
% \item Fix directionalty of numbers in Hebrew with XeTeX.
% \item Improve interoperatability with \pkg{biblatex} (some language variants did not work yet).
% \end{itemize}
% 
% \subsubsection*{Interface and defaults changes}
% \begin{itemize}
% \item Some boolean options had ¦false¦ value by default, which meant if you passed
%       them without value, the logic was reversed. This has been changed, leading to
%       change of behavior should you have used one of these options without value (\TXI{363}).
%       Concerned are the following options:
%       \begin{itemize}
% 	   \item \xpgoption{babelshorthands} in language Belarusian, Mongolian, Ukrainian, and Russian
%              (now \xpgoption{babelshorthands} equals \xpgoption{babelshorthand=true}, no longer \xpgoption{babelshorthands=false}).
% 	   \item \xpgoption{localalph} in language Slovenian (\xpgoption{localalph} now equals \xpgoption{localalph=true}).
% 	   \item \xpgoption{fullyear} in package \pkg{hebrewcal} (\xpgoption{fullyear} now equals \xpgoption{fullyear=true}).
%       \end{itemize}
% \item The option \xpgoption{latesthyphen} in language German is deprecated. \XeTeX\ and \LuaTeX\ nowadays
%       always use the latest German hyphens.
% \item The command ¦\setlanguagealias*¦ (introduced in v1.46) does no longer define
%       dedicated alias environments.
% \item The babelnames for Latin variants are now changed to ¦classiclatin¦, ¦ecclesiasticlatin¦
%       and ¦medievallatin¦. This is how the hyphenation patterns and \pkg{babel} ¦\extras¦ are named, even
%       though the variants can currently be selected in \pkg{babel} only via appended ``dot modifier''.
% \item In accordance with the respective \pkg{l3kernel} change, ¦\str_lower_case:n¦  has been renamed to
%       ¦\str_lowercase:n¦ where used in ¦polyglossia.sty¦. Thus \pkg{polyglossia} 1.47 requires \pkg{l3kernel}
%       2020-01-12 at least.
% \end{itemize}
% 
% \subsection*{1.46 (2019/11/15)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item Add option \xpgoption{indentfirst} to Russian (\TXI{78}).
% \item Add options to set and customize French-style itemize item labels to French (\TXI{89}).
% \item \pkg{Polyglossia} now decodes all supported \pkg{babel} language names in ¦\setdefaultlanguage¦,
%       ¦\setotherlanguage¦ and the language switching commands (\TXI{112}, \TXI{132}).
% \item Add optional localized math operators to Spanish (\TXI{123}).
% \item Swap section headings in Hungarian (\TXI{344}). New option \xpgoption{swapstrings} provides control
%       over this.
% \item Introduce macro ¦\setlanguagealias¦ and ¦\setlanguagealias*¦.
% \item Introduce language switching command ¦\textlang{lang}{...}¦ (these are equivalent to ¦\text<lang>¦,
%       but also available with ¦\setlanguagealias*¦ which does not define ¦\text<alias>¦).
% \item Add support for Afrikaans.
% \item Add support for Belarusian.
% \item Add support for Bosnian.
% \item Add support for Georgian.
% \item Add Spanish variant ¦mexican¦.
% \item Add babelshorthands as well as options \xpgoption{splithyphens} and \xpgoption{vlna} to Slovak.
% \item Add Latin language variant ¦ecclesiastic¦.
% \item Add Latin language options ¦capitalizemonth¦, ¦ecclesiasticfootnotes¦, ¦hyphenation¦,
%       ¦prosodicshorthands¦, and ¦usej¦.
% \item Add Latin shorthands for «, », æ, Æ, œ, and Œ.
% \item Add French language option \xpgoption{thincolonspace}.
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Fix problems with fragile font settings (\TXI{24}).
% \item Fix clash of French punctuation spacing with the \pkg{soul} package (\TXI{52}).
% \item Re-enable the possibility to pass a macro as main argument to ¦\setmainlanguage¦ and
%       ¦\setotherlanguage¦ (\TXI{331}).
% \item Fix detection of default ¦\languagevariant¦ (\TXI{332}).
% \item Fix LaTeX error with undefined hyphenation pattern (\TXI{346}).
% \item Fix some babel shorthand issues by updating the shorthand code from recent \pkg{babel}.
% \item Fix some problems with French and Latin auto-spacing (\TXI{345}, \TXI{352}).
% \item Fix an \pkg{expl3} declaration (\TXI{348}).
% \end{itemize}
% 
% \subsubsection*{Interface and defaults changes}
% \begin{itemize}
% \item The sub-package ¦cyrillicnumbers.sty¦ has been renamed to
%       ¦xpg-cyrillicnumbers.sty¦ (per TeXLive request).
% \item In Russian, all paragraphs are now indented by default, as common in Russian typography.
%       The behavior can be opted out by \xpgoption{indentfirst=false}.
% \item In Czech, \xpgoption{splithyphens} and \xpgoption{lvna} are enabled by default.
%       Also, the option does now work as well with LuaTeX.
% \item Changed option name ¦fraktur¦ to ¦blackletter¦ in German (the former is still available
%       as an alias).
% \item In French, high punctuation characters and guillemets are spaced by half an interword
%       space now instead of a ¦\thinspace¦ (cf. \TXI{345}).
% \end{itemize}
% 
% \subsection*{1.45 (2019/10/27)}
% 
% \subsubsection*{New features}
% \begin{itemize}
% \item Introduce a framework for external packages to access language variants. This fixes,
%       among other things, long-standing problems in the interaction of \pkg{biblatex} and \pkg{polyglossia}.
% \item Add new macros ¦\languagevariant¦ and ¦\mainlanguagevariant¦ as well as ¦\babelname¦ and ¦\mainbabelname¦
%       for package authors to access language information.
% \item Add new test ¦\iflanguageloaded{<language>}{<true>}{<false>}¦ where <language>
%       can be a \pkg{polyglossia} or \pkg{babel} language name.
% \item Add new macros ¦\localnumeral,¦ ¦\localnumeral*,¦ ¦\Localnumeral¦ and
%       ¦\Localnumeral*¦ that convert Arabic digitals to the local number scheme.
% \item Add new macro ¦\pghyphenation¦ to add language-specific hyphenation exceptions (\TXI{18}).
% \item Add support form (Khalkha \& Cyrillic) Mongolian in line with \pkg{babel-mongolian} (\TXI{23}).
% \item Add option \xpgoption{splithyphens} and \xpgoption{vlna} to Czech (XeTeX only; for LuaTeX, use the package
%       \pkg{luavlna} to get these features) (\TXI{32}).
% \item Add support for Kurdish, both Kurmanji and Sorani (\TXI{277}).
% \item Implement proper Cyrillic (alphanumeric) numbering (\TXI{285}).
% \item Add new language ¦friulian¦.
%       This deprecates ¦friulan¦ (which is still supported for backwards compatibility).
% \item Add new language ¦malay¦ with variants ¦indonesian¦ and ¦malaysian¦.
%       This deprecates ¦bahasai¦ and ¦bahasam¦ (which are still supported for
%       backwards compatibility).
% \item Add new language ¦gaelic¦ with variants ¦irish¦ and ¦scottish¦.
%       This deprecates ¦irish¦ and ¦scottish¦ as own \pkg{polyglossia} languages (which
%       are still supported for backwards compatibility).
% \item Add new language ¦hungarian¦.
%       This deprecates ¦magyar¦ (which is still supported for backwards compatibility).
% \item Add new language ¦sorbian¦ with variants ¦lower¦ and ¦upper¦.
%       This deprecates ¦lsorbian¦ and ¦usorbian¦ (which are still supported for
%       backwards compatibility).
% \item Add new language ¦portuguese¦ with variants ¦portuguese¦ and ¦brazilian¦.
%       This deprecates ¦brazil¦ and ¦portuges¦ (which are still supported for
%       backwards compatibility).
% \item Add new language ¦norwegian¦ with variants ¦nynorsk¦ and ¦bokmal¦.
%       This deprecates ¦nynorsk¦ and ¦norsk¦ (which are still supported for
%       backwards compatibility).
% \item Add new language ¦persian¦.
%       This deprecates ¦farsi¦ (which is still supported for backwards compatibility).
% \item Add new language ¦sami¦. Currently only Northern Sami is supported.
%       This deprecates ¦samin¦ (which is still supported for backwards compatibility).
% \item ¦gloss-serbian¦: add \xpgoption{numerals=cyrillic} option. Add ¦\asbuk¦ and ¦\Asbuk¦ (\TXI{285}).
% \item Implement basic support for (French) ¦canadien¦ and (English) ¦canadian¦ (\TXI{22}).
% \item Improve support for Armenian (\TXI{79}): Add captions, Eastern month names
%       (accessible via variant=eastern) and Armenian alphabetic numbering
%       (via \xpgoption{numerals=armenian} and ¦\armenicnumeral¦).
% \item Add french option \xpgoption{autospacing} and commands ¦\AutoSpacing,¦ ¦\NoAutoSpacing¦
%       This allows to switch off autospacing globally or locally (\TXI{113}).
% \item Fixup ¦\normalfont¦ (\TXI{203}).
% \item Fix directionality issues in mixed RTL/LTR paragraphs (\TXI{204}).
% \item Implement \xpgoption{babelshorthands} for Finnish (\TXI{212}) and Czech.
% \item Implement access to current language via Lua (\TXI{243}).
% \item Introduce french option option \xpgoption{autospacetypewriter}
%       alias \xpgoption{OriginalTypewriter}.
% \item Support ¦\aemph¦ with lualatex
% \item Rename \xpgoption{automaticspacesaroundguillemets} to \xpgoption{autospaceguillemets} 
%       The old option is kept for backwards compatibility.
% \end{itemize}
% 
% \subsubsection*{Bug fixes}
% \begin{itemize}
% \item Fix equation number in Arabic and Farsi (\TXI{7}).
% \item Simplify and document Hebrew \xpgoption{marcheshvan} option (\TXI{16}).
% \item Fix hyphenation of Greek with LuaTeX (\TXI{55}).
% \item Fix N'ko date format (\TXI{63}).
% \item Disable the extras of a language when a nested language starts (\TXI{66}, \TXI{169}).
% \item Properly implement Bengali numbers (\TXI{69}, \TXI{184}).
% \item Fix conflicts with other packages caused by premature shorthand activation
%       in preamble (\TXI{81}, \TXI{200}).
% \item Fix kerning in math with French (\TXI{92}).
% \item Fix expansion issue in Hebrew (\TXI{93}).
% \item Fix numbering expansion issue in Greek (\TXI{110}).
% \item Postpone ¦\disablehyphenation¦ in preamble until after setting of
%       document language (\TXI{125}).
% \item Postpone the assignment of defaultfamily to ¦\AtBeginDocument¦,
%       thus do not overwrite ¦\familydefault¦ redefinitions in the preamble (\TXI{127}).
% \item Reset number settings when switching language (\TXI{133}).
% \item Hebrew: Properly store ¦\MakeUppercase¦ for later restoration (\TXI{152}).
% \item Fix whitespace issue in ¦\datewelsh¦ (\TXI{158}).
% \item When switching language, set the language/script specific font families (\TXI{164}).
% \item Correct some Bengali captions (\TXI{165}).
% \item Fix documentation of Serbian (\TXI{168}).
% \item Reset ucl codes in Latin only if the respective variant is used (\TXI{172}).
% \item Fix ¦\disablehyphenation¦ with LuaTeX (\TXI{187}).
% \item Fix typos in Hindi captions (\TXI{202}).
% \item Pass language options to the aux files (\TXI{205}).
% \item Rewrite and fix English variant handling (\TXI{208}).
% \item Define magyar caption formats in ¦\blockextras¦ and undef them in ¦\noextras¦ (\TXI{209}).
% \item Ensure proper direction with arabic digits in Arabic and Farsi (\TXI{213}).
% \item Fix ¦\linespread¦ with Korean (\TXI{218}).
% \item Define Russian caption before key allocation (\TXI{219}).
% \item Register current language in \pkg{polyglossia} lua module after selection (\TXI{234}).
% \item Fix \pkg{babel} language switching commands (\TXI{239}):
%       ¦\foreignlanguage¦ and the starred ¦otherlanguage*¦ environment are not
%       supposed to change dates.
% \item Fix French spacing leaking beyond French (\TXI{270}).
% \item Redefine font families for French only if language is loaded (\TXI{270}).
% \item ¦gloss-russian¦: 
%      \begin{itemize}
% 	 \item Check whether command exist before redefining (\TXI{280}).
% 	 \item Fix some whitespace issues.
%      \end{itemize}
% \item Fix and simplify ¦\frenchfootnote¦ definition (\TXI{294}).
% \item Fix footnote numbering in Farsi.
% \item Fix Latin footnotes in Arabic documents.
% \item Set the correct main direction with \pkg{luabidi}.
% \item Fix \xpgoption{autospaceguillemets} option in French.
% \item Fix grouping in ¦gloss-danish.ldf¦.
% \item Properly store ¦\MakeUppercase¦ and ¦\@arabic¦ for later restoration.
% \end{itemize}
% 
% \subsubsection*{Documentation}
% \begin{itemize}
% \item Add documentation about footnotes in RTL context
% \item Document Tibetan numerals option (\TXI{109}).
% \item Improve ¦\frenchfootnote¦ documentation.
% \item Mention Japanese support in the docs.
% \end{itemize}
% 
% \subsection*{1.44 (2019/04/04)}
% \begin{itemize}
% \item Correction to Russian language file, by \TA{Maksim Zholudev} (commit d2f383e).
% \item Added Macedonian language file, by \TA{Stefan Zlatinov} (commit cd379e1).
% \end{itemize}
% 
% \subsection*{1.43 (2019/03/05)}
% \begin{itemize}
% \item Correction to Hindi language file, by \TA{Zdenĕk Wagner}.
% \end{itemize}
% 
% \subsection*{1.42.5 (2017/04/13)}
% \begin{itemize}
% \item Many changes to the French language file, by \TA{Maïeul Rouquette}.
% \end{itemize}
% 
% \subsection*{1.42.4 (February, March 2016)}
% \begin{itemize}
% \item Remedial actions for the \pkg{babel} changes.
% \item Fixed side effect of pull request \TXI{122} (see commit d2a34ff).
% \item Added automatic Josa selection, variant, and captions options to Korean, by \TA{Dohyun Kim} (pull request \TXI{128}).
% \item Updated ¦gloss-occitan¦ from CTAN.
% \end{itemize}
% 
% \subsection*{18-01-2016}
% \begin{itemize}
% 	\item Fixed issue \TXI{124} (minor typo in ¦polyglossia-frpt.lua¦)
% 	\item Merged pull request \TXI{117} for more French guillemet spacing
% 	\item Merged pull request \TXI{121} to add ¦\bbl@loaded¦; fixes issue \TXI{120}
% 	\item Merged pull request \TXI{122} that build on \TXI{121}
% 	\item Merged pull request \TXI{116} for French (spacing around guillemets)
% 	\item Fixed issue \TXI{115} (spurious spaces in Arabic)
% \end{itemize}
% 	
% \subsection*{19-08-2015}
% \begin{itemize}
% 	\item Fixed issue \TXI{107} for Marathi (labels and month names)
% \end{itemize}
% 		
% \subsection*{1.42.0 (2015/08/06)}
% \begin{itemize}
% 	\item Add Bengali digits package, and option to reset all numbering functions.
% 	\item Add ¦long¦ option for Welsh date.
% 	\item Add local alphabet in Slovenian, for enumerations and such.
% 	\item Fix long-standing bug with Welsh: date should use ordinals.
% 	\item Fix for Latin with LuaTeX: all variants had same problems as Classic.
% 	\item Fixed error with British variant of English and LuaTeX (issue \TXI{86}).
% \end{itemize}
% 			
% \subsection*{1.41.0 (2015/07/16)}
% \begin{itemize}
% 	\item Added support for Khmer, by \TA{Say Ol} (private email)
% \end{itemize}
% 			
% \subsection*{1.40.1 (2015/07/14)}
% \begin{itemize}
% 	\item Bugfix for Korean, by \TA{Dohyun Kim} (pull request \TXI{103})
% \end{itemize}
% 			
% \subsection*{1.40.0 (2015/07/07)}
% \begin{itemize}
% 	\item ¦gloss-korean.ldf¦ contributed by \TA{Dohyun Kim} (pull request \TXI{102})
% \end{itemize}
% 			
% \subsection*{1.33.7 (2015/07/04)}
% \begin{itemize}
% 	\item Release to CTAN, no code change
% 	\item Fixed extraneous space in code for Swiss German (pull request \TXI{101})
% 	\item Fixed a typo in Ukrainian alphabet, for ¦\Asbuk¦ (pull request \TXI{99})
% 	\item Fix for Classic Latin: load patterns for LuaTeX
% 	\item Made ¦\rmfamily¦, ¦\sffamily¦ and ¦\ttfamily¦ robust again
% 	\item Merged fix for Hebrew date format, by \TA{Guy Rutenberg} (pull request \TXI{94})
% 	\item Merged fix for spurious space, by \TA{Caleb McKennan} (pull request \TXI{91})
% 	\item Merged pull request \TXI{84} by \TA{Élie Roux} for Tibetan
% 	\item Added support for Swiss German (pull request \TXI{75})
% 	\item Added commands ¦\Asbuk¦ and ¦\asbuk¦ for Ukrainian (pull request \TXI{76}), similar to Russian
% 	\item Documented changes to Latin from last year.
% 	\item Be friendlier to right-to-left languages with LuaTeX
% 	\item Enhanced Latin support by \TA{Claudio Beccari}
% \end{itemize}
% 
% \subsection*{1.33.6 (2015/05/15)}
% \begin{itemize}
% 	\item Introduce a ¦classical¦ and ¦medieval¦ variant of Latin
% 	\item Add ¦\asbuk¦ and ¦\Asbuk¦ for Ukrainian (after their Russian counterpart)
% 	\item Fix a number of bugs
% \end{itemize}
% 					
% \subsection*{1.33.5 (2014/05/21)}
% \begin{itemize}
% 	\item Option to disable hyphenation entirely, by \TA{Élie Roux}
% 	\item Fix spurious spaces in gloss-russian.ldf, by \TA{Oleg Domanov}
% 	\item Support for the Austrian variant of German, by \TA{Jürgen Spitzmüller}
% 	\item Changes to the Croatian translations, by \TA{Ivan Kokan}
% 	\item Correction to the Lithuanian translations, by \TA{Ignas Anikevičius}
% \end{itemize}
% 					
% \subsection*{1.33.4 (2013/06/27)}
% \begin{itemize}
% 	\item Emergency release for a bug introduced in ¦babelsh.def¦
% \end{itemize}
% 					
% \subsection*{1.33.3 (2013/05/28)}
% \begin{itemize}
% 	\item Changed formatting of some error messages (emergency fixes for TeX Live 2013)
% \end{itemize}
% 					
% \subsection*{1.33.2 (2013/05/26)}
% \begin{itemize}
% 	\item Added ¦\disablehyphenation¦ and ¦\enablehyphenation¦, contributed by
% 	      \TA{Élie Roux}.
% 	\item Fixed bug related to package inclusion. \pkg{Polyglossia} would break if
% 	      we loaded ¦breqn.sty¦, and then called ¦\setmainlanguage{english}¦, this
% 	      is no longer the case.
% 	\item Removed spurious space introduced by ¦\captionswedish¦.
% \end{itemize}
% 					
% \subsection*{1.33.1 (2013/05/23)}
% \begin{itemize}
% 	\item Editorial changes to the documentation
% 	\item Hunted and documented bugs
% \end{itemize}
% 					
% \subsection*{1.33.0 (2013/05/20)}
% \begin{itemize}
% 	\item Added support for N’Ko.
% 	\item Bugfixes for LuaTeX
% 	\item More work in progress on Bidi in LuaTeX.
% \end{itemize}
% 					
% \subsection*{1.32.0 (2013/05/15)}
% \begin{itemize}
% 	\item Transitional version to support right-to-left languages with LuaTeX.
% \end{itemize}
% 
% \subsection*{1.31 (2013/05/10) / 1.3 (2013/05/11)}
% \begin{itemize}
% 	\item Several bugfixes.
% 	\item Sync with \pkg{babel} 3.9.
% 	\item Consolidated support for LuaTeX for all languages but the ones using
% 	      South and South-East Asian scripts, and languages written from right
% 	      to left.  Many thanks to \TA{Élie Roux} for his help.
% 	\item Added support for Tibetan, contributed by \TA{Élie Roux} (end of lines are experimental).
% \end{itemize}
% 					
% \subsection*{1.30 (2012/08/06)}
% \begin{itemize}
% 	\item Added support for LuaTeX.  Many languages don’t work yet.  Please be patient.
% \end{itemize}
% 					
% \subsection*{1.2.0e (2012/04/28)}
% \begin{itemize}
% 	\item Fixed a number of outstanding and not very interesting bugs.
% 	\item Added gloss files for Romansh and Friulan, contributed by \TA{Claudio Beccari}.
% \end{itemize}
% 					
% \subsection*{1.2.0d (2012/01/12)}
% \begin{itemize}
% 	\item Removed ¦\makeatletter¦ and ¦\makeother¦ from gloss files entirely.
% \end{itemize}
% 					
% \subsection*{1.2.0c (2011/10/12) [First update by Arthur Reutenauer]}
% \begin{itemize}
% 	\item Update to ¦gloss-italian.ldf¦ by \TA{Claudio Beccari}, incorporating changes
% 	      by \TA{Enrico Gregorio}.
% 	\item Conclude every gloss file with ¦\makeatother¦ to match the initial
% 	      ¦\makeatletter¦.  (Not necessary from a technical point of vue, because of one 
% 	      of the changes by Enrico reported below, but I like it better that way :-)
% 	\item Conclude ¦polyglossia.sty¦ with ¦\ExplSyntaxOff¦ to match the initial
% 	      ¦\ExplSyntaxOn¦.
% 	\item Added gloss file for Kannada, contributed by \TA{Aravinda VK} and others.
% 	\item Corrections to the gloss-dutch.ldf thanks to \TA{Wouter Bolsterlee}.
% 	\item Several patches by \TA{Enrico Gregorio}, fixing long-standing bugs.
% 	      From the git log:
% 			\begin{itemize}
% 				\item Deleted setup for right-to-left writing direction, see \url{http://tug.org/pipermail/xetex/2011-April/020319.html}
% 				\item Changed three appearances of ¦\newcommand¦ to ¦\newrobustcmd,¦ as the commands needs to be protected.
% 				      Bug reported by \TA{kamensky}.
% 				\item Corrected ¦\datepolish¦ as suggested by \TA{Piotr Kempa}
% 				\item Changed ¦\lccode"¦ into ¦\lccode\string",¦ because it might come into action at wrong times when ¦"¦ is active
% 				\item Changed definition of key ¦\xpg@setup¦, as ¦\@tmpfirst¦ and ¦\@tmpsecond¦ were not expanded, causing dependence
% 				      of ¦\lefthyphenmin¦ and   ¦\righthyphenmin¦ to the last loaded language.
% 				      Raised by \TA{Vadim Rodionov} on the XeTeX mailing list.
% 				\item Deleted ¦\bgroup¦ and ¦\egroup¦ tokens from the definition of ¦otherlanguage*¦; they serve no purpose
% 				      (we are already inside an environment) and conflict with \pkg{csquotes}. Noticed by \TA{P. Lehman}.
% 				\item Changed the calls of \verb|\input| to ¦\xpg@input¦, which inputs the required file and resets the catcode
% 				      of ¦@¦ to the same value as it had before the input. Since each ¦.ldf¦ file starts with ¦\makeatletter¦,
% 				      the old behaviour would leave a category 11 @, which is wrong.
% 				\item Added ¦\csuse{date#2}¦ to the definition of ¦otherlanguage*¦.
% 			\end{itemize}
% \end{itemize}				
% 						
% \subsection*{1.2.0b (2011/10/03) [Update by Philipp Stephani]}
% \begin{itemize}
% 	\item Load \pkg{xkeyval} package explicitly since newer versions
% 	      of \pkg{fontspec} don't load it any more.
% \end{itemize}
% 							
% \subsection*{1.2.0a (2010/07/27) [Last update by François Charette]}
% \begin{itemize}
% 	\item Initialize ¦\fontfamily¦ acc to value of ¦\familydefault¦
% 	      (Fixes a bug when using \pkg{polyglossia} with beamer)
% 	\item Remove spurious space in def of ¦\dateenglish¦
% 	\item Add missing English variant ¦american¦
% 	\item Serbian: fix date format and captions (Latin+Cyrillic)
% 	\item Fix ¦\atticnumeral¦ in ¦gloss-greek¦
% 	\item Small improvements and fixes in documentation
% \end{itemize}
% 								
% 								
% \subsection*{1.2.0 (2010/07/15)}
% \begin{itemize}
% 	\item Adapted for \pkg{fontspec} 2.0 (will not work with earlier versions!)
% 	\item Implementation of a ¦\PolyglossiaSetup¦ interface
% 	      that simplifies writing ¦gloss-*.ldf¦ files
% 	\item Many internal enhancements and refactoring
% 	      (including a patch by \TA{Dirk Ulrich})
% 	\item Improved automatic font setup when ¦\<lang>font¦ is not defined
% 	\item New environment \texttt{otherlanguage*} (equivalent to ¦\foreignlanguage¦
% 	      (\TA{Enrico Gregorio})
% 	\item Bugfix to prevent bogus expansion of ¦\{rm,sf,tt}family¦ even in aux files (\TA{Enrico Gregorio})
% 	\item New gloss files for Armenian, Bengali, Occitan, Bengali, Lao,
% 	      Malayalam, Marathi, Tamil, Telugu, and Turkmen.
% 	\item New auxiliary packages ¦devanagaridigits¦ and ¦bengalidigits¦
% 	\item \pkg{hijrical} no longer loads \pkg{bidi} and checks for incompatible \pkg{l3calc}
% 	\item Add \pkg{babel} shorthands for Russian (based on a patch by \TA{Vladimir Lomov})
% 	\item Fix ¦\fnum@{table,figure}¦ for Lithuanian
% 	\item Various improvements in ¦gloss-russian¦ (provided by \TA{Vladimir Lomov} and
% 	      others)
% 	\item Corrected captions for Bahasai, Lithuanian, Russian, Croatian
% 	\item Add option \xpgoption{indentfirst=true} for Spanish, Croatian and other languages
% 	      (\xpgoption{indentfirst} was previously named \xpgoption{frenchindent})
% 	\item New option \xpgoption{script} for German: Setting \xpgoption{script=fraktur} modifies the
% 	      captions for typesetting in Fraktur.
% 	\item New command ¦\aemph¦ for Arabic, Farsi, Urdu, etc. to mark emphasis through
% 	      overlining.
% 	\item Package option \xpgoption{nolocalmarks} is now true by default: to activate it the
% 	      option \xpgoption{localmarks} must be passed instead.
% 	\item Loading languages à la \pkg{babel} as package options is no longer possible (this
% 	      feature was deprecated since v1.1.0).
% \end{itemize}
% 							
% \subsection*{1.1.1 (2010/03/23)}
% \begin{itemize}
% 	\item Bugfix for French: explicit spaces before/after double punctuation
% 	      signs (Par exemple : les grands « espaces » du Canada !) are
% 	      now replaced by the appropriate non-breaking spaces, as in \pkg{babel}.
% 	\item Bugfix for font switching mechanism within Latin script
% 	      (pending a complete re-implemen\-tation in v1.2):
% 	      the font shape and series are no longer reset when switching language.
% 	\item New macros for non-Western decimal digits
% 	      (instead of fontmappings)
% 	\item New gloss files for Asturian, Lithuanian and Urdu
% 	\item ¦hijrical.sty¦ is now locale-aware: ¦\hijritoday¦ is
% 	      formatted differently in Arabic, Farsi, Urdu, Turkish
% 	      and Bahasa Indonesia.
% 	\item Enable \xpgoption{babelshorthands} for Dutch
% 	\item Add missing macro ¦\allowhyphens¦
% 	\item Add global option \xpgoption{babelshorthands}
% 	\item Support Catalan geminated l
% 	\item Bugfix when declaring more than one pkg option
% 	\item Protect ¦\reset@font¦
% 	\item Add missing requirement \pkg{makecmds}
% 	\item Bugfix for smallcaps in captions
% 	\item Typo for ¦ccname¦ in Hebrew
% 	\item Add option \xpgoption{numerals} to ¦gloss-russian¦
% 	\item Provide ¦\newXeTeXintercharclass¦ when undefined
% 	\item Bugfix for Russian ¦\alph¦
% 	\item Remove superfluous level of ¦{}¦ in definition of ¦\markright¦
% 	\item Bugfix for ¦\datecatalan¦
% 	\item Change ¦hyphenmins¦ for Sanskrit
% \end{itemize}
% 							
% \subsection*{1.1.0b (2009/11/22)}
% \begin{itemize}
% 	\item Modify ¦\hyphenmins¦ for Sanskrit (\TA{Yves Codet})
% 	\item Bugfixes for Serbian and Bulgarian (\TA{Enrico Gregorio})
% \end{itemize}
% 
% \subsection*{1.1.0a (2009/11/22)}
% \begin{itemize}
% 	\item Bugfix for interchar tokens
% \end{itemize}
% 
% \subsection*{1.1.0 (2009/11/20)}
% \begin{itemize}
% 	\item Use ¦\newXeTeXintercharclass¦ (thanks to \TA{Enrico Gregorio})
% 	\item Fixed implementation of shorthands for German (\pkg{babel} code in file ¦babelsh.def¦)
% 	\item Arabic (\TA{Khaled Hosny}):
% 	\begin{itemize}
% 		\item Fix abjad form for 3 and 5 and add option ¦\abjadjimnotail¦
% 		\item bugfix for ¦\arabicnumber¦
% 		\item make Gregorian calendar the default
% 		\item fixed typos in the sample text
% 	\end{itemize}
% 	\item Turkish (\TA{S. Ö. Yıldız}):
% 	\begin{itemize}
% 		\item fix white-space before : and !
% 		\item also check if the font specified TRK for language
% 		\item added missing Turkish translation of ``Glossary''
% 	\end{itemize}
% 	\item Suppress ¦nopattern¦ warning for non-hyphenated scripts
% 	\item Changed U+0163 to U+021B for Romanian (\TA{Elie Roux})
% 	\item Stylistic fixes and use macro ¦\xpg@option¦ for package options (\TA{E. Gregorio})
% 	\item Fix month names in Dutch (\TA{A. Ledda})
% 	\item Add Brazilian translation for ``glossary''
% 	\item Remove spurious space generated by ¦gloss-spanish¦
% 	\item Fix ¦ldf¦ file for brazilian
% 	\item Various improvements in the code communicated by \TA{E. Gregorio}:
% 	\begin{itemize}
% 		\item remove superfluous ¦\protect\language¦
% 		\item change default language from ¦0¦ to ¦\l@nohyphenation=255¦
% 		\item localize ¦lccode¦ handling of apostrophe in French; add it to Italian
% 	\end{itemize}
% 	\item Fix ¦frenchspacing¦ for Vietnamese
% 	\item Other minor bugfixes
% \end{itemize}
% 							
% \subsection*{1.0.2 (2009/01/27)}
% \begin{itemize}
% 	\item Captions corrected in Hebrew, Russian and Spanish
% 	\item Removed all ¦\text<lang>¦ wrappers within caption definitions
% 	\item Improved compatibility with \pkg{babel}
% 	\item New option \xpgoption{babelshorthands} for German
% 	\item New option \xpgoption{Script} for Sanskrit
% \end{itemize}
% 							
% \subsection*{1.0.1 (2008/07/31)}
% \begin{itemize}
% 	\item Improved documentation (added sections on font setup and numeration mappings)
% 	\item Improvements and bug fixes for English and German
% 	\item Bugfix in ¦gloss-syriac.ldf¦ (spurious space after ¦\textsyriac{...}¦)
% 	\item Extended the scope of ¦\syriacabjad¦
% 	\item Added ¦gloss-amharic.ldf¦ (ported from ¦ethiop.ldf¦ in the package \pkg{ethiop})
% \end{itemize}
% 							
% \subsection*{1.0 (2008/07/13)}
% \begin{itemize}
% 	\item Initial release on CTAN.
% \end{itemize}
% \egroup
% 
% \section{Acknowledgements (by François Charette)}
% \pkg{Polyglossia} is notable for being a recycle box of previous contributions
% by other people. I take this opportunity to thank the following individuals,
% whose splendid work has made my task almost trivial in comparision: \TA{Johannes
% Braams} and the numerous contributors to the \pkg{babel} package (in particular
% \TA{Boris Lavva} and others for its Hebrew support), \TA{Alexej Kryukov} (\pkg{antomega}),
% \TA{Will Robertson} (\pkg{fontspec}), \TA{Apostolos Syropoulos} (\pkg{xgreek}), \TA{Youssef Jabri}
% (\pkg{arabi}), and \TA{Vafa Khalighi} (\pkg{xepersian} and \pkg{bidi}).
% The work of \TA{Mojca Miklavec} and \TA{Arthur Reutenauer} on hyphenation patterns with their package
% \pkg{hyph-utf8} is of course invaluable. I should also thank other
% individuals for their assistance in supporting specific languages: \TA{Yves Codet}
% (Sanskrit), \TA{Zdenĕk Wagner} (Hindi), \TA{Mikhal Oren} (Hebrew), \TA{Sergey Astanin} (Russian),
% \TA{Khaled Hosny} (Arabic), \TA{Sertaç Ö. Yıldız} (Turkish), \TA{Kamal Abdali} (Urdu),
% and several other members of the \XeTeX\ user community, notably \TA{Enrico Gregorio}, who
% has sent me many useful suggestions and corrections and contributed the \cmd\newXeTeXintercharclass\
% mechanism in xelatex.ini which is now used by polyglossia.
% More recently, \TA{Kevin Godby} of the \href{http://ubuntu-manual.org}{Ubuntu Manual} project has
% contributed very useful feedback, bug hunting and, with the help of translators,
% new language definition files for Asturian, Lithuanian, Occitan, Bengali, Malayalam, Marathi, Tamil, and Telugu.
% It is particularly heartening to realize that this package is used to typeset a widely-read
% document in dozens of different languages!
% Support for Lao was also added thanks to \TA{Brian Wilson}.
% I also thank \TA{Alan Munn} for kindly proof-reading the penultimate version of this documentation.
% And of course my gratitude also goes to \TA{Jonathan Kew}, the formidable author of \XeTeX!
% 
% \section{More acknowledgements (by the current development team)}
% Many thanks to all the people who have contributed bugfixes and new features to \pkg{polyglossia}
% since we took over.
% In alphabetical order: \TA{Ignas Anikevicius}, \TA{Sina Ahmadi}, \TA{Wouter Bolsterlee}, \TA{Christian Buhtz},
% \TA{Zgarbul Andrey}, \TA{Oleg Domanov}, user \TA{fakhriaunur}, \TA{Udi Fogiel}, \TA{Philipp Gesang}, \TA{Kevin Godby},
% \TA{Enrico Gregorio}, \TA{Khaled Hosny}, \TA{Najib Idrissi}, user \TA{julroy67}, \TA{Dohyun Kim}, \TA{Phil Kime},
% \TA{Mike Kroutikov}, \TA{Ivan Kokan}, \TA{Caleb Maclennan}, \TA{Gyula Magyarkuti}, \TA{José Mancera}, \TA{Miquel Ortega},
% \TA{Yevgen Pogribnyi}, \TA{Will Robertson}, \TA{Maïeul Rouquette}, \TA{Elie Roux}, \TA{Hugo Roy},  \TA{Guy Rutenberg},
% \TA{Marcin Serwin}, \TA{Arvinder Singh}, \TA{Philipp Stephani}, \TA{Niranjan Tambe}, \TA{Takuji Tanaka}, \TA{Osman Tursun},
% \TA{Keno Wehr}, \TA{Dominik Wujastyk}, \TA{Sertaç Ö. Yıldız}, \TA{Maksim Zholudev}, \TA{Yan Zhou}, and \TA{Stefan Zlatinov}.
% Their respective contributions can be identified from the contributor statistics on
% \href{https://github.com/reutenauer/polyglossia/graphs/contributors}{GitHub}.
% 
% Among the ones who sent contributions directly to us we would like to especially thank
% \TA{Claudio Beccari}, the indefatigable champion of Romance languages, and beyond! Furthermore,
% kudos go to \TA{Moritz Wemheuer} (of \pkg{biblatex}) who has helped a lot to improve \pkg{polyglossia} interaction
% with \pkg{biblatex} and \pkg{csquotes}.
% 
% Not at least, we are very grateful for all bug reports and feature enhancement requests we received from
% the numerous users we cannot list all here (but again, you can find all names on \href{https://github.com/reutenauer/polyglossia/issues?utf8=%E2%9C%93&q=is%3Aissue}{GitHub}).
% Please go on with that, you are keeping \pkg{polyglossia} running!
% 
% 
% 
% 
% \StopEventually{}
% \section{Implementation}
% \iffalse
%<*polyglossia.sty>
% \fi
% \clearpage
% 
% \subsection{polyglossia.sty}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{polyglossia}[2023/07/21 v1.64
  Modern multilingual typesetting with XeLaTeX and LuaLaTeX]
\RequirePackage{etoolbox}
\RequirePackage{makecmds}
\RequirePackage{xkeyval}[2008/08/13]
% Will raise error if used with anything else than XeTeX or LuaTeX
\RequirePackage{fontspec}[2010/06/08]% v2.0
\RequirePackage{iftex}
\RequirePackage{expl3}
\RequirePackage{l3keys2e}
\RequirePackage{xparse}

% fontspec now uses LaTeX3 packages such as expl3, so we need this:
\ExplSyntaxOn

% Execute code #3 if package #1 has been loaded already, else
% add to package hook #2
\cs_new_nopar:Nn \__xpg_at_package_hook:nnn{
  \@ifpackageloaded{#1}{#3}{\AddToHook{#2}{#3}}%
}

% safe according to expl3 bug #960
\cs_generate_variant:Nn \prop_item:Nn { Ne, Nf, No, Nx }
\cs_generate_variant:Nn \clist_set:Nn { Ne, Nf, No, Nx }
\cs_generate_variant:Nn \clist_gput_right:Nn {Ne}
\cs_generate_variant:Nn  \prop_get:NnN {NeN}
\cs_generate_variant:Nn  \prop_gput:Nnn {Nne, Nee, Nen}
\cs_generate_variant:Nn  \cs_gset:Npn {Npe}
\cs_generate_variant:Nn  \cs_new:Nn {Ne}
\cs_generate_variant:Nn  \cs_new_nopar:Nn {Ne}
\cs_generate_variant:Nn  \cs_gset_nopar:Npn {Npe}
\cs_generate_variant:Nn  \cs_gset_nopar:Npn {cpe}
\cs_generate_variant:Nn  \tl_set:Nn {Ne}
\cs_generate_variant:Nn  \str_foldcase:n {e}
\prg_generate_conditional_variant:Nnn \file_if_exist:n {e} {TF, T, F, p}
\prg_generate_conditional_variant:Nnn \tl_if_blank:n {e} {TF, T, F, p}
\prg_generate_conditional_variant:Nnn \clist_if_in:Nn {Ne} {TF, T, F, p}
\prg_generate_conditional_variant:Nnn \prop_if_in:Nn {Ne} {TF, T, F, p}
% correct a bug in tracklang
\__xpg_at_package_hook:nnn{tracklang}{file/tracklang.sty/after}{%
  \@ifpackagelater{tracklang}{2019/08/30}{}{\global\def\AddTrackedLangage{\AddTrackedLanguage}}
}

%% This is for compatibility with Babel-aware package:
\def\languageshorthands#1{\relax} %this is for scrlttr2 class
\def\bbl@cs#1{\csname bbl@#1\endcsname}%
\AtEndPreamble{\let\bbl@set@language\xpg@set@language@aux} %for biblatex
\AtEndPreamble{\let\bbl@main@language\xpg@main@language} %for biblatex
\AtEndPreamble{
  \providecommand\texorpdfstring[2]{#1}% dummy command if hyperref is not loaded
}

\sys_if_engine_luatex:T{
  \RequirePackage{luatexbase} % already included by fontspec, but needed here
  \RequireLuaModule{polyglossia}
}

% Which version of XeTeX do we use? What is the boudary class? 4095 or 255
\@ifundefined{e@alloc@intercharclass@top}
  {\chardef\xpg@boundaryclass=\@cclv}
  {\let\xpg@boundaryclass=\e@alloc@intercharclass@top}

% Useful for getting list of loaded languages and variants. Like babel's bbl@loaded
% all language loaded
\seq_new:N \__xpg_langs_loaded
% list of loaded languages (polyglossia name)
\clist_new:N \xpg@loaded
% list of loaded variants
\clist_new:N \xpg@vloaded
% list of loaded languages (babel name)
\clist_new:N \xpg@bloaded
% list of loaded languages (bcp-47 id)
\clist_new:N \xpg@bcp@loaded

% counter in latin
\def\latinalph#1{\expandafter\latin@alph\csname c@#1\endcsname}
\def\latinAlph#1{\expandafter\latin@Alph\csname c@#1\endcsname}

% select language hook
\cs_new_nopar:Nn \polyglossia@AtBeginDocument@selectlanguage: {}
% \disablehyphenation hook
\cs_new_nopar:Nn \polyglossia@AtBeginDocument@hyphenation: {}

% hook to be executed at begin of document
\cs_new_nopar:Nn \polyglossia@AtBeginDocument: {
  % save various command
  \let\latin@alph\@alph   % TODO rename when we have the C locale
  \let\latin@Alph\@Alph   % TODO rename when we have the C locale
  % push to C language gloss
  \let\polyglossia@Clang@@arabic\@arabic
  \let\polyglossia@Clang@arabic\arabic
  
  \xpg@initial@setup
  % apply \familydefault changes
  \xpg@set@familydefault
}

\AtBeginDocument{
  \polyglossia@AtBeginDocument:
}

% The following needs to go after any \AtBeginDocument (also of packages
% loaded after \set[main|other]language
\AfterEndPreamble{
  % now we have the C locale definition: select the language
  \polyglossia@AtBeginDocument@selectlanguage:
  % If hyphenation disabling has been requested in preamble, do it now
  \polyglossia@AtBeginDocument@hyphenation:
}

%% custom message macros
\providecommand*{\xpg@error}[1]{%
   \PackageError{polyglossia}{#1}{}%
}

\providecommand*{\xpg@warning}[1]{%
   \PackageWarning{polyglossia}{#1}%
}

\providecommand*{\xpg@info}[1]{%
   \PackageInfo{polyglossia}%
   {#1\@gobble}%
} %% the \@gobble is to prevent displaying the line nr

%TODO change all instances of \xpg@nopatterns in gloss-*.ldf files
\providecommand*{\xpg@nopatterns@fallback}[2][nohyphenation]{%
   \xpg@warning{No~ hyphenation~ patterns~ were~ loaded~ for~ `#2'\MessageBreak
         I~ will~ use~ \string\language=\string\l@ #1\space instead}%
   \expandafter\adddialect\csname l@#2\expandafter\endcsname\csname l@#1\endcsname\relax}

\providecommand*{\xpg@nopatterns}[1]{%
   \xpg@warning{No~ hyphenation~ patterns~ were~ loaded~ for~ `#1'\MessageBreak
         I~ will~ use~ \string\language=\string\l@nohyphenation\space instead}%
   %%TODO? \expandafter\adddialect\csname l@#1\endcsname\l@nohyphenation\relax
   }

\def\xpg@ill@value#1#2{%
  \xpg@warning{Illegal~ value~ (#1)~ for~ #2}}

% error out if lang is not loaded
\cs_new_nopar:Nn \polyglossia@error@iflangnotloaded:n
{
  \seq_if_in:NxF \__xpg_langs_loaded {#1}
  {
    \xpg@error{language~ #1~ is~ not~ loaded.~ Please~ load~ it~ before~ using~ it.}
  }
}

\msg_new:nnn { polyglossia } { languagenotloaded }
{
  The~ language~ #1~ is~ not~ loaded.~ You~ should~ load~ it.
}
\msg_redirect_name:nnn { polyglossia } { languagenotloaded } { critical }

\msg_new:nnn { polyglossia } { languagenolongerloaded }
{
  The~ language~ #1~ is~ no~ longer~ loaded.~ Please~ rerun~ LaTeX.
}
\msg_redirect_name:nnn { polyglossia } { languagenolongerloaded } { warning }

% 

%% use macro if defined, else warn that it is not
\cs_new_nopar:Nn \__xpg_use_or_warn:N
{
  \cs_if_exist_use:NF {#1}
  {
    \xpg@warning {  \tl_to_str:N {#1} ~ is~ not~ defined }
  }
}
\cs_generate_variant:Nn \__xpg_use_or_warn:N {c}


%% ensure directionality if bidi is loaded, else ignore
\def\@@ensure@dir#1{\ifcsundef{@ensure@dir}{#1}{\@ensure@dir{#1}}}
\def\@@ensure@maindir#1{\ifcsundef{@ensure@maindir}{#1}{\@ensure@maindir{#1}}}

%% Used by the language definitions files for right-to-left languages
\def\RequireBidi{%
  \str_case_e:nnF{\c_sys_engine_str}{
    {luatex}{\ifx\@onlypreamble\@notprerr\else\RequirePackage{luabidi}\fi}
    {xetex}{\ifx\@onlypreamble\@notprerr\else\RequirePackage{bidi}\fi}
  }
  {
    \xpg@warning{You’re running a TeX engine that is not LuaTeX or XeTeX.\MessageBreak
      That is almost guaranteed to cause problems.}
  }
}

% if #1 is LR run #2 else #3
\prg_set_conditional:Nnn \__xpg_if_LR_str:n {p, T, F, TF}
{
  \str_case_e:nnF{#1}{
    {LR}{\prg_return_true:}
    {RL}{\prg_return_false:}
  }
  {
    \xpg@error{Unknown~ direction~#1}
    \prg_return_false:
  }
}
\prg_generate_conditional_variant:Nnn \__xpg_if_LR_str:n {e} {p, T, F, TF}

% (lua)bidi commands to change directionality for paragraphs
% and inline text.
% overwritten with correct package
\cs_new_nopar:Nn{\polyglossia@setpardirection:n}{%
  \__xpg_if_LR_str:nF {#1}
  {
    \xpg@error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}
  }
}
\cs_new_nopar:Nn{\polyglossia@settextdirection:n}{%
  \__xpg_if_LR_str:nF {#1}
  {
    \xpg@error{right-to-left,~ but~ (lua)bidi~ package~ was~ not~ loaded!}
  }
}
\__xpg_at_package_hook:nnn{bidi}{package/bidi/after}{%
  \ExplSyntaxOn%
  \cs_gset_nopar:Nn{\polyglossia@setpardirection:n}{%
    \__xpg_if_LR_str:nTF{#1}%
    {%
      \setLR%
    }%
    {%
      \setRL%
    }%
  }%
  \cs_gset_nopar:Nn{\polyglossia@settextdirection:n}{%
    \__xpg_if_LR_str:nTF{#1}%
    {%
      \LRE%
    }%
    {%
      \RLE%
    }%
  }%
  \ExplSyntaxOff%
}
\__xpg_at_package_hook:nnn{luabidi}{package/luabidi/after}{%
  \ExplSyntaxOn%
  \cs_gset_nopar:Nn{\polyglossia@setpardirection:n}{%
    \__xpg_if_LR_str:nTF{#1}%
    {%
      \setLR%
    }%
    {%
      \setRL%
    }%
  }%
  \cs_gset_nopar:Nn{\polyglossia@settextdirection:n}{%
    \__xpg_if_LR_str:nTF{#1}%
    {%
      \LRE%
    }%
    {%
      \RLE%
    }%
  }%
  \ExplSyntaxOff%
}

% emulate \RTLmain
\cs_new_nopar:Nn \__xpg_setRTLmain: {}
\str_case_e:nnF{\c_sys_engine_str}{%
  {luatex}{\cs_gset:Nn \__xpg_setRTLmain: {\setRTLmain}}
  {xetex}{\cs_gset:Nn \__xpg_setRTLmain: {\@RTLmaintrue\setnonlatin}}
}
{
  \cs_gset:Nn \__xpg_setRTLmain:
  {
    \xpg@warning{You’re~ running a~ TeX~ engine~ that~ is~ not~ LuaTeX~ or~ XeTeX.\MessageBreak
      That~ is~ almost~ guaranteed~ to~ cause~ problems.}
  }
}

%% compatibility with babel
\let\addto\gappto% gappto is defined in etoolbox

%% NEW EXPERIMENTAL SETUP INTERFACE FOR GLOSS FILES
%% options currently available:
%% language : the name of the language (as understood by fontspec)
%% hyphennames : the different hyphenation patterns to try (comma separated list)
%%%   TODO: if pattern is prefixed by !, then it should be loaded as a fallback, with \xpg@nopatterns@fallback - i.e. with a warning: e.g. sanskrit for hindi, or catalan for asturian. – Also for languages with variants!  (English and German, etc.)
%% script : the name of the script (as understood by fontspec) – default is Latin
%% scripttag : the OpenType tag for the script
%% langtag : the OpenType tag for the language
%% hyphenmins : the hyphenmins for this language (comma-sep list of two integers)
%% frenchspacing : boolean
%% indentfirst : boolean
%% fontsetup : boolean
%% TODO: nouppercase : boolean (for scripts like Arabic, Devanagari, etc which have no concept of uppercase/lowercase)
%% TODO: localalph = {<alph_csname>,<Alph_csname>}
%% TODO: localnumeral = <csname>
%%       or even better localdigits = {0123456789} for fully automatic setup
\newif\if@xpg@language@really@defined@
\newcommand*\PolyglossiaSetup[2]{%
  \polyglossia@keys_define_lang:n{#1}%
  \keys_set:nn { polyglossia / #1 } { #2 }%
  \prop_log:N{\polyglossia@langsetup}
  \polyglossia_setup_hyphen:n {#1}
  %define booleans etoolbox style and set defaults
  %% TODO ? \providetoggle{#1@setup@done}%
  % we initialize these so that we can use \gappto below
  \csgdef{init@extras@#1}{}%
  \csgdef{init@noextras@#1}{}% we don't use this yet: remove?
  % here we do the fontsetup:
  \polyglossia@lang@autosetupfont:n{#1}
  %% TODO? \toggletrue{#1@setup@done}%
  % reinit \do
  \def\do##1{\setotherlanguage{##1}}%
  % register base alias
  \xpg_language_alias { #1 } { #1 }
}

% Adjust language key setting after initial setup
% This is needed, e.g., for languages with varying script
\DeclareDocumentCommand \SetLanguageKeys { m m }
{
  \clist_map_inline:nn { #1 } { \keys_set:nn { polyglossia / ##1 } { #2 } }
}


% setup hyphennames from a str list of hyphen
\cs_new:Nn \polyglossia_setup_hyphen:n {
  \clist_set:Ne{\l_tmpa_clist}{\prop_item:Nn \polyglossia@langsetup {#1 / hyphennames}}
  \providebool{havehyphen}
  \boolfalse{havehyphen}
  % for each hyphen in the set until we find one that works
  \clist_map_inline:Nn \l_tmpa_clist {
    \ifbool{havehyphen}{}{%
       % check if language hyphenname is defined
      \__xpg_check_if_exist_l@:NF{#1}{%
          % if not, first consider nohyphenation
          \str_if_eq:nnTF{##1}{nohyphenation}
            {%
               \cs_gset_eq:cc{l@#1}{l@##1}
               \global\booltrue{havehyphen}
            }{%
               % then test if hyphenation is defined
               \xpg@ifdefined{##1}{
                  % test if language hyphenation is nohyphenation
                  \cs_if_eq:cNF{l@#1}{\l@nohyphenation}{\global\booltrue{havehyphen}}{%
                      % if false define language to hyphenation if it is not equal...
                      \str_if_eq:nnF{#1}{##1}{\cs_gset_eq:cc{l@#1}{l@##1}}
                      % ...and load
                      \xpg@set@hyphenation@patterns{##1}
                      \global\booltrue{havehyphen}
                  }%
                }{}%
           }%
       }%
    }%
  }%
  % if l@#1 does not yet exist,
  % we assign it to nohyphenation
  % we do this here in case and if the hyphennames key was omitted
  \ifbool{havehyphen}{}{%
    \xpg@ifdefined{#1}{}%
    {
      \xpg@nopatterns{#1}
      \expandafter\adddialect\csname l@#1\endcsname\l@nohyphenation\relax
    }%
  }%
  \csdef{#1@language}{%
    \polyglossia@setup@language@patterns{#1}%
  }%
  % setup hyphenmins
  \clist_set:Ne \l_tmpa_clist
    { \prop_item:Nn \polyglossia@langsetup {#1 / hyphenmins} }
  \cs_if_eq:cNF {l@#1} \l@nohyphenation
    {
      \use:x
        {
          \exp_not:N \setlocalhyphenmins {#1}
            { \clist_item:Nn \l_tmpa_clist {1} }
            { \clist_item:Nn \l_tmpa_clist {2} }
        }
    }
}

\newcommand*\polyglossia@setup@language@patterns[1]{%
  \ifbool{xpg@hyphenation@disabled}{%
    \xdef\xpg@lastlanguage{\the\csname l@#1\endcsname}%
  }{%
    % first, test if \l@#1 exists
    % without that, \csname l@#1\endcsname will be defined as \relax
    \cs_if_exist:cTF {l@#1}
      {
        \cs_if_eq:cNTF {l@#1} \l@nohyphenation
          {
            \language=\l@nohyphenation
          }
          {
            \xpg@set@hyphenation@patterns{#1}
          }
      }
      {%
        % Since this function is sometimes called from the gloss files
        % directly, we need to check whether the requested hyphenname exists.
        \xpg@ifdefined{#1}{}%
        {%
          \xpg@nopatterns{#1}
          \expandafter\adddialect\csname l@#1\endcsname\l@nohyphenation\relax%
        }%
        \xpg@set@hyphenation@patterns{#1}
      }
  }
}

\prop_new:N \polyglossia@langsetup

\cs_new_protected:Npn \polyglossia@keys_define_lang:n #1 {
  \keys_define:nn {polyglossia}{
    % the script font
    #1 / script
       .code:n = {
          \prop_gput:Nnn{\polyglossia@langsetup}{#1/script}{##1}
          \prop_gput:Nnx{\polyglossia@langsetup}{#1/lcscript}
               {\tl_if_empty:nF{##1}{\str_lowercase:n##1}}
    },
    #1 / script
       .value_required:n = true,
    #1 / script
       .initial:n = latin,
    % the opentype script tag
    #1 / scripttag
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/scripttag}{##1}},
    #1 / scripttag
       .default:n = {},
    #1 / scripttag
      .initial:n = {},
    % the language full name
    #1 / language
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/language}{##1}},
    #1 / language
       .value_required:n = true,
    #1 / language
        .initial:x = {\str_upper_case:n#1},
    % the language tag
    #1 / langtag
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/langtag}{##1}},
    #1 / langtag
       .value_required:n = true,
    #1 / langtag
       .initial:n = {},
    % the BCP-47 tag
    #1 / bcp47
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47}{##1}},
    #1 / bcp47
       .value_required:n = true,
    #1 / bcp47
       .initial:n = {},
    % the BCP-47 language tag
    #1 / bcp47-language
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-language}{##1}},
    #1 / bcp47-language
       .value_required:n = true,
    #1 / bcp47-language
       .initial:n = {},
    % the BCP-47 region tag
    #1 / bcp47-region
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-region}{##1}},
    #1 / bcp47-region
       .value_required:n = false,
    #1 / bcp47-region
       .initial:n = {},
    % the BCP-47 script tag
    #1 / bcp47-script
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-script}{##1}},
    #1 / bcp47-script
       .value_required:n = true,
    #1 / bcp47-script
       .initial:n = {},
    % the BCP-47 variant tag
    #1 / bcp47-variant
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-variant}{##1}},
    #1 / bcp47-variant
       .value_required:n = false,
    #1 / bcp47-variant
       .initial:n = {},
    % the BCP-47 extension-t tag
    #1 / bcp47-extension-t
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-extension-t}{##1}},
    #1 / bcp47-extension-t
       .value_required:n = false,
    #1 / bcp47-extension-t
       .initial:n = {},
    % the BCP-47 extension-u tag
    #1 / bcp47-extension-u
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-extension-u}{##1}},
    #1 / bcp47-extension-u
       .value_required:n = false,
    #1 / bcp47-extension-u
       .initial:n = {},
    % the BCP-47 extension-x tag
    #1 / bcp47-extension-x
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-extension-x}{##1}},
    #1 / bcp47-extension-x
       .value_required:n = false,
    #1 / bcp47-extension-x
       .initial:n = {},
    % the BCP-47 casing alias
    #1 / bcp47-casing
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/bcp47-casing}{##1}},
    #1 / bcp47-casing
       .value_required:n = false,
    #1 / bcp47-casing
       .initial:n = {},
    % hyphennames
    #1 / hyphennames
    .code:n = {
      \clist_set:Nn{\l_tmpa_clist}{##1}
      \prop_gput:Nnx{\polyglossia@langsetup}{#1/hyphennames}{\clist_use:Nn \l_tmpa_clist {,}}
    },
    #1 / hyphennames
       .value_required:n = true,
    #1 / hyphennames
      .initial:x = {\c_empty_clist},
    % direction
    #1 / direction
    .  code:n = {
           \str_case_e:nnTF{##1}{
             {LR}{}
             {RL}{\RequireBidi}
           }
           {\prop_gput:Nnn{\polyglossia@langsetup}{#1/direction}{##1}}
           {\xpg@error{Unknown~ direction~ "##1"~ for~ language~ "#1"}}
       },
    #1 / direction
      .value_required:n = true,
    #1 / direction
      .initial:n = {LR},
    % minimal left and right hyphenation minima using
    #1 / hyphenmins
    .code:n = {
      % check syntax
      \int_compare:nNnF { \clist_count:n {##1} } = {2}
        {\xpg@error{hypenmins~should~be~a~list~of~two~entries,~got~"##1"}}
      % set prop
      \prop_gput:Nnn \polyglossia@langsetup {#1/hyphenmins} {##1}
    },
    #1 / hyphenmins
      .value_required:n = true,
    #1 / hyphenmins
     .initial:n = {2,3},
    % minimal length for hyphenation (LuaTeX only)
    #1 / totalhyphenmin
    .code:n = {
      % check syntax
      \int_compare:nNnF { \clist_count:n {##1} } = {1}
        {\xpg@error{totalhyphenhypenmin~should~be~a~single~entry,~got~"##1"}}
      % set prop
      \prop_gput:Nnn \polyglossia@langsetup {#1/totalhyphenmin} {##1}
    },
    #1 / totalhyphenmin
      .value_required:n = false,
    % frenchspacing
    #1 / frenchspacing
    .code:n = {
        \str_case_e:nnTF{##1}{
            {true}{}
            {false}{}
          }
          {}
          {\xpg@error{frenchspacing~should~be~true~or~false. Is~ "##1"~ for~ language~ "#1"}}
        \prop_gput:Nnn{\polyglossia@langsetup}{#1/frenchspacing}{##1}
    },
    #1 / frenchspacing
      .default:n = true,
    #1 / frenchspacing
      .initial:n = false,
    % indent first line
    #1 / indentfirst
    .code:n = {
      \str_case_e:nnTF{##1}{
            {true}{}
            {false}{}
          }
          {}
          {\xpg@error{indentfirst~should~be~true~or~false. Is~ "##1"~ for~ language "#1"}}
      \prop_gput:Nnn{\polyglossia@langsetup}{#1/indentfirst}{##1}
    },
    #1 / indentfirst
      .default:n = true,
    #1 / indentfirst
      .initial:n = false,
    % fontsetup
    #1 / fontsetup
      .code:n = {
         \str_case_e:nnTF{##1}{
            {true}{}
            {false}{}
          }
          {}
          {\xpg@error{fontsetup~should~be~true~or~false. Is "##1"~ for~ language~ "#1"}}
       \prop_gput:Nnn{\polyglossia@langsetup}{#1/fontsetup}{##1}
       },
    #1 / fontsetup
      .default:n = true,
    #1 / fontsetup
      .initial:n = false,
    % environment name
    #1 / envname
       .code:n = {
           \prop_gput:Nnn{\polyglossia@langsetup}{#1/envname}{##1}
       },
    #1/ envname.value_required:n = true,
    #1/ envname.initial:n = {#1},
    % babel name
    #1 / babelname
       .code:n = {
           \prop_gput:Nnn{\polyglossia@langsetup}{#1/babelname}{##1}
       },
    #1/ babelname.value_required:n = true,
    #1/ babelname.initial:n = {#1},
    % default numerals
    #1 / localnumeral
         . code:n =  {
            \prop_gput:Nnn{\polyglossia@langsetup}{#1/localnumeral}{##1}
            \prop_gput:Nnn{\polyglossia@langsetup}{#1/Localnumeral}{##1}
         },
    #1 / localnumeral.value_required:n = true,
    #1 / localnumeral.initial:n = {polyglossia@C@localnumeral},
    % uppercased
    #1 / Localnumeral
         . code:n =  {
            \prop_gput:Nnn{\polyglossia@langsetup}{#1/Localnumeral}{##1}
         },
    #1 / Localnumeral.value_required:n = true,
    #1 / Localnumeral.initial:n = {polyglossia@C@localnumeral},
    % environment define command (by default create the environment)
    #1 / DefineCommandsCmd
       .code:n = {\prop_gput:Nnn{\polyglossia@langsetup}{#1/DefineCommandsCmd}{##1}},
    #1 / DefineCommandsCmd
       .value_required:n = true,
    #1 / DefineCommandsCmd
      .initial:n = {xpg_define_language_commands:e}
  }
}

% TODO move to C module
\newcommand*{\polyglossia@C@localnumeral}[2]{
   \polyglossia@Clang@@arabic{#2}
}

% print using main language
% #2 is the numeral to print
% #3 is the mainlanguage (should be expanded)
% #4 is the current language (should be expanded)
% #1 is the option list (should be expanded)
% #5 is the name of the field to use
\cs_new:Nn \polyglossia_localnumeral_mainlang:nnnnn {
  \foreignlanguage{#3}{\use:c {\prop_item:Nn \polyglossia@langsetup  {#3/#5}} {#1} {#2}}
}


% print using local language
% #2 is the numeral to print
% #3 is the mainlanguage (should be expanded)
% #4 is the current language (should be expanded)
% #1 is the option list (should be expanded)
% #5 is the name of the field to use
\cs_new:Nn \polyglossia_localnumeral_locallang:nnnnn {
  \use:c {\prop_item:Nn \polyglossia@langsetup  {#4/#5}} {#1} {#2}
}

% this function try to resolve some simple parameter about lang
% call #2 then branching if found
% call parameter #3 if not found
% (use curing)
\cs_new:Npn \polyglossia_localnumeral_callshortcutorlong:nF #1#2 {
  \str_case:nnF{#1}{
    {lang=local}{\polyglossia_localnumeral_locallang:nnnnn}
  }
  {#2}
}

\cs_new:Npn \polyglossia_iii_map_csv_field_split_kv_iii_localnumeral:w  #1 = #2 \q_stop {
  \str_case:nnF{#2}{
    {local}  {\clist_map_break:n{\use_i:nn \polyglossia_localnumeral_locallang:nnnnn }}
    {default}{\clist_map_break:n{\use_i:nn \polyglossia_localnumeral_locallang:nnnnn }}
    {*}      {\clist_map_break:n{\use_i:nn\polyglossia_localnumeral_mainlang:nnnnn   }}
    {main}   {\clist_map_break:n{\use_i:nn\polyglossia_localnumeral_mainlang:nnnnn   }}
  }{
    \clist_map_break:n{ \use_i_ii:nnn \polyglossia_localnumeral_langlang:nnnnnn {{#2}} }
  }
}


% call the language
% #3 is the numeral to print
% #4 is the mainlanguage (should be expanded)
% #5 is the current language (should be expanded)
% #2 is the option list (should be expanded)
% #6 is the name of the field to use
% #1 is the language used
\cs_new:Nn \polyglossia_localnumeral_langlang:nnnnnn {
   \foreignlanguage{#1}{\use:c {\prop_item:Nn \polyglossia@langsetup  {#1/#6}} {#2} {#3}}
}


% check if empty value
\cs_new:Npn \polyglossia_iii_map_csv_field_split_kv_ii_localnumeral:w  #1 #2 = #3 \q_stop {
  \quark_if_no_value:NTF {#3}
  {
    \clist_map_break:n{\use_i:nn \polyglossia_localnumeral_locallang:nnnnn}
  }
  {
    \polyglossia_iii_map_csv_field_split_kv_iii_localnumeral:w #1 \q_stop
  }
}

\cs_new:Npn \polyglossia_iii_map_csv_field_split_kv_i_localnumeral:nw #1 #2 = #3 \q_stop {
  % parse only lang tag
  \tl_trim_spaces_apply:nN {#2} \str_if_eq:nnT {lang}
  {
    % if empty value
    \quark_if_nil:nTF{#3}
    {
      \clist_map_break:n{\use_i:nn \polyglossia_localnumeral_locallang:nnnn}
    }
    {
      % here we know what we have an equal sign
      \polyglossia_iii_map_csv_field_split_kv_ii_localnumeral:w {#1} #1 \q_no_value \q_stop
    }
  }
}

% map function 
\cs_new:Nn \polyglossia_iii_map_csv_localnumeral:n {
  % fast case is do nothing is empty 
  \tl_if_empty:nF{#1}
  {
    \polyglossia_iii_map_csv_field_split_kv_i_localnumeral:nw {#1} #1 = \q_nil \q_stop
  }
}


% treat option is empty and option is lang=local
% #2 number
% #3 mainlanguage
% #4 locallanguage
% #5 field to call
% #1 option
% strip space to option
\cs_new:Nn \polyglossia_iii_localnumeral:nnnnn {
  \tl_if_blank:nTF{#1}
  {
    \polyglossia_localnumeral_mainlang:nnnnn
  }
  {
    \str_if_eq:nnTF{#1}{lang=local}
    {
      \polyglossia_localnumeral_locallang:nnnnn
    }
    {
      % use postscript like trick push to stack {#1} {#2} {#3} {#4}
      \polyglossia_localnumeral_callshortcutorlong:nF {#1}
      {
        % same trick here if found we emit  \use_i:nn
        % thus discarding the default choice that is not lang specified thus local
        \clist_map_function:nN {#1} {\polyglossia_iii_map_csv_localnumeral:n}
        \polyglossia_localnumeral_locallang:nnnnn
      }
    }
    {#1} {#2} {#3} {#4} {#5}
  }
}


% internal helper useful for oeee and onnn
% #1 number
% #2 mainlanguage
% #3 locallanguage
% #4 option
% #5 field to call
% strip space to option
\cs_new:Nn \polyglossia_ii_localnumeral:nnnnn {
  \tl_trim_spaces_apply:nN {#4} \polyglossia_iii_localnumeral:nnnnn {#1}{#2}{#3}{#5}
}
\cs_generate_variant:Nn \polyglossia_ii_localnumeral:nnnnn {
  eeenn, eeeon, eeeen
}

% convert the counter to value
% #1 counter
% #2 mainlanguage
% #3 locallanguage
% #4 option
\cs_new:Nn \polyglossia_i_localnumeral:nnnnn
{
  \polyglossia_ii_localnumeral:eeeen {\int_value:w #1} {#2} {#3} {#4} {#5}
}

% print number usage \localnumeral[option]{numeral}
% or \localnumeral*[option]{counter}
% \Localnumeral[]{numeral} use main language
% \localnumeral{numeral} use local language
\NewExpandableDocumentCommand{\localnumeral}{som}
{
  \IfBooleanTF{#1}%
    {% starred: take counter
      \exp_args:Nc \polyglossia_i_localnumeral:nnnnn {c@#3}
         {\mainlanguagename} {\languagename} {\IfNoValueTF {#2}{lang=local}{#2}} {localnumeral}
    }{% unstarred: take number
      \polyglossia_ii_localnumeral:eeeen {\int_eval:n{#3}}
         {\mainlanguagename} {\languagename} {\IfNoValueTF {#2}{lang=local}{#2}} {localnumeral}
    }
}

% print number usage \Localnumeral[option]{numeral}
% or \Localnumeral*[option]{counter}
% \Localnumeral[]{numeral} use main language
% \localnumeral{numeral} use local language
\NewExpandableDocumentCommand{\Localnumeral}{som}
{
  \IfBooleanTF{#1}%
    {% starred: take counter
      \exp_args:Nc \polyglossia_i_localnumeral:nnnnn {c@#3}
         {\mainlanguagename} {\languagename} {\IfNoValueTF {#2}{lang=local}{#2}} {Localnumeral}
    }{% unstarred: take number
      \polyglossia_ii_localnumeral:eeeon {\int_eval:n{#3}}
         {\mainlanguagename} {\languagename} {\IfNoValueTF {#2}{lang=local}{#2}} {Localnumeral}
    }
}

\cs_new_nopar:Nn{\polyglossia@lang@frenchspacing:n}{
  \prop_get:NxNTF \polyglossia@langsetup {#1/frenchspacing} \l_tmpa_tl
      {
        \str_case_e:nnF{\l_tmpa_tl}{
          {true}{\frenchspacing}
          {false}{\nonfrenchspacing}
        }
        {\xpg@error{frenchspacing~should~be~true~or~false. Is~"\l_tmpa_ttl"~ for~ language~ "#1"}}
      }
      {
        \xpg@error{Could~ not~ retrieve~ key~ frenchspacing~ for~ language~ "#1"}
        \prop_show:N{\polyglossia@langsetup}
      }
}

\cs_new_nopar:Nn{\polyglossia@lang@indentfirst:n}{
  \prop_get:NxNTF \polyglossia@langsetup {#1/indentfirst} \l_tmpa_tl
      {
        \str_case_e:nnF{\l_tmpa_tl}{
          {true}{\french@indent}
          {false}{\nofrench@indent}
        }
        {\xpg@error{indentfirst~should~be~true~or~false. Is~"\l_tmpa_ttl"~ for~ language~ "#1"}}
      }
      {
        \xpg@error{Could~ not~ retrieve~ key~ indentfirst~ for~ language~ "#1"}
        \prop_show:N{\polyglossia@langsetup}
      }
}


\cs_new:Nn{\polyglossia@lang@setpardirection:n}{
  \prop_get:NxNTF \polyglossia@langsetup {#1/direction} \l_tmpa_tl
      {
        \polyglossia@setpardirection:n{\l_tmpa_tl}
      }
      {
        \xpg@error{Could~ not~ retrieve~ key~ direction~ for~ language~ "#1"}
        \prop_show:N{\polyglossia@langsetup}
      }
}


\cs_new:Nn{\polyglossia@lang@settextdirection:nn}{
  \prop_get:NxNTF \polyglossia@langsetup {#1/direction} \l_tmpa_tl
      {
        \polyglossia@settextdirection:n{\l_tmpa_tl}{#2}
      }
      {
        \xpg@error{Could~ not~ retrieve~ key~ direction~ for~ language~ "#1"}
        \prop_show:N{\polyglossia@langsetup}
      }
}

\AtEndDocument{
  \prop_log:N{\polyglossia@langsetup}
  \prop_log:N{\__xpg_alias}
}
\def\xpg@lastlanguage{0}%

\providebool{xpg@hyphenation@disabled}%
\boolfalse{xpg@hyphenation@disabled}

\def\xpg@disablehyphenation{%
  \ifx\@onlypreamble\@notprerr%
     \xpg@@disablehyphenation%
  \else%
     % if this is used in the preamble, we have to postpone
     % the execution until the main language has been set (#125).
     \cs_gset_nopar:Nn \polyglossia@AtBeginDocument@hyphenation: {
        \xpg@@disablehyphenation%
     }%
  \fi%
}

\def\xpg@@disablehyphenation{%
  \ifbool{xpg@hyphenation@disabled}{}{%
    \booltrue{xpg@hyphenation@disabled}%
    \xdef\xpg@lastlanguage{\the\language}%
    % We do not call \xpg@set@hyphenation@patterns here to avoid a warning message.
    % "nohyphenation" is not listed in language.dat.lua.
    \language=\l@nohyphenation%
  }%
}

\def\xpg@enablehyphenation{%
  \ifbool{xpg@hyphenation@disabled}{%
    \boolfalse{xpg@hyphenation@disabled}%
    \language=\csname xpg@lastlanguage\endcsname%
  }{}%
}

\let\disablehyphenation\xpg@disablehyphenation
\let\enablehyphenation\xpg@enablehyphenation

%\def\xpg@fontsetup#1{\xpg@csifdef@warn{xpg@fontsetup@#1}}
%\def\xpg@fontsetup@none#1{\csgdef{#1@font}{\ifcsdef{#1font}{\csname #1font\endcsname}{}}} %<-- simplistic
%\def\xpg@fontsetup@custom#1{\csuse{#1@font}}

\cs_new:Nn \polyglossia@lang@autosetupfont:n {
  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia@langsetup}{#1/fontsetup}}{true}
  {
    \str_if_eq:eeTF{\prop_item:Nn{\polyglossia@langsetup}{#1/lcscript}}{latin}%
         {\xpg@fontsetup@latin{#1}}
         {\xpg@fontsetup@nonlatin{#1}}
  }
  {
    \xpg@info{Skipping~ automatic~ font~ setup~ for~ language~ #1}
  }
}


% add fontfeature Language=#2 to langtag #1
% do nothing if #1 or #2 is empty
\cs_new:Nn \polyglossia@addfontfeature@language:nn {
  \bool_if:nTF{\tl_if_empty_p:n{#1} || \tl_if_empty_p:n{#2}}
  {
    % maybe an error ?
    \xpg@warning{Asking~ to~ add~ empty~ feature~to~ latin~ font~
      (Language="#2"~ to~ langtag~ "#1")}
  }
  {
    \str_if_eq:nnTF{#2}{Turkish}{
      \fontspec_if_language:nTF {TRK}%
      {
        \addfontfeature{Language=Turkish}
      }
      {
        \fontspec_if_language:nTF {TUR}%
        {
          \addfontfeature{Language=Turkish}
        }{}
      }
    }{
      \fontspec_if_language:nTF{#1}
      {
        \addfontfeature{Language=#2}
      }
      {}
    }
  }
}
\cs_generate_variant:Nn  \polyglossia@addfontfeature@language:nn { on , no, oo , Vn, nV, VV , xn, nx, xx}

% add fontfeature Script=#2 to scripttag #1
% do nothing if #1 or #2 is empty
\cs_new:Nn \polyglossia@addfontfeature@script:nnn {
  \bool_if:nTF{\tl_if_empty_p:n{#2} || \tl_if_empty_p:n{#3}}
  {
    % maybe an error ?
    \xpg@warning{Asking~ to~ add~ empty~ feature~to~ latin~ font
                 (Script="#3"~ to~ scripttag~ "#2")}
  }
  {
    \fontspec_if_script:nTF{#2}
       {\addfontfeature{Script=#3}}
       {
        \tl_set:Nn \l_ffamily_tl {}
        \tl_set:Nn \l_ffamilysh_tl { #1 }
        \str_if_eq:nnT { #1 } { rm }
           {
             \tl_set:Nn \l_ffamily_tl { roman }
             \tl_set:Nn \l_ffamilysh_tl {}
           }
        \str_if_eq:nnT { #1 } { sf }
           {
             \tl_set:Nn \l_ffamily_tl { sans~ serif }
           }
        \str_if_eq:nnT { #1 } { tt }
           {
             \tl_set:Nn \l_ffamily_tl { monospace }
           }
        \xpg@error{
          The~ current~ latin ~ \l_ffamily_tl\space font~ does~ not~ contain~ the~"#3"~ script!\MessageBreak
          Please~ define~\csname\tl_if_empty:nF{#3}{\str_lowercase:n#3}font\l_ffamilysh_tl\endcsname~
          with~ \string\newfontfamily\space command
          }
        }
  }
}
\cs_generate_variant:Nn  \polyglossia@addfontfeature@script:nnn { non , nno, noo , nVn, nnV, nVV , nxn, nnx, nxx}

\def\xpg@fontsetup@latin#1{%
  \begingroup
  \csgdef{#1@font@rm}{%
    \cs_if_exist_use:cF{#1font}{
      \rmfamilylatin
      \polyglossia@addfontfeature@language:xx{\prop_item:Nn{\polyglossia@langsetup}{#1/langtag}}
                                              {\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
    }
  }
  \csgdef{#1@font@sf}{%
    \cs_if_exist_use:cF{#1fontsf}{
      \sffamilylatin
      \polyglossia@addfontfeature@language:xx{\prop_item:Nn{\polyglossia@langsetup}{#1/langtag}}
                                              {\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
    }%
  }%
  \csgdef{#1@font@tt}{%
    \cs_if_exist_use:cF{#1fonttt}{
      \ttfamilylatin
      \polyglossia@addfontfeature@language:xx{\prop_item:Nn{\polyglossia@langsetup}{#1/langtag}}
                                              {\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
    }%
  }%
  \endgroup
}

\def\xpg@fontsetup@nonlatin#1{%
  \begingroup
  \csgdef{#1@font@rm}{%
    \cs_if_exist_use:cF{#1font}
      {
       \providetoggle{#1@use@script@font}%
       \str_if_eq:nnTF{\prop_item:Nn{\polyglossia@langsetup}{#1/script}}{\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
        {\rmfamilylatin}%
        {\cs_if_exist_use:cTF{\prop_item:Nn{\polyglossia@langsetup}{#1/lcscript} font}
          {
             \toggletrue{#1@use@script@font}%
           }
           {
             \rmfamilylatin
           }
       }
       \iftoggle{#1@use@script@font}{}{%
           \polyglossia@addfontfeature@script:nxx{rm}
                                                 {\prop_item:Nn{\polyglossia@langsetup}{#1/scripttag}}
                                                 {\prop_item:Nn{\polyglossia@langsetup}{#1/script}}
       }%
       \polyglossia@addfontfeature@language:xx{\prop_item:Nn{\polyglossia@langsetup}{#1/langtag}}
                                              {\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
      }%
      \def\familytype{rm}%
  }%
  \csgdef{#1@font@sf}{%
    \cs_if_exist_use:cF{#1fontsf}%
      {
       \providetoggle{#1@use@script@fontsf}%
       \str_if_eq:nnTF{\prop_item:Nn{\polyglossia@langsetup}{#1/script}}{\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
        {\sffamilylatin}%
        {\cs_if_exist_use:cTF{\prop_item:Nn{\polyglossia@langsetup}{#1/lcscript} fontsf}
          {
             \toggletrue{#1@use@script@fontsf}%
           }
           {
             \sffamilylatin
           }
       }
       \iftoggle{#1@use@script@fontsf}{}{%
           \polyglossia@addfontfeature@script:nxx{sf}
                                                 {\prop_item:Nn{\polyglossia@langsetup}{#1/scripttag}}
                                                 {\prop_item:Nn{\polyglossia@langsetup}{#1/script}}
       }%
       \polyglossia@addfontfeature@language:xx{\prop_item:Nn{\polyglossia@langsetup}{#1/langtag}}
                                              {\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
      }%
      \def\familytype{sf}%
  }%
  \csgdef{#1@font@tt}{%
    \cs_if_exist_use:cF{#1fonttt}%
      {
       \providetoggle{#1@use@script@fonttt}%
       \str_if_eq:nnTF{\prop_item:Nn{\polyglossia@langsetup}{#1/script}}{\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
       {\ttfamilylatin}%
       {\cs_if_exist_use:cTF{\prop_item:Nn{\polyglossia@langsetup}{#1/lcscript} fonttt}
           {
             \toggletrue{#1@use@script@fonttt}%
           }
           {
             \ttfamilylatin
           }
       }
       \iftoggle{#1@use@script@fonttt}{}{%
           \polyglossia@addfontfeature@script:nxx{tt}
                                                 {\prop_item:Nn{\polyglossia@langsetup}{#1/scripttag}}
                                                 {\prop_item:Nn{\polyglossia@langsetup}{#1/script}}
       }%
       \polyglossia@addfontfeature@language:xx{\prop_item:Nn{\polyglossia@langsetup}{#1/langtag}}
                                              {\prop_item:Nn{\polyglossia@langsetup}{#1/language}}
      }%
      \def\familytype{tt}%
  }%
  \endgroup
}

%%% END OF PolyglossiaSetup

%% ensure localization of \markright and \markboth commands
%%% THIS IS NOW DISABLED BY DEFAULT
\cs_new_nopar:Nn {\polyglossia@local@marks:n} {}
\cs_new_nopar:Nn {\polyglossia@enable@local@marks:}
{
      \xpg@info{Option:~ localmarks}%
      \cs_gset_nopar:Nn \polyglossia@local@marks:n
      {%
         \def\xpg@tmp@lang{##1}%
         \DeclareRobustCommand\markboth[2]{%
            \begingroup
               \let\label\relax \let\index\relax \let\glossary\relax
               \unrestored@protected@xdef\@themark
               {%
                {\lowercase{\foreignlanguage{\xpg@tmp@lang}}{\protect\@@ensure@maindir{####1}}}%
                {\lowercase{\foreignlanguage{\xpg@tmp@lang}}{\protect\@@ensure@maindir{####2}}}%
               }%
               \@temptokena \expandafter{\@themark}%
               \mark{\the\@temptokena}%
            \endgroup
            \if@nobreak\ifvmode\nobreak\fi\fi%
         }%
         \DeclareRobustCommand\markright[1]{%
            \begingroup
               \let\label\relax \let\index\relax \let\glossary\relax
               \expandafter\@markright\@themark
               {\lowercase{\foreignlanguage{\xpg@tmp@lang}}{\protect\@@ensure@maindir{####1}}}%
               \@temptokena \expandafter{\@themark}%
               \mark{\the\@temptokena}%
            \endgroup
            \if@nobreak\ifvmode\nobreak\fi\fi%
         }%
% This part seems wrong (see #396 for explanation). Remove after a while.
%         \def\@markright####1####2####3{%
%            \@temptokena{\protect\@@ensure@maindir{####1}}%
%            \unrestored@protected@xdef\@themark{%
%               {\the\@temptokena}%
%               {\protect\@@ensure@maindir{####3}}%
%            }%
%         }%
      }%
}


% Easy way out – Arthur, 2012-08-01
\ifcsdef{newXeTeXintercharclass}{%
% to reset the intercharclass of a character to "normal"
\newXeTeXintercharclass\xpg@normalclass %TODO
}{}

%% when no patterns are available, we use \l@nohyphenation, assigned to 255
%%  (suggestion by Enrico Gregorio)
\str_case_e:nn{\c_sys_engine_str}{
  {luatex}
    {
      \@ifundefined{l@nohyphenation}
        {\chardef\l@nohyphenation=\directlua{
           tex.sprint(polyglossia.newloader_loaded_languages.nohyphenation)}\relax
        }
        {}
    }
  {xetex}
    {
      \@ifundefined{l@nohyphenation}{\chardef\l@nohyphenation=255 }{}
    }
}


%we call this macro when a gloss file is not found for a given language
\def\xpg@nogloss#1{%
   \xpg@warning{Neither~ file~ gloss-#1.ldf~ nor file~ gloss-#1.lde~ exists!\MessageBreak
   I~ will~ nevertheless~ try~ to~ use~ hyphenation~ patterns~ for~ #1.}%
  \PolyglossiaSetup{#1}{hyphenmins={2,3},hyphennames={#1},fontsetup=true}%
  % the above amounts to:
  %\ifcsundef{l@#1}%
  %  {\expandafter\adddialect\csname l@#1\endcsname\l@nohyphenation\relax}%
  %  {\setlocalhyphenmins{#1}{2}{3}}%
  %\csdef{#1@language}{\language=\csname l@#1\endcsname}%
}

\newcommand{\xpg@input}[1]{%
  % Store catcode of @ before making at letter
  \chardef\xpg@saved@at@catcode\catcode`\@
  \makeatletter
  \input{#1}%
  % restore former @ catcode
  \catcode`\@=\xpg@saved@at@catcode%
}

%% Load a lde file
\cs_new_nopar:Nn \__xpg_gloss_ext: {lde}
\cs_new_nopar:Ne \__xpg_saved_@pkgextension: {\@pkgextension}

\msg_new:nnn { polyglossia } { directloadgloss }
{
  You~ should~ not~ load~ directly~ the~ gloss~ file. ~
  You~ must~ use~ `\string\setotherlanguage\{#1\}' or  `\string\setmainlanguage\{#1\}'.
}
\msg_redirect_name:nnn { polyglossia } { directloadgloss } { critical }
\NewDocumentCommand{\__xpg_ProvidesLanguageDefinitionExtension_error}{m m m m}
{
  \msg_critical:nn { polyglossia } { directloadgloss }
}
% ProvideExplPackage but for language file
\cs_new_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension_error
\cs_new_eq:NN \__xpg_saved_ProvidesExplPackage \ProvidesExplPackage
\NewDocumentCommand{\__xpg_ProvidesLanguageDefinitionExtension}{m m m m}
{
  \__xpg_saved_ProvidesExplPackage{#1}{#2}{#3}{#4}
  \cs_gset_eq:NN \@pkgextension \__xpg_saved_@pkgextension:
  \cs_gset_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension_error
}


% wrapper for loading a gle file
\NewDocumentCommand{\RequireLanguageDefinitionExtension}{O{} m}
{
  \cs_gset_eq:NN \__xpg_saved_@pkgextension: \@pkgextension
  \cs_gset_eq:NN \__xpg_saved_ProvidesExplPackage \ProvidesExplPackage
  \cs_gset_eq:NN \@pkgextension \__xpg_gloss_ext:
  \cs_gset_eq:NN \ProvidesLanguageDefinitionExtension \__xpg_ProvidesLanguageDefinitionExtension
  \RequirePackage[#1]{gloss-#2}
  % be paranoiac restore
  \cs_gset_eq:NN \@pkgextension \__xpg_saved_@pkgextension:
  \cs_gset_eq:NN \__xpg_ProvidesLanguageDefinitionExtension_error \ProvideLanguageDefinitionExtension
}

% try to load a language file
\cs_new:Nn \polyglossia_load_lang_definition:nn {
  \file_if_exist:eTF{gloss-#2.lde}
  {
    \RequireLanguageDefinitionExtension[#1]{#2}
    \setkeys{#2}{#1}
  }
  {
    \file_if_exist:nTF{gloss-#2.ldf}
    {
      % Temporarily force catcode of ~ to 13 since babelsh.def
      % requires it. This is needed particularly with LaTeX3
      % packages which force \ExplSyntaxOn (#425)
      \protected\edef\xpg@restore@tilde@catcode{\catcode 126 = \the\catcode 126\relax}
      \catcode 126 = 13
      \xpg@input{gloss-#2.ldf}
      \setkeys{#2}{#1}
      % restore former ~ catcode
      \xpg@restore@tilde@catcode
    }
    {
      \xpg@nogloss{#2}
    }
  }
}
\cs_generate_variant:Nn \polyglossia_load_lang_definition:nn {
  ee, ef, en, eo, ex,
  fe, ff, fn, fo, fx,
  ne, nf,     no, nx,
  oe, of, on, oo, ox,
  xe, xf, xn, xo, xx
}

% load a master language from an alias file
\newcommand*\xpg@load@master@language[1] {
  \file_if_exist:eTF{gloss-#1.lde}
  {
    \RequireLanguageDefinitionExtension{#1}
  }
  {
    \xpg@input{gloss-#1.ldf}
  }
  \seq_if_in:NxF \__xpg_langs_loaded {#1}
  {
    % define environment and command if not alias
    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#1/target}} {#1} {
      \use:c{\prop_item:Nn{\polyglossia@langsetup}
                          {#1/DefineCommandsCmd}}
                          {#1}
      }
  }
  \polyglossia@register@language:nn{}{#1}%
  \seq_gput_right:Nn \__xpg_langs_loaded {#1}
}

\prop_new:N \__xpg_alias

% define environment and command if not alias
\cs_new:Nn \xpg_define_language_commands:n {
  \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#1/target}} {#1}
  {
    \exp_args:Ne
    \newenvironment {\prop_item:Nn{\polyglossia@langsetup}{#1/envname}} [1] []
    {
      \begin{otherlanguage}[##1]{#1}
    }%
    {
      \end{otherlanguage}
    }%
    \exp_args:Nc \newcommand {text#1} [2][]
    {%
      \__xpg_textlanguage:een{##1}{#1}{##2}%
    }%
  }
}
\cs_generate_variant:Nn \xpg_define_language_commands:n {e}

\AtBeginDocument{
  \prop_log:N{\__xpg_alias}
}

% resolve alias property #1 lang #2 item
\cs_new:Nn \xpg_alias_prop_item:nn {
  \prop_if_in:NeTF \__xpg_alias {#1/#2}
  {
    \prop_item:Ne \__xpg_alias {#1/#2}
  }
  {
    \prop_if_in:NeTF \__xpg_alias {#1/target}
    {
      % target to self fall back to language table
      \str_if_eq:eeTF { \prop_item:Ne \__xpg_alias {#1/target} } { #1 }
      {
        \prop_item:Nn{\polyglossia@langsetup} {#1/#2}
      }
      % load alias by recursion
      {
        \xpg_alias_prop_item:ee { \prop_item:Ne \__xpg_alias {#1/target} } {#2}
      }
    }
    {
      % empty
    }
  }
}
\cs_generate_variant:Nn \xpg_alias_prop_item:nn {en, ne, ee}

% add option #2 to list of option of language #1
\cs_new:Nn \xpg_alias_add_to_option_i:nn
{
  \tl_if_blank:eTF {#2}
  {
    \xpg_alias_prop_item:nn {#1}{options}
  }
  {
    \tl_if_blank:eTF { \xpg_alias_prop_item:nn {#1}{options} }
    {
      #2
    }
    {
      \xpg_alias_prop_item:nn {#1}{options},#2
    }
  }
}


% get base language
\cs_new:Nn \xpg_alias_base_lang:n {
  \str_if_eq:eeTF { \prop_item:Ne \__xpg_alias {#1/target} } { #1 }
  {
    #1
  }
  {
    \xpg_alias_base_lang:n {  \prop_item:Ne \__xpg_alias {#1/target} }
  }
}
\cs_generate_variant:Nn \xpg_alias_base_lang:n {e}

\keys_define:nn { polyglossia/alias }
{
  % babelname\l_tmpa_prop
  babelname .prop_put:N = \__xpg_language_alias_prop,
  % bcp47
  bcp47 .prop_put:N = \__xpg_language_alias_prop,
  % variant
  variant .prop_put:N = \__xpg_language_alias_prop,
}



% provide way to define alias environment and command
% #1 () variant
% #2 [] option (not yet without variant and bcp47 name)
% #3 language
% #4 () babel name
% #5 [] bcp47 name
% #6 alias
\DeclareDocumentCommand \xpg_language_alias { D(){} O{} m D(){} O{} m}
{
  \prop_gremove:Nn \__xpg_alias {#6/target}
  \prop_gremove:Nn \__xpg_alias {#6/options}
  \prop_gremove:Nn \__xpg_alias {#6/bcp47}
  \prop_gremove:Nn \__xpg_alias {#6/babelname}
  \prop_gremove:Nn \__xpg_alias {#6/variant}
  \prop_gput:Nee \__xpg_alias {#6/target} {#3}
  \tl_if_blank:eF {#1}
  {
    \prop_gput:Nee \__xpg_alias {#6/variant} {#1}
  }
  \tl_if_blank:eF {#5}
  {
    \prop_gput:Nee \__xpg_alias {#6/bcp47} {#5}
  }
  \tl_if_blank:eF {#4}
  {
    \prop_gput:Nee \__xpg_alias {#6/babelname} {#1}
  }
  \tl_if_blank:eF {#2}
  {
    \prop_gput:Nee \__xpg_alias {#6/options} {#2}
  }
}


% provide way to define alias environment and command
% \setlanguagealias[<options>]{<language>}{<alias>}
\DeclareDocumentCommand \setlanguagealias {s O{} m m}
{
  % The starred version does not define commands and environments
  \IfBooleanF {#1}
  {
    \exp_args:Nc \providecommand {text#4} [2][] {}
    \exp_args:Nc \renewcommand {text#4} [2][]
    {
      \__xpg_textlanguage:een{##1}{#4}{##2}
    }
    \exp_args:Nc \providecommand {#4} {}
    \exp_args:Ne  \renewenvironment {#4}
    {
      \begin{otherlanguage}{#4}
    }
    {
      \end{otherlanguage}
    }
  }%
  \tl_clear_new:N \__xpg_alias_option_tl
  \prop_clear_new:N \__xpg_language_alias_prop
  \keys_set_known:nnN{polyglossia/alias} {#2} \__xpg_alias_option_tl
  \xpg_language_alias
    (\prop_item:Nn \__xpg_language_alias_prop {variant})
    % TODO not yet [\__xpg_alias_option_tl]
    [#2]
    {#3}
    (\prop_item:Nn \__xpg_language_alias_prop {babelname})
    [\prop_item:Nn \__xpg_language_alias_prop {bcp47}]
    {#4}
}

\cs_new:Nn \polyglossia@register@language:nn {
  \clist_if_in:NeF \xpg@loaded {#2}{
    \clist_gput_right:Ne \xpg@loaded {#2}
  }
  % Register the language options
  \polyglossia@set@lang@options:nnn {#2} {#1} {@xpg@set@langvariant}
  % register babelname
  \prop_get:NeN \polyglossia@langsetup {#2/babelname} \l_tmpa_tl
  \clist_if_in:NeF \xpg@bloaded {\l_tmpa_tl}{
    \clist_gput_right:Ne \xpg@bloaded {\l_tmpa_tl}
  }
  % register BCP-47 ID
  \prop_get:NeN \polyglossia@langsetup {#2/bcp47} \l_tmpa_tl
  \clist_if_in:NeF \xpg@bcp@loaded {\l_tmpa_tl}{
    \clist_gput_right:Ne \xpg@bcp@loaded {\l_tmpa_tl}
  }
}

\DeclareDocumentCommand \setdefaultlanguage { O{} m }
{
  % latex is an internal language, so do not record
  \str_if_eq:eeF{#2}{latex}
  {
    \clist_if_in:NeF \xpg@loaded {\xpg_alias_base_lang:n{##2}}{
      \clist_gput_right:Ne \xpg@loaded {\xpg_alias_base_lang:n{##2}}
    }
  }
  \seq_if_in:NxF \__xpg_langs_loaded {#2}
  {
    \polyglossia_load_lang_definition:nn{#1}{#2}
    % define environment and command if not alias
    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#2/target}} {#2} {
       \use:c{\prop_item:Ne{\polyglossia@langsetup}
            {#2/DefineCommandsCmd}}
            {#2}
    }
    \exp_args:Nnx \seq_gput_right:Nn \__xpg_langs_loaded {#2}
  }
  \polyglossia@set@default@language:ee {\xpg_alias_add_to_option_i:nn{#2}{#1}}
    {\xpg_alias_base_lang:n{#2}}%
}


\cs_new:Nn \polyglossia@set@default@language:nn
{
  \gdef\xpg@main@language{#2}%
  \tl_if_blank:nTF {#1}
  {
    \cs_gset_nopar:Npn \mainlanguagevariant {}
  }
  {%
     % Register the language options
     \polyglossia@set@lang@options:nnn {#2} {#1} {@xpg@main@langvariant}%
  }%
  \csgdef{#2@gvar}{\mainlanguagevariant}%
  %% The following settings are for the default language and script
  % this tells bidi.sty or luabidi.sty that the document is RTL
  \__xpg_if_LR_str:eF{\prop_item:Nn{\polyglossia@langsetup}{#2/direction}}
  {
    \__xpg_setRTLmain:
  }
  \cs_gset_nopar:Nn \polyglossia@AtBeginDocument@selectlanguage: {
    \selectbackgroundlanguage{#2}
    \selectlanguage[#1]{#2}%
  }
  \xpg@info{Default~ language~ is~ #2}%
  \polyglossia@set@language@name[#1]{#2}%

  \cs_gset_nopar:Npn \mainlanguagename {#2}
  % Store babelname of main language (for external packages such as biblatex)
  \cs_gset_nopar:Npe \mainbabelname { \prop_item:Nn  \polyglossia@langsetup {#2/babelname} }
  % Store babelname of current language (for external packages such as biblatex)
  \cs_gset_eq:NN \babelname \mainbabelname
  \cs_gset_eq:cc{#2@gbabelname}{babelname}%
  % Store BCP-47 ID and subtags of main language:
  % 1. store main.* (sub)tags
  \cs_gset_nopar:cpe {bcp47.main.tag} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47 } }
  \cs_gset_nopar:cpe {bcp47.main.language} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47-language } }
  \cs_gset_nopar:cpe {bcp47.main.region} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47-region } }
  \cs_gset_nopar:cpe {bcp47.main.script} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47-script } }
  \cs_gset_nopar:cpe {bcp47.main.variant} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47-variant } }
  \cs_gset_nopar:cpe {bcp47.main.extension.t} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47extension-t } }
  \cs_gset_nopar:cpe {bcp47.main.extension.u} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47-extension-u } }
  \cs_gset_nopar:cpe {bcp47.main.extension.x} { \prop_item:Nn  \polyglossia@langsetup { #2 / bcp47-extension-x } }
  % For casing, we fall back to language if bcp47-casing is not explicitly set
  \cs_set_nopar:cpx {tmpcasing} { \prop_item:Ne \polyglossia@langsetup { #2 / bcp47-casing } }
  \str_if_empty:NTF \tmpcasing
           { \cs_gset_nopar:cpe {bcp47.main.casing} { \prop_item:Nn  \polyglossia@langsetup {#2 / bcp47-language} } }
           { \cs_gset_nopar:cpe {bcp47.main.casing} { \tmpcasing } }
  % 2. Store lang (sub)tags
  \cs_gset_eq:cc {bcp47.tag} {bcp47.main.tag}
  \cs_gset_eq:cc {bcp47.language} {bcp47.main.language}
  \cs_gset_eq:cc {bcp47.region} {bcp47.main.region}
  \cs_gset_eq:cc {bcp47.script} {bcp47.main.script}
  \cs_gset_eq:cc {bcp47.variant} {bcp47.main.variant}
  \cs_gset_eq:cc {bcp47.extension.t} {bcp47.main.extension.t}
  \cs_gset_eq:cc {bcp47.extension.u} {bcp47.main.extension.u}
  \cs_gset_eq:cc {bcp47.extension.x} {bcp47.main.extension.x}
  \cs_gset_eq:cc {bcp47.casing} {bcp47.main.casing}
  % 3. Store global language BCP47 settings (with default subtags as set by main language options)
  \cs_gset_eq:cc{#2@g.bcp47.tag}{bcp47.tag}
  \cs_gset_eq:cc{#2@g.bcp47.language}{bcp47.language}
  \cs_gset_eq:cc{#2@g.bcp47.region}{bcp47.region}
  \cs_gset_eq:cc{#2@g.bcp47.script}{bcp47.script}
  \cs_gset_eq:cc{#2@g.bcp47.variant}{bcp47.variant}
  \cs_gset_eq:cc{#2@g.bcp47.extension.t}{bcp47.extension.t}
  \cs_gset_eq:cc{#2@g.bcp47.extension.u}{bcp47.extension.u}
  \cs_gset_eq:cc{#2@g.bcp47.extension.x}{bcp47.extension.x}
  \cs_gset_eq:cc{#2@g.bcp47.casing}{bcp47.casing}
  % Set luatex main language
  \sys_if_engine_luatex:T
   {
     \directlua{polyglossia.set_default_language('\luatexluaescapestring{\string#2}')}%
   }
}
\cs_generate_variant:Nn\polyglossia@set@default@language:nn {
  ee, ef, en, eo, ex,
  fe, ff, fn, fo, fx,
  ne, nf,     no, nx,
  oe, of, on, oo, ox,
  xe, xf, xn, xo, xx
}

\let\setmainlanguage=\setdefaultlanguage

% Returns the language ID of the current language
% Currently supported: bcp-47
\DeclareDocumentCommand \languageid {m}
{
    \str_case:nnF {#1}
      {
        {bcp-47}    { \csuse{bcp47.tag} }
        {bcp47}     { \csuse{bcp47.tag} }
      }
      {
        \xpg@error{Invalid~ \string\languageid\space argument:~ #1}
      }
}

% Returns the language ID of the main language
% Currently supported: bcp-47
\DeclareDocumentCommand \mainlanguageid {m}
{
    \str_case:nnF {#1}
      {
        {bcp-47}    { \csuse{bcp47.main.tag} }
        {bcp47}     { \csuse{bcp47.main.tag} }
      }
      {
        \xpg@error{Invalid~ \string\mainlanguageid\space argument:~ #1}
      }
}
% Kernel command to access to BCP-47 data.
% Shared interface with babel.
% We support:
% * language (e.g., de)
% * region (e.g., AT)
% * script (e.g., Latn)
% * variant (e.g., 1901)
% * extension-t (transformation, e.g., en-t-ja)
% * extension-u (additional locale information, e.g., ar-u-nu-latn)
% * extension-x (e.g., classic for la-x-classic)
% * casing (whatever is suitable for \MakeUppercase and friends,
%           usually alias to language but could also be something
%           like el-x-iota or ckb-Latn)
% * tag (the registered full tag)
% and main.* variants thereof
% See https://github.com/latex3/latex2e/issues/1035
\DeclareExpandableDocumentCommand \BCPdata {m}
{
   \cs_if_exist_use:cF{bcp47.#1}
        { \xpg@error{Invalid~ \string\BCPdata\space argument:~ #1} }
}

% main babel name
\cs_new_nopar:Npn \mainlanguagename {}
\cs_new_nopar:Npn \mainbabelname {}
\cs_new_nopar:cpn {bcp47.main.tag} {}
\cs_new_nopar:cpn {bcp47.main.language} {}
\cs_new_nopar:cpn {bcp47.main.region} {}
\cs_new_nopar:cpn {bcp47.main.script} {}
\cs_new_nopar:cpn {bcp47.main.variant} {}
\cs_new_nopar:cpn {bcp47.main.extension.t} {}
\cs_new_nopar:cpn {bcp47.main.extension.u} {}
\cs_new_nopar:cpn {bcp47.main.extension.x} {}
\cs_new_nopar:cpn {bcp47.main.casing} {}
\cs_new_nopar:Npn \mainlanguagevariant {}%
% Store main language variant for external packages
\define@key{xpg@main@langvariant}{variant}{%
  \cs_gset_nopar:Npn \mainlanguagevariant {#1}%
}

\cs_new_nopar:Npn \babelname {}
\def\languagevariant{}%
% Store current language variant for external packages
\define@key{xpg@set@langvariant}{variant}{%
  \def\languagevariant{#1}%
}

\newcommand*\polyglossia@set@language@name[2][]{
  \def\languagename{#2}%
  \tl_if_blank:nTF {#1}{%
     \ifcsundef{#2@gvar}{\def\languagevariant{}}{\def\languagevariant{\csuse{#2@gvar}}}
   }{%
     % Register the language options
     \polyglossia@set@lang@options:nnn {#2} {#1} {@xpg@set@langvariant}%
     \cs_set_eq:cc{#2@gvar}{languagevariant}%
  }%
}


\newcommand*{\resetdefaultlanguage}[2][]{%
  \polyglossia@reset@default@language:nn
    {\xpg_alias_add_to_option_i:nn{#2}{#1}}
    {\xpg_alias_base_lang:n{#2}}%
}

\cs_new:Nn \__xpg_store_bcp_info:nn
{
  % Store BCP-47 ID and subtags of current language
  \tl_if_blank:nTF {#1}{%
    % tag (e.g., en-US)
    \ifcsundef{#2@g.bcp47.tag}{%
       \csedef{bcp47.tag}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47 } }%
    }{%
       \csedef{bcp47.tag}{\csuse{#2@g.bcp47.tag}}%
    }%
    % language (e.g., en)
    \ifcsundef{#2@g.bcp47.language}{%
       \csedef{bcp47.language}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-language } }%
    }{%
       \csedef{bcp47.language}{\csuse{#2@g.bcp47.language}}%
    }%
    % region (e.g., US)
    \ifcsundef{#2@g.bcp47.region}{%
       \csedef{bcp47.region}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-region } }%
    }{%
       \csedef{bcp47.region}{\csuse{#2@g.bcp47.region}}%
    }%
    % script (e.g., Latn)
    \ifcsundef{#2@g.bcp47.script}{%
       \csedef{bcp47.script}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-script } }%
    }{%
       \csedef{bcp47.script}{\csuse{#2@g.bcp47.script}}%
    }%
    % variant (e.g., 1996)
    \ifcsundef{#2@g.bcp47.variant}{%
       \csedef{bcp47.variant}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-variant } }%
    }{%
       \csedef{bcp47.variant}{\csuse{#2@g.bcp47.variant}}%
    }%
    % extension.t (tranformation)
    \ifcsundef{#2@g.bcp47.extension.t}{%
       \csedef{bcp47.extension.t}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-extension-t } }%
    }{%
       \csedef{bcp47.extension.t}{\csuse{#2@g.bcp47.extension.t}}%
    }%
    % extension.u (additional locale information)
    \ifcsundef{#2@g.bcp47.extension.u}{%
       \csedef{bcp47.extension.u}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-extension-u } }%
    }{%
       \csedef{bcp47.extension.u}{\csuse{#2@g.bcp47.extension.u}}%
    }%
    % extension.x (private use area)
    \ifcsundef{#2@g.bcp47.extension.x}{%
       \csedef{bcp47.extension.x}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-extension-x } }%
    }{%
       \csedef{bcp47.extension.x}{\csuse{#2@g.bcp47.extension.x}}%
    }%
    % casing
    \ifcsundef{#2@g.bcp47.casing}{%
       % For casing, we fall back to language if bcp47-casing is not explicitly set
       \cs_set_nopar:cpx {tmpcasing} { \prop_item:Ne \polyglossia@langsetup { #2 / bcp47-casing } }
       \str_if_empty:NTF \tmpcasing
           { \cs_gset_eq:cc {bcp47.casing} {bcp47.language} }
           { \csedef{bcp47.casing}{ \tmpcasing } }
    }{%
       \csedef{bcp47.casing}{\csuse{#2@g.bcp47.casing}}%
    }%
  }{%
    \csedef{bcp47.tag}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47 } }%
    \csedef{bcp47.language}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-language } }%
    \csedef{bcp47.region}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-region } }%
    \csedef{bcp47.script}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-script } }%
    \csedef{bcp47.variant}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-variant } }%
    \csedef{bcp47.extension.t}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-extension-t } }%
    \csedef{bcp47.extension.u}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-extension-u } }%
    \csedef{bcp47.extension.x}{ \prop_item:Nn{ \polyglossia@langsetup}{ #2 / bcp47-extension-x } }%
    % For casing, we fall back to language if bcp47-casing is not explicitly set
    \cs_set_nopar:cpx {tmpcasing} { \prop_item:Ne \polyglossia@langsetup { #2 / bcp47-casing } }
    \str_if_empty:NTF \tmpcasing
         { \cs_gset_eq:cc {bcp47.casing} {bcp47.language} }
         { \csedef{bcp47.casing}{ \tmpcasing } }
  }%
}

\cs_new:Nn \polyglossia@reset@default@language:nn
{
  \polyglossia@error@iflangnotloaded:n{#2}
  % disable globalnumbers of previously defined default language
  \csuse{no\xpg@main@language @globalnumbers}
  \csuse{noextras@\xpg@main@language}%
  % This is a hook for external packages which want to access variants
  % via babelname (such as biblatex)
  \cs_if_exist_use:c{noextras@bbl@\mainbabelname}%
  \csuse{init@noextras@\xpg@main@language}%
  \polyglossia@set@language@name[#1]{#2}%
  \__xpg_if_LR_str:eF{\prop_item:Ne{\polyglossia@langsetup}{#2/direction}}
  {
    \@rlmaintrue\@rl@footnotetrue
  }
  \selectlanguage[#1]{#2}%
  \selectbackgroundlanguage{#2}%
  % Store babelname of current language (for external packages such as biblatex)
  \tl_if_blank:nTF {#1}{%
    \ifcsundef{#2@gbabelname}{%
       \edef\babelname{\prop_item:Nn{\polyglossia@langsetup}{#2/babelname}}%
    }{%
       \edef\babelname{\csuse{#2@gbabelname}}%
    }%
  }{%
    \edef\babelname{\prop_item:Nn{\polyglossia@langsetup}{#2/babelname}}%
  }%
  % Store BCP-47 id of current language
  \__xpg_store_bcp_info:nn {#1}{#2}
}
\cs_generate_variant:Nn \polyglossia@reset@default@language:nn {
  ee, ef, en, eo, ex,
  fe, ff, fn, fo, fx,
  ne, nf,     no, nx,
  oe, of, on, oo, ox,
  xe, xf, xn, xo, xx
}

% This saves the normalfont for the latin script since we may change normalfont in other scripts
\let\normalfontlatin=\normalfont%

% Provide default fonts (as set with \setmainfont, \setsansfont and \setmonofont)
% for Latin scripts and as a fallback for non-Latin scripts.
\DeclareRobustCommand\xpg@defaultfont@rm{%
   \tl_if_empty:NF{\g__fontspec_nfss_enc_tl}{\fontencoding{\g__fontspec_nfss_enc_tl}}%
   \fontfamily\rmdefault%
   \ifdefined\UseHook\UseHook{rmfamily}\fi%
   \selectfont%
}
\DeclareRobustCommand\xpg@defaultfont@sf{%
   \tl_if_empty:NF{\g__fontspec_nfss_enc_tl}{\fontencoding{\g__fontspec_nfss_enc_tl}}%
   \fontfamily\sfdefault%
   \ifdefined\UseHook\UseHook{sffamily}\fi%
   \selectfont%
}
\DeclareRobustCommand\xpg@defaultfont@tt{%
   \tl_if_empty:NF{\g__fontspec_nfss_enc_tl}{\fontencoding{\g__fontspec_nfss_enc_tl}}%
   \fontfamily\ttdefault%
   \ifdefined\UseHook\UseHook{ttfamily}\fi%
   \selectfont%
}

\def\xpg@patch@fontfamilies{%
  % This robustifies the redefinitions of \<xx>family (suggestion by Enrico Gregorio)
  % e.g. to prevent expansion of the \familytype redefinition in auxiliary files
  \csgappto{rmfamily~}{\def\familytype{rm}}
  \csgappto{sffamily~}{\def\familytype{sf}}
  \csgappto{ttfamily~}{\def\familytype{tt}}
}

% These switches activate the default fonts
% Note that a simple \let\rmfamilylatin=\rmfamily
% does not work reliably (see #24)
\cs_gset_eq:cc{rmfamilylatin}{xpg@defaultfont@rm}%
\cs_gset_eq:cc{sffamilylatin}{xpg@defaultfont@sf}%
\cs_gset_eq:cc{ttfamilylatin}{xpg@defaultfont@tt}%

\def\xpg@set@familydefault{%
  % We need the \edef route here in order
  % to detect both \renewcommand and \let
  % changes.
  \edef\tempa{\familydefault}%
  \edef\tempb{\sfdefault}%
  \ifcsequal{tempa}{tempb}%
     {\def\familytype{sf}}
     {\edef\tempb{\ttdefault}%
      \ifcsequal{tempa}{tempb}%
         {\def\familytype{tt}}
         {\def\familytype{rm}}}
  \xpg@patch@fontfamilies%
  % This (re-)saves the normalfont for the latin script since we may
  % change normalfont in other scripts
  \let\normalfontlatin=\normalfont%
  % And for all cases, we also reset \<xx>familylatin
  \cs_gset_eq:cc{rmfamilylatin}{xpg@defaultfont@rm}%
  \cs_gset_eq:cc{sffamilylatin}{xpg@defaultfont@sf}%
  \cs_gset_eq:cc{ttfamilylatin}{xpg@defaultfont@tt}%
}

\def\resetfontlatin{%
  \DeclareRobustCommand\rmfamily{\xpg@defaultfont@rm}%
  \DeclareRobustCommand\sffamily{\xpg@defaultfont@sf}%
  \DeclareRobustCommand\ttfamily{\xpg@defaultfont@tt}%
  \xpg@patch@fontfamilies%
  \global\let\normalfont=\normalfontlatin%
}

\def\selectfontfamilylatin{%
  \def\tmp@tt{tt}\def\tmp@sf{sf}%
  \ifx\familytype\tmp@tt%
    \ttfamilylatin%
    \else\ifx\familytype\tmp@sf%
      \sffamilylatin%
      \else\rmfamilylatin\fi\fi}

\def\xpg@select@fontfamily#1{%
  \def\tmp@tt{tt}\def\tmp@sf{sf}%
  \ifx\familytype\tmp@tt
    \__xpg_use_or_warn:c{#1@font@tt}%
  \else\ifx\familytype\tmp@sf
    \__xpg_use_or_warn:c{#1@font@sf}%
      \else\__xpg_use_or_warn:c{#1@font@rm}\fi\fi}

\def\xpg@set@normalfont#1{%
  \letcs{\rmfamily}{#1@font@rm}%
  \letcs{\sffamily}{#1@font@sf}%
  \letcs{\ttfamily}{#1@font@tt}%
  \robustify\rmfamily%
  \robustify\sffamily%
  \robustify\ttfamily%
  \gdef\normalfont{\protect\xpg@select@fontfamily{#1}%
                   \fontseries{\seriesdefault}\selectfont%
                   \fontshape{\shapedefault}
                   \ifdefined\UseHook\UseHook{normalfont}\fi%
                   \selectfont}%
  \gdef\reset@font{\protect\normalfont}%
}

\let\@@fterindentfalse\@afterindentfalse
\def\french@indent{%
    \let\@afterindentfalse\@afterindenttrue
    \@afterindenttrue%
}
\def\nofrench@indent{%
    \let\@afterindentfalse\@@fterindentfalse
    \@afterindentfalse%
}

\cs_new_nopar:Npn \selectbackgroundlanguage #1
{%
  \polyglossia@select@background@language:n {\xpg_alias_base_lang:n{#1}}
}
\cs_new:Nn \polyglossia@select@background@language:n
{
  \str_if_eq:eeTF{\prop_item:Nn{\polyglossia@langsetup}{#1/lcscript}}{latin}
                   {}
                   {\xpg@set@normalfont{#1}}%
  \csuse{#1@globalnumbers}%
}
\cs_generate_variant:Nn \polyglossia@select@background@language:n {e}
%  Declare secondary language #2 with language options #1
\DeclareDocumentCommand \setotherlanguage { O{} m }
{
  \seq_if_in:NxF \__xpg_langs_loaded {#2}
  {
    \polyglossia_load_lang_definition:ee {#1} {#2}%
    % define environment and command if not alias
    \str_if_eq:eeT {\prop_item:Ne \__xpg_alias {#2/target}} {#2} {
       \use:c{\prop_item:Ne{\polyglossia@langsetup}
             {#2/DefineCommandsCmd}}
             {#2}
    }
    \polyglossia@set@other@language:ee {\xpg_alias_add_to_option_i:nn{#2}{#1}}
      {\xpg_alias_base_lang:n{#2}}%
    \exp_args:Nnx \seq_gput_right:Nn \__xpg_langs_loaded {#2}
  }
}

\cs_new:Nn \polyglossia@set@other@language:nn
{
  \polyglossia@register@language:nn{#1}{#2}%
  % If a variant is set, store it.
  \gdef\otherlanguagevariant{}
  % Register the language options
  \polyglossia@set@lang@options:nnn {#2} {#1} {@xpg@other@langvariant}%

  \csgdef{#2@gvar}{\otherlanguagevariant}%
  \prop_get:NxNT \polyglossia@langsetup {#2/babelname} \l_tmpa_tl
    { \xdef\otherlanguagebabelname{\l_tmpa_tl} }
  \cs_gset_eq:cc{#2@gbabelname}{otherlanguagebabelname}%
}
\cs_generate_variant:Nn  \polyglossia@set@other@language:nn {
  ee, ef, en, eo, ex,
  fe, ff, fn, fo, fx,
  ne, nf,     no, nx,
  oe, of, on, oo, ox,
  xe, xf, xn, xo, xx
}


% Store main language variant for external packages
\define@key{xpg@other@langvariant}{variant}{%
  \gdef\otherlanguagevariant{#1}%
}

\newcommand\setotherlanguages[1]{%
  \def\do##1{\setotherlanguage{##1}}%
   \exp_args:Nx\docsvlist{#1}}%

\def\common@language{% FIXME is this really needed???
  \ifbool{xpg@hyphenation@disabled}{%
    \xdef\xpg@lastlanguage{\z@}%
  }{%
    \language=\z@
  }%
  \lefthyphenmin=\tw@
  \righthyphenmin=\thr@@}

\def\xpg@initial@setup{%
  \common@language%
}


% Alias to \text<lang>, but more suitable
% for specific (esp. tag-based) aliases
% where \text<alias> would cause clashes
% (e.g., \textit)
\newcommand\textlang[3][]{%
  \xpg@str@lowercase{\xpg@tmp@lang}{#2}%
  \__xpg_textlanguage:een {#1} {\xpg@tmp@lang} {#3}
}%

% Alias to {<lang>}, but more suitable
% for specific (esp. tag-based) aliases
% where {<alias>} would cause clashes
% (e.g., \fi)
\newenvironment{lang}[2][]{%
  \begin{otherlanguage}[#1]{#2}%
}{%
  \end{otherlanguage}
}%

\providecommand{\foreignlanguage}{}

% wrapper for foreignlanguage and otherlanguage*
\newcommand*\polyglossia@setforeignlanguage[2][]{
  \select@@language[#1]{#2}
  \polyglossia@register@language:nn{#1}{#2}%
  % Store babelname of current language (for external packages such as biblatex)
  \tl_if_blank:nTF {#1}{%
    \ifcsundef{#2@gbabelname}{%
       \edef\babelname{\prop_item:Nn{\polyglossia@langsetup}{#2/babelname}}%
    }{%
       \edef\babelname{\csuse{#2@gbabelname}}%
    }%
  }{%
    \edef\babelname{\prop_item:Nn{\polyglossia@langsetup}{#2/babelname}}%
  }%
  % Store BCP-47 id of current language
  \__xpg_store_bcp_info:nn {#1}{#2}
}

% Expandable lowercasing. We use this to assure keyval
% options are lowercased (also when used in \MakeUppercase
% contexts e.g. in headings)
% Macro adapted from tudscr.sty
\newcommand*\xpg@str@lowercase[2]{%
  \protected@edef#1{%
    \lowercase{\def\noexpand#1{#2}}%
  }#1%
}

% lowercase options before passing to setkeys
\cs_new:Nn \polyglossia@set@keys:nn
{
    \xpg@str@lowercase{\xpg@tmp@opts}{#2}%
    \exp_args:Nne \setkeys{#1}{\xpg@tmp@opts}%
}

% joint code of \foreignlanguage, otherlanguage*
% and \text<lang>
% #1 option
% #2 language
\newcommand{\xpg@otherlanguage}[2][]
{%
  \polyglossia@error@iflangnotloaded:n{#2}
  \polyglossia@set@keys:nn{#2}{#1}%
  \polyglossia@setforeignlanguage[#1]{#2}
  % Hook for external packages such as biblatex
  \polyglossia@language@switched%
  % buggy restoration heure
  \csuse{inlineextras@#2}%
  % This is a hook for external packages which want to access variants
  % via babelname (such as biblatex)
  \cs_if_exist_use:c{inlineextras@bbl@\babelname}%
}

\renewcommand{\foreignlanguage}[3][]
{
  \__xpg_foreignlanguage:eeen {#1} {#2} {\xpg_alias_base_lang:n{#2}} {#3}
}

% Direct access to polyglossia@setforeignlanguage
% used in captions
\newcommand{\setforeignlanguage}[2][]
{
  \polyglossia@setforeignlanguage[#1]{#2}%
}

% internal wrapper for foreign language
% #1 option
% #2 alias
% #3 base lang
% #4 text
\cs_new:Nn \__xpg_foreignlanguage:nnnn
{
  \tl_if_blank:nTF {#3}
  {
    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
  }{
    \group_begin:
      \xpg@otherlanguage[\xpg_alias_add_to_option_i:nn{#2}{#1}]{#3}%
      \polyglossia@lang@settextdirection:nn{#3}{#4}%
    \group_end:
  }
}
\cs_generate_variant:Nn \__xpg_foreignlanguage:nnnn {eeen}


% otherlanguage* is the environment equivalent of \foreignlanguage
\expandafter\providecommand\csname otherlanguage*\endcsname{}

\renewenvironment{otherlanguage*}[2][]
{%
  \__xpg_otherlanguage:eee {#1} {#2} {\xpg_alias_base_lang:n{#2}}
}
{\egroup}

% internal wrapper
% #1 option
% #2 alias
% #3 base lang
\cs_new:Nn \__xpg_otherlanguage:nnn
{
  \tl_if_blank:nTF {#3}
  {
    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
  }{
    \xpg@otherlanguage[\xpg_alias_add_to_option_i:nn{#2}{#1}]{#3}%
    \polyglossia@lang@settextdirection:nn{#3}%
    \bgroup
  }
}
\cs_generate_variant:Nn \__xpg_otherlanguage:nnn {
  eee
}

% use by \text<lang> and \textlang. Equivalent to \foreignlanguage,
% except that dates are localized.
% #1: option
% #2: alias
% #3: text
\cs_new:Nn \__xpg_textlanguage:nnn
{
  \__xpg_textlanguage:nnen {#1} {#2} {\xpg_alias_base_lang:n{#2}} {#3}
}
\cs_generate_variant:Nn \__xpg_textlanguage:nnn {een}

% Track whether we are in an inline lang (\text...) switch
\bool_new:N \__xpg_inline_lang

% use by \text<lang> and \textlang. Equivalent to \foreignlanguage,
% except that dates are localized.
% #1: option
% #2: alias
% #3: base language
% #4: text
\cs_new:Nn \__xpg_textlanguage:nnnn
{
  \tl_if_blank:nTF {#3}
  {
    \msg_show:nnn { polyglossia } { languagenotloaded } {#2}
  }
  {
    \group_begin:
      \bool_set_true:N \__xpg_inline_lang
      \xpg@otherlanguage[#1]{#3}%
      \csuse{date#3}%
      % This is a hook for external packages which want to access variants
      % via babelname (such as biblatex)
      \cs_if_exist_use:c{date@bbl@\babelname}%
      \polyglossia@lang@settextdirection:nn{#3}{#4}%
    \group_end:
    % Reset the language's/script's font families if the embedding script is latin
    \str_if_eq:eeTF{\prop_item:Ne{\polyglossia@langsetup}{\languagename/lcscript}}{latin}{\resetfontlatin}{}%
  }
}
\cs_generate_variant:Nn \__xpg_textlanguage:nnnn {nnen}

% Define language-specific hyphenation exceptions
\newcommand\pghyphenation[3][]{
  \bgroup
  \polyglossia@error@iflangnotloaded:n{#2}
  \setkeys{#2}{#1}%
  \select@@language[#1]{#2}%
  \hyphenation{#3}%
  \egroup
}


% Hook that other package authors can use
% (for instance biblatex):
\newcommand*{\xpg@hook@setlanguage}{}

\def\xpg@pop@language@i#1#2{%
  \xpg@set@language@aux[#1]{#2}%
  \xpg@hook@setlanguage
  \let\emp@langname\@undefined}

\newif\ifxpginauxfile\xpginauxfilefalse

\DeclareDocumentCommand \selectlanguage {s O{} m}
{
  \tl_if_blank:eTF {\xpg_alias_base_lang:n{#3}}
  {
    \ifxpginauxfile
      \msg_show:nnn { polyglossia } { languagenolongerloaded } {#3}
    \else
      \msg_show:nnn { polyglossia } { languagenotloaded } {#3}
    \fi
  }
  {
    \polyglossia@select@language:nee {#1}
      {\xpg_alias_add_to_option_i:nn{#3}{#2}}
      {\xpg_alias_base_lang:n{#3}}
  }
}

\cs_new:Nn \polyglossia@select@language:nnn
{
  \IfBooleanF {#1}
  {
    \cs_set_nopar:Npx \xpg@pop@language { \exp_not:N \xpg@pop@language@i {#2} {#3} }
    \group_insert_after:N \xpg@pop@language
  }
  % Register the language options
  \polyglossia@set@lang@options:nnn {#3} {#2} {@xpg@set@langvariant}%
  % The starred variant does not write to the aux
  \IfBooleanTF#1{%
    \xpg@set@language@nonaux[#2]{#3}%
  }
  {%
    \xpg@set@language@aux[#2]{#3}%
  }%
  \sys_if_engine_luatex:T
  {
    \directlua{polyglossia.select_language('\luatexluaescapestring{\string#3}',
      \the\csname l@#3\endcsname)}%
  }
  \polyglossia@register@language:nn{#2}{#3}%
}
\cs_generate_variant:Nn \polyglossia@select@language:nnn {
 nee, nne
}


% set lang option #2 for lang #1
\cs_new:Nn \polyglossia@set@lang@options:nnn
{
  \tl_if_blank:nF {#2}
  {
    % If the optional argument sets a value for the key “variant”, copy it to xpg@langvariant
    \clist_map_inline:nn { #2 } {%
      \xpg@parsevariantkeyvalue##1=#3:#1\relax
    }%
    \polyglossia@set@keys:nn{#1}{#2}%
  }
}

% Initialize default language options, so that
% \iflanguageoption has the info it needs also
% for default settings
\newcommand*\xpg@initialize@gloss@options[2]{%
   \polyglossia@set@lang@options:nnn {#1} {#2} {@xpg@set@langvariant}%
}

% Record synonymous keyvals such as variant=us and variant=american
% Syntax: \xpg@set@alias@values{<lang>}{<key>}{<val>}{<alias vals, comma-separated>}
\newcommand*\xpg@set@alias@values[4]{%
   \prop_if_exist:cF { xpg@alias@keyvals@#1@#3 }
      { \prop_new:c {xpg@alias@keyvals@#1@#3} }
   \prop_put:cnn { xpg@alias@keyvals@#1@#3 }
      {#2}{#4}
   \prop_put:cnn { xpg@alias@keyvals@#1@#4 }
      {#2}{#3}
}

% Patch xkeyval to record default values of keys
\pretocmd{\XKV@define@default}{%
   \csgdef{xpg@default@opt@\XKV@header #1}{#2}%
}{}{\xpg@warning{Patching xkeyval failed!}}

% Helper to get and register option keyvals
\def\xpg@parsevariantkeyvalue#1=#2@#3:#4\relax{%
   \def\@tmpa{#1}
   \def\@tmpb{variant}
   % variant values are stored in specific macros
   % (\xpg@main@langvariant, \xpg@other@langvariant
   % and \xpg@set@langvariant)
   \ifx\@tmpa\@tmpb\setkeys{#3}{#1=#2}\fi
   \tl_if_empty:nTF{#2}
      {
        \ifcsdef{xpg@default@opt@KV@#4@#1}%
           {\xpg@store@opt@keyval#1:\csuse{xpg@default@opt@KV@#4@#1}=:#4\relax}%
           {}%
      }
      { \xpg@store@opt@keyval#1:#2:#4\relax }
}%

% Store option keys and values
% This strips trailing '=' from values.
\def\xpg@store@opt@keyval#1:#2=:#3\relax{%
   \prop_if_exist:cF { xpg@current@options@#3 }
      { \prop_new:c {xpg@current@options@#3} }
   \prop_put:cnn { xpg@current@options@#3 }
      {#1}{#2}
}


\prg_set_conditional:Npnn \polyglossia@check@option@value:NNN #1#2#3 { p , T , F , TF }
{
  \prop_get:cnNTF {xpg@current@options@#1} {#2} \l_tmpa_tl
     {
       \str_if_eq:eeTF{\l_tmpa_tl}{#3}
          {\prg_return_true:}
          {
            \prop_get:cnNTF {xpg@alias@keyvals@#1@#3} {#2} \l_tmpb_tl
               {
                \clist_set:Ne{\l_tmpa_clist}{\l_tmpb_tl}
                \providetoggle{xpgvalfound}
                \togglefalse{xpgvalfound}
                \clist_map_inline:Nn \l_tmpa_clist {
                   \str_if_eq:eeT{##1}{\l_tmpa_tl}
                      { \toggletrue{xpgvalfound} }
                }
                \iftoggle{xpgvalfound}{\prg_return_true:}{\prg_return_false:}
              }
              {
                \prg_return_false:
              }
         }
     }
     {
       \prg_return_false:
     }
}

% Test if option value is set
\newcommand*\iflanguageoption[5]{%
  \polyglossia@check@option@value:NNNTF{#1}{#2}{#3}{#4}{#5}%
}


% Append any variant to csv list of variants
\define@key{xpg@langvariant}{variant}{%
  \clist_if_in:NeF \xpg@vloaded {#1}{
    \clist_gput_right:Ne \xpg@vloaded {#1}
  }
}

% Test if language is loaded
\newcommand*\iflanguageloaded[3]{%
   \AddToHook{begindocument/end}{%
     \clist_if_in:NeTF \xpg@loaded{#1}{#2}{#3}%
   }%
}

% Same for babellanguage is loaded
\newcommand*\ifbabellanguageloaded[3]{%
  \AddToHook{begindocument/end}{%
     \clist_if_in:NeTF \xpg@bloaded{#1}{#2}{#3}%
  }%
}

% Same for languageid
\DeclareDocumentCommand \iflanguageidloaded {mmmm}
{
  \AddToHook{begindocument/end}{%
    \str_case:nnTF {#1}
      {
        {bcp-47}    { \clist_if_in:NeTF \xpg@bcp@loaded{#2}{#3}{#4} }
        {bcp47}     { \clist_if_in:NeTF \xpg@bcp@loaded{#2}{#3}{#4} }
      }
      {}
      {
        \xpg@error{Invalid~ \string\iflanguageidloaded\space argument:~ #1}
      }
   }%
}

% Check if the current font has a given glyph
\prg_set_conditional:Npnn \polyglossia@check@if@char@available:N #1 { p , T , F , TF }
{
  \str_case_e:nnF{\c_sys_engine_str}{
    {luatex}{
             \int_compare:nNnTF { \directlua{polyglossia.check_char(0x#1)} } > { 0 }
                {\prg_return_true:}
                {\prg_return_false:}
            }
    {xetex}{
             \int_compare:nNnTF { \the\XeTeXcharglyph"#1 } > { 0 }
                {\prg_return_true:}
                {\prg_return_false:}
           }
  }
  {
    \xpg@warning{You’re ~ running ~ a ~ TeX engine ~ that ~ is ~
      not ~ LuaTeX ~ or ~ XeTeX.\MessageBreak
      That~ is~ almost~ guaranteed~ to~ cause~ problems.}
    \prg_return_false:
  }
}

% Test if a char (by char code) is available in the current font
\newcommand*\xpg@if@char@available[3]{%
  \polyglossia@check@if@char@available:NTF{#1}{#2}{#3}%
}

\newcommand*\charifavailable[2]{%
   \xpg@if@char@available{#1}{\char"#1}{#2}%
}


\newcommand*{\xpg@set@language@nonaux}[2][]{%
   \@select@language[#1]{#2}%
}


\newcommand*{\xpg@set@language@aux}[2][]{%
   % Store babelname of current language (for external packages such as biblatex)
   \tl_if_blank:nTF {#1}{%
     \ifcsundef{#2@gbabelname}{%
        \edef\babelname{\prop_item:Nn{\polyglossia@langsetup}{#2/babelname}}%
     }{%
        \edef\babelname{\csuse{#2@gbabelname}}%
     }%
   }{%
     \edef\babelname{\prop_item:Nn{\polyglossia@langsetup}{#2/babelname}}%
   }%
   % Store BCP-47 id of current language
   \__xpg_store_bcp_info:nn {#1}{#2}%
   \@select@language[#1]{#2}%
    % Write to the aux
   \xpg@set@language@only@aux[#1]{#2}%
}

\newcommand*{\xpg@set@language@only@aux}[2][]{%
    % Write to the aux (toc files)
   \if@filesw%
      \ifx#1\\\\%
          \addtocontents{toc}{\protect\selectlanguage*{#2}}%
       \else
          \addtocontents{toc}{\protect\selectlanguage*[#1]{#2}}%
       \fi
   \fi
}

\AtBeginDocument{%
   % Tell polyglossia that we are in an aux file
   \if@filesw%
      \addtocontents{toc}{\protect\xpginauxfiletrue}%
      \addtocontents{lof}{\protect\xpginauxfiletrue}%
      \addtocontents{lot}{\protect\xpginauxfiletrue}%
   \fi%
}

\AtEndDocument{%
   % Tell polyglossia that we are no longer in an aux file
   \if@filesw%
      \addtocontents{toc}{\protect\xpginauxfilefalse}%
      \addtocontents{lof}{\protect\xpginauxfilefalse}%
      \addtocontents{lot}{\protect\xpginauxfilefalse}%
   \fi%
}

% Since captions might float to other language regions,
% we need to change the language here (#542)
\AddToHook{cmd/caption/before}{%
    \ifhmode\unskip\fi%
    \addtocontents{lof}{\protect\setforeignlanguage{\languagename}}%
    \addtocontents{lot}{\protect\setforeignlanguage{\languagename}}%
}

% The bidi package swaps the output stream within RTL tables
% (to get the column order right). This also swaps group
% delimiters inserted to the aux files via otherlanguage (see #354).
% We therefore patch bidi and insert a bool that tells us
% whether we are in such a table.
\newbool{xpg@inbiditable}
\AtBeginDocument{%
  \@ifpackageloaded{bidi}{%
     \patchcmd{\@tabular}%
               {\if@RTLtab}%
               {\if@RTLtab\booltrue{xpg@inbiditable}}%
               {}% success
               {\xpg@warning{Patching bidi table failed!}}%
  }{}%
}

% check if language is defined
\prg_set_conditional:Npnn \__xpg_check_if_exist_l@:N #1 { p , T , F , TF }{
  \cs_if_exist:cTF {l@#1}
    {
      \cs_if_eq:cNTF {l@#1} \l@nohyphenation
        {
          \prg_return_false:
        }
        {
          % it's possible that sometimes \csname l@#1\endcsname becomes \relax
          \cs_if_eq:cNTF {l@#1} \relax
            { \prg_return_false: }
            { \prg_return_true: }
        }
    }
    {
      \prg_return_false:
    }
}

\def\polyglossia@luatex@load@lang#1{%
  % if \l@#1 is not properly defined, call lua function newloader(#1),
  % and assign the returned number to \l@#1
  \__xpg_check_if_exist_l@:NF {#1}
  {
    \expandafter\chardef\csname l@#1\endcsname=
    \directlua{ tex.sprint(polyglossia.newloader'#1') }\relax
  }
}

% This check is also used by biblatex, so don't
% rename silently.
\newcommand\xpg@ifdefined[3]{%
  % With luatex, we first need to define \l@#1.
  \sys_if_engine_luatex:T
  {
    \polyglossia@luatex@load@lang{#1}%
  }
  \__xpg_check_if_exist_l@:NTF{#1}{#2}{#3}%
}%

% Set \bbl@hyphendata@\the\language, which is (lua)babel's
% hyphenation pattern hook
% FIXME Clarifiy why/when this is needed.
\newcommand*\xpg@set@bbl@hyphendata[1]{%
  \sys_if_engine_luatex:T
  {
    \ifcsdef{bbl@hyphendata@#1}{}{%
      \global\@namedef{bbl@hyphendata@\the\language}{}%
    }%
  }
}

% Set hyphenation patterns for a given language. This does the right
% thing both for XeTeX and LuaTeX
\newcommand*\xpg@set@hyphenation@patterns[1]{%
  \str_case_e:nnF{\c_sys_engine_str}{
      {luatex}
        {
          \polyglossia@luatex@load@lang{#1}%
          \language=\csname l@#1\endcsname
        }
      {xetex}
        {
          \language=\csname l@#1\endcsname
        }
    }
    {
      \xpg@warning{You’re~running~a~TeX~engine~that~is~not~LuaTeX~or~XeTeX.\MessageBreak
        That~is~almost~guaranteed~to~cause~problems.}%
    }
}


\newcommand*\@select@language[2][]{
   % hook for compatibility with biblatex
   \select@language{#2}
   \xpg@set@bbl@hyphendata{\the\language}
   \xpg@initial@setup%
   \select@@language[#1]{#2}%
   % Hook for external packages such as biblatex
   \polyglossia@language@switched%
   \polyglossia@lang@setpardirection:n{#2}%
   \csuse{captions#2}%
   \csuse{date#2}%
   % These are hooks for external packages which want to access variants
   % via babelname (such as biblatex)
   \cs_if_exist_use:c{captions@bbl@\babelname}%
   \cs_if_exist_use:c{date@bbl@\babelname}%
   \polyglossia@local@marks:n{#2}%
   \csuse{init@extras@#2}%
   \polyglossia@lang@indentfirst:n{#2}%
   \csuse{blockextras@#2}%
   % This is a hook for external packages which want to access variants
   % via babelname (such as biblatex)
   \cs_if_exist_use:c{blockextras@bbl@\babelname}%
 }

% hook for compatibility with biblatex
% (probably no longer used due to the
%  more general hook that follows, but
%  we keep it for backwards comp.)
\def\select@language#1{}

% Hook for external packages such as biblatex
\def\polyglossia@language@switched{}

% remove all custumization for language #1
\cs_new:Npn \noextrascurrent #1
{%
  \cs_if_exist_use:c{noextras@#1}%
  % This is a hook for external packages which want to access variants
  % via babelname (such as biblatex)
  \cs_if_exist_use:c{noextras@bbl@\babelname}
}

% Common code for `\select@language' and `\foreignlanguage'.
\newcommand{\select@@language}[2][]{%
  % disable the extras and number settings of the previous language
  \cs_if_exist:cT{languagename}
  {%
    \noextrascurrent{\languagename}%
    \cs_if_exist_use:c{no\languagename @numbers}%
    \sys_if_engine_xetex:T{
      \__xpg_if_LR_str:eTF{\prop_item:Ne{\polyglossia@langsetup}{\languagename/direction}}
      {
        \__xpg_if_LR_str:eF{\prop_item:Nn{\polyglossia@langsetup}{#2/direction}}
          {\setnonlatin}% LTR -> RTL
      }%
      {%
        \__xpg_if_LR_str:eT{\prop_item:Nn{\polyglossia@langsetup}{#2/direction}}
          {\setlatin}% RTL -> LTR
      }
    }
  }%
  \polyglossia@set@language@name[#1]{#2}%
  % Set the language's/script's font families
  \str_if_eq:eeT{\prop_item:Nn{\polyglossia@langsetup}{#2/lcscript}} {latin}
  {
    \resetfontlatin
  }
  \bool_if:NF \__xpg_inline_lang
  { % This for non-inline font switches
    % in case a \<lang>font is defined
    \xpg@set@normalfont{#2}%
  }
  \xpg@select@fontfamily{#2}%
  \__xpg_use_or_warn:c{#2@language}%
  \cs_if_exist_use:c{#2@numbers}%
  \use@localhyphenmins[#1]{#2}%
  \polyglossia@lang@frenchspacing:n{#2}
}


\let\xpg@pop@language\relax

\provideenvironment{otherlanguage}{}{}

%
% Keep track of the active (nested) languages and options
%
\clist_new:N \l_xpg_lang_stack

\cs_new:Nn \polyglossia@stack@language:nn
{
  \clist_gpush:Nn \l_xpg_lang_stack {#1:#2}
}

\cs_generate_variant:Nn \polyglossia@stack@language:nn {nx}

\cs_generate_variant:Nn \seq_set_split:Nnn {Nnx}

\cs_new:Nn \polyglossia@unstack@language:n
{
  \clist_gpop:NNTF \l_xpg_lang_stack \l_tmpa_tl {
     % Stored format = options:language => split:
     \seq_set_split:Nnx \l_tmpa_seq {:} \l_tmpa_tl
     \seq_get_left:NN \l_tmpa_seq \l_tmpb_tl
     \seq_get_right:NN \l_tmpa_seq \l_tmpc_tl
     % Execute passed command with language and maybe options
     % and re-set stored language's keys
     \tl_if_empty:NTF \l_tmpb_tl {\cs_if_exist_use:c{#1}{\l_tmpc_tl}}
                                 {\polyglossia@set@keys:nn{\l_tmpc_tl}{\l_tmpb_tl}
                                  \cs_if_exist_use:c{#1}[\l_tmpb_tl]{\l_tmpc_tl}
                                 }
  }
  {}
}

\renewenvironment{otherlanguage}[2][]
{%
  % Get real current (pre-switch) options (incl. defaults)
  \clist_clear_new:N \l_xpg_current_options
  \prop_map_inline:cn {xpg@current@options@\languagename}
  {
      \clist_put_right:Nn \l_xpg_current_options {##1=##2}
  }
  % Store current (pre-switch) options and language on stack
  \polyglossia@stack@language:nx{\clist_use:Nn \l_xpg_current_options {,}}{\languagename}%
  \selectlanguage[#1]{#2}%
}
{%
   % restore previous language in aux file and remove closed one from stack
   \polyglossia@unstack@language:n{xpg@set@language@only@aux}%
}

\newcommand{\setlocalhyphenmins}[3]{%
   \xpg@ifdefined{#1}{%
      \expandafter\ifx\csname l@#1\endcsname\l@nohyphenation%
        \xpg@warning{\string\setlocalhyphenmin\space~ useless~ for~ unhyphenated~ language~ #1}%
      \else
      \providehyphenmins{#1}{#2#3}%
      \fi
   }{%
     \xpg@warning{\string\setlocalhyphenmin\space~ useless~ for~ unknown~ language~ #1}%
   }%
}%

% \setlanghyphenmins[options]{lang}{l}{r}
\newcommand*\setlanghyphenmins[4][]{%
  % Check for real language name and options
  \edef\xpg@tmp@opts{\xpg_alias_add_to_option_i:nn{#2}{#1}}
  \edef\xpg@tmp@lang{\xpg_alias_base_lang:n{#2}}
  \bgroup
  \polyglossia@error@iflangnotloaded:n{\xpg@tmp@lang}
  \polyglossia@set@keys:nn{\xpg@tmp@lang}{\xpg@tmp@opts}%
  % Store bcp47.tag@hypenmins
  \tl_if_blank:nTF {\xpg@tmp@opts}{%
    \ifcsundef{\csname xpg@tmp@lang\endcsname @g.bcp47.tag}{%
       \csedef{tmp@bcp47.tag}{\prop_item:Ne{\polyglossia@langsetup}{ \xpg@tmp@lang / bcp47 }}%
    }{%
       \csedef{tmp@bcp47.tag}{\csuse{#2@g.bcp47.tag}}%
    }%
  }{%
    \csedef{tmp@bcp47.tag}{\prop_item:Ne{\polyglossia@langsetup}{ \xpg@tmp@lang / bcp47 }}%
  }%
  \csgdef{\csname tmp@bcp47.tag\endcsname @hyphenmins}{{#3}{#4}}%
  \egroup
}

% \use@localhypenmins[options]{lang}
\newcommand*\use@localhyphenmins[2][]{%
  \bgroup
  \polyglossia@error@iflangnotloaded:n{#2}
  \polyglossia@set@keys:nn{#2}{#1}%
  % Use bcp47.tag@hypenmins
  \tl_if_blank:nTF {#1}{%
    \ifcsundef{#2@g.bcp47.tag}{%
       \csxdef{tmp@bcp47.tag}{\prop_item:Nn{\polyglossia@langsetup}{ #2 / bcp47 }}%
    }{%
       \csxdef{tmp@bcp47.tag}{\csuse{#2@g.bcp47.tag}}%
    }%
  }{%
    \csxdef{tmp@bcp47.tag}{\prop_item:Nn{\polyglossia@langsetup}{ #2 / bcp47 }}%
  }%
  \egroup
  \ifcsundef{\csname tmp@bcp47.tag\endcsname @hyphenmins}{%
     \ifcsundef{#2hyphenmins}{}%
        {%
          \expandafter\expandafter\expandafter\set@hyphenmins\csname #2hyphenmins\endcsname\relax%
        }
   }{%
      \edef\tmpa{\csuse{\csname tmp@bcp47.tag\endcsname @hyphenmins}}%
      \expandafter\expandafter\expandafter\set@hyphenmins\tmpa\relax%
   }
   \sys_if_engine_luatex:T{
     % Set \totalhyphenmin if specified
     \prop_get:NxNTF \polyglossia@langsetup {#2/totalhyphenmin} \l_tmpa_tl
     {
        \xpg@info{totalhyphenmin: '\l_tmpa_tl'}
        \expandafter\hyphenationmin \l_tmpa_tl%
     }%
     {}%
   }
}

% Babel previously compiled in hyphenrules into the kernel (via hyphen.cfg)
% but this is no longer the case. In any case, we roll our own one now
% and possibly overwrite babel's.
\provideenvironment{hyphenrules}{}{}

% As opposed to the one inherited from switch.def/babel, our environment
% supports language options and aliases.
\renewenvironment{hyphenrules}[2][]
{%
  % Check for real language name and options
  \edef\xpg@tmp@opts{\xpg_alias_add_to_option_i:nn{#2}{#1}}
  \edef\xpg@tmp@lang{\xpg_alias_base_lang:n{#2}}
  % Register the language options
  \polyglossia@set@lang@options:nnn {\xpg@tmp@lang} {\xpg@tmp@opts} {@xpg@set@langvariant}%
  % Now switch patterns
  \__xpg_use_or_warn:c{\use:c{xpg@tmp@lang}@language}%
  % And activate hyphenmins
  \use@localhyphenmins[\xpg@tmp@opts]{\xpg@tmp@lang}%
}
{}

\AtEndPreamble{%
   \@ifpackageloaded{bidi}{%
      \providecommand*{\aemph}[1]{$\overline{\hboxR{#1}}$}%
   }{}%
   \@ifpackageloaded{luabidi}{%
      \providecommand*{\aemph}[1]{$\overline{\hbox{\RL{#1}}}$}%
   }{}%
}


% keys for main package
\keys_define:nn { polyglossia } {
  verbose
     .bool_set:N = \l_polyglossia_verbose_bool,
  verbose
     .default:n = true,
  % compatibility
  quiet
     .meta:n =  { verbose = false },

  localmarks
     .bool_set:N = \l_polyglossia_localmarks_bool,
  localmarks
     .default:n = true,
  % compatibility
  nolocalmarks
     .meta:n = { localmarks = false },
   
  babelshorthands
     .bool_set:N = \l_polyglossia_babelshorthands_bool,
  babelshorthands
     .default:n = true,

  luatexrenderer
     .cs_set:Np = \l_polyglossia_luatex_renderer,
  luatexrenderer
     .value_required:n = true,
}

\keys_set:nn { polyglossia } {
  localmarks = false,
  verbose = true,
  babelshorthands = false,
  luatexrenderer = Harfbuzz
}

% load by default latex
\setmainlanguage{latex}
% then process key in order to overwrite
\ProcessKeysOptions{polyglossia}

% Set the LuaTeX renderer. As opposed to fontspec, we use Harfbuzz by default.
% This can be changed via the luatexrenderer package option.
\sys_if_engine_luatex:T{
  \str_if_eq:eeF{\l_polyglossia_luatex_renderer}{none}
  {
    \xpg@info{Setting~ LuaTeX~ font~ renderer~ to~ \l_polyglossia_luatex_renderer}
    \exp_args:Ne \defaultfontfeatures{Renderer=\l_polyglossia_luatex_renderer}
  }
}

\bool_if:nF \l_polyglossia_verbose_bool {
   \gdef\@latex@info#1{\relax}% no latex info
   \gdef\@font@info#1{\relax}% no latex font info
   \gdef\@font@warning#1{\relax}% no latex font warnings
   \gdef\zf@PackageInfo#1{\relax}% no fontspec info
   \gdef\xpg@info#1{\relax}% no polyglossia info
}

\bool_if:nT \l_polyglossia_localmarks_bool {
  \polyglossia@enable@local@marks:
}

% Control shorthand (de-)activation
% This checks that the shorthand char is only deactivated
% if we have activated it ourselves and hence keeps
% activation of other packages if no shorthands are used.
\seq_new:N \__xpg_active_shorthands

\DeclareDocumentCommand \xpg@activate@shorthands { O{"} }
{
  \seq_if_in:NnF \__xpg_active_shorthands { #1 }
    {
     \bbl@activate{#1}
     \seq_gpush:Nn \__xpg_active_shorthands { #1 }
    }
}

\DeclareDocumentCommand \xpg@deactivate@shorthands { O{"} }
{
  \seq_if_in:NnT \__xpg_active_shorthands { #1 }
    {
     \cs_if_exist:cT{initiate@active@char}{\bbl@deactivate{#1}}
     \seq_remove_all:Nn \__xpg_active_shorthands {#1}
    }
}

% compatibility
\newif\ifsystem@babelshorthands
\bool_if:nTF \l_polyglossia_babelshorthands_bool {
  \system@babelshorthandstrue
}{
  \system@babelshorthandsfalse
}

%
% FIXME these should also be loaded \AtEndOfPackage !!!
\def\xpg@option#1#2{%
  \ifcsundef{xpg@main@language}{\setdefaultlanguage}{\setotherlanguage}%
    [#1]{#2}}
\ExplSyntaxOff

%    \end{macrocode}
% \iffalse
%</polyglossia.sty>
%<*farsical.sty>
% \fi
% \clearpage
% 
% \subsection{farsical.sty}
%    \begin{macrocode}
\ProvidesPackage{farsical}
        [2019/12/12 v0.2 %
         Farsi (jalali) calendar]
\ifluatex\RequirePackage{luabidi}\else\RequirePackage{bidi}\fi
\RequirePackage{calc,arabicnumbers}

%TODO - rewrite completely using calc 
%%    - use Reingold & Dershowitz ME
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Modified from Arabiftoday.sty which is part of the Arabi package:
%%%  Copyright (C) 2006 Youssef Jabri
%%% itself a modification of the code in the FarsiTeX system:
%%%  Copyright (C) 1996 Hassan Abolhassani
%%%  Copyright (C) 1996-2001 Roozbeh Pournader <roozbeh@sharif.edu>
%%%  Copyright (C) 2000-2001 Behdad Esfahbod <behdad@bamdad.org>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifJALALI@leap \newif\ifJALALI@kabiseh
\newcount\JALALI@i  \newcount\JALALI@y  \newcount\JALALI@m  \newcount\JALALI@d
\newcount\JALALI@latini    \newcount\JALALI@farsii
\newcount\JALALI@latinii   \newcount\JALALI@farsiii
\newcount\JALALI@latiniii  \newcount\JALALI@farsiiii
\newcount\JALALI@latiniv   \newcount\JALALI@farsiiv
\newcount\JALALI@latinv    \newcount\JALALI@farsiv
\newcount\JALALI@latinvi   \newcount\JALALI@farsivi
\newcount\JALALI@latinvii  \newcount\JALALI@farsivii
\newcount\JALALI@latinviii \newcount\JALALI@farsiviii
\newcount\JALALI@latinix   \newcount\JALALI@farsiix
\newcount\JALALI@latinx    \newcount\JALALI@farsix
\newcount\JALALI@latinxi   \newcount\JALALI@farsixi
\newcount\JALALI@latinxii  \newcount\JALALI@farsixii
                           \newcount\JALALI@farsixiii

\newcount\JALALI@temp
\newcount\JALALI@temptwo
\newcount\JALALI@tempthree
\newcount\JALALI@yModHundred
\newcount\JALALI@thirtytwo
\newcount\JALALI@dn
\newcount\JALALI@sn
\newcount\JALALI@mminusone

% \ftoday renamed to \Jalalitoday - FC
\def\Jalalitoday{%
\JALALI@y=\year \JALALI@m=\month \JALALI@d=\day
%
\JALALI@temp=\JALALI@y
\divide\JALALI@temp by 100\relax
\multiply\JALALI@temp by 100\relax
\JALALI@yModHundred=\JALALI@y
\advance\JALALI@yModHundred by -\JALALI@temp\relax
%
\ifodd\JALALI@yModHundred
   \JALALI@leapfalse
\else
   \JALALI@temp=\JALALI@yModHundred
   \divide\JALALI@temp by 2\relax
   \ifodd\JALALI@temp\JALALI@leapfalse
   \else
      \ifnum\JALALI@yModHundred=0%
         \JALALI@temp=\JALALI@y
         \divide\JALALI@temp by 400\relax
         \multiply\JALALI@temp by 400\relax
         \ifnum\JALALI@y=\JALALI@temp\JALALI@leaptrue\else\JALALI@leapfalse\fi
      \else\JALALI@leaptrue
      \fi
   \fi
\fi
%
\JALALI@latini=31\relax
\ifJALALI@leap
  \JALALI@latinii = 29\relax
\else
  \JALALI@latinii = 28\relax
\fi
\JALALI@latiniii = 31\relax
\JALALI@latiniv  = 30\relax
\JALALI@latinv = 31\relax
\JALALI@latinvi = 30\relax
\JALALI@latinvii = 31\relax
\JALALI@latinviii = 31\relax
\JALALI@latinix = 30\relax
\JALALI@latinx = 31\relax
\JALALI@latinxi = 30\relax
\JALALI@latinxii = 31\relax
%
\JALALI@thirtytwo=32\relax
%
\JALALI@temp=\JALALI@y
\advance\JALALI@temp by -17\relax
\JALALI@temptwo=\JALALI@temp
\divide\JALALI@temptwo by 33\relax
\multiply\JALALI@temptwo by 33\relax
\advance\JALALI@temp by -\JALALI@temptwo
\ifnum\JALALI@temp=\JALALI@thirtytwo\JALALI@kabisehfalse
\else
   \JALALI@temptwo=\JALALI@temp
   \divide\JALALI@temptwo by 4\relax
   \multiply\JALALI@temptwo by 4\relax
   \advance\JALALI@temp by -\JALALI@temptwo
   \ifnum\JALALI@temp=\z@\JALALI@kabisehtrue\else\JALALI@kabisehfalse\fi
\fi
%
% --BE
% In fact farsii is equal to the Leap years from a fixed year to the last
% year minus the Kabise years from a fixed year to the last year plus a const.
%
\JALALI@tempthree=\JALALI@y                 % Number of Leap years
\advance\JALALI@tempthree by -1
\JALALI@temp=\JALALI@tempthree              % T := (MY-1) div 4
\divide\JALALI@temp by 4\relax
\JALALI@temptwo=\JALALI@tempthree           % T := T - ((MY-1) div 100)
\divide\JALALI@temptwo by 100\relax
\advance\JALALI@temp by -\JALALI@temptwo
\JALALI@temptwo=\JALALI@tempthree           % T := T + ((MY-1) div 400)
\divide\JALALI@temptwo by 400\relax
\advance\JALALI@temp by \JALALI@temptwo
\advance\JALALI@tempthree by -611       % Number of Kabise years
\JALALI@temptwo=\JALALI@tempthree           % T := T - ((SY+10) div 33) * 8
\divide\JALALI@temptwo by 33\relax
\multiply\JALALI@temptwo by 8\relax
\advance\JALALI@temp by -\JALALI@temptwo
\JALALI@temptwo=\JALALI@tempthree           %
\divide\JALALI@temptwo by 33\relax
\multiply\JALALI@temptwo by 33\relax
\advance\JALALI@tempthree by -\JALALI@temptwo
\ifnum\JALALI@tempthree=32\advance\JALALI@temp by 1\fi % if (SY+10) mod 33=32 then Inc(T);
\divide\JALALI@tempthree by 4\relax     % T := T - ((SY+10) mod 33) div 4
\advance\JALALI@temp by -\JALALI@tempthree
\advance\JALALI@temp by -137            % T := T - 137  Adjust the value
\JALALI@farsii=31
\advance\JALALI@farsii by -\JALALI@temp                 % now 31 - T is the farsii
%
\JALALI@farsiii = 30\relax
\ifJALALI@kabiseh
  \JALALI@farsiiii = 30\relax
\else
  \JALALI@farsiiii = 29\relax
\fi
\JALALI@farsiiv  = 31\relax
\JALALI@farsiv   = 31\relax
\JALALI@farsivi  = 31\relax
\JALALI@farsivii = 31\relax
\JALALI@farsiviii= 31\relax
\JALALI@farsiix  = 31\relax
\JALALI@farsix   = 30\relax
\JALALI@farsixi  = 30\relax
\JALALI@farsixii = 30\relax
\JALALI@farsixiii= 30\relax
%
\JALALI@dn= 0\relax
\JALALI@sn= 0\relax
\JALALI@mminusone=\JALALI@m
\advance\JALALI@mminusone by -1\relax
%
\JALALI@i=0\relax
\ifnum\JALALI@i < \JALALI@mminusone
\loop
\advance \JALALI@i by 1\relax
\advance\JALALI@dn by \csname JALALI@latin\romannumeral\the\JALALI@i\endcsname
\ifnum\JALALI@i<\JALALI@mminusone \repeat
\fi
\advance \JALALI@dn by \JALALI@d
%
\JALALI@i=1\relax
\JALALI@sn = \JALALI@farsii
\ifnum \JALALI@sn<\JALALI@dn
\loop
\advance \JALALI@i by 1\relax
\advance\JALALI@sn by \csname JALALI@farsi\romannumeral\the\JALALI@i\endcsname
\ifnum \JALALI@sn<\JALALI@dn \repeat
\fi
\ifnum \JALALI@i < 4
   \JALALI@m = 9 \advance\JALALI@m by \JALALI@i
   \advance \JALALI@y by -622\relax
\else
   \JALALI@m = \JALALI@i \advance \JALALI@m by -3\relax
   \advance \JALALI@y by -621\relax
\fi
\advance\JALALI@sn by -\csname JALALI@farsi\romannumeral\the\JALALI@i%
\endcsname
\ifnum\JALALI@i = 1
  \JALALI@d = \JALALI@dn \advance \JALALI@d by 30 \advance\JALALI@d by -\JALALI@farsii
\else
  \JALALI@d = \JALALI@dn \advance \JALALI@d by -\JALALI@sn
\fi
%% DATE FORMATTING
\if@RTL{\farsidigits{\number\JALALI@d}\space%
\Jalalimonth{\JALALI@m}\space\farsidigits{\number\JALALI@y}}%
\else
\number\JALALI@d\space\JalalimonthEnglish{\JALALI@m}%
\space\number\JALALI@y%
\fi}
%%%
\def\Jalalimonth#1{\ifcase#1\or فروردین\or
اردیبهشت\or خرداد\or تیر\or مرداد\or شهریور%
\or مهر\or آبان\or آذر\or دی\or بهمن\or اسفند%
\fi}
\def\JalalimonthEnglish#1{\ifcase#1%
\or Farvardīn\or Ordībehesht\or Khordād\or Tīr%
\or Mordād\or Shahrīvar\or Mihr\or Ābān\or Āzar%
\or Dai\or Bahman\or Esfand\fi}
%    \end{macrocode}
% \iffalse
%</farsical.sty>
%<*hebrewcal.sty>
% \fi
% \clearpage
% 
% \subsection{hebrewcal.sty}
%    \begin{macrocode}
\ProvidesPackage{hebrewcal}
        [2022/07/18 v2.8 %
         Hebrew calendar for polyglossia (adapted from hebcal.sty in Babel)]

\RequirePackage{iftex}
\ifluatex
  \RequirePackage{luabidi}
\else
  \RequirePackage{bidi}
\fi

%% TODO rewrite this on the basis of Reingold & Dershowitz 
%%      on the model of hijrical (using calc)

\@ifundefined{@Remainder}{\input{cal-util.def}}{}

%
% OPTIONS
%
\RequirePackage{xkeyval}

% marcheshvan=true|false
\define@boolkey{hebrewcal}[@xpg@hebrew@]{marcheshvan}[true]{}

% fullyear=true|false
\define@boolkey{hebrewcal}[@xpg@hebrew@]{fullyear}[true]{}

% transliteration=academy|alt
\newif\if@hebrewcal@academytrans
\@hebrewcal@academytransfalse
\define@choicekey*+{hebrewcal}{transliteration}[\hcal@val\hcal@nr]{academy,alt}[alt]{%
   \ifcase\hcal@nr\relax
      % academy:
     \@hebrewcal@academytranstrue
   \or
      % alt:
      \@hebrewcal@academytransfalse
   \fi
   \PackageInfo{hebrewcal}{Setting transliteration=\hcal@val}%
}{%
  \PackageWarning{hebrewcal}{Unknown transliteration option `#1'}%
}

% Process
\ProcessOptionsX*<hebrewcal>
%%
%% END OPTIONS

\newcount\hebrewday  \newcount\hebrewmonth \newcount\hebrewyear
\def\hebrewdate#1#2#3{%
    \HebrewFromGregorian{#1}{#2}{#3}%
                        {\hebrewday}{\hebrewmonth}{\hebrewyear}%
    \if@RTL%
      \@FormatForHebrew{\hebrewday}{\hebrewmonth}{\hebrewyear}%
    \else%
      \@FormatForEnglish{\hebrewday}{\hebrewmonth}{\hebrewyear}%
    \fi}
\def\hebrewtoday{\hebrewdate{\day}{\month}{\year}}
% The command name is capitalised in the doc, and this is consistent
% with other names such as \Hijritoday and \Jalalitoday.
\let\Hebrewtoday=\hebrewtoday
\def\hebrewsetreg{%
    \HebrewFromGregorian{\day}{\month}{\year}%
                        {\hebrewday}{\hebrewmonth}{\hebrewyear}}
\def\HebrewYearName#1{{%
   \@tempcnta=#1\divide\@tempcnta by 1000\multiply\@tempcnta by 1000
   \ifnum#1=\@tempcnta\relax % divisible by 1000: disambiguate
     \Hebrewnumeral{#1}\ (לפ"ג)%
   \else % not divisible by 1000
     \ifnum#1<1000\relax     % first millennium: disambiguate
       \Hebrewnumeral{#1}\ (לפ"ג)%
     \else 
       \ifnum#1<5000
         \Hebrewnumeral{#1}%
       \else
         \ifnum#1<6000 % current millenium, print without thousands
           \@tempcnta=#1\relax
           \if@xpg@hebrew@fullyear\else\advance\@tempcnta by -5000\fi
           \Hebrewnumeral{\@tempcnta}%
         \else % #1>6000
           \Hebrewnumeral{#1}%
         \fi
       \fi
     \fi
   \fi}}
\def\HebrewMonthName#1#2{%
    \ifnum #1 = 7 %
    \@CheckLeapHebrewYear{#2}%
        \if@HebrewLeap אדר\ ב'%
           \else אדר%
        \fi%
    \else%
        \ifcase#1%
           % nothing for 0
           \or תשרי%
           \or\if@xpg@hebrew@marcheshvan מרחשון\else חשון\fi%
           \or כסלו%
           \or טבת%
           \or שבט%
           \or אדר\ א'%
           \or אדר\ ב'%
           \or ניסן%
           \or אייר%
           \or סיון%
           \or תמוז%
           \or אב%
           \or אלול%
        \fi%
    \fi}
\def\@FormatForHebrew#1#2#3{%
  \Hebrewnumeral{#1}~ב\HebrewMonthName{#2}{#3}~%
  \HebrewYearName{#3}}
\def\HebrewMonthNameInEnglish#1#2{%
    \ifnum #1 = 7%
    \@CheckLeapHebrewYear{#2}%
        \if@HebrewLeap Adar II\else Adar\fi%
    \else%
        \ifcase #1%
            % nothing for 0
            \or \if@hebrewcal@academytrans Tishri \else Tishrei \fi%
            \or%
              \if@hebrewcal@academytrans%
                 \if@xpg@hebrew@marcheshvan Marẖeshvan\else Heshvan\fi%
              \else%
                 \if@xpg@hebrew@marcheshvan Marcheshvan\else Heshvan\fi%
              \fi%
            \or Kislev%
            \or \if@hebrewcal@academytrans Tevet \else Tebeth \fi%
            \or \if@hebrewcal@academytrans Shvat \else Shebat \fi%
            \or Adar I%
            \or Adar II%
            \or Nisan%
            \or \if@hebrewcal@academytrans Iyyar \else Iyar \fi%
            \or Sivan%
            \or Tammuz%
            \or \if@hebrewcal@academytrans Av \else Ab \fi%
            \or Elul%
        \fi
    \fi}
\def\@FormatForEnglish#1#2#3{%
    \HebrewMonthNameInEnglish{#2}{#3} \number#1,\ \number#3}
\newcount\@common
\newif\if@HebrewLeap
\def\@CheckLeapHebrewYear#1{%
    {%
        \countdef\tmpa = 0%       % \tmpa==\count0
        \countdef\tmpb = 1%       % \tmpb==\count1
        \tmpa = #1%
        \multiply \tmpa by 7%
        \advance \tmpa by 1%
        \@Remainder{\tmpa}{19}{\tmpb}%
        \ifnum \tmpb < 7%         % \tmpb = (7*year+1)%19
            \global\@HebrewLeaptrue%
        \else%
            \global\@HebrewLeapfalse%
        \fi}}
\def\@HebrewElapsedMonths#1#2{%
    {%
        \countdef\tmpa = 0%       % \tmpa==\count0
        \countdef\tmpb = 1%       % \tmpb==\count1
        \countdef\tmpc = 2%       % \tmpc==\count2
        \tmpa = #1%               %
        \advance \tmpa by -1%     %
        #2 = \tmpa%               % #2 = \tmpa = year-1
        \divide #2 by 19%         % Number of complete Meton cycles
        \multiply #2 by 235%      % #2 = 235*((year-1)/19)
        \@Remainder{\tmpa}{19}{\tmpb}% \tmpa = years%19-years this cycle
        \tmpc = \tmpb%            %
        \multiply \tmpb by 12%    %
        \advance #2 by \tmpb%     % add regular months this cycle
        \multiply \tmpc by 7%     %
        \advance \tmpc by 1%      %
        \divide \tmpc by 19%      % \tmpc = (1+7*((year-1)%19))/19 -
        \advance #2 by \tmpc%     %  add leap months
        \global\@common = #2}%
    #2 = \@common}
\def\@HebrewElapsedDays#1#2{%
    {%
        \countdef\tmpa = 0%       % \tmpa==\count0
        \countdef\tmpb = 1%       % \tmpb==\count1
        \countdef\tmpc = 2%       % \tmpc==\count2
        \@HebrewElapsedMonths{#1}{#2}%
        \tmpa = #2%               %
        \multiply \tmpa by 13753% %
        \advance \tmpa by 5604%   % \tmpa=MonthsElapsed*13758 + 5604
        \@Remainder{\tmpa}{25920}{\tmpc}% \tmpc == ConjunctionParts
        \divide \tmpa by 25920%
        \multiply #2 by 29%
        \advance #2 by 1%
        \advance #2 by \tmpa%     %  #2 = 1 + MonthsElapsed*29 +
        \@Remainder{#2}{7}{\tmpa}% %  \tmpa == DayOfWeek
        \ifnum \tmpc < 19440%
            \ifnum \tmpc < 9924%
            \else%                % New moon at 9 h. 204 p. or later
                \ifnum \tmpa = 2% % on Tuesday ...
                    \@CheckLeapHebrewYear{#1}% of a common year
                    \if@HebrewLeap%
                    \else%
                        \advance #2 by 1%
                    \fi%
                \fi%
            \fi%
            \ifnum \tmpc < 16789%
            \else%                 % New moon at 15 h. 589 p. or later
                \ifnum \tmpa = 1%  % on Monday ...
                    \advance #1 by -1%
                    \@CheckLeapHebrewYear{#1}% at the end of leap year
                    \if@HebrewLeap%
                        \advance #2 by 1%
                    \fi%
                \fi%
            \fi%
        \else%
            \advance #2 by 1%      %  new moon at or after midday
        \fi%
        \@Remainder{#2}{7}{\tmpa}%  %  \tmpa == DayOfWeek
        \ifnum \tmpa = 0%          %  if Sunday ...
            \advance #2 by 1%
        \else%                     %
            \ifnum \tmpa = 3%      %  Wednesday ...
                \advance #2 by 1%
            \else%
                \ifnum \tmpa = 5%  %  or Friday
                     \advance #2 by 1%
                \fi%
            \fi%
        \fi%
        \global\@common = #2}%
    #2 = \@common}
\def\@DaysInHebrewYear#1#2{%
    {%
        \countdef\tmpe = 12%   % \tmpe==\count12
        \@HebrewElapsedDays{#1}{\tmpe}%
        \advance #1 by 1%
        \@HebrewElapsedDays{#1}{#2}%
        \advance #2 by -\tmpe%
        \global\@common = #2}%
    #2 = \@common}
\def\@HebrewDaysInPriorMonths#1#2#3{%
    {%
        \countdef\tmpf= 14%    % \tmpf==\count14
        #3 = \ifcase #1%       % Days in prior month of regular year
               0 \or%          % no month number 0
               0 \or%          % Tishri
              30 \or%          % Heshvan
              59 \or%          % Kislev
              89 \or%          % Tevet
             118 \or%          % Shvat
             148 \or%          % Adar I
             148 \or%          % Adar II
             177 \or%          % Nisan
             207 \or%          % Iyyar
             236 \or%          % Sivan
             266 \or%          % Tammuz
             295 \or%          % Av
             325 \or%          % Elul
             400%              % Dummy
        \fi%
        \@CheckLeapHebrewYear{#2}%
        \if@HebrewLeap%            % in leap year
            \ifnum #1 > 6%         % if month after Adar I
                \advance #3 by 30% % add  30 days
            \fi%
        \fi%
        \@DaysInHebrewYear{#2}{\tmpf}%
        \ifnum #1 > 3%
            \ifnum \tmpf = 353%    %
                \advance #3 by -1% %
            \fi%                   %  Short Kislev
            \ifnum \tmpf = 383%    %
                \advance #3 by -1% %
            \fi%                   %
        \fi%
        \ifnum #1 > 2%
            \ifnum \tmpf = 355%    %
                \advance #3 by 1%  %
            \fi%                   %  Long Heshvan
            \ifnum \tmpf = 385%    %
                \advance #3 by 1%  %
            \fi%                   %
        \fi%
        \global\@common = #3}%
    #3 = \@common}
\def\@FixedFromHebrew#1#2#3#4{%
    {%
        #4 = #1%
        \@HebrewDaysInPriorMonths{#2}{#3}{#1}%
        \advance #4 by #1%         % Add days in prior months this year
        \@HebrewElapsedDays{#3}{#1}%
        \advance #4 by #1%         % Add days in prior years
        \advance #4 by -1373429%   % Subtract days before Gregorian
        \global\@common = #4}%     %   01.01.0001
    #4 = \@common}
\def\@GregorianDaysInPriorMonths#1#2#3{%
    {%
        #3 = \ifcase #1%
               0 \or%             % no month number 0
               0 \or%
              31 \or%
              59 \or%
              90 \or%
             120 \or%
             151 \or%
             181 \or%
             212 \or%
             243 \or%
             273 \or%
             304 \or%
             334%
        \fi%
        \@CheckIfGregorianLeap{#2}%
        \if@GregorianLeap%
            \ifnum #1 > 2%        % if month after February
                \advance #3 by 1% % add leap day
            \fi%
        \fi%
        \global\@common = #3}%
    #3 = \@common}
\def\@GregorianDaysInPriorYears#1#2{%
     {%
         \countdef\tmpc = 4%      % \tmpc==\count4
         \countdef\tmpb = 2%      % \tmpb==\count2
         \tmpb = #1%              %
         \advance \tmpb by -1%    %
         \tmpc = \tmpb%           % \tmpc = \tmpb = year-1
         \multiply \tmpc by 365%  % Days in prior years =
         #2 = \tmpc%              % = 365*(year-1) ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 4%      % \tmpc = (year-1)/4
         \advance #2 by \tmpc%    % ... plus Julian leap days ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 100%    % \tmpc = (year-1)/100
         \advance #2 by -\tmpc%   % ... minus century years ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 400%    % \tmpc = (year-1)/400
         \advance #2 by \tmpc%    % ... plus 4-century years.
         \global\@common = #2}%
    #2 = \@common}
\def\@AbsoluteFromGregorian#1#2#3#4{%
    {%
        \countdef\tmpd = 0%       % \tmpd==\count0
        #4 = #1%                  % days so far this month
        \@GregorianDaysInPriorMonths{#2}{#3}{\tmpd}%
        \advance #4 by \tmpd%     % add days in prior months
        \@GregorianDaysInPriorYears{#3}{\tmpd}%
        \advance #4 by \tmpd%     % add days in prior years
        \global\@common = #4}%
    #4 = \@common}
\def\HebrewFromGregorian#1#2#3#4#5#6{%
    {%
        \countdef\tmpx= 17%        % \tmpx==\count17
        \countdef\tmpy= 18%        % \tmpy==\count18
        \countdef\tmpz= 19%        % \tmpz==\count19
        #6 = #3%                   %
        \global\advance #6 by 3761%  approximation from above
        \@AbsoluteFromGregorian{#1}{#2}{#3}{#4}%
        \tmpz = 1  \tmpy = 1%
        \@FixedFromHebrew{\tmpz}{\tmpy}{#6}{\tmpx}%
        \ifnum \tmpx > #4%              %
            \global\advance #6 by -1% Hyear = Gyear + 3760
            \@FixedFromHebrew{\tmpz}{\tmpy}{#6}{\tmpx}%
        \fi%                            %
        \advance #4 by -\tmpx%     % Days in this year
        \advance #4 by 1%          %
        #5 = #4%                   %
        \divide #5 by 30%          % Approximation for month from below
        \loop%                     % Search for month
            \@HebrewDaysInPriorMonths{#5}{#6}{\tmpx}%
            \ifnum \tmpx < #4%
                \advance #5 by 1%
                \tmpy = \tmpx%
        \repeat%
        \global\advance #5 by -1%
        \global\advance #4 by -\tmpy%
   }%
}

%    \end{macrocode}
% \iffalse
%</hebrewcal.sty>
%<*hijrical.sty>
% \fi
% \clearpage
% 
% \subsection{hijrical.sty}
%    \begin{macrocode}
\ProvidesPackage{hijrical}
        [2010/07/12 v0.2 %
         Islamic calendar]
\RequirePackage{calc}
\RequirePackage{arabicnumbers}
\@ifpackageloaded{bidi}{}{\newif\if@RTL\@RTLfalse}
\@ifpackageloaded{l3calc}{\PackageError{hijrical}{\MessageBreak
Package l3calc is loaded, which replaces the functionality of
calc. Computation of Hijri dates will not work properly with
% FIXME by Arthur: François couldn’t possibly mean ‘l3calc’ on the
% following line :-)  Find out if he meant ‘calc’.
l3calc! The latest version of expl3 on CTAN no longer loads
l3calc. Please update expl3!
}{}}{}

\@ifundefined{@Remainder}{\input{cal-util.def}}{}

%% The following functions are straightforward implementation 
%% of Reingold & Dershowitz, Calendrical Calculations, The Millenium Edition
%%

\def\@FixedFromHijri#1#2#3#4{% year,month,day,counter
\@ifundefined{c@#4}{\newcounter{#4}}{}%
\setcounter{tmpA}{#2/2}% see errata of Reingold+Dershowitz
%\message{tmpA is \thetmpA}%
\setcounter{tmpB}{(3+11*#1)/30}%
%\message{tmpB is \thetmpB}%
\setcounter{#4}{227014+(#1-1)*354+\value{tmpB}+(29*(#2-1))+\value{tmpA}+#3}%
}

\newcounter{Hijriday}\newcounter{Hijrimonth}\newcounter{Hijriyear}

\def\HijriFromGregorian#1#2#3{% year,month,day
\@FixedFromGregorian{#1}{#2}{#3}{RDdate}%
\setcounter{Hijriyear}{(30*(\value{RDdate}-227015)+10646)/10631}%
\@FixedFromHijri{\value{Hijriyear}}{1}{1}{tmpx}%
%\message{tmpx is \thetmpx}%
\setcounter{tmpB}{\value{RDdate}-\value{tmpx}}%
%\message{tmpB is \thetmpB}%
\setcounter{Hijrimonth}{((11*\value{tmpB})+330)/325}%
\@FixedFromHijri{\value{Hijriyear}}{\value{Hijrimonth}}{1}{tmpy}%
%\message{tmpy is \thetmpy}%
\setcounter{Hijriday}{1+\value{RDdate}-\value{tmpy}}%
}

%\HijriFromGregorian{\year}{\month}{\day}%

%\def\PlainHijritoday{%
%\theHijriday.\theHijrimonth.\theHijriyear}

\def\Hijridate#1#2#3{%
    \HijriFromGregorian{#1}{#2}{#3}%
    \FormatHijriDate}

% added option \Hijritoday[n] (default 0) for adjusting the date + n days
\@ifundefined{@hijri@correction}{\gdef\@hijri@correction{0}}{}
\newcommand\Hijritoday[1][\@hijri@correction]{%
 \@ifundefined{c@adj@day}{\global\newcounter{adj@day}}{}%
 \setcounter{adj@day}{\the\day+#1}% 
 \Hijridate{\year}{\month}{\value{adj@day}}}
%\def\Hijritoday{\Hijridate{\year}{\month}{\day}}
\let\hijritoday=\Hijritoday
%FIXME necessary?
%\def\Hijrisetreg{%
% \HijriFromGregorian{\year}{\month}{\day}}

\def\HijriMonthTranslit#1{\ifcase#1\or Muḥarram\or Ṣafar\or Rabīʿ I\or Rabīʿ II\or%
Jumādā I\or Jumādā II\or Rajab\or Shaʿbān\or Ramaḍān\or%
Shawwāl\or Dhū ’l-Qaʿda\or Dhū ’l-Ḥijja\fi}

\def\HijriMonthArabic#1{\ifcase#1\or محرم\or صفر\or ربيع الأول\or ربيع الآخر\or%
جمادى الأولى\or جمادى الآخرة\or رجب\or شعبان\or رمضان\or%
شوال\or ذو القعدة\or ذو الحجة\fi}

%% This macro is now locale-aware!
\def\FormatHijriDate{%
  \@ifundefined{FormatHijriDate@\languagename}%
    {\if@RTL\FormatHijriDate@defaultRTL\else\FormatHijriDate@defaultLTR\fi}%
    {\csname FormatHijriDate@\languagename\endcsname}}

\newcommand\DefineFormatHijriDate[2]{%
   \@namedef{FormatHijriDate@#1}{#2}}

% we provide this as a reasonable default.
% Further definitions are in polyglossia’s language definition files.
\DefineFormatHijriDate{defaultRTL}{\@ensure@RTL{%
\arabicdigits{\value{Hijriday}}\space\HijriMonthArabic{\value{Hijrimonth}}\space\arabicdigits{\value{Hijriyear}}}}

\DefineFormatHijriDate{defaultLTR}{%
\number\value{Hijriday}\space\HijriMonthTranslit{\value{Hijrimonth}}\space\number\value{Hijriyear}}
%    \end{macrocode}
% \iffalse
%</hijrical.sty>
%<*polyglossia-french.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-french.lua}
%    \begin{macrocode}
--
-- polyglossia-punct.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia-punct')

local function set_left_space(lang, char, kern, rubber)
    polyglossia.add_left_spaced_character(lang, char, kern, "space", rubber)
end

local function set_right_space(lang, char, kern, rubber)
    polyglossia.add_right_spaced_character(lang, char, kern, "space", rubber)
end

local function activate_french_punct(thincolonspace, autospaceguillemets)
    -- We need different language tags here to make switching of options possible
    -- within a paragraph.
    local lang = "french"
    if thincolonspace then
        lang = lang.."-thincolon"
    end
    if autospaceguillemets then
        lang = lang.."-autospace"
    end

    polyglossia.activate_punct(lang)
    polyglossia.clear_spaced_characters(lang)

    if thincolonspace then
        set_left_space(lang, ':', 0.5)
    else
        set_left_space(lang, ':', 1, true) -- stretchable and shrinkable space
    end

    set_left_space(lang, '!', 0.5)
    set_left_space(lang, '?', 0.5)
    set_left_space(lang, ';', 0.5)
    set_left_space(lang, '‼', 0.5)
    set_left_space(lang, '⁇', 0.5)
    set_left_space(lang, '⁈', 0.5)
    set_left_space(lang, '⁉', 0.5)
    set_left_space(lang, '‽', 0.5) -- U+203D (interrobang)

    if autospaceguillemets then
        set_left_space(lang, '»', 0.5)
        set_left_space(lang, '›', 0.5)
        set_right_space(lang, '«', 0.5)
        set_right_space(lang, '‹', 0.5)
    end
end

local function deactivate_french_punct()
    polyglossia.deactivate_punct()
end

polyglossia.activate_french_punct   = activate_french_punct
polyglossia.deactivate_french_punct = deactivate_french_punct
%    \end{macrocode}
% \iffalse
%</polyglossia-french.lua>
%<*polyglossia-korean.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-korean.lua}
%    \begin{macrocode}
--
-- polyglossia-korean.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

local glyph_id = node.id"glyph"
local hbox_id  = node.id"hlist"
local vbox_id  = node.id"vlist"
local glue_id  = node.id"glue"
local penalty_id = node.id"penalty"
local disc_id  = node.id"disc"

--
-- attr_korean: variant = plain (0), classic (1), modern (2)
--
local attr_korean = luatexbase.attributes["xpg@attr@korean"]
local attr_josa   = luatexbase.attributes["xpg@attr@autojosa"]

--
-- characters after which linebreak is not allowed
--
local nobr_after = {
    [0x28] = 1, -- ( LEFT PARENTHESIS
    [0x3C] = 1, -- < LESS-THAN SIGN
    [0x5B] = 1, -- [ LEFT SQUARE BRACKET
    [0x60] = 1, -- ` GRAVE ACCENT
    [0x7B] = 1, -- { LEFT CURLY BRACKET
    [0xAB] = 1, -- « LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
    [0x2018] = 1, -- ‘ LEFT SINGLE QUOTATION MARK
    [0x201C] = 1, -- “ LEFT DOUBLE QUOTATION MARK
    [0x2329] = 1, -- 〈 LEFT-POINTING ANGLE BRACKET
    [0x3008] = 1, -- 〈 LEFT ANGLE BRACKET
    [0x300A] = 1, -- 《 LEFT DOUBLE ANGLE BRACKET
    [0x300C] = 1, -- 「 LEFT CORNER BRACKET
    [0x300E] = 1, -- 『 LEFT WHITE CORNER BRACKET
    [0x3010] = 1, -- 【 LEFT BLACK LENTICULAR BRACKET
    [0x3014] = 1, -- 〔 LEFT TORTOISE SHELL BRACKET
    [0x3016] = 1, -- 〖 LEFT WHITE LENTICULAR BRACKET
    [0x3018] = 1, -- 〘 LEFT WHITE TORTOISE SHELL BRACKET
    [0x301A] = 1, -- 〚 LEFT WHITE SQUARE BRACKET
    [0x301D] = 1, -- 〝 REVERSED DOUBLE PRIME QUOTATION MARK
    [0xFE17] = 1, -- ︗ PRESENTATION FORM FOR VERTICAL LEFT WHITE LENTICULAR BRACKET
    [0xFE35] = 1, -- ︵ PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS
    [0xFE37] = 1, -- ︷ PRESENTATION FORM FOR VERTICAL LEFT CURLY BRACKET
    [0xFE39] = 1, -- ︹ PRESENTATION FORM FOR VERTICAL LEFT TORTOISE SHELL BRACKET
    [0xFE3B] = 1, -- ︻ PRESENTATION FORM FOR VERTICAL LEFT BLACK LENTICULAR BRACKET
    [0xFE3D] = 1, -- ︽ PRESENTATION FORM FOR VERTICAL LEFT DOUBLE ANGLE BRACKET
    [0xFE3F] = 1, -- ︿ PRESENTATION FORM FOR VERTICAL LEFT ANGLE BRACKET
    [0xFE41] = 1, -- ﹁ PRESENTATION FORM FOR VERTICAL LEFT CORNER BRACKET
    [0xFE43] = 1, -- ﹃ PRESENTATION FORM FOR VERTICAL LEFT WHITE CORNER BRACKET
    [0xFE47] = 1, -- ﹇ PRESENTATION FORM FOR VERTICAL LEFT SQUARE BRACKET
    [0xFE59] = 1, -- ﹙ SMALL LEFT PARENTHESIS
    [0xFE5B] = 1, -- ﹛ SMALL LEFT CURLY BRACKET
    [0xFE5D] = 1, -- ﹝ SMALL LEFT TORTOISE SHELL BRACKET
    [0xFF08] = 1, -- （ FULLWIDTH LEFT PARENTHESIS
    [0xFF3B] = 1, -- ［ FULLWIDTH LEFT SQUARE BRACKET
    [0xFF5B] = 1, -- ｛ FULLWIDTH LEFT CURLY BRACKET
    [0xFF5F] = 1, -- ｟ FULLWIDTH LEFT WHITE PARENTHESIS
    [0xFF62] = 1, -- ｢ HALFWIDTH LEFT CORNER BRACKET
}

--
-- characters before which linebreak is not allowed
--   (currently, not much differences among the followings)
--   1: normal chars
--   2: hangul jamo vowels and trailing consonants
--   3: kana small letters
--   0: dashes (supress visible spacing)
--
local nobr_before = setmetatable({
    [0x21] = 1, -- ! EXCLAMATION MARK
    [0x22] = 1, -- " QUOTATION MARK
    [0x27] = 1, -- ' APOSTROPHE
    [0x29] = 1, -- ) RIGHT PARENTHESIS
    [0x2C] = 1, -- , COMMA
    [0x2D] = 0, -- - HYPHEN-MINUS
    [0x2E] = 1, -- . FULL STOP
    [0x2F] = 0, -- / SOLIDUS
    [0x3A] = 0, -- : COLON
    [0x3B] = 1, -- ; SEMICOLON
    [0x3E] = 1, -- > GREATER-THAN SIGN
    [0x3F] = 1, -- ? QUESTION MARK
    [0x5C] = 0, -- \ REVERSE SOLIDUS
    [0x5D] = 1, -- ] RIGHT SQUARE BRACKET
    [0x7D] = 1, -- } RIGHT CURLY BRACKET
    [0x7E] = 0, -- ~ TILDE
    [0xB7] = 1, -- · MIDDLE DOT
    [0xBB] = 1, -- » RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
    [0x2013] = 0, -- – EN DASH
    [0x2014] = 0, -- — EM DASH
    [0x2015] = 1, -- ― HORIZONTAL BAR
    [0x2019] = 1, -- ’ RIGHT SINGLE QUOTATION MARK
    [0x201D] = 1, -- ” RIGHT DOUBLE QUOTATION MARK
    [0x2025] = 1, -- ‥ TWO DOT LEADER
    [0x2026] = 1, -- … HORIZONTAL ELLIPSIS
    [0x232A] = 1, -- 〉 RIGHT-POINTING ANGLE BRACKET
    [0x3001] = 1, -- 、 IDEOGRAPHIC COMMA
    [0x3002] = 1, -- 。 IDEOGRAPHIC FULL STOP
    [0x3005] = 1, -- 々 IDEOGRAPHIC ITERATION MARK
    [0x3009] = 1, -- 〉 RIGHT ANGLE BRACKET
    [0x300B] = 1, -- 》 RIGHT DOUBLE ANGLE BRACKET
    [0x300D] = 1, -- 」 RIGHT CORNER BRACKET
    [0x300F] = 1, -- 』 RIGHT WHITE CORNER BRACKET
    [0x3011] = 1, -- 】 RIGHT BLACK LENTICULAR BRACKET
    [0x3015] = 1, -- 〕 RIGHT TORTOISE SHELL BRACKET
    [0x3017] = 1, -- 〗 RIGHT WHITE LENTICULAR BRACKET
    [0x3019] = 1, -- 〙 RIGHT WHITE TORTOISE SHELL BRACKET
    [0x301B] = 1, -- 〛 RIGHT WHITE SQUARE BRACKET
    [0x301C] = 1, -- 〜 WAVE DASH
    [0x301E] = 1, -- 〞 DOUBLE PRIME QUOTATION MARK
    [0x301F] = 1, -- 〟 LOW DOUBLE PRIME QUOTATION MARK
    [0x3035] = 1, -- 〵 VERTICAL KANA REPEAT MARK LOWER HALF
    [0x303B] = 1, -- 〻 VERTICAL IDEOGRAPHIC ITERATION MARK
    [0x303C] = 1, -- 〼 MASU MARK
    [0x3041] = 3, -- ぁ HIRAGANA LETTER SMALL A
    [0x3043] = 3, -- ぃ HIRAGANA LETTER SMALL I
    [0x3045] = 3, -- ぅ HIRAGANA LETTER SMALL U
    [0x3047] = 3, -- ぇ HIRAGANA LETTER SMALL E
    [0x3049] = 3, -- ぉ HIRAGANA LETTER SMALL O
    [0x3063] = 3, -- っ HIRAGANA LETTER SMALL TU
    [0x3083] = 3, -- ゃ HIRAGANA LETTER SMALL YA
    [0x3085] = 3, -- ゅ HIRAGANA LETTER SMALL YU
    [0x3087] = 3, -- ょ HIRAGANA LETTER SMALL YO
    [0x308E] = 3, -- ゎ HIRAGANA LETTER SMALL WA
    [0x3095] = 3, -- ゕ HIRAGANA LETTER SMALL KA
    [0x3096] = 3, -- ゖ HIRAGANA LETTER SMALL KE
    [0x3099] = 1, --  COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK
    [0x309A] = 1, --  COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
    [0x309B] = 1, -- ゛ KATAKANA-HIRAGANA VOICED SOUND MARK
    [0x309C] = 1, -- ゜ KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
    [0x309D] = 1, -- ゝ HIRAGANA ITERATION MARK
    [0x309E] = 1, -- ゞ HIRAGANA VOICED ITERATION MARK
    [0x30A0] = 1, -- ゠ KATAKANA-HIRAGANA DOUBLE HYPHEN
    [0x30A1] = 3, -- ァ KATAKANA LETTER SMALL A
    [0x30A3] = 3, -- ィ KATAKANA LETTER SMALL I
    [0x30A5] = 3, -- ゥ KATAKANA LETTER SMALL U
    [0x30A7] = 3, -- ェ KATAKANA LETTER SMALL E
    [0x30A9] = 3, -- ォ KATAKANA LETTER SMALL O
    [0x30C3] = 3, -- ッ KATAKANA LETTER SMALL TU
    [0x30E3] = 3, -- ャ KATAKANA LETTER SMALL YA
    [0x30E5] = 3, -- ュ KATAKANA LETTER SMALL YU
    [0x30E7] = 3, -- ョ KATAKANA LETTER SMALL YO
    [0x30EE] = 3, -- ヮ KATAKANA LETTER SMALL WA
    [0x30F5] = 3, -- ヵ KATAKANA LETTER SMALL KA
    [0x30F6] = 3, -- ヶ KATAKANA LETTER SMALL KE
    [0x30FB] = 1, -- ・ KATAKANA MIDDLE DOT
    [0x30FC] = 1, -- ー KATAKANA-HIRAGANA PROLONGED SOUND MARK
    [0x30FD] = 1, -- ヽ KATAKANA ITERATION MARK
    [0x30FE] = 1, -- ヾ KATAKANA VOICED ITERATION MARK
    [0xFE30] = 1, -- ︰ PRESENTATION FORM FOR VERTICAL TWO DOT LEADER
    [0xFE31] = 1, -- ︱ PRESENTATION FORM FOR VERTICAL EM DASH
    [0xFE32] = 1, -- ︲ PRESENTATION FORM FOR VERTICAL EN DASH
    [0xFE36] = 1, -- ︶ PRESENTATION FORM FOR VERTICAL RIGHT PARENTHESIS
    [0xFE38] = 1, -- ︸ PRESENTATION FORM FOR VERTICAL RIGHT CURLY BRACKET
    [0xFE3A] = 1, -- ︺ PRESENTATION FORM FOR VERTICAL RIGHT TORTOISE SHELL BRACKET
    [0xFE3C] = 1, -- ︼ PRESENTATION FORM FOR VERTICAL RIGHT BLACK LENTICULAR BRACKET
    [0xFE3E] = 1, -- ︾ PRESENTATION FORM FOR VERTICAL RIGHT DOUBLE ANGLE BRACKET
    [0xFE40] = 1, -- ﹀ PRESENTATION FORM FOR VERTICAL RIGHT ANGLE BRACKET
    [0xFE42] = 1, -- ﹂ PRESENTATION FORM FOR VERTICAL RIGHT CORNER BRACKET
    [0xFE44] = 1, -- ﹄ PRESENTATION FORM FOR VERTICAL RIGHT WHITE CORNER BRACKET
    [0xFE48] = 1, -- ﹈ PRESENTATION FORM FOR VERTICAL RIGHT SQUARE BRACKET
    [0xFE5A] = 1, -- ﹚ SMALL RIGHT PARENTHESIS
    [0xFE5C] = 1, -- ﹜ SMALL RIGHT CURLY BRACKET
    [0xFE5E] = 1, -- ﹞ SMALL RIGHT TORTOISE SHELL BRACKET
    [0xFF01] = 1, -- ！ FULLWIDTH EXCLAMATION MARK
    [0xFF09] = 1, -- ） FULLWIDTH RIGHT PARENTHESIS
    [0xFF0C] = 1, -- ， FULLWIDTH COMMA
    [0xFF0E] = 1, -- ． FULLWIDTH FULL STOP
    [0xFF1A] = 1, -- ： FULLWIDTH COLON
    [0xFF1B] = 1, -- ； FULLWIDTH SEMICOLON
    [0xFF1F] = 1, -- ？ FULLWIDTH QUESTION MARK
    [0xFF3D] = 1, -- ］ FULLWIDTH RIGHT SQUARE BRACKET
    [0xFF5D] = 1, -- ｝ FULLWIDTH RIGHT CURLY BRACKET
    [0xFF60] = 1, -- ｠ FULLWIDTH RIGHT WHITE PARENTHESIS
    [0xFF61] = 1, -- ｡ HALFWIDTH IDEOGRAPHIC FULL STOP
    [0xFF63] = 1, -- ｣ HALFWIDTH RIGHT CORNER BRACKET
    [0xFF64] = 1, -- ､ HALFWIDTH IDEOGRAPHIC COMMA
    [0xFF65] = 1, -- ･ HALFWIDTH KATAKANA MIDDLE DOT
    [0xFF9E] = 1, -- ﾞ HALFWIDTH KATAKANA VOICED SOUND MARK
    [0xFF9F] = 1, -- ﾟ HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK
}, { __index = function(_,c)
        if c >= 0x1160  and c <= 0x11FF  then return 2 end
        if c >= 0xD7B0  and c <= 0xD7FF  then return 2 end
        if c >= 0x302A  and c <= 0x302F  then return 1 end
        if c >= 0x31F0  and c <= 0x31FF  then return 3 end
        if c >= 0xFF67  and c <= 0xFF70  then return 3 end
        if c >= 0xFE00  and c <= 0xFE0F  then return 1 end
        if c >= 0xFE10  and c <= 0xFE19 and not (c == 0xFE17) then return 1 end
        if c >= 0xFE50  and c <= 0xFE58  then return 1 end
        if c >= 0xE0100 and c <= 0xE01EF then return 1 end
    end
})

--
-- whether 'c' is a cjk character
--
local function is_cjk (c)
    return c >= 0xAC00  and c <= 0xD7FF
    or     c >= 0x1100  and c <= 0x11FF
    or     c >= 0xA960  and c <= 0xA97F
    or     c >= 0x2E80  and c <= 0x9FFF
    or     c >= 0xF900  and c <= 0xFAFF
    or     c >= 0xFE10  and c <= 0xFE1F
    or     c >= 0xFE30  and c <= 0xFE6F
    or     c >= 0xFF00  and c <= 0xFFEF
    or     c >= 0x1F100 and c <= 0x1F2FF
    or     c >= 0x20000 and c <= 0x2FA1F
    or     nobr_after[c]  and c > 0x2014
    or     nobr_before[c] and c > 0x2014
end

--
-- classify cjk characters
--   1: openings
--   2: closings
--   3: centered chars
--   4: full stops
--   5: ellipses
--   6: exclamation and question marks
--   0: all others
--
local charclass = setmetatable({
    [0x2018] = 1, [0x201C] = 1, [0x2329] = 1, [0x3008] = 1,
    [0x300A] = 1, [0x300C] = 1, [0x300E] = 1, [0x3010] = 1,
    [0x3014] = 1, [0x3016] = 1, [0x3018] = 1, [0x301A] = 1,
    [0x301D] = 1, [0xFE17] = 1, [0xFE35] = 1, [0xFE37] = 1,
    [0xFE39] = 1, [0xFE3B] = 1, [0xFE3D] = 1, [0xFE3F] = 1,
    [0xFE41] = 1, [0xFE43] = 1, [0xFE47] = 1, [0xFF08] = 1,
    [0xFF3B] = 1, [0xFF5B] = 1, [0xFF5F] = 1, [0xFF62] = 1,
    [0x2019] = 2, [0x201D] = 2, [0x232A] = 2, [0x3001] = 2,
    [0x3009] = 2, [0x300B] = 2, [0x300D] = 2, [0x300F] = 2,
    [0x3011] = 2, [0x3015] = 2, [0x3017] = 2, [0x3019] = 2,
    [0x301B] = 2, [0x301E] = 2, [0x301F] = 2, [0xFE10] = 2,
    [0xFE11] = 2, [0xFE18] = 2, [0xFE36] = 2, [0xFE38] = 2,
    [0xFE3A] = 2, [0xFE3C] = 2, [0xFE3E] = 2, [0xFE40] = 2,
    [0xFE42] = 2, [0xFE44] = 2, [0xFE48] = 2, [0xFF09] = 2,
    [0xFF0C] = 2, [0xFF3D] = 2, [0xFF5D] = 2, [0xFF60] = 2,
    [0xFF63] = 2, [0xFF64] = 2, [0x00B7] = 3, [0x30FB] = 3,
    [0xFF1A] = 3, [0xFF1B] = 3, [0xFF65] = 3, [0x3002] = 4,
    [0xFE12] = 4, [0xFF0E] = 4, [0xFF61] = 4, [0x2015] = 5,
    [0x2025] = 5, [0x2026] = 5, [0xFE19] = 5, [0xFE30] = 5,
    [0xFE31] = 5, [0xFE15] = 6, [0xFE16] = 6, [0xFF01] = 6,
    [0xFF1F] = 6,
}, { __index = function() return 0 end })

--
-- table for spacing between char classes
--   1 stands for 0.5*fontsize when variant=classic
--
local intercharclass = { [0] =
    { [0] = nil,    {1,1},  nil,    {.5,.5} },
    { [0] = nil,    nil,    nil,    {.5,.5} },
    { [0] = {1,1},  {1,1},  nil,    {.5,.5}, nil,    {1,1},  {1,1} },
    { [0] = {.5,.5},{.5,.5},{.5,.5},{1,.5},  {.5,.5},{.5,.5},{.5,.5} },
    { [0] = {1,0},  {1,0},  nil,    {1.5,.5},nil,    {1,0},  {1,0} },
    { [0] = nil,    {1,1},  nil,    {.5,.5} },
    { [0] = {1,1},  {1,1},  nil,    {.5,.5} },
}

--
-- get a new penalty node
--
local function get_new_penalty (p)
    local penalty = node.new("penalty")
    penalty.penalty = p
    return penalty
end

--
-- get a new glue node
--
local function get_new_glue (...)
    local glue = node.new("glue")
    node.setglue(glue, ...)
    return glue
end

--
-- return 0.5*fontsize of given fontid
--   space: true if variant=modern; then 0.5*interword_space
--
local function get_font_size (fid, space)
    local size = font.getparameters(fid)
    if space then
        size = size and size.space or 196608
    else
        size = size and size.quad  or 655360
    end
    return size/2
end

--
-- charclass 1 thru 4 will be packed in \hbox to 0.5em{\hss? curr \hss?}
--   when variant=classic/modern
--
local function glyph_to_box (head, curr, class)
    local g, h = curr
    local size = get_font_size(g.font)
    head, curr = node.remove(head, curr)
    g.next, g.prev = nil, nil
    local hss = get_new_glue(0, 65536, 65536, 2, 2)
    if class == 1 then
        h, hss.next, g.prev = hss, g, hss
    elseif class == 2 or class == 4 then
        h, g.next, hss.prev = g, hss, g
    else
        local hss2 = node.copy(hss)
        h, hss.next, g.prev, g.next, hss2.prev = hss, g, hss, hss2, g
    end
    h = nodes.simple_font_handler(h)
    local box = node.hpack(h, size, "exactly")
    if curr then
        head, curr = node.insert_before(head, curr, box)
    else
        head, curr = node.insert_after(head, node.tail(head), box)
    end
    return head, curr
end

--
-- insert spacing defined as charclass[a][b] between a and b
--   f:    fontid
--   var:  variant = plain, classic, modern
--   cc:   charclass of current char
--   nc:   charclass of next char
--   nobr: linebreak is not allowed
--
local function insert_cjk_penalty_glue (head, curr, f, var, cc, nc, nobr)
    if nobr or cc == 1 or nc > 1 then
        local penalty = get_new_penalty(10000)
        head, curr = node.insert_after(head, curr, penalty)
    end
    local factor = get_font_size(f, var == 2)
    local t = intercharclass[cc][nc]
    local glue = get_new_glue(t[1]*factor, nil, t[2]*factor)
    head, curr = node.insert_after(head, curr, glue)
    return head, curr
end

--
-- insert inter-character spacing in other normal cases
--   f:   fontid
--   var: variant = plain, classic, modern
--   x:   true between cjk and non-cjk (a little more spacing)
--
local function insert_penalty_glue (head, curr, f, var, x)
    if var ~= 1 then
        local penalty = get_new_penalty(50)
        head, curr = node.insert_after(head, curr, penalty)
    end
    local size, glue = get_font_size(f, x and var == 2)
    if x then
        glue = get_new_glue(size/2, size/4, size/8)
    else
        glue = get_new_glue(0, size/10, size/50)
    end
    head, curr = node.insert_after(head, curr, glue)
    return head, curr
end

--
-- main process for linebreak and inter-character spacing
--   lb: true if pre_linebreak_filter
--
local function korean_break (head, lb)
    local curr = head
    while curr do
        if curr.id == glyph_id then
            local var = node.has_attribute(curr, attr_korean)
            if var then
                local c, f = curr.char or 0, curr.font or 0
                local cc, cjkc = charclass[c], is_cjk(c)

                -- compress cjk punctuations when charclass is 1 thru 4
                if var > 0 and cc > 0 and cc < 5 then
                    head, curr = glyph_to_box(head, curr, cc)
                end

                local next = curr.next
                if next and next.id == glyph_id then
                    local n = next.char or 0
                    local nc = charclass[n]
                    local nobr = nobr_before[n] or nobr_after[c]

                    -- insert spacing as of intercharclass
                    if var > 0 and intercharclass[cc][nc] then
                        head, curr = insert_cjk_penalty_glue(head, curr, f, var, cc, nc, nobr)

                    -- or insert spacing when linebreak is allowed
                    elseif not nobr then
                        local cjkn = is_cjk(n)

                        -- if curr or next is cjk char
                        if cjkc or cjkn then

                            -- if between cjk and non-cjk
                            if var > 0 and not (cjkc and cjkn) and nobr_before[c] ~= 0 then
                                head, curr = insert_penalty_glue(head, curr, f, var, true)

                            -- or under pre_linebreak_filter
                            elseif lb then
                                head, curr = insert_penalty_glue(head, curr, f, var)
                            end
                        end
                    end
                end
            end
        end
        curr = curr.next
    end
    return head
end

--
-- process for reordering hangul tone marks (U+302E, U+302F)
--   some hangul fonts (eg. Noto CJK) are so designed that hangul tone marks
--   should be moved to the first position of a syllable.
--   Currently, this functionality is not provided by luaotfload.
--
local function reorder_tm (head)
    local curr, tone = node.slide(head)
    while curr do
        if curr.id == glyph_id and node.has_attribute(curr, attr_korean) then
            local f = font.getfont(curr.font) or font.fonts[curr.font]
            if f and f.hb then -- harfbuzz do the right thing
                tone = nil
            else
                local c, wd = curr.char or 0, curr.width or 0
                if (c == 0x302E or c == 0x302F) and wd > 0 then
                    tone = curr
                elseif tone and not nobr_before[c] then
                    head = node.remove(head, tone)
                    tone.next, tone.prev = nil, nil
                    head, curr = node.insert_before(head, curr, tone)
                    tone = nil
                end
            end
        end
        curr = curr.prev
    end
    return head
end

--
-- automatic josa selection
--
local josa_table = {
    --          consonant ㄹ, vowel,  other consonants
    [0xAC00] = {0xC774,       0xAC00, 0xC774}, -- 가 => 이, 가, 이
    [0xC740] = {0xC740,       0xB294, 0xC740}, -- 은 => 은, 는, 은
    [0xC744] = {0xC744,       0xB97C, 0xC744}, -- 을 => 을, 를, 을
    [0xC640] = {0xACFC,       0xC640, 0xACFC}, -- 와 => 과, 와, 과
    [0xC73C] = {nil,          nil,    0xC73C}, -- 으(로) =>   ,  , 으
    [0xC774] = {0xC774,       nil,    0xC774}, -- 이(라) => 이,  , 이
}

--
-- helper function for number-like characters
--
local function josa_char_num (t, c)
    c = c % 10 + 0x30
    return t[c] or 2
end

--
-- decide josa selection
--
local josa_code = setmetatable({
    [0x30] = 3, [0x31] = 1, [0x33] = 3, [0x36] = 3, [0x37] = 1,
    [0x38] = 1, [0x4C] = 1, [0x4D] = 3, [0x4E] = 3, [0x6C] = 1,
    [0x6D] = 3, [0x6E] = 3, [0xFB02] = 1, [0xFB04] = 1,
},{ __index = function(t,c)
        if c >= 0xAC00 and c <= 0xD7A3 then
            c = (c - 0xAC00) % 28 + 0x11A7
        end
        if c >= 0x11A8 and c <= 0x11FF then
            if c == 0x11AF then return 1 end
            return 3
        end
        if c >= 0xD7CB and c <= 0xD7FB then return 3 end
        if c >= 0x2170 and c <= 0x217F then c = c - 0x10 end
        if c >= 0x2160 and c <= 0x216F then
            if c >= 0x216C then return 3 end
            return josa_char_num(t, c - 0x215F)
        end
        if c >= 0x2460 and c <= 0x2473 then return josa_char_num(t, c - 0x245F) end
        if c >= 0x2474 and c <= 0x2487 then return josa_char_num(t, c - 0x2473) end
        if c >= 0x2488 and c <= 0x249B then return josa_char_num(t, c - 0x2487) end
        if c >= 0x249C and c <= 0x24B5 then return t[c - 0x249C + 0x61] or 2 end
        if c >= 0x24B6 and c <= 0x24CF then return t[c - 0x24B6 + 0x61] or 2 end
        if c >= 0x24D0 and c <= 0x24E9 then return t[c - 0x24D0 + 0x61] or 2 end
        if c >= 0x3131 and c <= 0x318E then
            if c == 0x3139 then return 1 end
            if c >= 0x314F and c <= 0x3163 or c >= 0x3187 then return 2 end
            return 3
        end
        if c >= 0x3260 and c <= 0x327E then c = c - 0x60 end
        if c >= 0x3200 and c <= 0x321E then
            if c == 0x3203 then return 1 end
            if c >= 0x320E then return 2 end
            return 3
        end
        if c >= 0xFF10 and c <= 0xFF19 then return josa_char_num(t, c - 0xFF10) end
        if c >= 0xFF21 and c <= 0xFF3A then return t[c - 0xFF21 + 0x61] or 2 end
        if c >= 0xFF41 and c <= 0xFF5A then return t[c - 0xFF41 + 0x61] or 2 end
        return 2
    end
})

--
-- obtain char that comes just before the josa
--
local function get_prev_char (p)
    while p do
        if p.id == glyph_id then
            local pc = p.char or 0
            if not nobr_after[pc] then
                if not nobr_before[pc] or nobr_before[pc] >= 2 then
                    return pc
                end
            end
        elseif p.id == hbox_id or p.id == vbox_id then
            local pc = get_prev_char(node.slide(p.head))
            if pc then return pc end
        end
        p = p.prev
    end
end

--
-- main process of josa selection
--
local function auto_josa (head)
    local curr, tofree = head, {}
    while curr do
        if curr.id == glyph_id then
            local josa = node.has_attribute(curr, attr_josa)
            if josa then
                local cc = curr.char or 0
                if josa == 0 then
                    josa = josa_code[get_prev_char(curr.prev) or 0x30]
                end
                if cc == 0xC774 then
                    local n = curr.next
                    if n and n.char and n.char >= 0xAC00 and n.char <= 0xD7A3 then
                    else
                        cc = 0xAC00
                    end
                end
                local new = josa_table[cc]
                if new then
                    cc = new[josa]
                    if cc then
                        curr.char = cc
                    else
                        head = node.remove(head, curr)
                        table.insert(tofree, curr)
                    end
                end
                node.unset_attribute(curr, attr_josa)
            end
        end
        curr = curr.next
    end
    for _,v in ipairs(tofree) do node.free(v) end
    return head
end

--
-- now register to luatex callbacks
--   As char value of glyphs can be changed by opentype GSUB process,
--   we have to occupy the first position among callback functions.
--
local prepend_to_callback
if luatexbase.base_add_to_callback then
    prepend_to_callback = function(name, func, desc)
        luatexbase.add_to_callback(name, func, desc, 1)
    end
else
    prepend_to_callback = function(name, func, desc)
        local t = { {func, desc} }
        for _,v in ipairs(luatexbase.callback_descriptions(name)) do
            table.insert(t, {luatexbase.remove_from_callback(name, v)})
        end
        for _,v in ipairs(t) do
            luatexbase.add_to_callback(name, v[1], v[2])
        end
    end
end

prepend_to_callback ("pre_linebreak_filter",
    function(head)
        head = auto_josa(head)
        head = korean_break(head, true)
        head = reorder_tm(head)
        return head
    end,
    "polyglossia.lang_korean")

prepend_to_callback ("hpack_filter",
    function(head)
        head = auto_josa(head)
        head = korean_break(head)
        head = reorder_tm(head)
        return head
    end,
    "polyglossia.lang_korean")

-- vim:ft=lua:tw=0:sw=4:ts=4:expandtab
%    \end{macrocode}
% \iffalse
%</polyglossia-korean.lua>
%<*polyglossia-latin.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-latin.lua}
%    \begin{macrocode}
--
-- polyglossia-latin.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia-punct')

-- For ecclesiastic Latin (and sometimes for Italian) a very small space is
-- used for the punctuation. The ecclesiastic package uses a space of
-- 0.3\fontdimen2, where \fontdimen2 is a interword space, which is typically
-- between 1/4 and 1/3 of a quad. We choose a half of a \thinspace here.
local hairspace = 0.08333 -- 1/12

local function space_left(char)
    polyglossia.add_left_spaced_character('latin', char, hairspace, 'quad')
end

local function space_right(char)
    polyglossia.add_right_spaced_character('latin', char, hairspace, 'quad')
end

polyglossia.clear_spaced_characters('latin')
space_left('!')
space_left('?')
space_left('‼')
space_left('⁇')
space_left('⁈')
space_left('⁉')
space_left('‽') -- U+203D (interrobang)
space_left(':')
space_left(';')
space_left('»')
space_left('›')
space_right('«')
space_right('‹')

local function activate_latin_punct()
    polyglossia.activate_punct('latin')
end

local function deactivate_latin_punct()
    polyglossia.deactivate_punct()
end

polyglossia.activate_latin_punct   = activate_latin_punct
polyglossia.deactivate_latin_punct = deactivate_latin_punct
%    \end{macrocode}
% \iffalse
%</polyglossia-latin.lua>
%<*polyglossia-punct.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-punct.lua}
%    \begin{macrocode}
--
-- polyglossia-punct.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia') -- just in case...

local add_to_callback      = luatexbase.add_to_callback
local remove_from_callback = luatexbase.remove_from_callback
local priority_in_callback = luatexbase.priority_in_callback
local new_attribute        = luatexbase.new_attribute

local node = node

local insert_node_before = node.insert_before
local insert_node_after  = node.insert_after
local remove_node        = node.remove
local has_attribute      = node.has_attribute
local node_copy          = node.copy
local new_node           = node.new
local end_of_math        = node.end_of_math
local getnext            = node.getnext
local getprev            = node.getprev

-- node types according to node.types()
local glue_code    = node.id"glue"
local glyph_code   = node.id"glyph"
local penalty_code = node.id"penalty"
local kern_code    = node.id"kern"
local math_code    = node.id"math"

-- we need some node subtypes
local userkern = 1
local userskip = 0
local removable_skip = {
    [0]  = true, -- userskip
    [13] = true, -- spaceskip
    [14] = true, -- xspaceskip
}

-- we make a new node, so that we can copy it later on
local kern_node = new_node(kern_code)
kern_node.subtype = userkern -- this kern can be removed later on

local function get_kern_node(dim)
    local n = node_copy(kern_node)
    n.kern = dim
    return n
end

local glue_node = new_node(glue_code)
glue_node.subtype = userskip

local function get_glue_node(dim, stretch, shrink)
    local n   = node_copy(glue_node)
    n.width   = dim
    n.stretch = stretch
    n.shrink  = shrink
    return n
end

local penalty_node   = new_node(penalty_code)
penalty_node.penalty = 10000

local function get_penalty_node()
    return node_copy(penalty_node)
end

-- all possible space characters according to section 6.2 of the Unicode Standard
-- https://www.unicode.org/versions/Unicode12.0.0/ch06.pdf
local space_chars = {
    [0x20] = true, -- space
    [0xA0] = true, -- no-break space
    [0x1680] = true, -- ogham space mark
    [0x2000] = true, -- en quad
    [0x2001] = true, -- em quad
    [0x2002] = true, -- en space
    [0x2003] = true, -- em space
    [0x2004] = true, -- three-per-em-space
    [0x2005] = true, -- four-per-em space
    [0x2006] = true, -- six-per-em space
    [0x2007] = true, -- figure space
    [0x2008] = true, -- punctuation space
    [0x2009] = true, -- thin space
    [0x200A] = true, -- hair space
    [0x202F] = true, -- narrow no-break space
    [0x205F] = true, -- medium mathematical space
    [0x3000] = true -- ideographic space
}

-- all left bracket characters, referenced by their Unicode slot
local left_bracket_chars = {
    [0x28] = true, -- left parenthesis
    [0x5B] = true, -- left square bracket
    [0x7B] = true, -- left curly bracket
    [0x27E8] = true -- mathematical left angle bracket
}

-- all right bracket characters, referenced by their Unicode slot
local right_bracket_chars = {
    [0x29] = true,  -- right parenthesis
    [0x5D] = true,  -- right square bracket
    [0x7D] = true,  -- right curly bracket
    [0x27E9] = true -- mathematical right angle bracket
}

-- question and exclamation marks, referenced by their Unicode slot
local question_exclamation_chars = {
    [0x21] = true,   -- exclamation mark !
    [0x3F] = true,   -- question mark ?
    [0x203C] = true, -- double exclamation mark ‼
    [0x203D] = true, -- interrobang ‽
    [0x2047] = true, -- double question mark ⁇
    [0x2048] = true, -- question exclamation mark ⁈
    [0x2049] = true  -- exclamation question mark ⁉
}

-- from nodes-tst.lua, adapted
local function somespace(n)
    if n then
        local id, subtype = n.id, n.subtype
        if id == glue_code then
            -- it is dangerous to remove all the type of glue
            return removable_skip[subtype]
        elseif id == kern_code then
            -- remove only user's kern
            return subtype == userkern
        elseif id == glyph_code then
            return space_chars[n.char]
        end
    end
end

local function someleftbracket(n)
    if n then
        local id = n.id
        if id == glyph_code then
            return left_bracket_chars[n.char]
        end
    end
end

local function somerightbracket(n)
    if n then
        local id = n.id
        if id == glyph_code then
            return right_bracket_chars[n.char]
        end
    end
end

local function question_exclamation_sequence(n1, n2)
    if n1 and n2 then
        local id1 = n1.id
        local id2 = n2.id
        if id1 == glyph_code and id2 == glyph_code then
            return question_exclamation_chars[n1.char] and question_exclamation_chars[n2.char]
        end
    end
end

-- idem
local function somepenalty(n, value)
    if n then
        local id = n.id
        if id == penalty_code then
            if value then
                return n.penalty == value
            else
                return true
            end
        end
    end
end

local punct_attr = new_attribute("polyglossia_punct")

local lang_id      = {}
local lang_counter = 0
local left_space   = {}
local right_space  = {}

local function ensure_lang_id(lang)
    if not lang_id[lang] then
        lang_counter = lang_counter + 1
        lang_id[lang] = lang_counter
    end
    return lang_id[lang]
end

local function clear_spaced_characters(lang)
    local id = ensure_lang_id(lang)
    left_space[id]  = {}
    right_space[id] = {}
end

local function illegal_unit(unit)
    if unit then
        texio.write_nl('Illegal spacing unit "'..unit..'".')
    else
        texio.write_nl('Spacing unit is a nil value.')
    end
end

local function add_left_spaced_character(lang, char, kern, unit, rubber)
-- The parameter kern is a number meant as a fraction of the unit.
-- The unit can be "quad" (1em) or "space" (interword space).
-- The parameter rubber is a Boolean value indicating if the inserted space is
-- stretchable and shrinkable (only relevant if the unit is "space").
    local id = ensure_lang_id(lang)
    if unit == "quad" or unit == "space" then
        left_space[id][char] = {}
        left_space[id][char]["kern"] = kern
        left_space[id][char]["unit"] = unit
        left_space[id][char]["rubber"] = rubber
    else
        illegal_unit(unit)
    end
end

local function add_right_spaced_character(lang, char, kern, unit, rubber)
    local id = ensure_lang_id(lang)
    if unit == "quad" or unit == "space" then
        right_space[id][char] = {}
        right_space[id][char]["kern"] = kern
        right_space[id][char]["unit"] = unit
        right_space[id][char]["rubber"] = rubber
    else
        illegal_unit(unit)
    end
end

-- from typo-spa.lua, adapted
local function process(head)
    local current = head
    while current do
        local id = current.id
        if id == glyph_code then
            local attr = has_attribute(current, punct_attr)
            if attr then
                local char, leftspace, rightspace
                if current.char <= 0x10FFFF then -- greater values may cause problems with utf8.char
                    char = utf8.char(current.char)
                    leftspace  = left_space[attr][char]
                    rightspace = right_space[attr][char]
                end
                if leftspace or rightspace then
                    local fontparameters = fonts.hashes.parameters[current.font]
                    local unit, stretch, shrink, spacing_node
                    if leftspace and fontparameters then
                        local prev = getprev(current)
                        local space_exception = false
                        if prev then
                            -- do not add space after left (opening) bracket and between question/exclamation marks
                            space_exception = someleftbracket(prev) or question_exclamation_sequence(prev, current)
                            -- TODO: there is a question here: do we override a preceding space or not?...
                            while somespace(prev) do
                                head = remove_node(head, prev)
                                prev = getprev(current)
                            end
                            if somepenalty(prev, 10000) then
                                head = remove_node(head, prev)
                            end
                        end
                        if leftspace.unit == "quad" then
                            unit = fontparameters.quad
                            spacing_node = get_kern_node(leftspace.kern*unit)
                        elseif leftspace.unit == "space" then
                            unit = fontparameters.space
                            if leftspace.rubber then
                                stretch = leftspace.kern*fontparameters.space_stretch
                                shrink  = leftspace.kern*fontparameters.space_shrink
                                spacing_node = get_glue_node(leftspace.kern*unit, stretch, shrink)
                                head = insert_node_before(head, current, get_penalty_node())
                            else
                                spacing_node = get_kern_node(leftspace.kern*unit)
                            end
                        end
                        if not space_exception then
                            head = insert_node_before(head, current, spacing_node)
                        end
                    end
                    if rightspace and fontparameters then
                        local next = getnext(current)
                        local space_exception = false
                        if next then
                            -- do not add space before right (closing) bracket
                            space_exception = somerightbracket(next)
                            local nextnext = getnext(next)
                            if somepenalty(next, 10000) and somespace(nextnext) then
                                head, next = remove_node(head, next)
                            end
                            while somespace(next) do
                                head, next = remove_node(head, next)
                            end
                        end
                        if rightspace.unit == "quad" then
                            unit = fontparameters.quad
                            spacing_node = get_kern_node(rightspace.kern*unit)
                        elseif rightspace.unit == "space" then
                            unit = fontparameters.space
                            if rightspace.rubber then
                                stretch = rightspace.kern*fontparameters.space_stretch
                                shrink  = rightspace.kern*fontparameters.space_shrink
                                spacing_node = get_glue_node(rightspace.kern*unit, stretch, shrink)
                                if not space_exception then
                                    head, current = insert_node_after(head, current, get_penalty_node())
                                end
                            else
                                spacing_node = get_kern_node(rightspace.kern*unit)
                            end
                        end
                        if not space_exception then
                            head, current = insert_node_after(head, current, spacing_node)
                        end
                    end
                end
            end
        elseif id == math_code then
            -- warning: this is a feature of luatex > 0.76
            current = end_of_math(current) -- weird, can return nil .. no math end?
        end
        current = getnext(current) -- no error even if current is nil
    end
    return head
end

local function activate(lang)
    local id = ensure_lang_id(lang)
    -- We set the punctuation attribute to a language id here. This is
    -- important to be able to intermix languages with different spacings
    -- in one paragraph.
    tex.setattribute(punct_attr, id)
    for _, callback_name in ipairs{ "pre_linebreak_filter", "hpack_filter" } do
        if not priority_in_callback(callback_name, "polyglossia-punct.process") then
            add_to_callback(callback_name, process, "polyglossia-punct.process", 1)
        end
    end
end

local function deactivate()
    tex.setattribute(punct_attr, -0x7FFFFFFF) -- this value means "unset"
    -- Though it would make compilation slightly faster, it is not possible to
    -- safely uncomment the following lines. Imagine the following case: you
    -- start a paragraph by some spaced punctuation text, then, in the same
    -- paragraph, you change the language to something else, and thus call the
    -- following lines. This means that, at the end of the paragraph, the
    -- function won't be in the callback, so the beginning of the paragraph
    -- won't be processed by it.
    -- if priority_in_callback(callback_name, "polyglossia-punct.process") then
    --     remove_from_callback(callback_name, "polyglossia-punct.process")
    -- end
end

polyglossia.activate_punct             = activate
polyglossia.deactivate_punct           = deactivate
polyglossia.add_left_spaced_character  = add_left_spaced_character
polyglossia.add_right_spaced_character = add_right_spaced_character
polyglossia.clear_spaced_characters    = clear_spaced_characters
%    \end{macrocode}
% \iffalse
%</polyglossia-punct.lua>
%<*polyglossia-sanskrit.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-sanskrit.lua}
%    \begin{macrocode}
--
-- polyglossia-sanskrit.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia-punct')

-- How do we now, in Lua, what a \thinspace is? In the LaTeX source (latex.ltx)
-- it is defined as:
-- \def\thinspace{\leavevmode@ifvmode\kern .16667em }
-- I see no way of seeing if it has been overriden or not. So we stick to this
-- value.
local thinspace = 0.16667 -- 1/6

local function space_left(char)
    polyglossia.add_left_spaced_character('sanskrit', char, thinspace, 'quad')
end

polyglossia.clear_spaced_characters('sanskrit')
space_left('!')
space_left('?')
space_left('‼')
space_left('⁇')
space_left('⁈')
space_left('⁉')
space_left('‽') -- U+203D (interrobang)
space_left(':')
space_left(';')
space_left('।') -- danda, U+0964
space_left('॥') -- double danda, U+0965

local function activate_sanskrit_punct()
    polyglossia.activate_punct('sanskrit')
end

local function deactivate_sanskrit_punct()
    polyglossia.deactivate_punct()
end

polyglossia.activate_sanskrit_punct   = activate_sanskrit_punct
polyglossia.deactivate_sanskrit_punct = deactivate_sanskrit_punct
%    \end{macrocode}
% \iffalse
%</polyglossia-sanskrit.lua>
%<*polyglossia-tibt.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-tibt.lua}
%    \begin{macrocode}
--
-- polyglossia-tibt.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia') -- just in case...

local add_to_callback = luatexbase.add_to_callback
local remove_from_callback = luatexbase.remove_from_callback
local priority_in_callback = luatexbase.priority_in_callback

local next, type = next, type

local nodes, fonts, node = nodes, fonts, node

local nodecodes          = nodes.nodecodes --- <= preloaded node.types()

local insert_node_before = node.insert_before
local insert_node_after  = node.insert_after
local remove_node        = nodes.remove
local copy_node          = node.copy
local has_attribute      = node.has_attribute

local end_of_math        = node.end_of_math
if not end_of_math then -- luatex < .76
  local traverse_nodes = node.traverse_id
  local math_code      = nodecodes.math
  local end_of_math = function (n)
    for n in traverse_nodes(math_code, n.next) do
      return n
    end
  end
end

-- node types as of April 2013
local glyph_code         = nodecodes.glyph
local penalty_code       = nodecodes.penalty
local kern_code          = nodecodes.kern

-- we make a new node, so that we can copy it later on
local penalty_node  = node.new(penalty_code)
penalty_node.penalty = 50 -- corresponds to the penalty LaTeX sets at explicit hyphens

local function get_penalty_node()
  return copy_node(penalty_node)
end

local xpgtibtattr = luatexbase.attributes['xpg@tibteol']

local tsheg = unicode.utf8.byte('་')

-- from typo-spa.lua
local function process(head)
    local start = head
    -- head is always begin of par (whatsit), so we have at least two prev nodes
    -- penalty followed by glue
    while start do
        local id = start.id
        if id == glyph_code then 
            local attr = has_attribute(start, xpgtibtattr)
            if attr and attr > 0 then
                if start.char == tsheg then
                    if start.next then
                        insert_node_after(head,start,get_penalty_node())
                    end
                end
            end
        elseif id == math_code then
            -- warning: this is a feature of luatex > 0.76
            start = end_of_math(start) -- weird, can return nil .. no math end?
        end
        if start then
            start = start.next
        end
    end
    return head
end

local callback_name = "pre_linebreak_filter"

local function activate()
  if not priority_in_callback (callback_name, "polyglossia-tibt.process") then
    add_to_callback(callback_name, process, "polyglossia-tibt.process", 1)
  end
end

local function desactivate()
  if priority_in_callback (callback_name, "polyglossia-tibt.process") then
    remove_from_callback(callback_name, "polyglossia-tibt.process")
  end
end

polyglossia.activate_tibt_eol    = activate
polyglossia.desactivate_tibt_eol = desactivate
%    \end{macrocode}
% \iffalse
%</polyglossia-tibt.lua>
%<*polyglossia.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia.lua}
%    \begin{macrocode}
--
-- polyglossia.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

local module_name = "polyglossia"
local polyglossia_module = {
    name          = module_name,
    version       = 1.3,
    date          = "2013/05/11",
    description   = "Polyglossia",
    author        = "Elie Roux",
    copyright     = "Elie Roux",
    license       = "CC0"
}

luatexbase.provides_module(polyglossia_module)

local log_info = function(message, ...)
    luatexbase.module_info(module_name, message:format(...))
end
local log_warn = function(message, ...)
    luatexbase.module_warning(module_name, message:format(...))
end

polyglossia = polyglossia or {}
local polyglossia = polyglossia

local function select_language(lang, id)
    polyglossia.current_language = lang
end

local function set_default_language(lang, id)
    polyglossia.default_language = lang
end

local byte = utf8.codepoint -- use standard module of lua 5.3

local check_char

if luaotfload and luaotfload.aux and luaotfload.aux.font_has_glyph then
    local font_has_glyph = luaotfload.aux.font_has_glyph
    function check_char(chr)
        local codepoint = tonumber(chr) or byte(chr)
        if font_has_glyph(font.current(), codepoint) then
            tex.sprint('1')
        else
            tex.sprint('0')
        end
    end
else
    function check_char(chr) -- always in current font
        local fontid    = font.current()
        local fontdata  = font.getfont(fontid) or font.fonts[fontid]
        local chardata  = fontdata.characters
        local codepoint = tonumber(chr) or byte(chr)
        if chardata and chardata[codepoint] then
            tex.sprint('1')
        else
            tex.sprint('0')
        end
    end
end

local function load_tibt_eol()
    require('polyglossia-tibt')
end

-- predefined l@nohyphenation or LuaTeX's maximum value for \language
local nohyphid = luatexbase.registernumber'l@nohyphenation' or 16383

-- key `nohyphenation` is for .sty file when possibly undefined l@nohyphenation
local newloader_loaded_languages = { nohyphenation = nohyphid }

local newloader_available_languages = require'language.dat.lua'
-- Suggestion by Dohyun Kim on #129
local t = { }
for k, v in pairs(newloader_available_languages) do
    t[k] = v
    for _, vv in pairs(v.synonyms) do
        t[vv] = v
    end
end
newloader_available_languages = t

-- LaTeX's language register is \count19
local lang_register = 19

-- New hyphenation pattern loader: use language.dat.lua directly and the language identifiers
local function newloader(langentry)
    local loaded_language = newloader_loaded_languages[langentry]
    if loaded_language then
        local langid = lang.id(loaded_language)
        log_info('Language %s already loaded; id is %i', langentry, langid)
        return langid
    else
        local langdata = newloader_available_languages[langentry]
        if langdata then

            local special = langdata.special
            if special then
                -- language0 (USenglish) is already included in the format
                if special == 'language0' then
                    return 0

                -- disabled language should not be used for utf-8 text
                elseif special:find'^disabled:' then
                    log_warn('Hyphenation of language %s %s', langentry, special)
                    return nohyphid
                end
            end

            -- language info will be written into the .log file
            local s = { "Language data for " .. langentry }
            for k, v in pairs(langdata) do
                if type(v) == 'table' then -- for 'synonyms'
                    s[#s+1] = k .. "\t" .. table.concat(v,',')
                else
                    s[#s+1] = k .. "\t" .. tostring(v)
                end
            end
            log_info(table.concat(s,"\n"))

            --
            -- LaTeX's \newlanguage increases language register (count19),
            -- whereas LuaTeX's lang.new() increases its own language id.
            -- So when a user has declared, say, \newlanguage\lang@xyz, then
            -- these two numbers do not match each other. If we do not consider
            -- this possible situation, our newloader() function will
            -- unfortunately overwrite the language \lang@xyz.
            --
            -- Threfore here we will compare LaTeX's \newlanguage number with
            -- LuaTeX's lang.new() id and select the bigger one for our new
            -- language object. Also we will update LaTeX's language register
            -- by this new id, so that another possible \newlanguage should not
            -- overwrite our language object.
            --
            -- get next \newlanguage allocation number
            local langcnt = tex.count[lang_register] + 1
            -- get new lang object
            local langobject = lang.new()
            local langid = lang.id(langobject)
            -- get bigger one between \newlanguage and new lang obj id
            local newlangid = math.max(langcnt, langid)
            -- set language register for possible \newlanguage
            tex.setcount('global', lang_register, newlangid)
            -- get new lang object if needeed
            if langid ~= newlangid then
                langobject = lang.new(newlangid)
            end

            -- load hyphenation patterns and exceptions
            for _,v in ipairs{ 'patterns', 'hyphenation' } do
                local data = langdata[v]
                if data and data ~= '' then
                    -- cope with comma separated list, such as serbian
                    for _,vv in ipairs(data:explode',+') do
                        local filepath = kpse.find_file(vv)
                        if filepath then
                            local fh = io.open(filepath)
                            lang[v](langobject, fh:read'a')
                            fh:close()
                        else
                            log_warn('Hyphenation file %s not found', vv)
                        end
                    end
                end
            end

            newloader_loaded_languages[langentry] = langobject

            log_info('Language %s was not yet loaded; created with id %i',
                     langentry, newlangid)
            return newlangid
        else
            log_warn('Language %s not found in language.dat.lua', langentry)
            return nohyphid
        end
    end
end

polyglossia.select_language = select_language
polyglossia.set_default_language = set_default_language
polyglossia.check_char = check_char
polyglossia.load_tibt_eol = load_tibt_eol
polyglossia.newloader = newloader
polyglossia.newloader_loaded_languages = newloader_loaded_languages
-- global variables:
-- polyglossia.default_language
-- polyglossia.current_language
%    \end{macrocode}
% \iffalse
%</polyglossia.lua>
%<*babel-hebrewalph.def>
% \fi
% \clearpage
% 
% \subsection{babel-hebrewalph.def}
%    \begin{macrocode}
\ProvidesFile{babel-hebrewalph.def}
         [2023/06/01 %
         Expandable definitions for Hebrew numerals]

\newcommand*\hebrewnumeral[1]{%
  \expandafter\@hebrew@numeral\expandafter{\the\numexpr#1}%
}
\newcommand*\Hebrewnumeral[1]{%
  \expandafter\@Hebrew@numeral\expandafter{\the\numexpr#1}%
}
\newcommand*\Hebrewnumeralfinal[1]{%
  \expandafter\@Hebrew@numeralfinal\expandafter{\the\numexpr#1}%
}

\newcommand*\hebrew@div@trancate[2]{%
	\ifnum\numexpr #1 - #2*\numexpr #1/#2\relax<0
	\the\numexpr #1/#2 -1\relax\else\the\numexpr #1/#2\relax\fi
}
 
\newcommand*\@hebrew@@numeral[2]{%
  \ifnum#1<\z@\space\xpg@warning{Illegal value (#1) for Hebrew numeral}%
  \else
    \ifnum #1<1000
		\gim@nomil{#1}{#2}%
    \else
		\hebrewnumeral{\hebrew@div@trancate{#1}{1000}}׳%
        \expandafter\gim@nomil\expandafter{\the\numexpr #1 - 1000*\hebrew@div@trancate{#1}{1000}}{#2}%
    \fi
  \fi
}

\newcommand*\@hebrew@numeral[1]{\@hebrew@@numeral{#1}{0}}
\newcommand*\@Hebrew@numeral[1]{\@hebrew@@numeral{#1}{1}}
\newcommand*\@Hebrew@numeralfinal[1]{\@hebrew@@numeral{#1}{2}}

\newcommand*\hebrew@alph@zero{}
\newcommand*\gim@nomil[2]{%
  \ifcase\hebrew@div@trancate{#1}{100}  % print nothing if no hundreds
     \or ק\ifnum #2>0\ifnum #1=100 ׳\fi\fi
     \or ר\ifnum #2>0\ifnum #1=200 ׳\fi\fi
     \or ש\ifnum #2>0\ifnum #1=300 ׳\fi\fi
     \or ת\ifnum #2>0\ifnum #1=400 ׳\fi\fi
     \or ת\ifnum #2>0\ifnum #1=500 ״\fi\fi ק%
     \or ת\ifnum #2>0\ifnum #1=600 ״\fi\fi ר%
     \or ת\ifnum #2>0\ifnum #1=700 ״\fi\fi ש%
     \or ת\ifnum #2>0\ifnum #1=800 ״\fi\fi ת%
     \or תת\ifnum #2>0\ifnum #1=900 ״\fi\fi ק%
  \fi
  \ifnum \the\numexpr #1 - 100*\hebrew@div@trancate{#1}{100} = 16
  \ifnum #2>0 ט״ז\else טז\fi% tet-zayin
  \else\ifnum \the\numexpr #1 - 100*\hebrew@div@trancate{#1}{100} = 15
  \ifnum #2>0  ט״ו\else טו\fi% tet-vav
  \else
  \ifcase\expandafter\hebrew@div@trancate\expandafter{\the\numexpr #1 - 100*\hebrew@div@trancate{#1}{100}}{10}  % print nothing if no tens
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 י\else\ifnum #2>0\ifnum #1=10 י׳\else ״י\fi\else י\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 כ\else\ifnum #2>0\ifnum #1>20 ״\fi\fi\if #22ך\else כ\fi\ifnum #2>0\ifnum #1=20 ׳\fi\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 ל\else\ifnum #2>0\ifnum #1=30 ל׳\else ״ל\fi\else ל\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 מ\else\ifnum #2>0\ifnum #1>40 ״\fi\fi\if #22ם\else מ\fi\ifnum #2>0\ifnum #1=40 ׳\fi\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 נ\else\ifnum #2>0\ifnum #1>50 ״\fi\fi\if #22ן\else נ\fi\ifnum #2>0\ifnum #1=50 ׳\fi\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 ס\else\ifnum #2>0\ifnum #1=60 ס׳\else ״ס\fi\else ס\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 ע\else\ifnum #2>0\ifnum #1=70 ע׳\else ״ע\fi\else ע\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 פ\else\ifnum #2>0\ifnum #1>80 ״\fi\fi\if #22ף\else פ\fi\ifnum #2>0\ifnum #1=80 ׳\fi\fi\fi
      \or \ifnum \the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}>0 צ\else\ifnum #2>0\ifnum #1>90 ״\fi\fi\if #22ץ\else צ\fi\ifnum #2>0\ifnum #1=90 ׳\fi\fi\fi
  \fi
  \ifcase\the\numexpr #1 - 10*\hebrew@div@trancate{#1}{10}
      \hebrew@alph@zero %  empty but can be defined if desired
      \or \ifnum #2>0\ifnum #1=1 א׳\else ״א\fi\else א\fi
      \or \ifnum #2>0\ifnum #1=2 ב׳\else ״ב\fi\else ב\fi
      \or \ifnum #2>0\ifnum #1=3 ג׳\else ״ג\fi\else ג\fi
      \or \ifnum #2>0\ifnum #1=4 ד׳\else ״ד\fi\else ד\fi
      \or \ifnum #2>0\ifnum #1=5 ה׳\else ״ה\fi\else ה\fi
      \or \ifnum #2>0\ifnum #1=6 ו׳\else ״ו\fi\else ו\fi
      \or \ifnum #2>0\ifnum #1=7 ז׳\else ״ז\fi\else ז\fi
      \or \ifnum #2>0\ifnum #1=8 ח׳\else ״ח\fi\else ח\fi
      \or \ifnum #2>0\ifnum #1=9 ט׳\else ״ט\fi\else ט\fi
  \fi\fi\fi
}

\newcommand*\Alphfinal[1]{\expandafter\@Alphfinal\csname c@#1\endcsname}
\newcommand*\@Alphfinal[1]{\Hebrewnumeralfinal{#1}}

%    \end{macrocode}
% \iffalse
%</babel-hebrewalph.def>
%<*babelsh.def>
% \fi
% \clearpage
% 
% \subsection{babelsh.def}
%    \begin{macrocode}
\ifx\initiate@active@char\@undefined
\else
  \bbl@afterfi\endinput
\fi
\ProvidesFile{babelsh.def}
         [2022/06/21 %
         Babel common definitions for shorthands^^J
         Taken verbatim from babel files (2022/06/06 v3.76)]
%
% ------------------------------------------------------------------------------
%
% lines 52 to 56 from babel.sty
%
% ------------------------------------------------------------------------------
%
\def\bbl@error#1#2{%
  \begingroup
    \def\\{\MessageBreak}%
    \PackageError{babel}{#1}{#2}%
  \endgroup}
%
% ------------------------------------------------------------------------------
%
% lines 69 to 73 from babel.sty
%
% ------------------------------------------------------------------------------
%
\def\bbl@info#1{%
  \begingroup
    \def\\{\MessageBreak}%
    \PackageInfo{babel}{#1}%
  \endgroup}
%
% ------------------------------------------------------------------------------
%
% lines 75 to 80 from babel.sty
%
% ------------------------------------------------------------------------------
%
\def\bbl@stripslash{\expandafter\@gobble\string}
\def\bbl@add#1#2{%
  \bbl@ifunset{\bbl@stripslash#1}%
    {\def#1{#2}}%
    {\expandafter\def\expandafter#1\expandafter{#1#2}}}
\def\bbl@xin@{\@expandtwoargs\in@}
%
% ------------------------------------------------------------------------------
%
% line 97 to 98 from babel.sty
%
% ------------------------------------------------------------------------------
%
\long\def\bbl@afterelse#1\else#2\fi{\fi#1}
\long\def\bbl@afterfi#1\fi{\fi#1}
%
% ------------------------------------------------------------------------------
%
% line 376 from babel.sty
%
% ------------------------------------------------------------------------------
%
\let\bbl@opt@shorthands\@nnil
%
% ------------------------------------------------------------------------------
%
% lines 414 to 435 from babel.sty
%
% ------------------------------------------------------------------------------
%
\def\bbl@sh@string#1{%
  \ifx#1\@empty\else
    \ifx#1t\string~%
    \else\ifx#1c\string,%
    \else\string#1%
    \fi\fi
    \expandafter\bbl@sh@string
  \fi}
\ifx\bbl@opt@shorthands\@nnil
  \def\bbl@ifshorthand#1#2#3{#2}%
\else\ifx\bbl@opt@shorthands\@empty
  \def\bbl@ifshorthand#1#2#3{#3}%
\else
  \def\bbl@ifshorthand#1{%
    \bbl@xin@{\string#1}{\bbl@opt@shorthands}%
    \ifin@
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi}
  \edef\bbl@opt@shorthands{%
    \expandafter\bbl@sh@string\bbl@opt@shorthands\@empty}%
%
% ------------------------------------------------------------------------------
%
% line 440 from babel.sty
%
% ------------------------------------------------------------------------------
%
\fi\fi
%
% ------------------------------------------------------------------------------
%
% lines 387 to 406 from babel.def
%
% ------------------------------------------------------------------------------
%
\let\bbl@opt@shorthands\@nnil
\def\bbl@ifshorthand#1#2#3{#2}%
\let\bbl@language@opts\@empty
\ifx\babeloptionstrings\@undefined
  \let\bbl@opt@strings\@nnil
\else
  \let\bbl@opt@strings\babeloptionstrings
\fi
\def\BabelStringsDefault{generic}
\def\bbl@tempa{normal}
\ifx\babeloptionmath\bbl@tempa
  \def\bbl@mathnormal{\noexpand\textormath}
\fi
\def\AfterBabelLanguage#1#2{}
\ifx\BabelModifiers\@undefined\let\BabelModifiers\relax\fi
\let\bbl@afterlang\relax
\def\bbl@opt@safe{BR}
\ifx\@uclclist\@undefined\let\@uclclist\@empty\fi
\ifx\bbl@trace\@undefined\def\bbl@trace#1{}\fi
\expandafter\newif\csname ifbbl@single\endcsname
%
% ------------------------------------------------------------------------------
%
% line 938 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
%
% ------------------------------------------------------------------------------
%
% lines 941 to 947 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
  \ifx\@nnil#3\relax\else
    \def#1{#3}#2\bbl@afterfi\bbl@@loop#1{#2}%
  \fi}
\def\bbl@for#1#2#3{\bbl@loopx#1{#2}{\ifx#1\@empty\else#3\fi}}
%
% ------------------------------------------------------------------------------
%
% lines 956 to 965 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@exp#1{%
  \begingroup
    \let\\\noexpand
    \let\<\bbl@exp@en
    \let\[\bbl@exp@ue
    \edef\bbl@exp@aux{\endgroup#1}%
  \bbl@exp@aux}
\def\bbl@exp@en#1>{\expandafter\noexpand\csname#1\endcsname}%
\def\bbl@exp@ue#1]{%
  \unexpanded\expandafter\expandafter\expandafter{\csname#1\endcsname}}%
%
% ------------------------------------------------------------------------------
%
% lines 979 to 998 from babel.def
%
% ------------------------------------------------------------------------------
%
\begingroup
  \gdef\bbl@ifunset#1{%
    \expandafter\ifx\csname#1\endcsname\relax
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi}
  \bbl@ifunset{ifcsname}% TODO. A better test?
    {}%
    {\gdef\bbl@ifunset#1{%
       \ifcsname#1\endcsname
         \expandafter\ifx\csname#1\endcsname\relax
           \bbl@afterelse\expandafter\@firstoftwo
         \else
           \bbl@afterfi\expandafter\@secondoftwo
         \fi
       \else
         \expandafter\@firstoftwo
       \fi}}
\endgroup
%
% ------------------------------------------------------------------------------
%
% lines 1075 to 1084 from babel.def
%
% ------------------------------------------------------------------------------
%
\chardef\bbl@engine=%
  \ifx\directlua\@undefined
    \ifx\XeTeXinputencoding\@undefined
      \z@
    \else
      \tw@
    \fi
  \else
    \@ne
  \fi
%
% ------------------------------------------------------------------------------
%
% lines 1152 to 1155 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@withactive#1#2{%
  \begingroup
    \lccode`~=`#2\relax
    \lowercase{\endgroup#1~}}
%
% ------------------------------------------------------------------------------
%
% line 1185 from babel.def
%
% NOTE: In order to avoid importing more unneeded definitions, this macro
%       does nothing for us.
%
% ------------------------------------------------------------------------------
%
\def\bbl@usehooks#1#2{}
%
% ------------------------------------------------------------------------------
%
% lines 1348 to 1463 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@add@special#1{% 1:a macro like \", \?, etc.
  \bbl@add\dospecials{\do#1}% test @sanitize = \relax, for back. compat.
  \bbl@ifunset{@sanitize}{}{\bbl@add\@sanitize{\@makeother#1}}%
  \ifx\nfss@catcodes\@undefined\else % TODO - same for above
    \begingroup
      \catcode`#1\active
      \nfss@catcodes
      \ifnum\catcode`#1=\active
        \endgroup
        \bbl@add\nfss@catcodes{\@makeother#1}%
      \else
        \endgroup
      \fi
  \fi}
\def\bbl@remove@special#1{%
  \begingroup
    \def\x##1##2{\ifnum`#1=`##2\noexpand\@empty
                 \else\noexpand##1\noexpand##2\fi}%
    \def\do{\x\do}%
    \def\@makeother{\x\@makeother}%
  \edef\x{\endgroup
    \def\noexpand\dospecials{\dospecials}%
    \expandafter\ifx\csname @sanitize\endcsname\relax\else
      \def\noexpand\@sanitize{\@sanitize}%
    \fi}%
  \x}
\def\bbl@active@def#1#2#3#4{%
  \@namedef{#3#1}{%
    \expandafter\ifx\csname#2@sh@#1@\endcsname\relax
      \bbl@afterelse\bbl@sh@select#2#1{#3@arg#1}{#4#1}%
    \else
      \bbl@afterfi\csname#2@sh@#1@\endcsname
    \fi}%
  \long\@namedef{#3@arg#1}##1{%
    \expandafter\ifx\csname#2@sh@#1@\string##1@\endcsname\relax
      \bbl@afterelse\csname#4#1\endcsname##1%
    \else
      \bbl@afterfi\csname#2@sh@#1@\string##1@\endcsname
    \fi}}%
\def\initiate@active@char#1{%
  \bbl@ifunset{active@char\string#1}%
    {\bbl@withactive
      {\expandafter\@initiate@active@char\expandafter}#1\string#1#1}%
    {}}
\def\@initiate@active@char#1#2#3{%
  \bbl@csarg\edef{oricat@#2}{\catcode`#2=\the\catcode`#2\relax}%
  \ifx#1\@undefined
    \bbl@csarg\def{oridef@#2}{\def#1{\active@prefix#1\@undefined}}%
  \else
    \bbl@csarg\let{oridef@@#2}#1%
    \bbl@csarg\edef{oridef@#2}{%
      \let\noexpand#1%
      \expandafter\noexpand\csname bbl@oridef@@#2\endcsname}%
  \fi
  \ifx#1#3\relax
    \expandafter\let\csname normal@char#2\endcsname#3%
  \else
    \bbl@info{Making #2 an active character}%
    \ifnum\mathcode`#2=\ifodd\bbl@engine"1000000 \else"8000 \fi
      \@namedef{normal@char#2}{%
        \textormath{#3}{\csname bbl@oridef@@#2\endcsname}}%
    \else
      \@namedef{normal@char#2}{#3}%
    \fi
    \bbl@restoreactive{#2}%
    \AtBeginDocument{%
      \catcode`#2\active
      \if@filesw
        \immediate\write\@mainaux{\catcode`\string#2\active}%
      \fi}%
    \expandafter\bbl@add@special\csname#2\endcsname
    \catcode`#2\active
  \fi
  \let\bbl@tempa\@firstoftwo
  \if\string^#2%
    \def\bbl@tempa{\noexpand\textormath}%
  \else
    \ifx\bbl@mathnormal\@undefined\else
      \let\bbl@tempa\bbl@mathnormal
    \fi
  \fi
  \expandafter\edef\csname active@char#2\endcsname{%
    \bbl@tempa
      {\noexpand\if@safe@actives
         \noexpand\expandafter
         \expandafter\noexpand\csname normal@char#2\endcsname
       \noexpand\else
         \noexpand\expandafter
         \expandafter\noexpand\csname bbl@doactive#2\endcsname
       \noexpand\fi}%
     {\expandafter\noexpand\csname normal@char#2\endcsname}}%
  \bbl@csarg\edef{doactive#2}{%
    \expandafter\noexpand\csname user@active#2\endcsname}%
  \bbl@csarg\edef{active@#2}{%
    \noexpand\active@prefix\noexpand#1%
    \expandafter\noexpand\csname active@char#2\endcsname}%
  \bbl@csarg\edef{normal@#2}{%
    \noexpand\active@prefix\noexpand#1%
    \expandafter\noexpand\csname normal@char#2\endcsname}%
  \expandafter\let\expandafter#1\csname bbl@normal@#2\endcsname
  \bbl@active@def#2\user@group{user@active}{language@active}%
  \bbl@active@def#2\language@group{language@active}{system@active}%
  \bbl@active@def#2\system@group{system@active}{normal@char}%
  \expandafter\edef\csname\user@group @sh@#2@@\endcsname
    {\expandafter\noexpand\csname normal@char#2\endcsname}%
  \expandafter\edef\csname\user@group @sh@#2@\string\protect@\endcsname
    {\expandafter\noexpand\csname user@active#2\endcsname}%
  \if\string'#2%
    \let\prim@s\bbl@prim@s
    \let\active@math@prime#1%
  \fi
  \bbl@usehooks{initiateactive}{{#1}{#2}{#3}}}
\@ifpackagewith{babel}{KeepShorthandsActive}%
  {\let\bbl@restoreactive\@gobble}%
  {\def\bbl@restoreactive#1{%
     \bbl@exp{%
%
% ------------------------------------------------------------------------------
%
% lines 1466 to 1516 from babel.def
%
% ------------------------------------------------------------------------------
%
       \\\AtEndOfPackage
         {\catcode`#1=\the\catcode`#1\relax}}}%
   \AtEndOfPackage{\let\bbl@restoreactive\@gobble}}
\def\bbl@sh@select#1#2{%
  \expandafter\ifx\csname#1@sh@#2@sel\endcsname\relax
    \bbl@afterelse\bbl@scndcs
  \else
    \bbl@afterfi\csname#1@sh@#2@sel\endcsname
  \fi}
\begingroup
\bbl@ifunset{ifincsname}% TODO. Ugly. Correct? Only Plain?
  {\gdef\active@prefix#1{%
     \ifx\protect\@typeset@protect
     \else
       \ifx\protect\@unexpandable@protect
         \noexpand#1%
       \else
         \protect#1%
       \fi
       \expandafter\@gobble
     \fi}}
  {\gdef\active@prefix#1{%
     \ifincsname
       \string#1%
       \expandafter\@gobble
     \else
       \ifx\protect\@typeset@protect
       \else
         \ifx\protect\@unexpandable@protect
           \noexpand#1%
         \else
           \protect#1%
         \fi
         \expandafter\expandafter\expandafter\@gobble
       \fi
     \fi}}
\endgroup
\newif\if@safe@actives
\@safe@activesfalse
\def\bbl@restore@actives{\if@safe@actives\@safe@activesfalse\fi}
\chardef\bbl@activated\z@
\def\bbl@activate#1{%
  \chardef\bbl@activated\@ne
  \bbl@withactive{\expandafter\let\expandafter}#1%
    \csname bbl@active@\string#1\endcsname}
\def\bbl@deactivate#1{%
  \chardef\bbl@activated\tw@
  \bbl@withactive{\expandafter\let\expandafter}#1%
    \csname bbl@normal@\string#1\endcsname}
\def\bbl@firstcs#1#2{\csname#1\endcsname}
\def\bbl@scndcs#1#2{\csname#2\endcsname}
%
% ------------------------------------------------------------------------------
%
% lines 1525 to 1702 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\declare@shorthand#1#2{\@decl@short{#1}#2\@nil}
\def\@decl@short#1#2#3\@nil#4{%
  \def\bbl@tempa{#3}%
  \ifx\bbl@tempa\@empty
    \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@scndcs
    \bbl@ifunset{#1@sh@\string#2@}{}%
      {\def\bbl@tempa{#4}%
       \expandafter\ifx\csname#1@sh@\string#2@\endcsname\bbl@tempa
       \else
         \bbl@info
           {Redefining #1 shorthand \string#2\\%
            in language \CurrentOption}%
       \fi}%
    \@namedef{#1@sh@\string#2@}{#4}%
  \else
    \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@firstcs
    \bbl@ifunset{#1@sh@\string#2@\string#3@}{}%
      {\def\bbl@tempa{#4}%
       \expandafter\ifx\csname#1@sh@\string#2@\string#3@\endcsname\bbl@tempa
       \else
         \bbl@info
           {Redefining #1 shorthand \string#2\string#3\\%
            in language \CurrentOption}%
       \fi}%
    \@namedef{#1@sh@\string#2@\string#3@}{#4}%
  \fi}
\def\textormath{%
  \ifmmode
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi}
\def\user@group{user}
\def\language@group{english} % TODO. I don't like defaults
\def\system@group{system}
\def\useshorthands{%
  \@ifstar\bbl@usesh@s{\bbl@usesh@x{}}}
\def\bbl@usesh@s#1{%
  \bbl@usesh@x
    {\AddBabelHook{babel-sh-\string#1}{afterextras}{\bbl@activate{#1}}}%
    {#1}}
\def\bbl@usesh@x#1#2{%
  \bbl@ifshorthand{#2}%
    {\def\user@group{user}%
     \initiate@active@char{#2}%
     #1%
     \bbl@activate{#2}}%
    {\bbl@error
       {I can't declare a shorthand turned off (\string#2)}
       {Sorry, but you can't use shorthands which have been\\%
        turned off in the package options}}}
\def\user@language@group{user@\language@group}
\def\bbl@set@user@generic#1#2{%
  \bbl@ifunset{user@generic@active#1}%
    {\bbl@active@def#1\user@language@group{user@active}{user@generic@active}%
     \bbl@active@def#1\user@group{user@generic@active}{language@active}%
     \expandafter\edef\csname#2@sh@#1@@\endcsname{%
       \expandafter\noexpand\csname normal@char#1\endcsname}%
     \expandafter\edef\csname#2@sh@#1@\string\protect@\endcsname{%
       \expandafter\noexpand\csname user@active#1\endcsname}}%
  \@empty}
\newcommand\defineshorthand[3][user]{%
  \edef\bbl@tempa{\zap@space#1 \@empty}%
  \bbl@for\bbl@tempb\bbl@tempa{%
    \if*\expandafter\@car\bbl@tempb\@nil
      \edef\bbl@tempb{user@\expandafter\@gobble\bbl@tempb}%
      \@expandtwoargs
        \bbl@set@user@generic{\expandafter\string\@car#2\@nil}\bbl@tempb
    \fi
    \declare@shorthand{\bbl@tempb}{#2}{#3}}}
\def\languageshorthands#1{\def\language@group{#1}}
\def\aliasshorthand#1#2{%
  \bbl@ifshorthand{#2}%
    {\expandafter\ifx\csname active@char\string#2\endcsname\relax
       \ifx\document\@notprerr
         \@notshorthand{#2}%
       \else
         \initiate@active@char{#2}%
         \expandafter\let\csname active@char\string#2\expandafter\endcsname
           \csname active@char\string#1\endcsname
         \expandafter\let\csname normal@char\string#2\expandafter\endcsname
           \csname normal@char\string#1\endcsname
         \bbl@activate{#2}%
       \fi
     \fi}%
    {\bbl@error
       {Cannot declare a shorthand turned off (\string#2)}
       {Sorry, but you cannot use shorthands which have been\\%
        turned off in the package options}}}
\def\@notshorthand#1{%
  \bbl@error{%
    The character '\string #1' should be made a shorthand character;\\%
    add the command \string\useshorthands\string{#1\string} to
    the preamble.\\%
    I will ignore your instruction}%
   {You may proceed, but expect unexpected results}}
\newcommand*\shorthandon[1]{\bbl@switch@sh\@ne#1\@nnil}
\DeclareRobustCommand*\shorthandoff{%
  \@ifstar{\bbl@shorthandoff\tw@}{\bbl@shorthandoff\z@}}
\def\bbl@shorthandoff#1#2{\bbl@switch@sh#1#2\@nnil}
\def\bbl@switch@sh#1#2{%
  \ifx#2\@nnil\else
    \bbl@ifunset{bbl@active@\string#2}%
      {\bbl@error
         {I can't switch '\string#2' on or off--not a shorthand}%
         {This character is not a shorthand. Maybe you made\\%
          a typing mistake? I will ignore your instruction.}}%
      {\ifcase#1%   off, on, off*
         \catcode`#212\relax
       \or
         \catcode`#2\active
         \bbl@ifunset{bbl@shdef@\string#2}%
           {}%
           {\bbl@withactive{\expandafter\let\expandafter}#2%
              \csname bbl@shdef@\string#2\endcsname
            \bbl@csarg\let{shdef@\string#2}\relax}%
         \ifcase\bbl@activated\or
           \bbl@activate{#2}%
         \else
           \bbl@deactivate{#2}%
         \fi
       \or
         \bbl@ifunset{bbl@shdef@\string#2}%
           {\bbl@withactive{\bbl@csarg\let{shdef@\string#2}}#2}%
           {}%
         \csname bbl@oricat@\string#2\endcsname
         \csname bbl@oridef@\string#2\endcsname
       \fi}%
    \bbl@afterfi\bbl@switch@sh#1%
  \fi}
\def\babelshorthand{\active@prefix\babelshorthand\bbl@putsh}
\def\bbl@putsh#1{%
  \bbl@ifunset{bbl@active@\string#1}%
     {\bbl@putsh@i#1\@empty\@nnil}%
     {\csname bbl@active@\string#1\endcsname}}
\def\bbl@putsh@i#1#2\@nnil{%
  \csname\language@group @sh@\string#1@%
    \ifx\@empty#2\else\string#2@\fi\endcsname}
\ifx\bbl@opt@shorthands\@nnil\else
  \let\bbl@s@initiate@active@char\initiate@active@char
  \def\initiate@active@char#1{%
    \bbl@ifshorthand{#1}{\bbl@s@initiate@active@char{#1}}{}}
  \let\bbl@s@switch@sh\bbl@switch@sh
  \def\bbl@switch@sh#1#2{%
    \ifx#2\@nnil\else
      \bbl@afterfi
      \bbl@ifshorthand{#2}{\bbl@s@switch@sh#1{#2}}{\bbl@switch@sh#1}%
    \fi}
  \let\bbl@s@activate\bbl@activate
  \def\bbl@activate#1{%
    \bbl@ifshorthand{#1}{\bbl@s@activate{#1}}{}}
  \let\bbl@s@deactivate\bbl@deactivate
  \def\bbl@deactivate#1{%
    \bbl@ifshorthand{#1}{\bbl@s@deactivate{#1}}{}}
\fi
\newcommand\ifbabelshorthand[3]{\bbl@ifunset{bbl@active@\string#1}{#3}{#2}}
\def\bbl@prim@s{%
  \prime\futurelet\@let@token\bbl@pr@m@s}
\def\bbl@if@primes#1#2{%
  \ifx#1\@let@token
    \expandafter\@firstoftwo
  \else\ifx#2\@let@token
    \bbl@afterelse\expandafter\@firstoftwo
  \else
    \bbl@afterfi\expandafter\@secondoftwo
  \fi\fi}
\begingroup
  \catcode`\^=7  \catcode`\*=\active  \lccode`\*=`\^
  \catcode`\'=12 \catcode`\"=\active  \lccode`\"=`\'
  \lowercase{%
    \gdef\bbl@pr@m@s{%
      \bbl@if@primes"'%
        \pr@@@s
        {\bbl@if@primes*^\pr@@@t\egroup}}}
\endgroup
\initiate@active@char{~}
\declare@shorthand{system}{~}{\leavevmode\nobreak\ }
\bbl@activate{~}
%
% ------------------------------------------------------------------------------
%
% lines 1863 to 1900 from babel.def
%
% ------------------------------------------------------------------------------
%
\def\bbl@allowhyphens{\ifvmode\else\nobreak\hskip\z@skip\fi}
\def\bbl@t@one{T1}
\def\allowhyphens{\ifx\cf@encoding\bbl@t@one\else\bbl@allowhyphens\fi}
\newcommand\babelnullhyphen{\char\hyphenchar\font}
\def\babelhyphen{\active@prefix\babelhyphen\bbl@hyphen}
\def\bbl@hyphen{%
  \@ifstar{\bbl@hyphen@i @}{\bbl@hyphen@i\@empty}}
\def\bbl@hyphen@i#1#2{%
  \bbl@ifunset{bbl@hy@#1#2\@empty}%
    {\csname bbl@#1usehyphen\endcsname{\discretionary{#2}{}{#2}}}%
    {\csname bbl@hy@#1#2\@empty\endcsname}}
\def\bbl@usehyphen#1{%
  \leavevmode
  \ifdim\lastskip>\z@\mbox{#1}\else\nobreak#1\fi
  \nobreak\hskip\z@skip}
\def\bbl@@usehyphen#1{%
  \leavevmode\ifdim\lastskip>\z@\mbox{#1}\else#1\fi}
\def\bbl@hyphenchar{%
  \ifnum\hyphenchar\font=\m@ne
    \babelnullhyphen
  \else
    \char\hyphenchar\font
  \fi}
\def\bbl@hy@soft{\bbl@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}}
\def\bbl@hy@@soft{\bbl@@usehyphen{\discretionary{\bbl@hyphenchar}{}{}}}
\def\bbl@hy@hard{\bbl@usehyphen\bbl@hyphenchar}
\def\bbl@hy@@hard{\bbl@@usehyphen\bbl@hyphenchar}
\def\bbl@hy@nobreak{\bbl@usehyphen{\mbox{\bbl@hyphenchar}}}
\def\bbl@hy@@nobreak{\mbox{\bbl@hyphenchar}}
\def\bbl@hy@repeat{%
  \bbl@usehyphen{%
    \discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
\def\bbl@hy@@repeat{%
  \bbl@@usehyphen{%
    \discretionary{\bbl@hyphenchar}{\bbl@hyphenchar}{\bbl@hyphenchar}}}
\def\bbl@hy@empty{\hskip\z@skip}
\def\bbl@hy@@empty{\discretionary{}{}{}}
\def\bbl@disc#1#2{\nobreak\discretionary{#2-}{}{#1}\bbl@allowhyphens}
%
% ------------------------------------------------------------------------------
%
% end of the code copied from babel files
%
% ------------------------------------------------------------------------------
%
\def\bbl@disc@german#1#2{%
  \nobreak\discretionary{#2-}{}{#1}}
%    \end{macrocode}
% \iffalse
%</babelsh.def>
%<*cal-util.def>
% \fi
% \clearpage
% 
% \subsection{cal-util.def}
%    \begin{macrocode}
%%%%%%%%%%%%% cal-util.def %%%%%%%%%%%%%%%%
% Macros shared by hijrical and hebrewcal %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the following is adapted from hebcal.sty in babel
\def\@Remainder#1#2#3{%
    #3 = #1%                   %  c = a
    \divide #3 by #2%          %  c = a/b
    \multiply #3 by -#2%       %  c = -b(a/b)
    \advance #3 by #1}%        %  c = a - b(a/b)
\newif\if@Divisible
\def\@CheckIfDivisible#1#2{%
    {%
      \countdef\tmpx=0%        % temporary variable
      \@Remainder{#1}{#2}{\tmpx}%
      \ifnum\tmpx=0%
          \global\@Divisibletrue%
      \else%
          \global\@Divisiblefalse%
      \fi}}
\newif\if@GregorianLeap
\def\@CheckIfGregorianLeap#1{%
   {%
   \@CheckIfDivisible{#1}{4}%
    \if@Divisible%
        \@CheckIfDivisible{#1}{100}%
        \if@Divisible%
            \@CheckIfDivisible{#1}{400}%
            \if@Divisible%
                \global\@GregorianLeaptrue%
            \else%
                \global\@GregorianLeapfalse%
            \fi%
        \else%
            \global\@GregorianLeaptrue%
        \fi%
    \else%
        \global\@GregorianLeapfalse%
    \fi%
    }}
%%

\newcounter{tmpA}\newcounter{tmpB}
\newcounter{tmpC}\newcounter{tmpD}
\newcounter{tmpE}\newcounter{tmpF}


%% This is an algorithm from Reingold & Dershowitz, 
%% Calendrical Calculations, The Millenium Edition
%%
\def\@FixedFromGregorian#1#2#3#4{%
 \setcounter{tmpA}{(#1-1)*365}%
 \setcounter{tmpB}{(#1-1)/4}%
 \setcounter{tmpC}{(#1-1)/100}%
 \setcounter{tmpD}{(#1-1)/400}%
 \setcounter{tmpE}{(367*#2-362)/12}%
 \ifnum#2<3%
    \setcounter{tmpF}{0}%
 \else%
      \@CheckIfGregorianLeap{#1}%
      \if@GregorianLeap%
        \setcounter{tmpF}{-1}%
      \else%
        \setcounter{tmpF}{-2}%
      \fi%
 \fi%
 \@ifundefined{c@#4}{\global\newcounter{#4}}{}%
 \setcounter{#4}{\value{tmpA}+\value{tmpB}-\value{tmpC}+\value{tmpD}+\value{tmpE}+\value{tmpF}+#3}%
}
%    \end{macrocode}
% \iffalse
%</cal-util.def>
%<*xgreek-fixes.def>
% \fi
% \clearpage
% 
% \subsection{xgreek-fixes.def}
%    \begin{macrocode}
% the following fixes are taken verbatim from xgreek.sty:
% \message{Package `xgreek' version 3.0.1 by Apostolos Syropoulos}
\global\lccode"0370="0371 \global\uccode"0370="0370
\global\lccode"0371="0371 \global\uccode"0371="0370
\global\lccode"0372="0373 \global\uccode"0372="0372
\global\lccode"0373="0373 \global\uccode"0373="0372
\global\lccode"0376="0377 \global\uccode"0376="0376
\global\lccode"0377="0377 \global\uccode"0377="0376
\global\lccode"03FD="037B \global\uccode"03FD="03FD
\global\lccode"037B="037B \global\uccode"037B="03FD
\global\lccode"03FE="037C \global\uccode"03FE="03FE
\global\lccode"037C="037C \global\uccode"037C="03FE
\global\lccode"03FF="037D \global\uccode"03FF="03FF
\global\lccode"037D="037D \global\uccode"037D="03FF
\global\lccode"0386="03AC \global\uccode"0386="0391
\global\lccode"0388="03AD \global\uccode"0388="0395
\global\lccode"0389="03AC \global\uccode"0389="0397
\global\lccode"038A="03AF \global\uccode"038A="0399
\global\lccode"038C="03CC \global\uccode"038C="039F
\global\lccode"038E="03CD \global\uccode"038E="03A5
\global\lccode"038F="03CE \global\uccode"038F="03A9
\global\lccode"0390="0390 \global\uccode"0390="03AA
\global\lccode"0391="03B1 \global\uccode"0391="0391
\global\lccode"0392="03B2 \global\uccode"0392="0392
\global\lccode"0393="03B3 \global\uccode"0393="0393
\global\lccode"0394="03B4 \global\uccode"0394="0394
\global\lccode"0395="03B5 \global\uccode"0395="0395
\global\lccode"0396="03B6 \global\uccode"0396="0396
\global\lccode"0397="03B7 \global\uccode"0397="0397
\global\lccode"0398="03B8 \global\uccode"0398="0398
\global\lccode"0399="03B9 \global\uccode"0399="0399
\global\lccode"039A="03BA \global\uccode"039A="039A
\global\lccode"039B="03BB \global\uccode"039B="039B
\global\lccode"039C="03BC \global\uccode"039C="039C
\global\lccode"039D="03BD \global\uccode"039D="039D
\global\lccode"039E="03BE \global\uccode"039E="039E
\global\lccode"039F="03BF \global\uccode"039F="039F
\global\lccode"03A0="03C0 \global\uccode"03A0="03A0
\global\lccode"03A1="03C1 \global\uccode"03A1="03A1
\global\lccode"03A3="03C3 \global\uccode"03A3="03A3
\global\lccode"03A4="03C4 \global\uccode"03A4="03A4
\global\lccode"03A5="03C5 \global\uccode"03A5="03A5
\global\lccode"03A6="03C6 \global\uccode"03A6="03A6
\global\lccode"03A7="03C7 \global\uccode"03A7="03A7
\global\lccode"03A8="03C8 \global\uccode"03A8="03A8
\global\lccode"03A9="03C9 \global\uccode"03A9="03A9
\global\lccode"03AA="03CA \global\uccode"03AA="03AA
\global\lccode"03AB="03CB \global\uccode"03AB="03AB
\global\lccode"03AC="03AC \global\uccode"03AC="0391
\global\lccode"03AD="03AD \global\uccode"03AD="0395
\global\lccode"03AE="03AE \global\uccode"03AE="0397
\global\lccode"03AF="03AF \global\uccode"03AF="0399
\global\lccode"03B0="03B0 \global\uccode"03B0="03AB
\global\lccode"03B1="03B1 \global\uccode"03B1="0391
\global\lccode"03B2="03B2 \global\uccode"03B2="0392
\global\lccode"03B3="03B3 \global\uccode"03B3="0393
\global\lccode"03B4="03B4 \global\uccode"03B4="0394
\global\lccode"03B5="03B5 \global\uccode"03B5="0395
\global\lccode"03B6="03B6 \global\uccode"03B6="0396
\global\lccode"03B7="03B7 \global\uccode"03B7="0397
\global\lccode"03B8="03B8 \global\uccode"03B8="0398
\global\lccode"03B9="03B9 \global\uccode"03B9="0399
\global\lccode"03BA="03BA \global\uccode"03BA="039A
\global\lccode"03BB="03BB \global\uccode"03BB="039B
\global\lccode"03BC="03BC \global\uccode"03BC="039C
\global\lccode"03BD="03BD \global\uccode"03BD="039D
\global\lccode"03BE="03BE \global\uccode"03BE="039E
\global\lccode"03BF="03BF \global\uccode"03BF="039F
\global\lccode"03C0="03C0 \global\uccode"03C0="03A0
\global\lccode"03C1="03C1 \global\uccode"03C1="03A1
\global\lccode"03C2="03C2 \global\uccode"03C2="03A3
\global\lccode"03C3="03C3 \global\uccode"03C3="03A3
\global\lccode"03C4="03C4 \global\uccode"03C4="03A4
\global\lccode"03C5="03C5 \global\uccode"03C5="03A5
\global\lccode"03C6="03C6 \global\uccode"03C6="03A6
\global\lccode"03C7="03C7 \global\uccode"03C7="03A7
\global\lccode"03C8="03C8 \global\uccode"03C8="03A8
\global\lccode"03C9="03C9 \global\uccode"03C9="03A9
\global\lccode"03CA="03CA \global\uccode"03CA="03AA
\global\lccode"03CB="03CB \global\uccode"03CB="03AB
\global\lccode"03CC="03CC \global\uccode"03CC="039F
\global\lccode"03CD="03CD \global\uccode"03CD="03A5
\global\lccode"03CE="03CE \global\uccode"03CE="03A9
\global\lccode"03D0="03D0 \global\uccode"03D0="0392
\global\lccode"03D1="03D1 \global\uccode"03D1="0398
\global\lccode"03D2="03C5 \global\uccode"03D2="03A5
\global\lccode"03D3="03CD \global\uccode"03D3="03A5
\global\lccode"03D4="03CB \global\uccode"03D4="03AB
\global\lccode"03D5="03C6 \global\uccode"03D5="03A6
\global\lccode"03D6="03C0 \global\uccode"03D6="03A0
\global\lccode"03DA="03DB \global\uccode"03DA="03DA
\global\lccode"03DB="03DB \global\uccode"03DB="03DA
\global\lccode"03DC="03DD \global\uccode"03DC="03DC
\global\lccode"03DD="03DD \global\uccode"03DD="03DC
\global\lccode"03DE="03DF \global\uccode"03DE="03DE
\global\lccode"03DF="03DF \global\uccode"03DF="03DE
\global\lccode"03E0="03E1 \global\uccode"03E0="03E0
\global\lccode"03E1="03E1 \global\uccode"03E1="03E0
\global\lccode"03F0="03BA \global\uccode"03F0="039A
\global\lccode"03F1="03C1 \global\uccode"03F1="03A1
\global\lccode"03F2="03F2 \global\uccode"03F2="03F9
\global\lccode"03F9="03F2 \global\uccode"03F9="03F9
\global\lccode"1F00="1F00 \global\uccode"1F00="0391
\global\lccode"1F01="1F01 \global\uccode"1F01="0391
\global\lccode"1F02="1F02 \global\uccode"1F02="0391
\global\lccode"1F03="1F03 \global\uccode"1F03="0391
\global\lccode"1F04="1F04 \global\uccode"1F04="0391
\global\lccode"1F05="1F05 \global\uccode"1F05="0391
\global\lccode"1F06="1F06 \global\uccode"1F06="0391
\global\lccode"1F07="1F07 \global\uccode"1F07="0391
\global\lccode"1F08="1F00 \global\uccode"1F08="0391
\global\lccode"1F09="1F01 \global\uccode"1F09="0391
\global\lccode"1F0A="1F02 \global\uccode"1F0A="0391
\global\lccode"1F0B="1F03 \global\uccode"1F0B="0391
\global\lccode"1F0C="1F04 \global\uccode"1F0C="0391
\global\lccode"1F0D="1F05 \global\uccode"1F0D="0391
\global\lccode"1F0E="1F06 \global\uccode"1F0E="0391
\global\lccode"1F0F="1F07 \global\uccode"1F0F="0391
\global\lccode"1F10="1F10 \global\uccode"1F10="0395
\global\lccode"1F11="1F11 \global\uccode"1F11="0395
\global\lccode"1F12="1F12 \global\uccode"1F12="0395
\global\lccode"1F13="1F13 \global\uccode"1F13="0395
\global\lccode"1F14="1F14 \global\uccode"1F14="0395
\global\lccode"1F15="1F15 \global\uccode"1F15="0395
\global\lccode"1F18="1F10 \global\uccode"1F18="0395
\global\lccode"1F19="1F11 \global\uccode"1F19="0395
\global\lccode"1F1A="1F12 \global\uccode"1F1A="0395
\global\lccode"1F1B="1F13 \global\uccode"1F1B="0395
\global\lccode"1F1C="1F14 \global\uccode"1F1C="0395
\global\lccode"1F1D="1F15 \global\uccode"1F1D="0395
\global\lccode"1F20="1F20 \global\uccode"1F20="0397
\global\lccode"1F21="1F21 \global\uccode"1F21="0397
\global\lccode"1F22="1F22 \global\uccode"1F22="0397
\global\lccode"1F23="1F23 \global\uccode"1F23="0397
\global\lccode"1F24="1F24 \global\uccode"1F24="0397
\global\lccode"1F25="1F25 \global\uccode"1F25="0397
\global\lccode"1F26="1F26 \global\uccode"1F26="0397
\global\lccode"1F27="1F27 \global\uccode"1F27="0397
\global\lccode"1F28="1F20 \global\uccode"1F28="0397
\global\lccode"1F29="1F21 \global\uccode"1F29="0397
\global\lccode"1F2A="1F22 \global\uccode"1F2A="0397
\global\lccode"1F2B="1F23 \global\uccode"1F2B="0397
\global\lccode"1F2C="1F24 \global\uccode"1F2C="0397
\global\lccode"1F2D="1F25 \global\uccode"1F2D="0397
\global\lccode"1F2E="1F26 \global\uccode"1F2E="0397
\global\lccode"1F2F="1F27 \global\uccode"1F2F="0397
\global\lccode"1F30="1F30 \global\uccode"1F30="0399
\global\lccode"1F31="1F31 \global\uccode"1F31="0399
\global\lccode"1F32="1F32 \global\uccode"1F32="0399
\global\lccode"1F33="1F33 \global\uccode"1F33="0399
\global\lccode"1F34="1F34 \global\uccode"1F34="0399
\global\lccode"1F35="1F35 \global\uccode"1F35="0399
\global\lccode"1F36="1F36 \global\uccode"1F36="0399
\global\lccode"1F37="1F37 \global\uccode"1F37="0399
\global\lccode"1F38="1F30 \global\uccode"1F38="0399
\global\lccode"1F39="1F31 \global\uccode"1F39="0399
\global\lccode"1F3A="1F32 \global\uccode"1F3A="0399
\global\lccode"1F3B="1F33 \global\uccode"1F3B="0399
\global\lccode"1F3C="1F34 \global\uccode"1F3C="0399
\global\lccode"1F3D="1F35 \global\uccode"1F3D="0399
\global\lccode"1F3E="1F36 \global\uccode"1F3E="0399
\global\lccode"1F3F="1F37 \global\uccode"1F3F="0399
\global\lccode"1F40="1F40 \global\uccode"1F40="039F
\global\lccode"1F41="1F41 \global\uccode"1F41="039F
\global\lccode"1F42="1F42 \global\uccode"1F42="039F
\global\lccode"1F43="1F43 \global\uccode"1F43="039F
\global\lccode"1F44="1F44 \global\uccode"1F44="039F
\global\lccode"1F45="1F45 \global\uccode"1F45="039F
\global\lccode"1F48="1F40 \global\uccode"1F48="039F
\global\lccode"1F49="1F41 \global\uccode"1F49="039F
\global\lccode"1F4A="1F42 \global\uccode"1F4A="039F
\global\lccode"1F4B="1F43 \global\uccode"1F4B="039F
\global\lccode"1F4C="1F44 \global\uccode"1F4C="039F
\global\lccode"1F4D="1F45 \global\uccode"1F4D="039F
\global\lccode"1F50="1F50 \global\uccode"1F50="03A5
\global\lccode"1F51="1F51 \global\uccode"1F51="03A5
\global\lccode"1F52="1F52 \global\uccode"1F52="03A5
\global\lccode"1F53="1F53 \global\uccode"1F53="03A5
\global\lccode"1F54="1F54 \global\uccode"1F54="03A5
\global\lccode"1F55="1F55 \global\uccode"1F55="03A5
\global\lccode"1F56="1F56 \global\uccode"1F56="03A5
\global\lccode"1F57="1F57 \global\uccode"1F57="03A5
\global\lccode"1F59="1F51 \global\uccode"1F59="03A5
\global\lccode"1F5B="1F53 \global\uccode"1F5B="03A5
\global\lccode"1F5D="1F55 \global\uccode"1F5D="03A5
\global\lccode"1F5F="1F57 \global\uccode"1F5F="03A5
\global\lccode"1F60="1F60 \global\uccode"1F60="03A9
\global\lccode"1F61="1F61 \global\uccode"1F61="03A9
\global\lccode"1F62="1F62 \global\uccode"1F62="03A9
\global\lccode"1F63="1F63 \global\uccode"1F63="03A9
\global\lccode"1F64="1F64 \global\uccode"1F64="03A9
\global\lccode"1F65="1F65 \global\uccode"1F65="03A9
\global\lccode"1F66="1F66 \global\uccode"1F66="03A9
\global\lccode"1F67="1F67 \global\uccode"1F67="03A9
\global\lccode"1F68="1F60 \global\uccode"1F68="03A9
\global\lccode"1F69="1F61 \global\uccode"1F69="03A9
\global\lccode"1F6A="1F62 \global\uccode"1F6A="03A9
\global\lccode"1F6B="1F63 \global\uccode"1F6B="03A9
\global\lccode"1F6C="1F64 \global\uccode"1F6C="03A9
\global\lccode"1F6D="1F65 \global\uccode"1F6D="03A9
\global\lccode"1F6E="1F66 \global\uccode"1F6E="03A9
\global\lccode"1F6F="1F67 \global\uccode"1F6F="03A9
\global\lccode"1F70="1F70 \global\uccode"1F70="0391
\global\lccode"1F71="1F71 \global\uccode"1F71="0391
\global\lccode"1F72="1F72 \global\uccode"1F72="0395
\global\lccode"1F73="1F73 \global\uccode"1F73="0395
\global\lccode"1F74="1F74 \global\uccode"1F74="0397
\global\lccode"1F75="1F75 \global\uccode"1F75="0397
\global\lccode"1F76="1F76 \global\uccode"1F76="0399
\global\lccode"1F77="1F77 \global\uccode"1F77="0399
\global\lccode"1F78="1F78 \global\uccode"1F78="039F
\global\lccode"1F79="1F79 \global\uccode"1F79="039F
\global\lccode"1F7A="1F7A \global\uccode"1F7A="03A5
\global\lccode"1F7B="1F7B \global\uccode"1F7B="03A5
\global\lccode"1F7C="1F7C \global\uccode"1F7C="03A9
\global\lccode"1F7D="1F7D \global\uccode"1F7D="03A9
\global\lccode"1F80="1F80 \global\uccode"1F80="1FBC
\global\lccode"1F81="1F81 \global\uccode"1F81="1FBC
\global\lccode"1F82="1F82 \global\uccode"1F82="1FBC
\global\lccode"1F83="1F83 \global\uccode"1F83="1FBC
\global\lccode"1F84="1F84 \global\uccode"1F84="1FBC
\global\lccode"1F85="1F85 \global\uccode"1F85="1FBC
\global\lccode"1F86="1F86 \global\uccode"1F86="1FBC
\global\lccode"1F87="1F87 \global\uccode"1F87="1FBC
\global\lccode"1F88="1F80 \global\uccode"1F88="1FBC
\global\lccode"1F89="1F81 \global\uccode"1F89="1FBC
\global\lccode"1F8A="1F82 \global\uccode"1F8A="1FBC
\global\lccode"1F8B="1F83 \global\uccode"1F8B="1FBC
\global\lccode"1F8C="1F84 \global\uccode"1F8C="1FBC
\global\lccode"1F8D="1F85 \global\uccode"1F8D="1FBC
\global\lccode"1F8E="1F86 \global\uccode"1F8E="1FBC
\global\lccode"1F8F="1F87 \global\uccode"1F8F="1FBC
\global\lccode"1F90="1F90 \global\uccode"1F90="1FCC
\global\lccode"1F91="1F91 \global\uccode"1F91="1FCC
\global\lccode"1F92="1F92 \global\uccode"1F92="1FCC
\global\lccode"1F93="1F93 \global\uccode"1F93="1FCC
\global\lccode"1F94="1F94 \global\uccode"1F94="1FCC
\global\lccode"1F95="1F95 \global\uccode"1F95="1FCC
\global\lccode"1F96="1F96 \global\uccode"1F96="1FCC
\global\lccode"1F97="1F97 \global\uccode"1F97="1FCC
\global\lccode"1F98="1F90 \global\uccode"1F98="1FCC
\global\lccode"1F99="1F91 \global\uccode"1F99="1FCC
\global\lccode"1F9A="1F92 \global\uccode"1F9A="1FCC
\global\lccode"1F9B="1F93 \global\uccode"1F9B="1FCC
\global\lccode"1F9C="1F94 \global\uccode"1F9C="1FCC
\global\lccode"1F9D="1F95 \global\uccode"1F9D="1FCC
\global\lccode"1F9E="1F96 \global\uccode"1F9E="1FCC
\global\lccode"1F9F="1F97 \global\uccode"1F9F="1FCC
\global\lccode"1FA0="1FA0 \global\uccode"1FA0="1FFC
\global\lccode"1FA1="1FA1 \global\uccode"1FA1="1FFC
\global\lccode"1FA2="1FA2 \global\uccode"1FA2="1FFC
\global\lccode"1FA3="1FA3 \global\uccode"1FA3="1FFC
\global\lccode"1FA4="1FA4 \global\uccode"1FA4="1FFC
\global\lccode"1FA5="1FA5 \global\uccode"1FA5="1FFC
\global\lccode"1FA6="1FA6 \global\uccode"1FA6="1FFC
\global\lccode"1FA7="1FA7 \global\uccode"1FA7="1FFC
\global\lccode"1FA8="1FA0 \global\uccode"1FA8="1FFC
\global\lccode"1FA9="1FA1 \global\uccode"1FA9="1FFC
\global\lccode"1FAA="1FA2 \global\uccode"1FAA="1FFC
\global\lccode"1FAB="1FA3 \global\uccode"1FAB="1FFC
\global\lccode"1FAC="1FA4 \global\uccode"1FAC="1FFC
\global\lccode"1FAD="1FA5 \global\uccode"1FAD="1FFC
\global\lccode"1FAE="1FA6 \global\uccode"1FAE="1FFC
\global\lccode"1FAF="1FA7 \global\uccode"1FAF="1FFC
\global\lccode"1FB0="1FB0 \global\uccode"1FB0="1FB8
\global\lccode"1FB1="1FB1 \global\uccode"1FB1="1FB9
\global\lccode"1FB2="1FB2 \global\uccode"1FB2="1FBC
\global\lccode"1FB3="1FB3 \global\uccode"1FB3="1FBC
\global\lccode"1FB4="1FB4 \global\uccode"1FB4="1FBC
\global\lccode"1FB6="1FB6 \global\uccode"1FB6="0391
\global\lccode"1FB7="1FB7 \global\uccode"1FB7="1FBC
\global\lccode"1FB8="1FB0 \global\uccode"1FB8="1FB8
\global\lccode"1FB9="1FB1 \global\uccode"1FB9="1FB9
\global\lccode"1FBA="1F70 \global\uccode"1FBA="0391
\global\lccode"1FBB="1F71 \global\uccode"1FBB="0391
\global\lccode"1FBC="1FB3 \global\uccode"1FBC="1FBC
\global\lccode"1FBD="1FBD \global\uccode"1FBD="1FBD
\global\lccode"1FC2="1FC2 \global\uccode"1FC2="1FCC
\global\lccode"1FC3="1FC3 \global\uccode"1FC3="1FCC
\global\lccode"1FC4="1FC4 \global\uccode"1FC4="1FCC
\global\lccode"1FC6="1FC6 \global\uccode"1FC6="0397
\global\lccode"1FC7="1FC7 \global\uccode"1FC7="1FCC
\global\lccode"1FC8="1F72 \global\uccode"1FC8="0395
\global\lccode"1FC9="1F73 \global\uccode"1FC9="0395
\global\lccode"1FCA="1F74 \global\uccode"1FCA="0397
\global\lccode"1FCB="1F75 \global\uccode"1FCB="0397
\global\lccode"1FCC="1FC3 \global\uccode"1FCC="1FCC
\global\lccode"1FD0="1FD0 \global\uccode"1FD0="1FD8
\global\lccode"1FD1="1FD1 \global\uccode"1FD1="1FD9
\global\lccode"1FD2="1FD2 \global\uccode"1FD2="03AA
\global\lccode"1FD3="1FD3 \global\uccode"1FD3="03AA
\global\lccode"1FD6="1FD6 \global\uccode"1FD6="0399
\global\lccode"1FD7="1FD7 \global\uccode"1FD7="03AA
\global\lccode"1FD8="1FD0 \global\uccode"1FD8="1FD8
\global\lccode"1FD9="1FD1 \global\uccode"1FD9="1FD9
\global\lccode"1FDA="1F76 \global\uccode"1FDA="0399
\global\lccode"1FDB="1F77 \global\uccode"1FDB="0399
\global\lccode"1FE0="1FE0 \global\uccode"1FE0="1FE8
\global\lccode"1FE1="1FE1 \global\uccode"1FE1="1FE9
\global\lccode"1FE2="1FE2 \global\uccode"1FE2="03AB
\global\lccode"1FE3="1FE3 \global\uccode"1FE3="03AB
\global\lccode"1FE4="1FE4 \global\uccode"1FE4="03A1
\global\lccode"1FE5="1FE5 \global\uccode"1FE5="03A1
\global\lccode"1FE6="1FE6 \global\uccode"1FE6="03A5
\global\lccode"1FE7="1FE7 \global\uccode"1FE7="03AB
\global\lccode"1FE8="1FE0 \global\uccode"1FE8="1FE8
\global\lccode"1FE9="1FE1 \global\uccode"1FE9="1FE9
\global\lccode"1FEA="1F7A \global\uccode"1FEA="03A5
\global\lccode"1FEB="1F7B \global\uccode"1FEB="03A5
\global\lccode"1FEC="1FE5 \global\uccode"1FEC="1FEC
\global\lccode"1FF2="1FF2 \global\uccode"1FF2="1FFC
\global\lccode"1FF3="1FF3 \global\uccode"1FF3="1FFC
\global\lccode"1FF4="1FF4 \global\uccode"1FF4="1FFC
\global\lccode"1FF6="1FF6 \global\uccode"1FF6="03A9
\global\lccode"1FF7="1FF7 \global\uccode"1FF7="1FFC
\global\lccode"1FF8="1F78 \global\uccode"1FF8="039F
\global\lccode"1FF9="1F79 \global\uccode"1FF9="039F
\global\lccode"1FFA="1F7C \global\uccode"1FFA="03A9
\global\lccode"1FFB="1F7D \global\uccode"1FFB="03A9
\global\lccode"1FFC="1FF3 \global\uccode"1FFC="1FFC
%    \end{macrocode}
% \iffalse
%</xgreek-fixes.def>
%<*gloss-latex.lde>
% \fi
% \clearpage
% 
% \subsection{gloss-latex.lde}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesLanguageDefinitionExtension{gloss-latex}{2023/07/21}{v1.64}{polyglossia: module for default language}

\PolyglossiaSetup{latex}{
  bcp47=en-US,
  bcp47-language=en,
  bcp47-region=US,
  bcp47-script=Latn,
  hyphennames={english},
  hyphenmins={2,3},
  langtag=ENG,
  fontsetup=true,
  % ignore command
  DefineCommandsCmd={use_none:n}
}

\def\captionslatex{%
   \def\prefacename{Preface}%
   \def\refname{References}%
   \def\abstractname{Abstract}%
   \def\bibname{Bibliography}%
   \def\chaptername{Chapter}%
   \def\appendixname{Appendix}%
   \def\contentsname{Contents}%
   \def\listfigurename{List of Figures}%
   \def\listtablename{List of Tables}%
   \def\indexname{Index}%
   \def\figurename{Figure}%
   \def\tablename{Table}%
   \def\partname{Part}%
   \def\enclname{encl}%
   \def\ccname{cc}%
   \def\headtoname{To}%
   \def\pagename{Page}%
   \def\seename{see}%
   \def\alsoname{see also}%
   \def\proofname{Proof}%
}


%    \end{macrocode}
% \iffalse
%</gloss-latex.lde>
%<*gloss-acadien.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-acadien.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-acadien.ldf}[polyglossia: module for Canadian (Acadian) French]

% We provide this as a babel alias

\xpg@load@master@language{french}

%    \end{macrocode}
% \iffalse
%</gloss-acadien.ldf>
%<*gloss-aeb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-aeb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-aeb.ldf}[polyglossia: module for aeb (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-aeb.ldf>
%<*gloss-af.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-af.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-af.ldf}[polyglossia: module for af (Afrikaans)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{afrikaans}

%    \end{macrocode}
% \iffalse
%</gloss-af.ldf>
%<*gloss-afb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-afb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-afb.ldf}[polyglossia: module for afb (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-afb.ldf>
%<*gloss-afrikaans.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-afrikaans.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-afrikaans.ldf}[polyglossia: module for Afrikaans]

\PolyglossiaSetup{afrikaans}{
  bcp47=af,
  bcp47-language=af,
  bcp47-script=Latn,
  hyphennames={afrikaans,dutch},
  hyphenmins={2,2},
  langtag=AFK,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{afrikaans}{af}

\define@boolkey{afrikaans}[afrikaans@]{babelshorthands}[true]{}

% Register default options
\xpg@initialize@gloss@options{afrikaans}{babelshorthands=false}

\ifsystem@babelshorthands
  \setkeys{afrikaans}{babelshorthands=true}
\else
  \setkeys{afrikaans}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\afrikaans@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{afrikaans}%
  \declare@shorthand{afrikaans}{"-}{\nobreak-\bbl@allowhyphens}
  \declare@shorthand{afrikaans}{"~}{\textormath{\leavevmode\hbox{-}}{-}}
  \declare@shorthand{afrikaans}{"|}{%
    \textormath{\discretionary{-}{}{\kern.03em}}{}}
  \declare@shorthand{afrikaans}{""}{\hskip\z@skip}
  \declare@shorthand{afrikaans}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
  \def\-{\bbl@allowhyphens\discretionary{-}{}{}\bbl@allowhyphens}%
}

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

\def\captionsafrikaans{%
    \def\prefacename{Voorwoord}%
    \def\refname{Verwysings}%
    \def\abstractname{Samevatting}%
    \def\bibname{Bibliografie}%
    \def\chaptername{Hoofstuk}%
    \def\appendixname{Bylae}%
    \def\contentsname{Inhoudsopgawe}%
    \def\listfigurename{Lys van figure}%
    \def\listtablename{Lys van tabelle}%
    \def\indexname{Inhoud}%
    \def\figurename{Figuur}%
    \def\tablename{Tabel}%
    \def\partname{Deel}%
    \def\enclname{Bylae(n)}%
    \def\ccname{a.\,a.}%
    \def\headtoname{Aan}%
    \def\pagename{Bladsy}%
    \def\seename{sien}%
    \def\alsoname{sien ook}%
    \def\proofname{Bewys}%
%   \def\glossaryname{}%
}

\def\dateafrikaans{%
    \def\today{\number\day~\ifcase\month\or
      Januarie\or Februarie\or Maart\or April\or Mei\or Junie\or
      Julie\or  Augustus\or September\or Oktober\or November\or
      Desember\fi
      \space \number\year}%
}

\def\noextras@afrikaans{%
  \ifafrikaans@babelshorthands\noafrikaans@shorthands\fi%
}

\def\blockextras@afrikaans{%
  \ifafrikaans@babelshorthands\afrikaans@shorthands\else\noafrikaans@shorthands\fi%
}

\def\inlineextras@afrikaans{%
  \ifafrikaans@babelshorthands\afrikaans@shorthands\else\noafrikaans@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-afrikaans.ldf>
%<*gloss-albanian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-albanian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-albanian.ldf}[polyglossia: module for Albanian]

\PolyglossiaSetup{albanian}{
  bcp47=sq,
  bcp47-language=sq,
  bcp47-script=Latn,
  hyphennames={albanian},
  langtag=SQI,
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{albanian}{sq}

\def\captionsalbanian{%
   \def\refname{Referencat}%
   \def\abstractname{Përmbledhja}%
   \def\bibname{Bibliografia}%
   \def\prefacename{Parathenia}%
   \def\chaptername{Kapitulli}%
   \def\appendixname{Shtesa}%
   \def\contentsname{Përmbajtja}%
   \def\listfigurename{Figurat}%
   \def\listtablename{Tabelat}%
   \def\indexname{Indeksi}%
   \def\figurename{Figura}%
   \def\tablename{Tabela}%
   %\def\thepart{}%
   \def\partname{Pjesa}%
   \def\pagename{Faqe}%
   \def\seename{shiko}%
   \def\alsoname{shiko dhe}%
   %\def\enclname{}%
   %\def\ccname{}%
   %\def\headtoname{}%
   \def\proofname{Vërtetim}%
   \def\glossaryname{Përhasja e Fjalëve}%
   }
\def\datealbanian{%
   \def\today{{\number\day~\ifcase\month\or
    Janar\or Shkurt\or Mars\or Prill\or Maj\or
    Qershor\or Korrik\or Gusht\or Shtator\or Tetor\or Nëntor\or
    Dhjetor\fi \space \number\year}}}

%    \end{macrocode}
% \iffalse
%</gloss-albanian.ldf>
%<*gloss-am.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-am.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-am.ldf}[polyglossia: module for am (Amharic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{amharic}

%    \end{macrocode}
% \iffalse
%</gloss-am.ldf>
%<*gloss-american.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-american.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-american.ldf}[polyglossia: module for American English]

% We provide this as a babel alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-american.ldf>
%<*gloss-amharic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-amharic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-amharic.ldf}[polyglossia: module for Amharic]
\PolyglossiaSetup{amharic}{
  bcp47=am,
  bcp47-language=am,
  bcp47-script=Ethi,
  script=Ethiopic,
  scripttag=ethi,
  langtag=AMH,
  hyphennames={amharic,nohyphenation},
  %hyphenmins={2,2},
  fontsetup=true,
  %TODO localalph=ethnum
}

% BCP-47 compliant aliases
\setlanguagealias*{amharic}{am}

\def\captionsamharic{%
   \def\refname{የነሥ ጹሁፍ ምንጭ}%
   \def\abstractname{አኅጽተሮ ጽሁፍ}%
   \def\bibname{ቢዋ መጽሃፍት}%
   \def\prefacename{መቅድም}%
   \def\chaptername{ክፍል}%
   \def\appendixname{መድበል}%
   \def\contentsname{ይዘት}%
   \def\listfigurename{የሥዕችሎ ማውጫ}%
   \def\listtablename{የሰንጠዥረ ማውጫ}%
   \def\indexname{ምህጻር ቃል}%
   \def\figurename{ሥዕል}%
   \def\tablename{ሰንጠረዥ}%
   %\def\thepart{}%
   \def\partname{ንዑስ ክፍል}%
   \def\pagename{ገጽ}%
   \def\seename{ይመልከቱ}%
   \def\alsoname{ይህምን ይመልከቱ}%
   \def\enclname{አባሪዎች}%
   \def\ccname{ግልባጭ}%
   \def\headtoname{ለ}%
   \def\proofname{ማረጋገጫ}%
   %\def\glossaryname{<++>}%
   }

\newcommand{\eth@monthname}[1]{\ifcase#1\or
  መስከረም\or
  ጥቅምት\or
  ህዳር\or
  ታህሳስ\or
  ጥር\or
  የካቲት\or
  መጋቢት\or
  ሚያዝያ\or
  ግንቦት\or
  ሰኔ\or
  ሐምሌ\or
  ነሐሴ\or
  ጰጉሜን\fi
}
\newcount\ethcnt@temp
\newcount\ethcnt@modtemp
\newcount\ethcnt@leap
\newcount\ethcnt@yminone
\newcount\ethcnt@days
\newcount\ethcnt@jdn
\newcount\ethcnt@cycle
\newcount\ethcnt@ethdays
\newcount\ethcnt@ethyear
\newcount\ethcnt@ethmonth
\newcount\ethcnt@ethday
\newcommand{\eth@modulo}[2]{%
  \ethcnt@modtemp=#1%
  \divide\ethcnt@modtemp by #2%
  \multiply\ethcnt@modtemp by #2%
  \advance#1 by -\ethcnt@modtemp
}
\def\dateamharic{%
  \def\today{{%
    \ethcnt@yminone=\year
    \advance\ethcnt@yminone by -1
    \ethcnt@leap=\year
    \divide\ethcnt@leap by 4
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 4
    \advance\ethcnt@leap by -\ethcnt@temp
    \ethcnt@temp=\year
    \divide\ethcnt@temp by 100
    \advance\ethcnt@leap by -\ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 100
    \advance\ethcnt@leap by \ethcnt@temp
    \ethcnt@temp=\year
    \divide\ethcnt@temp by 400
    \advance\ethcnt@leap by \ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 400
    \advance\ethcnt@leap by -\ethcnt@temp
    \ifnum\month<3
      \ethcnt@days=\month
      \advance\ethcnt@days by -1
      \multiply\ethcnt@days by 31
      \advance\ethcnt@days by \day
      \advance\ethcnt@days by -1
    \else
      \ethcnt@days=\month
      \advance\ethcnt@days by -1
      \multiply\ethcnt@days by 30
      \advance\ethcnt@days by \day
      \advance\ethcnt@days by \ethcnt@leap
      \advance\ethcnt@days by -3
      \ethcnt@temp=\month
      \multiply\ethcnt@temp by 3
      \advance\ethcnt@temp by -2
      \divide\ethcnt@temp by 5
      \advance\ethcnt@days by \ethcnt@temp
    \fi
    \ethcnt@jdn=\ethcnt@days
    \advance\ethcnt@jdn by 1721426
    \ethcnt@temp=\ethcnt@yminone
    \multiply\ethcnt@temp by 365
    \advance\ethcnt@jdn by \ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 4
    \advance\ethcnt@jdn by \ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 100
    \advance\ethcnt@jdn by -\ethcnt@temp
    \ethcnt@temp=\ethcnt@yminone
    \divide\ethcnt@temp by 400
    \advance\ethcnt@jdn by \ethcnt@temp
    \ethcnt@cycle=\ethcnt@jdn
    \advance\ethcnt@cycle by -1723856
    \eth@modulo{\ethcnt@cycle}{1461}%
    \ethcnt@ethdays=\ethcnt@cycle
    \eth@modulo{\ethcnt@ethdays}{365}%
    \ethcnt@temp=\ethcnt@cycle
    \divide\ethcnt@temp by 1460
    \multiply\ethcnt@temp by 365
    \advance\ethcnt@ethdays by \ethcnt@temp
    \ethcnt@ethyear=\ethcnt@jdn
    \advance\ethcnt@ethyear by -1723856
    \divide\ethcnt@ethyear by 1461
    \multiply\ethcnt@ethyear by 4
    \ethcnt@temp=\ethcnt@cycle
    \divide\ethcnt@temp by 365
    \advance\ethcnt@ethyear by \ethcnt@temp
    \divide\ethcnt@cycle by 1460
    \advance\ethcnt@ethyear by -\ethcnt@cycle
    \ethcnt@ethmonth=\ethcnt@ethdays
    \divide\ethcnt@ethmonth by 30
    \advance\ethcnt@ethmonth by 1
    \ethcnt@ethday=\ethcnt@ethdays
    \eth@modulo{\ethcnt@ethday}{30}%
    \advance\ethcnt@ethday by 1%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \eth@monthname{\ethcnt@ethmonth}\relax\space%
      \number\ethcnt@ethday\relax\space%
      \number\ethcnt@ethyear%
  }}%
}

\def\ethiop#1{\expandafter\@ethiop\csname c@#1\endcsname}
\def\@ethiop#1{{%
  \ifnum#1<1\relax\ethnum@err{#1}%
  \else\ifnum#1<10\relax\expandafter\ethnum@one\number #1%
  \else\ifnum#1<100\relax\expandafter\ethnum@two\number #1%
  \else\ifnum#1<1000\relax\expandafter\ethnum@three\number #1%
  \else\ifnum#1<10000\relax\expandafter\ethnum@four\number #1%
  \else\ifnum#1<100000\relax\expandafter\ethnum@five\number #1%
  \else\ifnum#1<1000000\relax\expandafter\ethnum@six\number #1%
  \else%
    \ethnum@err%
    \number#1%
  \fi\fi\fi\fi\fi\fi\fi%
}}
\let\ethnum\@ethiop
\newcommand{\ethnum@tens}[1]{%
  \ifcase#1\or ፲\or ፳\or ፴%
           \or ፵\or ፶\or ፷%
           \or ፸\or ፹\or ፺\fi%
}%
\newcommand{\ethnum@one}[1]{%
  \ifcase#1\or ፩\or ፪\or ፫%
           \or ፬\or ፭\or ፮%
           \or ፯\or ፰\or ፱\fi%
}%
\newcommand{\ethnum@two}[1]{%
  \ethnum@tens#1%
  \ethnum@one%
}
\newcommand{\ethnum@three}[1]{%
  \ifnum#1>1\relax\ethnum@one#1\fi%
  \ifnum#1>0\relax ፻\fi%
  \ethnum@two%
}
\newcommand{\ethnum@four}[1]{%
  \ethnum@tens#1%
  \ifnum#1>0\relax ፻\fi%
  \ethnum@three%
}
\newcommand{\ethnum@five}[1]{%
  \ifnum#1>1\relax\ethnum@one#1\fi%
  \ifnum#1>0\relax ፼\fi%
  \ethnum@four%
}
\newcommand{\ethnum@six}[1]{%
  \ethnum@tens#1%
  \ifnum#1>0\relax ፼\fi%
  \ethnum@five%
}

%    \end{macrocode}
% \iffalse
%</gloss-amharic.ldf>
%<*gloss-apd.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-apd.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-apd.ldf}[polyglossia: module for apd (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-apd.ldf>
%<*gloss-ar-IQ.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-IQ.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar-IQ.ldf}[polyglossia: module for ar-IQ (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

\SetLanguageKeys{arabic}{bcp47=ar-IQ,bcp47-language=ar,bcp47-region=IQ}%

%    \end{macrocode}
% \iffalse
%</gloss-ar-IQ.ldf>
%<*gloss-ar-JO.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-JO.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar-JO.ldf}[polyglossia: module for ar-JO (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

\SetLanguageKeys{arabic}{bcp47=ar-JO,bcp47-language=ar,bcp47-region=JO}%

%    \end{macrocode}
% \iffalse
%</gloss-ar-JO.ldf>
%<*gloss-ar-LB.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-LB.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar-LB.ldf}[polyglossia: module for ar-LB (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

\SetLanguageKeys{arabic}{bcp47=ar-LB,bcp47-language=ar,bcp47-region=LB}%

%    \end{macrocode}
% \iffalse
%</gloss-ar-LB.ldf>
%<*gloss-ar-MR.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-MR.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar-MR.ldf}[polyglossia: module for ar-MR (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

\SetLanguageKeys{arabic}{bcp47=ar-MR,bcp47-language=ar,bcp47-region=MR}%

%    \end{macrocode}
% \iffalse
%</gloss-ar-MR.ldf>
%<*gloss-ar-PS.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-PS.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar-PS.ldf}[polyglossia: module for ar-PS (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

\SetLanguageKeys{arabic}{bcp47=ar-PS,bcp47-language=ar,bcp47-region=PS}%

%    \end{macrocode}
% \iffalse
%</gloss-ar-PS.ldf>
%<*gloss-ar-SY.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-SY.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar-SY.ldf}[polyglossia: module for ar-SY (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

\SetLanguageKeys{arabic}{bcp47=ar-SY,bcp47-language=ar,bcp47-region=SY}%

%    \end{macrocode}
% \iffalse
%</gloss-ar-SY.ldf>
%<*gloss-ar-YE.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-YE.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar-YE.ldf}[polyglossia: module for ar-YE (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

\SetLanguageKeys{arabic}{bcp47=ar-YE,bcp47-language=ar,bcp47-region=YE}%

%    \end{macrocode}
% \iffalse
%</gloss-ar-YE.ldf>
%<*gloss-ar.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ar.ldf}[polyglossia: module for ar (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar.ldf>
%<*gloss-arabic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-arabic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-arabic.ldf}[polyglossia: module for Arabic]
\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{hijrical}

\PolyglossiaSetup{arabic}{
  bcp47=ar,
  bcp47-language=ar,
  bcp47-script=Arab,
  bcp47-region=YE,
  script=Arabic,
  direction=RL,
  langtag=ARA,
  scripttag=arab,
  hyphennames={nohyphenation},
  fontsetup=true,
  envname=Arabic,
  localnumeral=arabicnumerals
  %TODO localalph={abjad,abjad}
}

% BCP-47 compliant aliases
\setlanguagealias*{arabic}{ar}
\setlanguagealias*[locale=mashriq]{arabic}{ar-IQ}
\setlanguagealias*[locale=default]{arabic}{ar-YE}
\setlanguagealias*[locale=mashriq]{arabic}{ar-LB}
\setlanguagealias*[locale=mashriq]{arabic}{ar-JO}
\setlanguagealias*[locale=default]{arabic}{afb}
\setlanguagealias*[locale=mauritania]{arabic}{ar-MR}
\setlanguagealias*[locale=default]{arabic}{arz}
\setlanguagealias*[locale=morocco]{arabic}{ary}
\setlanguagealias*[locale=algeria]{arabic}{arq}
\setlanguagealias*[locale=tunisia]{arabic}{aeb}
\setlanguagealias*[locale=mashriq]{arabic}{ar-SY}
\setlanguagealias*[locale=libya]{arabic}{ayl}
\setlanguagealias*[locale=default]{arabic}{apd}
\setlanguagealias*[locale=mashriq]{arabic}{ar-PS}

\define@boolkey{arabic}[arabic@]{abjadalph}[true]{}

\newif\ifeastern@numerals
\define@choicekey*+{arabic}{numerals}[\xpg@val\xpg@nr]{mashriq,maghrib,eastern,western}[mashriq]{%
   \ifcase\xpg@nr\relax
      % mashriq:
      \eastern@numeralstrue%
   \or
      % maghrib:
      \eastern@numeralsfalse
   \or
      % eastern:
      \eastern@numeralstrue%
   \or
      % western:
      \eastern@numeralsfalse
   \fi
   \xpg@info{Option: Arabic, numerals=\xpg@val}%
}{\xpg@warning{Unknown Arabic numerals option `#1'}}

%this is needed for \abjad in arabicnumbers.sty
\define@boolkey{arabic}[arabic@]{abjadjimnotail}[true]{%
  \ifarabic@abjadjimnotail
    \abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi}

\define@choicekey*+{arabic}{locale}[\xpg@val\xpg@nr]{default,mashriq,libya,algeria,tunisia,morocco,mauritania}[default]{%
   \ifcase\xpg@nr\relax
      % default:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ar-YE,bcp47-language=ar}%
      \xpg@info{Option: arabic, locale=default}%
   \or
      % mashriq:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ar-IQ,bcp47-language=ar}%
      \xpg@info{Option: arabic, locale=mashriq}%
   \or
      % libya:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ayl,bcp47-language=ar,bcp47-region=LY}%
      \xpg@info{Option: arabic, locale=libya}%
   \or
      % algeria:
      \eastern@numeralsfalse%
      \SetLanguageKeys{arabic}{bcp47=arq,bcp47-language=ar,bcp47-region=DZ,bcp47-extension-u=nu-latn}%
      \xpg@info{Option: arabic, locale=algeria}%
   \or
      % tunisia:
      \eastern@numeralsfalse%
      \SetLanguageKeys{arabic}{bcp47=aeb,bcp47-language=ar,bcp47-region=TN,bcp47-extension-u=nu-latn}%
      \xpg@info{Option: arabic, locale=tunisia}%
   \or
      % morocco:
      \eastern@numeralsfalse%
      \SetLanguageKeys{arabic}{bcp47=ary,bcp47-language=ar,bcp47-region=MA,bcp47-extension-u=nu-latn}%
      \xpg@info{Option: arabic, locale=morocco}%
   \or
      % mauritania:
      \eastern@numeralstrue%
      \SetLanguageKeys{arabic}{bcp47=ar-MR,bcp47-language=ar,bcp47-region=MR}%
      \xpg@info{Option: arabic, locale=mauritania}%
   \fi
   \gdef\@@arabic@month{\@arabic@month{#1}}
 }{\xpg@warning{Unknown Arabic locale `#1'}}

\newif\if@hijrical
\define@choicekey*+{arabic}{calendar}[\xpg@val\xpg@nr]{gregorian,hijri,islamic}[gregorian]{%
   \ifcase\xpg@nr\relax
      % gregorian:
      \@hijricalfalse
   \or
      % hijri:
      \@hijricaltrue
   \or
      % islamic:
      \@hijricaltrue
   \fi
   \xpg@info{Option: Arabic, calendar=\xpg@val}%
}{\xpg@warning{Unknown Arabic calendar option `#1'}}


\define@key{arabic}{hijricorrection}[0]{%
  \gdef\arabic@hijri@correction{#1}}%

\newif\ifarabic@customsep\arabic@customsepfalse
\def\xpg@sepmark{}
\define@key{arabic}{sectionsep}[.]{%
   \arabic@customseptrue%
   \gdef\xpg@sepmark{#1}%
}

% Register default options
\xpg@initialize@gloss@options{arabic}{locale=default,calendar=gregorian,numerals=mashriq,hijricorrection=0,abjadjimnotail=false}
% Register alias options
\xpg@set@alias@values{arabic}{calendar}{islamic}{hijri}

\def\arabicgregmonth@default#1{\ifcase#1%
  % Egypt, Sudan, Yemen and Golf states
  \or يناير\or فبراير\or مارس\or أبريل\or مايو\or يونيو\or يوليو\or أغسطس\or سبتمبر\or أكتوبر\or نوفمبر\or ديسمبر\fi}
\def\arabicgregmonth@mashriq#1{\ifcase#1%
  % Iraq Syria Jordan Lebanon Palestine
  \or  كانون الثاني\or شباط\or آذار\or نيسان\or أيار\or حزيران\or تموز\or آب\or أيلول\or تشرين الأول\or تشرين الثاني\or كانون الأول\fi}
\def\arabicgregmonth@libya#1{\ifcase#1%
  %Lybia «تعرف في ليبيا بأسماء عربية وضعها معمر القذافي ترمز إلى فصول السنة وبعض الشخصيات التاريخية» (ar.wikipedia.org)
  \or أي النار\or النوار\or الربيع\or الطير\or الماء\or الصيف\or ناصر\or هانيبال\or الفاتح\or التمور\or الحرث\or الكانون\fi}
\def\arabicgregmonth@morocco#1{\ifcase#1%
  \or يناير\or فبراير\or مارس\or أبريل\or ماي\or يونيو\or يوليوز\or غشت\or شتنبر\or أكتوبر\or نونبر\or دجنبر\fi}
\def\arabicgregmonth@algeria#1{\ifcase#1%
  % Tunisia and Algeria
  \or جانفي\or فيفري\or مارس\or أفريل\or ماي\or جوان\or جويلية\or أوت\or سبتمبر\or أكتوبر\or نوفمبر\or ديسمبر\fi}
\let\arabicgregmonth@tunisia\arabicgregmonth@algeria
\def\arabicgregmonth@mauritania#1{\ifcase#1%
  \or يناير\or فبراير\or مارس\or إبريل\or مايو\or يونيو\or يوليو\or أغشت\or شتمبر\or أكتوبر\or نوفمبر\or دجمبر\fi}

\def\@arabic@month#1{\ifcsdef{arabicgregmonth@#1}{\expandafter\csname arabicgregmonth@#1\endcsname}%
{\xpg@warning{Option `locale=#1' is not defined for Arabic: using `default' instead}%
\arabicgregmonth@default}}

%\Hijritoday is now locale-aware and will format the date with this macro:
\DefineFormatHijriDate{arabic}{\@ensure@RTL{\arabicnumber{\value{Hijriday}}%
  \space\HijriMonthArabic{\value{Hijrimonth}}\space\arabicnumber{\value{Hijriyear}}}}

\def\captionsarabic{%
  \def\prefacename{\@ensure@RTL{مدخل}}%
  \def\refname{\@ensure@RTL{المراجع}}%
  \def\abstractname{\@ensure@RTL{ملخص}}%
  \def\bibname{\@ensure@RTL{المصادر}}%
  \def\chaptername{\@ensure@RTL{باب}}%
  \def\appendixname{\@ensure@RTL{الملاحق}}%
  \def\contentsname{\@ensure@RTL{المحتويات}}%
  %\def\contentsname{\@ensure@RTL{الفهرس}}%
  \def\listfigurename{\@ensure@RTL{قائمة الأشكال}}%
  \def\listtablename{\@ensure@RTL{قائمة الجداول}}%
  \def\indexname{\@ensure@RTL{الفهرس}}%
  \def\figurename{\@ensure@RTL{شكل}}%
  \def\tablename{\@ensure@RTL{جدول}}%
  \def\partname{\@ensure@RTL{القسم}}%
  \def\enclname{\@ensure@RTL{المرفقات}}%<-- Needs translation
  \def\ccname{\@ensure@RTL{نسخة ل‬}}% <<
  \def\headtoname{\@ensure@RTL{إلى}}%<-- Needs translation
  \def\pagename{\@ensure@RTL{صفحة}}%
  \def\seename{\@ensure@RTL{راجع}}%\alefhamza\nun\za\ra
  \def\alsoname{\@ensure@RTL{راجع أيضًا}}%<<\alefhamza\nun\za\ra
  \def\proofname{\@ensure@RTL{برهان}}%
  \def\glossaryname{\@ensure@RTL{قاموس}}%<<
}
\def\datearabic{%
 \def\today{%
  \if@hijrical%
    \Hijritoday[\arabic@hijri@correction]%
  \else%
    \if@RTL%
       \arabicnumber\day\space\@@arabic@month{\month}%
        \space\arabicnumber\year%
    \else% in LR environment we format the gregorian date within \textenglish
       \ifcsdef{english@loaded}{\textenglish{\today}}%else US format
       {\normalfontlatin\ifcase\month\or January\or February\or March\or April\or May\or June\or%
       July\or August\or September\or October\or November\or December\fi%
       \space\number\day,\space\number\year}%
    \fi%
 \fi}}

% Use \providecommand here as the ldf file might
% be reloaded via aeb (BCP).
\providecommand{\arabicnumerals}[2]{\arabicnumber{#2}}

\def\arabicnumber#1{%
  \ifeastern@numerals
    \@ensure@LTR{\arabicdigits{\number#1}}%
  \else
    \number#1%
  \fi}

\def\@ornatebracearabic#1{\RL{\char"FD3F\@arabic#1\char"FD3E}}
\def\@ornatebracealph#1{\RL{\char"FD3F\@alph#1\char"FD3E}}

\def\abjadalph#1{\expandafter\arabic@abjad@alph{\number#1}}

% This is a poor man's Arabic alphanumeric. It just uses the alphabet and
% thus ends at 28.
\def\arabic@abjad@alph#1{\ifcase#1%
   \or ا\or ب\or\abjad@three\or د\or و\or ه‍\or ز%
   \or ح\or ط\or ي\or ك\or ل\or م\or ن%
   \or س\or ع\or ف\or ص\or ق\or ر\or ش%
   \or ت\or ث\or خ\or ذ\or ض\or ظ\or غ%
   \else\xpg@ill@value{#1}{arabic@abjad@alph}\fi%
}


\def\abjadmaghribi#1{%
\ifnum#1>1999\xpg@ill@value{#1}{abjad}%
\else
  \ifnum#1<\z@\space\xpg@ill@value{#1}{abjad}%
  \else
    \ifnum#1<10\expandafter\abj@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\abj@maghribi@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\abj@maghribi@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\abj@maghribi@num@iv\number#1%
          \fi
        \fi
      \fi
    \fi
  \fi
\fi
}

%maghribi س -> ص ص -> ض ش -> س ض -> ظ ظ -> غ غ -> ش
\def\abj@maghribi@num@ii#1{%
  \ifcase#1\or ي\or ك\or ل\or م\or ن%
           \or ص\or ع\or ف\or ض\fi
  \ifnum#1=\z@\abjad@zero\fi\abj@num@i}
\def\abj@maghribi@num@iii#1{%
  \ifcase#1\or ق\or ر\or س\or ت\or ث%
           \or خ\or ذ\or ظ\or غ\fi
  \ifnum#1=\z@\fi\abj@maghribi@num@ii}
\def\abj@maghribi@num@iv#1{%
  \ifcase#1\or ش\fi
  \ifnum#1=\z@\fi\abj@maghribi@num@iii}

\def\arabic@numbers{%
 \ifarabic@abjadalph
   \let\@alph\abjadalph%
   \let\@Alph\abjadalph%
 \else
   \let\@alph\abjad%
   \let\@Alph\abjad%
 \fi
}

\def\noarabic@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\arabic@globalnumbers{%
  \let\@arabic\arabicnumber%
  \renewcommand\thefootnote{\localnumeral*{footnote}}%
  \renewcommand\theequation{\localnumeral*{equation}}%
}

\def\noarabic@globalnumbers{%
   \let\@arabic\xpg@save@arabic%
}

\def\arabic@xetex@capsformat{%
  \let\xpg@save@sepmark\@SepMark%
  \SepMark{\xpg@sepmark}
}

\def\noarabic@xetex@capsformat{%
   \ifcsdef{xpg@save@sepmark}{%
     \SepMark{\xpg@save@sepmark}
   }{}%
}

\def\arabic@luatex@capsformat{%
  %
  % change chapter and part headings
  \ifarabic@customsep
     \ifcsdef{chapter}{%
        \let\xpg@save@thesection\thesection%
        \renewcommand*\thesection{\thechapter\xpg@sepmark\@arabic\c@section}
        \let\xpg@save@theequation\theequation%
        \renewcommand*\theequation{%
	    \ifnum \c@chapter>\z@ \thechapter\xpg@sepmark\fi\@arabic\c@equation}
        \let\xpg@save@thefigure\thefigure%
	\renewcommand*\thefigure{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@figure}
        \let\xpg@save@thetable\thetable%
	\renewcommand*\thetable{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@table}
     }{}
     \let\xpg@save@thesubsection\thesubsection%
     \renewcommand\thesubsection
	{\thesection\xpg@sepmark\@arabic\c@subsection}
     \let\xpg@save@thesubsubsection\thesubsubsection%
     \renewcommand\thesubsubsection{\thesubsection\xpg@sepmark\@arabic\c@subsubsection}
     \let\xpg@save@theparagraph\theparagraph%
     \renewcommand\theparagraph
         {\thesubsubsection\xpg@sepmark\@arabic\c@paragraph}
     \let\xpg@save@thesubparagraph\thesubparagraph%
     \renewcommand\thesubparagraph{\theparagraph\xpg@sepmark\@arabic\c@subparagraph}
  \fi% (end \ifarabic@customsep)
}

\def\noarabic@luatex@capsformat{%
   \ifcsdef{xpg@save@thesection}{%
        \let\thesection\xpg@save@thesection%
   }{}%
   \ifcsdef{xpg@save@theequation}{%
        \let\theequation\xpg@save@theequation%
   }{}%
   \ifcsdef{xpg@save@thefigure}{%
        \let\thefigure\xpg@save@thefigure%
   }{}%
   \ifcsdef{xpg@save@thetable}{%
        \let\thetable\xpg@save@thetable%
   }{}%
   \ifcsdef{xpg@save@thesubsection}{%
        \let\thesubsection\xpg@save@thesubsection%
   \ifcsdef{xpg@save@thesubsubsection}{%
        \let\thesubsubsection\xpg@save@thesubsubsection%
   }{}%
   }{}%
   \ifcsdef{xpg@save@theparagraph}{%
        \let\theparagraph\xpg@save@theparagraph%
   }{}%
   \ifcsdef{xpg@save@thesubparagraph}{%
        \let\thesubparagraph\xpg@save@thesubparagraph%
   }{}%
}

\def\blockextras@arabic{%
   \ifarabic@customsep
      \ifxetex
        \arabic@xetex@capsformat
      \else
        \arabic@luatex@capsformat
      \fi   
   \fi
}
%
\def\noextras@arabic{%
    \ifarabic@customsep
      \ifxetex
        \noarabic@xetex@capsformat
      \else
        \noarabic@luatex@capsformat
      \fi   
   \fi
}

%    \end{macrocode}
% \iffalse
%</gloss-arabic.ldf>
%<*gloss-armenian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-armenian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-armenian.ldf}[polyglossia: module for Armenian]

\PolyglossiaSetup{armenian}{
  bcp47=hy,
  bcp47-language=hy,
  bcp47-script=Armn,
  bcp47-region=AM,
  script=Armenian,
  scripttag=armn,
  langtag=HYE,
  hyphennames={armenian},
  hyphenmins={2,2},
  fontsetup=true,
  localnumeral=armeniannumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{armenian}{hy}

\newif\if@eastern@armenian
\@eastern@armenianfalse
\define@choicekey*+{armenian}{variant}[\xpg@val\xpg@nr]{western,eastern}[western]{%
   \ifcase\xpg@nr\relax
      % western:
      \@eastern@armenianfalse%
   \or
      % eastern:
      \@eastern@armeniantrue%
   \fi
   \xpg@info{Option: Armenian, variant=\xpg@val}%
}{\xpg@warning{Unknown Armenian variant `#1'}}

\newif\if@armenian@numerals
\@armenian@numeralsfalse
\define@key{armenian}{numerals}[armenian]{%
  \ifstrequal{#1}{arabic}{%
     \@armenian@numeralsfalse%
     \SetLanguageKeys{armenian}{bcp47-extension-u=nu-latn}%
   }{%
     \@armenian@numeralstrue%
     \SetLanguageKeys{armenian}{bcp47-extension-u={}}%
   }%
}

\define@boolkey{armenian}[armenian@]{capitalyiwn}[true]{%
  \ifarmenian@capitalyiwn
     % MakeUppercase capitalizes the ligature of letters ech and yiwn (U+0587)
     % to capital ech and yiwn (also the output if Armenian is not selected at all)
     \SetLanguageKeys{armenian}{bcp47-casing=hy-x-yiwn,bcp47-extension-x=yiwn}
  \else
     % Capitalize ech and yiwn ligature to capital ech and vew,
     % following Armenian spelling reform
     \SetLanguageKeys{armenian}{bcp47-casing=hy,bcp47-extension-x={}}
  \fi
}

% Register default options
\xpg@initialize@gloss@options{armenian}{numerals=armenian,variant=western}

% Taken from ArmTeX. Audit!
\def\captionsarmenian{%
   \def\refname{Հղումներ}%
   \def\abstractname{Սեղմագիր}%
   \def\bibname{Գրականություն}%
   \def\prefacename{Նախաբան}%
   \def\chaptername{Գլուխ}%
   \def\appendixname{Հավելված}%
   \def\contentsname{Բովանդակություն}%
   \def\listfigurename{Նկարների ցանկ}%
   \def\listtablename{Աղյուսակների ցանկ}%
   \def\indexname{Առարկայական ցանկ}%
   \def\figurename{Նկար}%
   \def\tablename{Աղյուսակ}%
   \def\partname{Մաս}%
   \def\pagename{էջ}%
   \def\seename{տե՛ս}%
   \def\alsoname{տե՛ս նաեւ}%
   \def\enclname{Կից՝}%
   \def\ccname{Կրկնօրինակը՝}%
% The \headtoname is empty: the typesetter should use the dative (trakan
% holov) of the recipient's name.
   \def\headtoname{}%
   \def\proofname{Ապացույց}%
   \def\glossaryname{Տերմինների ցանկ}%
}

\def\date@western@armenian{%
   \def\today{\ifcase\month\or
    Յունուար\or
    Փետրուար\or
    Մարտ\or
    Ապրիլ\or
    Մայիս\or
    Յունիս\or
    Յուլիս\or
    Օգոստոս\or
    Սեպտեմբեր\or
    Հոկտեմբեր\or
    Նոյեմբեր\or
    Դեկտեմբեր\fi
    \number\day,\space\number\year}%
}

\def\date@eastern@armenian{%
   \def\today{\ifcase\month\or
    Հունվար\or
    Փետրվար\or
    Մարտ\or
    Ապրիլ\or
    Մայիս\or
    Հունիս\or
    Հուլիս\or
    Օգոստոս\or
    Սեպտեմբեր\or
    Հոկտեմբեր\or
    Նոյեմբեր\or
    Դեկտեմբեր\fi
    \number\day,\space\number\year}%
}

\def\datearmenian{%
  \if@eastern@armenian
     \date@eastern@armenian%
  \else
     \date@western@armenian%
  \fi
}

\newcommand{\armeniannumerals}[2]{%
  \if@armenian@numerals
     \armeniannumber{#2}%
  \else
     #2%
  \fi%
}

\def\armenian@numbers{%
   \if@armenian@numerals
      \def\armenian@alph##1{\expandafter\armeniannumeral\expandafter{\the##1}}%
      \let\@alph\armenian@alph%
   \fi%
}

\def\noarmenian@numbers{%
  \let\@alph\latin@alph%
  \let\armenian@alph\@undefined%
}

\def\armenian@globalnumbers{%
  \if@armenian@numerals
    \let\@arabic\armeniannumber%
    \renewcommand\thefootnote{\localnumeral*{footnote}}%
    \renewcommand\theequation{\localnumeral*{equation}}%
  \fi
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\noarmenian@globalnumbers{
   \let\@arabic\xpg@save@arabic%
}

\protected\def\armeniannumber#1{\expandafter\@armeniannumber\expandafter{\number#1}}
\def\@armeniannumber#1{%
  \ifnum#1<\@ne\space\arm@ill@value{#1}%
  \else
    \ifnum#1<10\expandafter\arm@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\arm@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\arm@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\arm@num@iv\number#1%
          \else
             \space\arm@ill@value{#1}%
          \fi
        \fi
      \fi
    \fi
  \fi
}

\let\armeniannumeral=\armeniannumber
\def\arm@num@i#1{%
  \ifcase#1\or Ա\or Բ\or Գ\or Դ\or Ե\or Զ\or Է\or Ը\or Թ\fi}
\def\arm@num@ii#1{%
  \ifcase#1\or Ժ\or Ի\or Լ\or Խ\or Ծ\or Կ\or Հ\or Ձ\or Ղ\fi
  \arm@num@i}
\def\arm@num@iii#1{%
  \ifcase#1\or Ճ\or Մ\or Յ\or Ն\or Շ\or Ո\or Չ\or Պ\or Ջ\fi
  \arm@num@ii}
\def\arm@num@iv#1{%
  \ifcase#1\or Ռ\or Ս\or Վ\or Տ\or Ր\or Ց\or Ւ\or Փ\or Ք\fi
  \arm@num@iii}
\def\arm@ill@value#1{\xpg@warning{Illegal value (#1) for Armenian numeral}[$#1$]}

%    \end{macrocode}
% \iffalse
%</gloss-armenian.ldf>
%<*gloss-arq.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-arq.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-arq.ldf}[polyglossia: module for arq (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-arq.ldf>
%<*gloss-ary.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ary.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ary.ldf}[polyglossia: module for ary (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ary.ldf>
%<*gloss-arz.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-arz.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-arz.ldf}[polyglossia: module for arz (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-arz.ldf>
%<*gloss-ast.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ast.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ast.ldf}[polyglossia: module for ast (Asturian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{asturian}

%    \end{macrocode}
% \iffalse
%</gloss-ast.ldf>
%<*gloss-asturian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-asturian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
% Translated by Xuacu <xuacusk8 at gmail dot com>
% Contributed by Kevin Godby <godbyk at gmail dot com>
%
\ProvidesFile{gloss-asturian.ldf}[polyglossia: module for Asturian]
\PolyglossiaSetup{asturian}{
  bcp47=ast,
  bcp47-language=ast,
  bcp47-script=Latn,
  hyphennames={asturian,catalan},
  hyphenmins={2,2},
  langtag=AST,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{asturian}{ast}

\def\captionsasturian{%
   \def\prefacename{Entamu}%
   \def\refname{Referencies}%
   \def\abstractname{Sumariu}%
   \def\bibname{Bibliografía}%
   \def\chaptername{Capítulu}%
   \def\appendixname{Apéndiz}%
   \def\contentsname{Conteníu}%
   \def\listfigurename{Llista de figures}%
   \def\listtablename{Llista de tables}%
   \def\indexname{Índiz}%
   \def\figurename{Figura}%
   \def\tablename{Tabla}%
   \def\partname{Parte}%
   \def\enclname{incl.}%
   \def\ccname{cc}%
   \def\headtoname{Pa}%
   \def\pagename{Páxina}%
   \def\seename{ver}%
   \def\alsoname{ver tamién}%
   \def\proofname{Demostración}%
   \def\glossaryname{Glosariu}%
   }
\def\dateasturian{%
   \def\today{\number\day~\ifcase\month\or
    de~xineru\or de~febreru\or de~marzu\or d'abril\or de~mayu\or de~xunu\or
    de~xunetu\or d'agostu\or de~setiembre\or d'ochobre\or de~payares\or
    d'avientu\fi\space de~\number\year}%
}

%    \end{macrocode}
% \iffalse
%</gloss-asturian.ldf>
%<*gloss-australian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-australian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-australian.ldf}[polyglossia: module for Australian English]

% We provide this as a babel alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-australian.ldf>
%<*gloss-austrian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-austrian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-austrian.ldf}[polyglossia: module for Austrian German (old spelling)]

% We provide this as a babel alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-austrian.ldf>
%<*gloss-ayl.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ayl.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ayl.ldf}[polyglossia: module for ayl (Arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ayl.ldf>
%<*gloss-bahasa.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bahasa.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bahasa.ldf}[polyglossia: module for Bahasa Indonesia]

% We provide this as a babel alias

\xpg@load@master@language{malay}

%    \end{macrocode}
% \iffalse
%</gloss-bahasa.ldf>
%<*gloss-bahasai.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bahasai.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bahasai.ldf}[polyglossia: module for Bahasa Indonesia]

% We only provide this gloss for babel compatibility. Since bahasai is 
% a malay variety, we use 'malay' with variant 'indonesian' now.

\xpg@load@master@language{malay}

%    \end{macrocode}
% \iffalse
%</gloss-bahasai.ldf>
%<*gloss-bahasam.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bahasam.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bahasam.ldf}[polyglossia: module for Bahasa Melayu]

% We only provide this gloss for babel compatibility. Since bahasam is 
% a malay variety, we use 'malay' with variant 'malaysian' now.

\xpg@load@master@language{malay}

%    \end{macrocode}
% \iffalse
%</gloss-bahasam.ldf>
%<*gloss-basque.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-basque.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-basque.ldf}[polyglossia: module for Basque]
\PolyglossiaSetup{basque}{
  bcp47=eu,
  bcp47-language=eu,
  bcp47-region=ES,
  bcp47-script=Latn,
  hyphennames={basque},
  hyphenmins={2,2},
  langtag=EUQ,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{basque}{eu}

\def\captionsbasque{%
   \def\refname{Erreferentziak}%
   \def\abstractname{Laburpena}%
   \def\bibname{Bibliografia}%
   \def\prefacename{Hitzaurrea}%
   \def\chaptername{Kapitulua}%
   \def\appendixname{Eranskina}%
   \def\contentsname{Gaien Aurkibidea}%
   \def\listfigurename{Irudien Zerrenda}%
   \def\listtablename{Taulen Zerrenda}%
   \def\indexname{Kontzeptuen Aurkibidea}%
   \def\figurename{Irudia}%
   \def\tablename{Taula}%
   \def\thepart{}%
   \def\partname{Atala}%
   \def\pagename{Orria}%
   \def\seename{Ikusi}%
   \def\alsoname{Ikusi, halaber}%
   \def\enclname{Erantsia}%
   \def\ccname{Kopia}%
   \def\headtoname{Nori}%
   \def\proofname{Frogapena}%
   \def\glossaryname{Glosarioa}%
   }
\def\datebasque{%
   \def\today{\number\year.eko\space\ifcase\month\or
    urtarrilaren\or otsailaren\or martxoaren\or apirilaren\or
    maiatzaren\or ekainaren\or uztailaren\or abuztuaren\or
    irailaren\or urriaren\or azaroaren\or
    abenduaren\fi~\number\day}}

%    \end{macrocode}
% \iffalse
%</gloss-basque.ldf>
%<*gloss-be-tarask.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-be-tarask.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-be-tarask.ldf}[polyglossia: module for be-tarask (Belarusian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{belarusian}

%    \end{macrocode}
% \iffalse
%</gloss-be-tarask.ldf>
%<*gloss-be.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-be.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-be.ldf}[polyglossia: module for be (Belarusian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{belarusian}

%    \end{macrocode}
% \iffalse
%</gloss-be.ldf>
%<*gloss-belarusian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-belarusian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-belarusian.ldf}[polyglossia: module for Belarusian]

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{belarusian}{
  bcp47=be,
  bcp47-language=be,
  bcp47-region=BY,
  bcp47-variant=1959acad,
  bcp47-script=Cyrl,
  script=Cyrillic,
  scripttag=cyrl,
  langtag=BEL,
  hyphennames={belarusian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup,
  localnumeral=belarusiannumerals,
  Localnumeral=Belarusiannumerals
}

% BCP-47 compliant aliases
\setlanguagealias*[spelling=classic]{belarusian}{be-tarask}
\setlanguagealias*{belarusian}{be}

\def\belarusian@spelling{modern}
\define@choicekey*+{belarusian}{spelling}[\xpg@val\xpg@nr]{modern,classic,tarask}[modern]{%
   \ifcase\xpg@nr\relax
      % modern:
      \def\belarusian@spelling{modern}%
      \SetLanguageKeys{belarusian}{bcp47=be,bcp47-variant=1959acad}%
   \or
      % classic:
      \def\belarusian@spelling{tarask}%
      \SetLanguageKeys{belarusian}{bcp47=be-tarask,bcp47-variant=tarask}%
   \or
      % tarask:
      \def\belarusian@spelling{tarask}%
      \SetLanguageKeys{belarusian}{bcp47=be-tarask,bcp47-variant=tarask}%
   \fi
}{\xpg@warning{Unknown Belarusian spelling `#1'}}

\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals
\define@choicekey*+{belarusian}{numerals}[\xpg@val\xpg@nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
   \ifcase\xpg@nr\relax
      % arabic:
      \cyrillic@numeralsfalse%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic-trad:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic-alph:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralstrue%
   \fi
   \xpg@info{Option: Belarusian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Belarusian numerals value `#1'}}

\define@boolkey{belarusian}[belarusian@]{babelshorthands}[true]{}

% Register default options
\xpg@initialize@gloss@options{belarusian}{babelshorthands=false,numerals=arabic,spelling=modern}
% Register alias options
\xpg@set@alias@values{belarusian}{spelling}{classic}{tarask}

\ifsystem@babelshorthands
  \setkeys{belarusian}{babelshorthands=true}
\else
  \setkeys{belarusian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\belarusian@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{belarusian}%
  \declare@shorthand{belarusian}{"`}{„}%
  \declare@shorthand{belarusian}{"'}{“}%
  \declare@shorthand{belarusian}{"<}{«}%
  \declare@shorthand{belarusian}{">}{»}%
  \declare@shorthand{belarusian}{""}{\hskip\z@skip}%
  \declare@shorthand{belarusian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{belarusian}{"=}{\nobreak-\hskip\z@skip}%
  \declare@shorthand{belarusian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
  \declare@shorthand{belarusian}{"-}{%
     \def\belarusian@sh@tmp{%
       \if\belarusian@sh@next-\expandafter\belarusian@sh@emdash%
       \else\expandafter\belarusian@sh@hyphen\fi%
     }%
     \futurelet\belarusian@sh@next\belarusian@sh@tmp%
  }%
  \def\belarusian@sh@hyphen{%
    \nobreak\-\bbl@allowhyphens}%
  \def\belarusian@sh@emdash##1##2{\cdash-##1##2}%
  \def\cdash##1##2##3{\def\tempx@{##3}%
  \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
   \ifx\tempx@\tempa@\@Acdash\else
    \ifx\tempx@\tempb@\@Bcdash\else
     \ifx\tempx@\tempc@\@Ccdash\else
      \errmessage{Wrong usage of cdash}\fi\fi\fi}%
  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
    \cyrdash\hskip.2em\ignorespaces}%
  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
   \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
  \def\@Ccdash{\leavevmode
   \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
  \ifx\cyrdash\undefined
    \def\cyrdash{\hbox to.8em{\textendash\hss\textendash}}%
  \fi
  \declare@shorthand{belarusian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

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

% Taken from babel-belarusian
\def\captionsbelarusian@modern{%
    \def\prefacename{Прадмова}%
    \def\refname{Спіс літаратуры}%
    \def\abstractname{Анатацыя}%
    \def\bibname{Літаратура}%
    \def\chaptername{Глава}%
    \def\appendixname{Дадатак}%
    \def\contentsname{Змест}%
    \def\listfigurename{Спіс ілюстрацый}%
    \def\listtablename{Спіс табліц}%
    \def\indexname{Прадметны паказальнік}%
    \def\authorname{Паказальнік імён}%
    \def\figurename{Рыс.}%
    \def\tablename{Табліца}%
    \def\partname{Частка}%
    \def\enclname{укл.}%
    \def\ccname{зых.}%
    \def\headtoname{вх.}%
    \def\pagename{с.}%
    \def\seename{гл.}%
    \def\alsoname{гл.\ таксама}%
    \def\proofname{Доказ}%
    \def\glossaryname{Слоўнік тэрмінаў}%
    \def\acronymname{Абрэвіятуры}%
    \def\lstlistingname{Лістынг}%
    \def\lstlistlistingname{Лістынгі}%
    \def\notesname{Нататкі}%
}

\def\captionsbelarusian@tarask{%
    \def\prefacename{Прадмова}%
    \def\refname{Сьпіс літаратуры}%
    \def\abstractname{Анатацыя}%
    \def\bibname{Літаратура}%
    \def\chaptername{Глава}%
    \def\appendixname{Дадатак}%
    \def\contentsname{Зьмест}%
    \let\tocname=\contentsname
    \def\listfigurename{Сьпіс ілюстрацый}%
    \def\listtablename{Сьпіс табліц}%
    \def\indexname{Прадметны паказальнік}%
    \def\authorname{Паказальнік імён}%
    \def\figurename{Рыс.}%
    \def\tablename{Табліца}%
    \def\partname{Частка}%
    \def\enclname{укл.}%
    \def\ccname{зых.}%
    \def\headtoname{вх.}%
    \def\pagename{с.}%
    \def\seename{гл.}%
    \def\alsoname{гл.\ таксама}%
    \def\proofname{Доказ}%
    \def\glossaryname{Слоўнік тэрмінаў}%
    \def\acronymname{Абрэвіятуры}%
    \def\lstlistingname{Лістынг}%
    \def\lstlistlistingname{Лістынгі}%
    \def\nomname{Азначэньні}%
    \def\notesname{Нататкі}%
}

\def\captionsbelarusian{%
  \csuse{captionsbelarusian@\belarusian@spelling}%
}

\def\datebelarusian@modern{%
   \def\today{\number\day~\ifcase\month\or
    студзеня\or
    лютага\or
    сакавіка\or
    красавіка\or
    мая\or
    чэрвеня\or
    ліпеня\or
    жніўня\or
    верасня\or
    кастрычніка\or
    лістапада\or
    снежня\fi
    \space \number\year~г.}%
}

\def\datebelarusian@tarask{%
   \def\today{\number\day~\ifcase\month\or%
    студзеня\or
    лютага\or
    сакавіка\or
    красавіка\or
    траўня\or
    чэрвеня\or
    ліпеня\or
    жніўня\or
    верасьня\or
    кастрычніка\or
    лістапада\or
    сьнежня\fi%
    \space \number\year~г.}%
}

\def\datebelarusian{%
  \csuse{datebelarusian@\belarusian@spelling}%
}

% Use \providecommand here as the ldf file might
% be reloaded via be-tarask (BCP).
\providecommand{\belarusiannumerals}[2]{\belarusiannumber{#2}}
\providecommand{\Belarusiannumerals}[2]{\Belarusiannumber{#2}}

\def\belarusiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \belarusian@asbuk@alph{#1}%
    \else
      \cyr@alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\def\Belarusiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \belarusian@asbuk@Alph{#1}%
    \else
      \cyr@Alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\let\belarusiannumeral=\belarusiannumber
\let\Belarusiannumeral=\Belarusiannumber

\def\Asbuk#1{\expandafter\belarusian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\belarusian@asbuk@alph\csname c@#1\endcsname}

\def\AsbukTrad#1{\expandafter\cyr@Alph\csname c@#1\endcsname}
\def\asbukTrad#1{\expandafter\cyr@alph\csname c@#1\endcsname}


% This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
% thus ends at 30.
\def\belarusian@asbuk@Alph#1{\ifcase#1\or
   А\or Б\or В\or Г\or Д\or Е\or Ж\or
   З\or И\or К\or Л\or М\or Н\or О\or
   П\or Р\or С\or Т\or У\or Ф\or Х\or
   Ц\or Ч\or Ш\or Щ\or Э\or Ю\or Я%
   \else\xpg@ill@value{#1}{belarusian@asbuk@Alph}\fi%
}

\def\belarusian@asbuk@alph#1{\ifcase#1\or
   а\or б\or в\or г\or д\or е\or ж\or
   з\or и\or к\or л\or м\or н\or о\or
   п\or р\or с\or т\or у\or ф\or х\or
   ц\or ч\or ш\or щ\or э\or ю\or я%
   \else\xpg@ill@value{#1}{belarusian@asbuk@alph}\fi%
}

\def\belarusian@numbers{%
   \let\latin@alph\@alph
   \let\latin@Alph\@Alph
   \ifcyrillic@numerals%
     \def\belarusian@alph##1{\expandafter\belarusiannumeral\expandafter{\the##1}}%
     \def\belarusian@Alph##1{\expandafter\belarusiannumeral\expandafter{\the##1}}%
      \let\@alph\belarusian@alph%
      \let\@Alph\belarusian@Alph%
   \fi
}

\def\nobelarusian@numbers{%
   \let\@alph\latin@alph%
   \let\@Alph\latin@Alph%
}

\def\noextras@belarusian{%
   \ifcyrillic@numerals\nobelarusian@numbers\fi%
   \ifbelarusian@babelshorthands\nobelarusian@shorthands\fi%
}

\def\blockextras@belarusian{%
   \ifcyrillic@numerals\belarusian@numbers\else\nobelarusian@numbers\fi%
   \ifbelarusian@babelshorthands\belarusian@shorthands\else\nobelarusian@shorthands\fi%
}

\def\inlineextras@belarusian{%
   \ifbelarusian@babelshorthands\belarusian@shorthands\else\nobelarusian@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-belarusian.ldf>
%<*gloss-bengali.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bengali.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
% Translations provided by সাজেদুর রহিম জোয়ারদার <toshazed@gmail.com>
% TODO implement Bengali calendar

\ProvidesFile{gloss-bengali.ldf}[polyglossia: module for Bengali]

\RequirePackage{devanagaridigits}
\RequirePackage{bengalidigits}

\PolyglossiaSetup{bengali}{
  bcp47=bn,
  bcp47-language=bn,
  bcp47-script=Beng,
  script=Bengali,
  scripttag=beng,
  langtag=BEN,
  hyphennames={bengali},
  hyphenmins={2,2},%CHECK
  fontsetup=true,
  localnumeral=bengalinumerals
  %TODO nouppercase=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{bengali}{bn}

\newif\ifbengali@devanagari@numerals
\newif\ifbengali@bengali@numerals
\define@choicekey*+{bengali}{numerals}[\xpg@val\xpg@nr]{Devanagari,Bengali,Western}[Devanagari]{%
   \ifcase\xpg@nr\relax
      % Devanagari:
      \bengali@bengali@numeralsfalse%
      \bengali@devanagari@numeralstrue%
   \or
      % Bengali:
      \bengali@bengali@numeralstrue%
      \bengali@devanagari@numeralsfalse%
   \or
      % Western:
      \bengali@bengali@numeralsfalse%
      \bengali@devanagari@numeralsfalse%
   \fi
   \xpg@info{Option: Bengali, numerals=\xpg@val}%
}{\xpg@warning{Unknown Bengali numeral `#1'}}

\def\extras@bengali{}
\def\noextras@bengali{}

\define@boolkey{bengali}[bengali@]{changecounternumbering}[true]{}

% Register default options
\xpg@initialize@gloss@options{bengali}{changecounternumbering=false,numerals=Devanagari}

\def\captionsbengali{%
  \def\refname{তথ্যসূত্রসমূহ}%
  \def\abstractname{সারসংক্ষেপ}%
  \def\bibname{তথ্যবিবরণ}%
  \def\prefacename{পূর্বকথা}%
  \def\chaptername{অধ্যায়}%
  \def\appendixname{পরিশিষ্ট}%
  \def\contentsname{সূচীপত্র}%
  \def\listfigurename{ছবি/নকশা সমূহের তালিকা}%
  \def\listtablename{তালিকাসারণী}%
  \def\indexname{সূচক/নির্দেশক}%
  \def\figurename{চিত্র}%
  \def\tablename{সারণী}%
  %\def\thepart{}% TODO
  \def\partname{খন্ড}%
  \def\pagename{পৃষ্ঠা}%
  \def\seename{দেখুন}%
  \def\alsoname{আরও দেখুন}%
  \def\enclname{সংযুক্তি}%
  \def\ccname{অনুলিপি}%
  \def\headtoname{প্রতি}%
  \def\proofname{প্রমাণ}%
  \def\glossaryname{পরিভাষার শব্দসম্ভার}%
}
\def\datebengali{%
  \def\bengalimonth{%
    \ifcase\month\or
      জানুয়ারি\or
      ফেব্রুয়ারি\or
      মার্চ\or
      এপ্রিল\or
      মে\or
      জুন\or
      জুলাই\or
      আগস্ট\or
      সেপ্টেম্বর\or
      অক্টোবর\or
      নভেম্বর\or
      ডিসেম্বর\fi}%
  \def\today{\bengalinumber\day\space\bengalimonth\space\bengalinumber\year}%
}

\newcommand{\bengalinumerals}[2]{\bengalinumber{#2}}

\def\bengalinumber#1{%
  \ifbengali@devanagari@numerals
    \devanagaridigits{\number#1}%
  \else
    \ifbengali@bengali@numerals
      \bengalidigits{\number#1}%
    \else % Assumed Western
      \number#1%
    \fi
  \fi%
}

% Backwards compatibility. This command was never documented, but
% some people might use it nevertheless (see #381).
% This takes a counter.
\newcommand\bengalinumeral[1]{\localnumeral*[lang=bengali]{#1}}

\def\bengali@globalnumbers{%
   \ifbengali@changecounternumbering
     \let\@arabic\bengalinumber%
     \renewcommand\thefootnote{\localnumeral*{footnote}}%
  \fi
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\nobengali@globalnumbers{%
  \let\@arabic\xpg@save@arabic%
}

\def\blockextras@bengali{\extras@bengali}
\def\inlineextras@bengali{\extras@bengali}

%    \end{macrocode}
% \iffalse
%</gloss-bengali.ldf>
%<*gloss-bg.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bg.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bg.ldf}[polyglossia: module for bg (Bulgarian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{bulgarian}

%    \end{macrocode}
% \iffalse
%</gloss-bg.ldf>
%<*gloss-bn.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bn.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bn.ldf}[polyglossia: module for bn (Bengali)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{bengali}

%    \end{macrocode}
% \iffalse
%</gloss-bn.ldf>
%<*gloss-bo.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bo.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bo.ldf}[polyglossia: module for bo (Tibetan)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{tibetan}

%    \end{macrocode}
% \iffalse
%</gloss-bo.ldf>
%<*gloss-bosnian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bosnian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bosnian.ldf}[polyglossia: module for Bosnian]

\PolyglossiaSetup{bosnian}{
  bcp47=bs,
  bcp47-language=bs,
  bcp47-region=BA,
  bcp47-script=Latn,
  bcp47-casing=bs-Latn,
  langtag=BOS,
  hyphennames={bosnian,croatian},
  hyphenmins={2,2}, % adapted from gloss-croatian
  frenchspacing=true, % adapted from gloss-croatian
  indentfirst=false, % adapted from gloss-croatian
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*{bosnian}{bs}

% TODO: Add script=Cyrillic

% from babel-bosnian
\def\captionsbosnian{%
  \def\prefacename{Predgovor}%
  \def\refname{Literatura}%
  \def\abstractname{Sažetak}%
  \def\bibname{Bibliografija}%
  \def\chaptername{Poglavlje}%
  \def\appendixname{Dodatak}%
  \def\contentsname{Sadržaj}%
  \def\listfigurename{Popis slika}%
  \def\listtablename{Popis tablica}%
  \def\indexname{Indeks}%
  \def\figurename{Slika}%
  \def\tablename{Tablica}%
  \def\partname{Dio}%
  \def\enclname{Prilozi}%
  \def\ccname{Kopija}%
  \def\headtoname{Prima}%
  \def\pagename{Stranica}%
  \def\seename{Vidjeti}%
  \def\alsoname{Također vidjeti}%
  \def\proofname{Dokaz}%
  \def\glossaryname{Rječnik}%
}

\def\datebosnian{%
  \def\today{\number\day.~\ifcase\month\or
    januar\or februar\or mart\or april\or maj\or
    juni\or juli\or august\or septembar\or oktobar\or novembar\or
    decembar\fi \space \number\year.}%
}

%    \end{macrocode}
% \iffalse
%</gloss-bosnian.ldf>
%<*gloss-br.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-br.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-br.ldf}[polyglossia: module for br (Breton)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{breton}

%    \end{macrocode}
% \iffalse
%</gloss-br.ldf>
%<*gloss-brazil.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-brazil.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-brazil.ldf}[polyglossia: module for Brazilian Portuguese]

% We only provide this gloss for backwards compatibility. The name
% 'brazil' was selected in accordance with babel.
% Since brazil is a variety of portuguese, we use 'portuguese' now.

\xpg@load@master@language{portuguese}

%    \end{macrocode}
% \iffalse
%</gloss-brazil.ldf>
%<*gloss-breton.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-breton.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-breton.ldf}[polyglossia: module for Breton]
\PolyglossiaSetup{breton}{
  bcp47=br,
  bcp47-language=br,
  bcp47-region=FR,
  bcp47-script=Latn,
  hyphennames={breton},
  hyphenmins={2,2},
  langtag=BRE,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{breton}{br}

\ifluatex
  % TODO
\else
  \newXeTeXintercharclass\breton@punctthin % ! ? ;
  \newXeTeXintercharclass\breton@punctthick % :
\fi

\def\breton@punctthinspace{{\unskip\thinspace}}
\def\breton@punctthickspace{{\unskip\nobreakspace}}

\def\breton@punctuation{%
  \ifluatex
    % TODO
  \else
    \XeTeXinterchartokenstate=1%
    \XeTeXcharclass `\! \breton@punctthin
    \XeTeXcharclass `\? \breton@punctthin
    \XeTeXcharclass `\; \breton@punctthin
    \XeTeXcharclass `\: \breton@punctthick
    \XeTeXinterchartoks \z@ \breton@punctthin = \breton@punctthinspace
    \XeTeXinterchartoks \z@ \breton@punctthick = \breton@punctthickspace
  \fi
}

\def\nobreton@punctuation{%
  \ifluatex
    % TODO
  \else
    \XeTeXcharclass `\! \z@
    \XeTeXcharclass `\? \z@
    \XeTeXcharclass `\; \z@
    \XeTeXcharclass `\: \z@
    \XeTeXinterchartokenstate=0%
  \fi
}


\def\captionsbreton{%
   \def\refname{Daveennoù}%
   \def\abstractname{Dvierrañ}%
   \def\bibname{Lennadurezh}%
   \def\prefacename{Rakskrid}%
   \def\chaptername{Pennad}%
   \def\appendixname{Stagadenn}%
   \def\contentsname{Taolenn}%
   \def\listfigurename{Listenn ar Figurennoù}%
   \def\listtablename{Listenn an taolennoù}%
   \def\indexname{Meneger}%
   \def\figurename{Figurenn}%
   \def\tablename{Taolenn}%
   \def\thepart{}%
   \def\partname{Lodenn}%
   \def\pagename{Pajenn}%
   \def\seename{Gwelout}%
   \def\alsoname{Gwelout ivez}%
   \def\enclname{Dielloù kevret}%
   \def\ccname{Eilskrid da}%
   \def\headtoname{evit}%
   \def\proofname{Proof}%
   \def\glossaryname{Glossary}%
   }
\def\datebreton{%
   \def\today{\ifnum\day=1\relax 1\/\textsuperscript{añ}\else
    \number\day\fi \space a\space viz\space\ifcase\month\or
    Genver\or C'hwevrer\or Meurzh\or Ebrel\or Mae\or Mezheven\or
    Gouere\or Eost\or Gwengolo\or Here\or Du\or Kerzu\fi
    \space\number\year}}

\def\noextras@breton{%
   \nobreton@punctuation%
   }

\def\blockextras@breton{%
   \breton@punctuation%
   }

\def\inlineextras@breton{%
   \breton@punctuation%
   }

%    \end{macrocode}
% \iffalse
%</gloss-breton.ldf>
%<*gloss-british.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-british.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-british.ldf}[polyglossia: module for British English]

% We provide this as a babel alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-british.ldf>
%<*gloss-bs.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bs.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bs.ldf}[polyglossia: module for bs (Bosnian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{bosnian}

%    \end{macrocode}
% \iffalse
%</gloss-bs.ldf>
%<*gloss-bulgarian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bulgarian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-bulgarian.ldf}[polyglossia: module for Bulgarian]
\PolyglossiaSetup{bulgarian}{
  bcp47=bg,
  bcp47-language=bg,
  bcp47-region=BG,
  bcp47-script=Cyrl,
  script=Cyrillic,
  scripttag=cyrl,
  langtag=BGR,
  hyphennames={bulgarian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup
  %TODO localalph=bulgarian@alph
}

% BCP-47 compliant aliases
\setlanguagealias*{bulgarian}{bg}

\def\bulgarian@Alph#1{%
   \ifcase#1\or
   А\or Б\or В\or Г\or Д\or Е\or Ж\or
   З\or И\or Й\or К\or Л\or М\or Н\or
   О\or П\or Р\or С\or Т\or У\or Ф\or
   Х\or Ц\or Ч\or Ш\or Щ\or Ъ\or
   Ю\or Я\else
   \xpg@ill@value{#1}{bulgarian@Alph}\fi}%

\def\bulgarian@alph#1{%
   \ifcase#1\or
   а\or б\or в\or г\or д\or е\or ж\or
   з\or и\or й\or к\or л\or м\or н\or
   о\or п\or р\or с\or т\or у\or ф\or
   х\or ц\or ч\or ш\or щ\or ъ\or ь\or
   ю\or я\else
   \xpg@ill@value{#1}{bulgarian@alph}\fi}%

\def\bulgarian@numbers{%
   \let\@Alph\bulgarian@Alph%
   \let\@alph\bulgarian@alph%
 }

\def\nobulgarian@numbers{%
   \let\@Alph\latin@Alph%
   \let\@alph\latin@alph%
}

\def\captionsbulgarian{%
   \def\refname{Литература}%
   \def\abstractname{Абстракт}%
   \def\bibname{Библиография}%
   \def\prefacename{Предговор}%
   \def\chaptername{Глава}%
   \def\appendixname{Приложение}%
   \def\contentsname{Съдържание}%
   \def\listfigurename{Списък на фигурите}%
   \def\listtablename{Списък на таблиците}%
   \def\indexname{Азбучен указател}%
   \def\figurename{Фигура}%
   \def\tablename{Таблица}%
   %\def\thepart{}%
   %\def\partname{}%
   \def\pagename{Стр.}%
   \def\seename{вж.}%
   \def\alsoname{вж.\ също и}%
   \def\enclname{Приложения}%
   \def\ccname{копия}%
   %\def\headtoname{}%
   \def\proofname{Proof}%
   \def\glossaryname{Glossary}%
}

\def\datebulgarian{%
   \def\today{\number\day~\ifcase\month\or
       януари\or
       февруари\or
       март\or
       април\or
       май\or
       юни\or
       юли\or
       август\or
       септември\or
       октомври\or
       ноември\or
       декември\fi%
       \ \number\year~г.}%
    \def\month@Roman{\expandafter\@Roman\month}%
    \def\todayRoman{\number\day.\,\month@Roman.\,\number\year~г.}%
    }

%    \end{macrocode}
% \iffalse
%</gloss-bulgarian.ldf>
%<*gloss-ca.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ca.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ca.ldf}[polyglossia: module for ca (Catalan)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{catalan}

%    \end{macrocode}
% \iffalse
%</gloss-ca.ldf>
%<*gloss-canadian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-canadian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-canadian.ldf}[polyglossia: module for Canadian English]

% We provide this as a babel alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-canadian.ldf>
%<*gloss-canadien.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-canadien.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-canadien.ldf}[polyglossia: module for Canadian French]

% We provide this as a babel alias

\xpg@load@master@language{french}

%    \end{macrocode}
% \iffalse
%</gloss-canadien.ldf>
%<*gloss-catalan.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-catalan.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-catalan.ldf}[polyglossia: module for Catalan]
\PolyglossiaSetup{catalan}{
  bcp47=ca,
  bcp47-language=ca,
  bcp47-script=Latn,
  hyphennames={catalan},
  hyphenmins={2,2},
  langtag=CAT,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{catalan}{ca}

\define@boolkey{catalan}[catalan@]{babelshorthands}[true]{}
\ifsystem@babelshorthands
  \setkeys{catalan}{babelshorthands=true}
\else
  \setkeys{catalan}{babelshorthands=false}
\fi

% Register default options
\xpg@initialize@gloss@options{catalan}{babelshorthands=false}

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

%%% adapted from Babel's catalan.ldf
\newdimen\leftllkern \newdimen\rightllkern \newdimen\raiselldim

% we check if char · exists, and use it instead of raised dot:
\def\xpg@raiseddot{%
  \charifavailable{00B7}{\raise\raiselldim\hbox{.}}%
}

\def\lgem{%
  \ifmmode
    \csname normal@char\string"\endcsname l%
  \else
    \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
    \setbox0\hbox{l}%
    \xpg@if@char@available{00B7}%
          {\setbox2\hbox{\char"00B7}\setbox1\hbox{l}}%
          {\setbox2\hbox{.}\setbox1\hbox{l\/}}%
    \setbox3\hbox{.}%
    \advance\raiselldim by \the\fontdimen5\the\font%
    \advance\raiselldim by -\ht2%
    \leftllkern=-.25\wd0%
    \advance\leftllkern by \wd1%
    \advance\leftllkern by -\wd0%
    \advance\leftllkern by -0.5\wd2%
    \advance\leftllkern by 0.5\wd3%
    \rightllkern=-.25\wd0%
    \advance\rightllkern by -\wd1%
    \advance\rightllkern by \wd0%
    \advance\rightllkern by -0.5\wd2%
    \advance\rightllkern by 0.5\wd3%
    \allowhyphens\discretionary{l-}{l}%
    {\hbox{l}\kern\leftllkern\xpg@raiseddot%
      \kern\rightllkern\hbox{l}}\allowhyphens
  \fi
}

\def\Lgem{%
  \ifmmode
    \csname normal@char\string"\endcsname L%
  \else
    \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
    \setbox0\hbox{L}%
    \xpg@if@char@available{00B7}%
          {\setbox2\hbox{\char"00B7}\setbox1\hbox{L}}%
          {\setbox2\hbox{.}\setbox1\hbox{L\/}}%
    \setbox3\hbox{.}%
    \advance\raiselldim by .5\ht0%
    \advance\raiselldim by -.5\ht2%
    \leftllkern=-.125\wd0%
    \advance\leftllkern by \wd1%
    \advance\leftllkern by -\wd0%
    \advance\leftllkern by -0.5\wd2%
    \advance\leftllkern by 0.5\wd3%
    \rightllkern=-\wd0%
    \divide\rightllkern by 6%
    \advance\rightllkern by -\wd1%
    \advance\rightllkern by \wd0%
    \advance\rightllkern by -0.5\wd2%
    \advance\rightllkern by 0.5\wd3%
    \allowhyphens\discretionary{L-}{L}%
    {\hbox{L}\kern\leftllkern\xpg@raiseddot%
      \kern\rightllkern\hbox{L}}\allowhyphens
  \fi
}

\AtBeginDocument{%
  \let\lslash\l
  \let\Lslash\L
  \DeclareRobustCommand\l{\@ifnextchar.\bbl@l{\@ifnextchar·\bbl@l\lslash}}
  \DeclareRobustCommand\L{\@ifnextchar.\bbl@L{\@ifnextchar·\bbl@L\Lslash}}}
\def\bbl@l#1#2{\lgem}
\def\bbl@L#1#2{\Lgem}

\def\catalan@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{catalan}%
  \declare@shorthand{catalan}{"l}{\lgem{}}
  \declare@shorthand{catalan}{"L}{\Lgem{}}
}

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

\def\captionscatalan{%
   \def\refname{Referències}%
   \def\abstractname{Resum}%
   \def\bibname{Bibliografia}%
   \def\prefacename{Pròleg}%
   \def\chaptername{Capítol}%
   \def\appendixname{Apèndix}%
   \def\contentsname{Índex}%
   \def\listfigurename{Índex de figures}%
   \def\listtablename{Índex de taules}%
   \def\indexname{Índex alfabètic}%
   \def\figurename{Figura}%
   \def\tablename{Taula}%
   %\def\thepart{}%
   \def\partname{Part}%
   \def\pagename{Pàgina}%
   \def\seename{Vegeu}%
   \def\alsoname{Vegeu també}%
   \def\enclname{Adjunt}%
   \def\ccname{Còpies a}%
   \def\headtoname{A}%
   \def\proofname{Demostració}%
   \def\glossaryname{Glossari}%
   }
\def\datecatalan{%
   \def\today{\number\day~\ifcase\month\or
    de gener\or de febrer\or de març\or d'abril\or de maig\or
    de juny\or de juliol\or d'agost\or de setembre\or d'octubre\or
    de novembre\or de desembre\fi
    \space de~\number\year}}

\def\noextras@catalan{%
   \ifcatalan@babelshorthands\nocatalan@shorthands\fi%
}

\def\blockextras@catalan{%
   \ifcatalan@babelshorthands\catalan@shorthands\else\nocatalan@shorthands\fi%
}

\def\inlineextras@catalan{%
   \ifcatalan@babelshorthands\catalan@shorthands\else\nocatalan@shorthands\fi%
}
%    \end{macrocode}
% \iffalse
%</gloss-catalan.ldf>
%<*gloss-chinese.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-chinese.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-chinese.ldf}[polyglossia: module for Chinese]

\PolyglossiaSetup{chinese}{
    bcp47=zh,
    bcp47-language=zh,
    bcp47-region=CN,
    bcp47-script=Hans,
    script=CJK,
    scripttag=hani,
    language=Chinese,
    hyphennames={nohyphenation},
    frenchspacing=false,
    fontsetup=true,
    localnumeral=chinesenumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{chinese}{zh}
\setlanguagealias*[variant=simplified]{chinese}{zh-CN}
\setlanguagealias*[variant=traditional]{chinese}{zh-TW}

\providebool{chinese@traditional}

\def\chinese@variant{chinese}

\newif\ifchinese@numerals
\define@key{chinese}{numerals}[arabic]{%
   \ifstrequal{#1}{chinese}%
      {\chinese@numeralstrue%
       \SetLanguageKeys{chinese}{bcp47-extension-u=nu-hant}%
      }{\chinese@numeralsfalse%
       \SetLanguageKeys{chinese}{bcp47-extension-u=nu-latn}%
      }%
}


\define@choicekey*+{chinese}{variant}[\xpg@val\xpg@nr]{cn,simplified,tw,traditional}[cn]{%
   \ifcase\xpg@nr\relax
      % cn:
      \chinese@traditionalfalse
      \SetLanguageKeys{chinese}{bcp47=zh-CN,bcp47-language=zh,bcp47-region=CN,bcp47-script=Hans}%
      \xpg@info{Option: Chinese, variant=simplified}%
   \or
      % simplified:
      \chinese@traditionalfalse
      \SetLanguageKeys{chinese}{bcp47=zh-CN,bcp47-language=zh,bcp47-region=CN,bcp47-script=Hans}%
      \xpg@info{Option: Chinese, variant=simplified}%
   \or
      % tw:
      \chinese@traditionaltrue
      \SetLanguageKeys{chinese}{bcp47=zh-TW,bcp47-language=zh,bcp47-region=TW,bcp47-script=Hant}%
      \xpg@info{Option: Chinese, variant=traditional}%
   \or
      % traditional:
      \chinese@traditionaltrue
      \SetLanguageKeys{chinese}{bcp47=zh-TW,bcp47-language=zh,bcp47-region=TW,bcp47-script=Hant}%
      \xpg@info{Option: Chinese, variant=traditional}%
   \fi
}{\xpg@warning{Unknown Chinese variant `#1'}}

% Register default options
\xpg@initialize@gloss@options{chinese}{variant=cn,numerals=arabic}
%\xpg@initialize@gloss@options{chinese}{variant=tw,numerals=arabic}
% Register alias options
\xpg@set@alias@values{chinese}{variant}{cn}{simplified}
\xpg@set@alias@values{chinese}{variant}{tw}{traditional}


\def\chinese@capsformat{%
    \def\@seccntformat##1{%
        \csname pre##1\endcsname%
        \csname the##1\endcsname%
        \csname post##1\endcsname%
    }%
    \ifchinese@traditional
        \def\postsection{節\space}%
        \def\postsubsection{節\space}%
        \def\postsubsubsection{節\space}%
    \else
        \def\postsection{节\space}%
        \def\postsubsection{节\space}%
        \def\postsubsubsection{节\space}%
    \fi
    \def\presection{第}%
    \def\presubsection{第}%
    \def\presubsubsection{第}%
}

\def\captionschinese{%
    \ifchinese@traditional
        \captions@chinese@traditional
    \else
        \captions@chinese@simplified
    \fi
}

\def\captions@chinese@traditional{%
    \def\contentsname{目錄}%
    \def\listfigurename{插圖}%
    \def\listtablename{表格}%
    \def\figurename{圖}%
    \def\tablename{表}%
    \def\abstractname{摘要}%
    \def\prefacename{前言}%
    \def\indexname{索引}%
    \def\bibname{參考文獻}%
    \def\appendixname{附錄}%
    \def\proofname{證明}%
    \def\refname{參考文獻}%
    \def\partname##1##2{第##1##2 部分}%
    \def\chaptername##1##2{第##1##2 章}%
    \def\pagename##1##2{第##1##2 頁}%
    \def\seename{參照}%
    \def\alsoname{參照}%
    \def\enclname{附件}%
    \def\ccname{抄送}%
    \def\headtoname{收件人}%
    \def\\glossaryname{詞彙表}%
}
\def\captions@chinese@simplified{%
    \def\contentsname{目录}%
    \def\listfigurename{插图}%
    \def\listtablename{表格}%
    \def\figurename{图}%
    \def\tablename{表}%
    \def\abstractname{摘要}%
    \def\prefacename{前言}%
    \def\indexname{索引}%
    \def\bibname{参考文献}%
    \def\appendixname{附录}%
    \def\proofname{证明}%
    \def\refname{参考文献}%
    \def\partname##1##2{第##1##2 部分}%
    \def\chaptername##1##2{第##1##2 章}%
    \def\pagename##1##2{第##1##2 页}%
    \def\seename{参照}%
    \def\alsoname{参照}%
    \def\enclname{附件}%
    \def\ccname{抄送}%
    \def\headtoname{收件人}%
    \def\\glossaryname{词汇表}%
}

\newcount\c@TempJNum%

\def\@ChineseDigit#1{%
    \ifcase#1\or 一\or 二\or 三\or 四\or 五\or%
        六\or 七\or 八\or 九\or 十\or%
        十一\or 十二\or 十三\or 十四\or 十五\or%
        十六\or 十七\or 十八\or 十九\or 二十\or%
        二十一\or 二十二\or 二十三\or 二十四\or 二十五\or%
        二十六\or 二十七\or 二十八\or 二十九\or 三十\or%
        三十一\or 三十二\or 三十三\or 三十四\or 三十五\or%
        三十六\or 三十七\or 三十八\or 三十九\or 四十\or%
        四十一\or 四十二\or 四十三\or 四十四\or 四十五\or%
        四十六\or 四十七\or 四十八\or 四十九\or 五十\or%
        五十一\or 五十二\or 五十三\or 五十四\or 五十五\or%
        五十六\or 五十七\or 五十八\or 五十九\or 六十\or%
        六十一\or 六十二\or 六十三\or 六十四\or 六十五\or%
        六十六\or 六十七\or 六十八\or 六十九\or 七十\or%
        七十一\or 七十二\or 七十三\or 七十四\or 七十五\or%
        七十六\or 七十七\or 七十八\or 七十九\or 八十\or%
        八十一\or 八十二\or 八十三\or 八十四\or 八十五\or%
        八十六\or 八十七\or 八十八\or 八十九\or 九十\or%
        九十一\or 九十二\or 九十三\or 九十四\or 九十五\or%
        九十六\or 九十七\or 九十八\or 九十九%
    \else
        \@ctrerr%
    \fi\relax%
}

\def\@ChineseNum#1{%
    \c@TempJNum=#1\divide\c@TempJNum by 1000\relax%
    \ifnum\c@TempJNum=\z@\c@TempJNum=#1%
        \divide\c@TempJNum by 100\relax%
        \ifnum\c@TempJNum=\z@\@ChineseDigit{#1}\relax%
        \else
            \ifcase\c@TempJNum\or 百\or 二百\or 三百\or 四百\or 五百\or
                六百\or 七百\or 八百\or 九百%
            \fi
            \c@TempJNum=#1\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@ChineseDigit\c@TempJNum\relax%
        \fi%
    \else
        \ifcase\c@TempJNum\or 千\or 二千\or 三千\or 四千\or 五千\or
            六千\or 七千\or 八千\or 九千%
        \fi
        \c@TempJNum=#1\divide\c@TempJNum by 1000\multiply\c@TempJNum by -1000\advance\c@TempJNum#1\divide\c@TempJNum by 100\relax%
        \ifnum\c@TempJNum=\z@\c@TempJNum=#1%
            \divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@ChineseDigit\c@TempJNum\relax%
        \else
            \ifcase\c@TempJNum\or 百\or 二百\or 三百\or 四百\or 五百\or
                六百\or 七百\or 八百\or 九百%
            \fi
            \c@TempJNum=#1\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@ChineseDigit\c@TempJNum\relax%
        \fi
    \fi
}

\def\@chinesenumber#1{%
    \@tempcnta=#1%
    \ifnum\@tempcnta=\z@{〇}%
    \else
        \ifnum\@tempcnta<\z@{負}%
            \multiply\@tempcnta by -1%
        \fi
        \@tempcntb=\@tempcnta\divide\@tempcntb by 10000\relax%
        \ifnum\@tempcntb=\z@\@ChineseNum%
            \@tempcnta%
        \else
            \@tempcntb=\@tempcnta\divide\@tempcntb by 100000000\relax%
            \ifnum\@tempcntb=\z@\@tempcntb=\@tempcnta%
                \divide\@tempcntb by 10000%
                \@ChineseNum\@tempcntb{万}\@tempcntb=\@tempcnta%
                \divide\@tempcntb by 10000\multiply\@tempcntb by -10000%
                \advance\@tempcntb\@tempcnta\relax\@ChineseNum\@tempcntb%
            \else
                \@ChineseNum\@tempcntb{億}\@tempcntb=\@tempcnta%
                \divide\@tempcntb by 100000000\multiply\@tempcntb by -100000000%
                \advance\@tempcntb\@tempcnta\divide\@tempcntb by 10000\relax%
                \ifnum\@tempcntb=\z@%
                \else
                    \@ChineseNum\@tempcntb{万}%
                \fi
                \@tempcntb=\@tempcnta\divide\@tempcntb by 10000%
                \multiply\@tempcntb by -10000\advance\@tempcntb\@tempcnta%
                \@ChineseNum\@tempcntb%
            \fi
        \fi
    \fi
}


\newcommand{\chinesenumerals}[2]{\chinesenumber{#2}}

\def\chinesenumber#1{%
  \ifchinese@numerals
    \@chinesenumber{\number#1}%
  \else
    \number#1%
  \fi}

\let\chinesenumeral=\chinesenumber

\def\datechinese{%
    \def\today{%
        \ifchinese@numerals
           \@chinesenumber{\number\year}%
        \else
           \number\year\,%
        \fi
        {年}%
        \ifchinese@numerals
           \@chinesenumber{\number\month}%
        \else
           \,\number\month\,%
        \fi
        {月}%
        \ifchinese@numerals
           \@chinesenumber{\number\day}%
        \else
           \,\number\day\,%
        \fi
        {日}%
    }%
}

\def\noextras@chinese{%
    \chinese@capsformat%
}

\def\blockextras@chinese{%
    \chinese@capsformat%
}

\def\inlineextras@chinese{%
    \chinese@capsformat%
}
% Based on contributions of Toru Inagaki, Norio Iwase, François Charette

%    \end{macrocode}
% \iffalse
%</gloss-chinese.ldf>
%<*gloss-ckb-Arab.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ckb-Arab.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ckb-Arab.ldf}[polyglossia: module for ckb-Arab (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-ckb-Arab.ldf>
%<*gloss-ckb-Latn.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ckb-Latn.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ckb-Latn.ldf}[polyglossia: module for ckb-Latn (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-ckb-Latn.ldf>
%<*gloss-ckb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ckb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ckb.ldf}[polyglossia: module for ckb (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-ckb.ldf>
%<*gloss-cop.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-cop.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-cop.ldf}[polyglossia: module for cop (Coptic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{coptic}

%    \end{macrocode}
% \iffalse
%</gloss-cop.ldf>
%<*gloss-coptic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-coptic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-coptic.ldf}[polyglossia: module for Coptic]
\PolyglossiaSetup{coptic}{
  bcp47=cop,
  bcp47-language=cop,
  bcp47-region=CN,
  bcp47-script=Copt,
  script=Coptic,
  scripttag=copt,
  langtag=COP,
  hyphennames={coptic},
  hyphenmins={2,2},
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*{coptic}{cop}

%\def\captionscoptic{%
%   \def\refname{<++>}%
%   \def\abstractname{<++>}%
%   \def\bibname{<++>}%
%   \def\prefacename{<++>}%
%   \def\chaptername{<++>}%
%   \def\appendixname{<++>}%
%   \def\contentsname{<++>}%
%   \def\listfigurename{<++>}%
%   \def\listtablename{<++>}%
%   \def\indexname{<++>}%
%   \def\figurename{<++>}%
%   \def\tablename{<++>}%
%   \def\thepart{}%
%   \def\partname{<++>}%
%   \def\pagename{<++>}%
%   \def\seename{<++>}%
%   \def\alsoname{<++>}%
%   \def\enclname{<++>}%
%   \def\ccname{<++>}%
%   \def\headtoname{<++>}%
%   \def\proofname{<++>}%
%   \def\glossaryname{<++>}%
%   }
%\def\datecoptic{%
%   \def\today{<++>}%
%   }

%    \end{macrocode}
% \iffalse
%</gloss-coptic.ldf>
%<*gloss-croatian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-croatian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-croatian.ldf}[polyglossia: module for Croatian]
\PolyglossiaSetup{croatian}{
  bcp47=hr,
  bcp47-language=hr,
  bcp47-script=Latn,
  langtag=HRV,
  hyphennames={croatian},
  hyphenmins={2,2}, % aligned with https://ctan.org/pkg/hrhyph patterns and http://lebesgue.math.hr/~nenad/Diplomski/Maja_Ribaric_2011.pdf
  frenchspacing=true, % recommendation from Damir Bralić
  indentfirst=false, % recommendation from Damir Bralić
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*{croatian}{hr}

\ifluatex
  \RequirePackage{luavlna}
\fi

\define@boolkey{croatian}[croatian@]{babelshorthands}[true]{}

\define@boolkey{croatian}[croatian@]{disabledigraphs}[true]{}

% Alias kept for backwards compatibility. Please do not remove
\define@boolkey{croatian}[croatian@]{disableligatures}[true]{%
   \xpg@warning{The option disableligatures is deprected.\MessageBreak
                Please use disabledigraphs instead}%
   \ifcroatian@disableligatures
      \croatian@disabledigraphstrue
   \else
      \croatian@disabledigraphsfalse
   \fi
}

\define@boolkey{croatian}[croatian@]{splithyphens}[true]{}

\define@boolkey{croatian}[croatian@]{localalph}[true]{}

% Register default options
\xpg@initialize@gloss@options{croatian}{babelshorthands=false,disabledigraphs=false,
                                        splithyphens=true,localalph=true}

\ifsystem@babelshorthands
  \setkeys{croatian}{babelshorthands=true}
\else
  \setkeys{croatian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\let\xpg@hyphen@char-
\def\croatian@@splhyphen#1{%
  \def\croatian@sh@tmp{%
       \ifx\croatian@sh@next\xpg@hyphen@char#1%
       \else\expandafter\croatian@@@splhyphen{#1}\fi%
     }%
     \futurelet\croatian@sh@next\croatian@sh@tmp%
}

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

\def\croatian@splhyphen{%
  \croatian@@splhyphen{-}%
}

\def\croatian@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{croatian}%
  \declare@shorthand{croatian}{"=}{\penalty\@M-\hskip\z@skip}%
  \declare@shorthand{croatian}{""}{\hskip\z@skip}%
  \declare@shorthand{croatian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{croatian}{"-}{\nobreak\-\bbl@allowhyphens}%
  \declare@shorthand{croatian}{"|}{%
      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
      \bbl@allowhyphens}{}%
  }%
  \declare@shorthand{croatian}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
  \declare@shorthand{croatian}{"`}{„}%
  \declare@shorthand{croatian}{"'}{”}%
  \declare@shorthand{croatian}{"<}{«}%
  \declare@shorthand{croatian}{">}{»}%
  \declare@shorthand{croatian}{"D}{\xpg@hr@digraph{D}}%
  \declare@shorthand{croatian}{"d}{\xpg@hr@digraph{d}}%
  \declare@shorthand{croatian}{"L}{\xpg@hr@digraph{L}}%
  \declare@shorthand{croatian}{"l}{\xpg@hr@digraph{l}}%
  \declare@shorthand{croatian}{"N}{\xpg@hr@digraph{N}}%
  \declare@shorthand{croatian}{"n}{\xpg@hr@digraph{n}}%
}

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

\ifxetex
  % splithyphens
  \newXeTeXintercharclass\croatian@hyphen % -
  \newXeTeXintercharclass\croatian@nonsyllabicpreposition%
\fi

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

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

\newcommand*\hr@charifavailable[3]{%
   \ifcroatian@disabledigraphs% no notion of digraphs at all
     \bgroup#3\egroup%
   \else% digraph...
     \charifavailable{#1}{#2}% ... either a Unicode original or a mimic of one
   \fi%
}

% Provide croatian digraphs if available in current font
\protected\def\xpg@hr@digraph#1#2{%
 \bgroup%
  % 1. DŽ, Dž and dž
  \ifx#1D%
    \ifx#2Z\relax%
       \hr@charifavailable{01C4}{D\nobreak Ž}{DŽ}%
    \else%
       \ifx#2z\relax
          \hr@charifavailable{01C5}{D\nobreak ž}{Dž}%
       \else
           D#2%
       \fi%
    \fi%
  \fi%
  \ifx#1d%
    \ifx#2z\relax
       \hr@charifavailable{01C6}{d\nobreak ž}{dž}%
    \else
       d#2%
    \fi%
  \fi%
  % 2. LJ, Lj and lj
  \ifx#1L%
    \ifx#2J\relax%
       \hr@charifavailable{01C7}{L\nobreak J}{LJ}%
    \else%
       \ifx#2j\relax
          \hr@charifavailable{01C8}{L\nobreak j}{Lj}%
       \else
           L#2%
       \fi%
    \fi%
  \fi%
  \ifx#1l%
    \ifx#2j\relax
       \hr@charifavailable{01C9}{l\nobreak j}{lj}%
    \else
       l#2%
    \fi%
  \fi%
  % 2. NJ, Nj and nj
  \ifx#1N%
    \ifx#2J\relax%
       \hr@charifavailable{01CA}{N\nobreak J}{NJ}%
    \else%
       \ifx#2j\relax
          \hr@charifavailable{01CB}{N\nobreak j}{Nj}%
       \else
           N#2%
       \fi%
    \fi%
  \fi%
  \ifx#1n%
    \ifx#2j\relax
       \hr@charifavailable{01CC}{n\nobreak j}{nj}%
    \else
       n#2%
    \fi%
  \fi%
  \egroup%
}

\def\captionscroatian{%
  \def\prefacename{Predgovor}%
  \def\refname{Literatura}%
  \def\abstractname{Sažetak}%
  \def\bibname{Bibliografija}%
  \def\chaptername{Poglav\xpg@hr@digraph{l}{j}e}%
  \def\appendixname{Dodatak}%
  \def\contentsname{Sadržaj}%
  \def\listfigurename{Popis slika}%
  \def\listtablename{Popis tablica}%
  \def\indexname{Kazalo}%
  \def\figurename{Slika}%
  \def\tablename{Tablica}%
  \def\partname{Dio}%
  \def\enclname{Prilozi}%
  \def\ccname{Kopija}%
  \def\headtoname{Prima}%
  \def\pagename{Stranica}%
  \def\seename{Vidjeti}%
  \def\alsoname{Također vidjeti}%
  \def\proofname{Dokaz}%
  \def\glossaryname{Pojmovnik}%
}

\def\datecroatian{%
  \def\today{\number\day.~\ifcase\month\or
    siječ\xpg@hr@digraph{n}{j}a\or ve\xpg@hr@digraph{l}{j}ače\or
    ožujka\or trav\xpg@hr@digraph{n}{j}a\or svib\xpg@hr@digraph{n}{j}a\or
    lip\xpg@hr@digraph{n}{j}a\or srp\xpg@hr@digraph{n}{j}a\or
    kolovoza\or rujna\or listopada\or studenoga\or prosinca\fi \space \number\year.}%
}

\def\croatian@@alph#1{%
  \ifcase#1\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or
  m\or n\or o\or p\or r\or s\or t\or u\or v\or z\else#1\fi
}
\def\croatian@@Alph#1{%
  \ifcase#1\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or
  M\or N\or O\or P\or R\or S\or T\or U\or V\or Z\else#1\fi
}

\def\croatian@alph#1{\expandafter\croatian@@alph\csname c@#1\endcsname}
\def\croatian@Alph#1{\expandafter\croatian@@Alph\csname c@#1\endcsname}

\def\noextras@croatian{%
  \ifcroatian@babelshorthands\nocroatian@shorthands\fi%
  \nocroatian@hyphens%
  \let\alph\latinalph\let\Alph\latinAlph%
}

\def\blockextras@croatian{%
  \ifcroatian@babelshorthands\croatian@shorthands\else\nocroatian@shorthands\fi%
  \ifcroatian@splithyphens\croatian@hyphens\else\nocroatian@hyphens\fi%
  \ifcroatian@localalph\let\alph\croatian@alph\let\Alph\croatian@Alph\fi%
}

\def\inlineextras@croatian{%
  \ifcroatian@babelshorthands\croatian@shorthands\else\nocroatian@shorthands\fi%
  \ifcroatian@splithyphens\croatian@hyphens\else\nocroatian@hyphens\fi%
  \ifcroatian@localalph\let\alph\croatian@alph\let\Alph\croatian@Alph\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-croatian.ldf>
%<*gloss-cy.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-cy.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-cy.ldf}[polyglossia: module for cy (Welsh)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{welsh}

%    \end{macrocode}
% \iffalse
%</gloss-cy.ldf>
%<*gloss-cz.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-cz.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-cz.ldf}[polyglossia: module for cz (Czech)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{czech}

%    \end{macrocode}
% \iffalse
%</gloss-cz.ldf>
%<*gloss-czech.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-czech.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\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,
  fontsetup=true,
}

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

\ifluatex
  \RequirePackage{luavlna}
\fi

\define@boolkey{czech}[czech@]{babelshorthands}[true]{}

\define@boolkey{czech}[czech@]{splithyphens}[true]{}

\define@boolkey{czech}[czech@]{vlna}[true]{}

% Register default options
\xpg@initialize@gloss@options{czech}{babelshorthands=false,splithyphens=true,vlna=true}

\ifsystem@babelshorthands
  \setkeys{czech}{babelshorthands=true}
\else
  \setkeys{czech}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\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%
}

%    \end{macrocode}
% \iffalse
%</gloss-czech.ldf>
%<*gloss-da.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-da.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-da.ldf}[polyglossia: module for da (Danish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{danish}

%    \end{macrocode}
% \iffalse
%</gloss-da.ldf>
%<*gloss-danish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-danish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-danish.ldf}[polyglossia: module for Danish]
\PolyglossiaSetup{danish}{
  bcp47=da,
  bcp47-language=da,
  bcp47-script=Latn,
  hyphennames={danish},
  hyphenmins={2,3},
  langtag=DAN,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{danish}{da}

\def\captionsdanish{%
  \def\prefacename{Forord}%
  \def\refname{Litteratur}%
  \def\abstractname{Resumé}%
  \def\bibname{Litteratur}%
  \def\chaptername{Kapitel}%
  \def\appendixname{Bilag}%
  \def\contentsname{Indhold}%
  \def\listfigurename{Figurer}%
  \def\listtablename{Tabeller}%
  \def\indexname{Indeks}%
  \def\figurename{Figur}%
  \def\tablename{Tabel}%
  \def\partname{Del}%
  \def\enclname{Vedlagt}%
  \def\ccname{Kopi til}%   or    Kopi sendt til
  \def\headtoname{Til}% in letter
  \def\pagename{Side}%
  \def\seename{Se}%
  \def\alsoname{Se også}%
  \def\proofname{Bevis}%
  \def\glossaryname{Gloseliste}%
}

\def\datedanish{%
  \def\today{\number\day.~\ifcase\month\or
    januar\or februar\or marts\or april\or maj\or juni\or
    juli\or august\or september\or oktober\or november\or december\fi
    \space\number\year}%
}

%    \end{macrocode}
% \iffalse
%</gloss-danish.ldf>
%<*gloss-de-AT-1901.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-AT-1901.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-AT-1901.ldf}[polyglossia: module for de-AT-1901 (Austrian German, old spelling)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-AT-1901.ldf>
%<*gloss-de-AT-1996.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-AT-1996.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-AT-1996.ldf}[polyglossia: module for de-AT-1996 (Austrian German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-AT-1996.ldf>
%<*gloss-de-AT.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-AT.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-AT.ldf}[polyglossia: module for de-AT (Austrian German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-AT.ldf>
%<*gloss-de-CH-1901.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-CH-1901.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-CH-1901.ldf}[polyglossia: module for de-CH-1901 (Swiss German, old spelling)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-CH-1901.ldf>
%<*gloss-de-CH-1996.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-CH-1996.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-CH-1996.ldf}[polyglossia: module for de-CH-1996 (Swiss German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-CH-1996.ldf>
%<*gloss-de-CH.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-CH.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-CH.ldf}[polyglossia: module for de-CH (Swiss German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-CH.ldf>
%<*gloss-de-DE-1901.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-DE-1901.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-DE-1901.ldf}[polyglossia: module for de-DE-1901 (Germany's German, old spelling)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-DE-1901.ldf>
%<*gloss-de-DE-1996.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-DE-1996.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-DE-1996.ldf}[polyglossia: module for de-DE-1996 (Germany's German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-DE-1996.ldf>
%<*gloss-de-DE.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-DE.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-DE.ldf}[polyglossia: module for de-DE (Germany's German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-DE.ldf>
%<*gloss-de-Latf-AT-1901.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-AT-1901.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-AT-1901-Latf.ldf}[polyglossia: module for de-AT-1901-Latf (Austrian German, old spelling)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-AT-1901.ldf>
%<*gloss-de-Latf-AT-1996.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-AT-1996.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-AT-1996-Latf.ldf}[polyglossia: module for de-AT-1996-Latf (Austrian German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-AT-1996.ldf>
%<*gloss-de-Latf-AT.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-AT.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-AT-Latf.ldf}[polyglossia: module for de-AT-Latf (Austrian German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-AT.ldf>
%<*gloss-de-Latf-CH-1901.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-CH-1901.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-CH-1901-Latf.ldf}[polyglossia: module for de-CH-1901-Latf (Swiss German, old spelling)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-CH-1901.ldf>
%<*gloss-de-Latf-CH-1996.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-CH-1996.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-CH-1996-Latf.ldf}[polyglossia: module for de-CH-1996-Latf (Swiss German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-CH-1996.ldf>
%<*gloss-de-Latf-CH.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-CH.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-CH-Latf.ldf}[polyglossia: module for de-CH-Latf (Swiss German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-CH.ldf>
%<*gloss-de-Latf-DE-1901.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-DE-1901.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-DE-1901-Latf.ldf}[polyglossia: module for de-DE-1901-Latf (Germany's German, old spelling)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-DE-1901.ldf>
%<*gloss-de-Latf-DE-1996.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-DE-1996.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-DE-1996-Latf.ldf}[polyglossia: module for de-DE-1996-Latf (Germany's German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-DE-1996.ldf>
%<*gloss-de-Latf-DE.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf-DE.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-DE-Latf.ldf}[polyglossia: module for de-DE-Latf (Germany's German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf-DE.ldf>
%<*gloss-de-Latf.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de-Latf.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de-Latf.ldf}[polyglossia: module for de-Latf (German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de-Latf.ldf>
%<*gloss-de.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-de.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-de.ldf}[polyglossia: module for de (German)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-de.ldf>
%<*gloss-divehi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-divehi.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-divehi.ldf}[polyglossia: module for Divehi]

\RequireBidi
\PolyglossiaSetup{divehi}{
  bcp47=dv,
  bcp47-language=dv,
  bcp47-script=Thaa,
  script=Thaana,
  scripttag=thaa,
  langtag=DIV,% TODO Support DHV as well?
  direction=RL,
  hyphennames={nohyphenation},
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*{divehi}{dv}

%\def\captionsdivehi{%
%   \def\refname{<++>}%
%   \def\abstractname{<++>}%
%   \def\bibname{<++>}%
%   \def\prefacename{<++>}%
%   \def\chaptername{<++>}%
%   \def\appendixname{<++>}%
%   \def\contentsname{<++>}%
%   \def\listfigurename{<++>}%
%   \def\listtablename{<++>}%
%   \def\indexname{<++>}%
%   \def\figurename{<++>}%
%   \def\tablename{<++>}%
%   \def\thepart{}%
%   \def\partname{<++>}%
%   \def\pagename{<++>}%
%   \def\seename{<++>}%
%   \def\alsoname{<++>}%
%   \def\enclname{<++>}%
%   \def\ccname{<++>}%
%   \def\headtoname{<++>}%
%   \def\proofname{<++>}%
%   \def\glossaryname{<++>}%
%   }
%\def\datedivehi{\def\today{<++>}}

%    \end{macrocode}
% \iffalse
%</gloss-divehi.ldf>
%<*gloss-dsb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-dsb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-dsb.ldf}[polyglossia: module for dsb (Sorbian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{sorbian}

%    \end{macrocode}
% \iffalse
%</gloss-dsb.ldf>
%<*gloss-dutch.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-dutch.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\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,
  fontsetup=true,
}

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

\define@boolkey{dutch}[dutch@]{babelshorthands}[true]{}

\define@boolkey{dutch}[dutch@]{tremahyphenation}[true]{}

% Register default options
\xpg@initialize@gloss@options{dutch}{babelshorthands=false,tremahyphenation=true}

\ifsystem@babelshorthands
  \setkeys{dutch}{babelshorthands=true}
\else
  \setkeys{dutch}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\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}{"-}{\nobreak-\bbl@allowhyphens}%
  \declare@shorthand{dutch}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{dutch}{"|}{%
    \textormath{\discretionary{-}{}{\kern.03em}}{}}%
  \declare@shorthand{dutch}{""}{\hskip\z@skip}%
  \declare@shorthand{dutch}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
  \def\-{\bbl@allowhyphens\discretionary{-}{}{}\bbl@allowhyphens}%
}

\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%
}

%    \end{macrocode}
% \iffalse
%</gloss-dutch.ldf>
%<*gloss-dv.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-dv.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-dv.ldf}[polyglossia: module for dv (Divehi)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{divehi}

%    \end{macrocode}
% \iffalse
%</gloss-dv.ldf>
%<*gloss-el-monoton.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-el-monoton.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-el-monoton.ldf}[polyglossia: module for el-monoton (Greek)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{greek}

%    \end{macrocode}
% \iffalse
%</gloss-el-monoton.ldf>
%<*gloss-el-polyton.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-el-polyton.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-el-polyton.ldf}[polyglossia: module for el-polyton (Greek)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{greek}

%    \end{macrocode}
% \iffalse
%</gloss-el-polyton.ldf>
%<*gloss-el.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-el.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-el.ldf}[polyglossia: module for el (Greek)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{greek}

%    \end{macrocode}
% \iffalse
%</gloss-el.ldf>
%<*gloss-en-AU.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-en-AU.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-en-AU.ldf}[polyglossia: module for en-AU (Australian English)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-en-AU.ldf>
%<*gloss-en-CA.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-en-CA.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-en-CA.ldf}[polyglossia: module for en-CA (Canadan English)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-en-CA.ldf>
%<*gloss-en-GB.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-en-GB.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-en-GB.ldf}[polyglossia: module for en-GB (British English)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-en-GB.ldf>
%<*gloss-en-NZ.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-en-NZ.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-en-NZ.ldf}[polyglossia: module for en-NZ (Newzealand English)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-en-NZ.ldf>
%<*gloss-en-US.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-en-US.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-en-US.ldf}[polyglossia: module for en-US (American English)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-en-US.ldf>
%<*gloss-en.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-en.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-en.ldf}[polyglossia: module for en (English)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-en.ldf>
%<*gloss-english.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-english.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-english.ldf}[polyglossia: module for English]

\PolyglossiaSetup{english}{
  bcp47=en-US,
  bcp47-language=en,
  bcp47-region=US,
  bcp47-script=Latn,
  hyphennames={english,american,usenglish,USenglish},
  hyphenmins={2,3},
  langtag=ENG,
  fontsetup=true,
  babelname=english
}

% BCP-47 compliant aliases
\setlanguagealias*{english}{en}
\setlanguagealias*[variant=australian]{english}{en-AU}
\setlanguagealias*[variant=canadian]{english}{en-CA}
\setlanguagealias*[variant=british]{english}{en-GB}
\setlanguagealias*[variant=newzealand]{english}{en-NZ}
\setlanguagealias*[variant=us]{english}{en-US}


% Babel aliases
\setlanguagealias[variant=us]{english}{american}
\setlanguagealias[variant=australian]{english}{australian}
\setlanguagealias[variant=british]{english}{british}
\setlanguagealias[variant=canadian]{english}{canadian}
\setlanguagealias[variant=newzealand]{english}{newzealand}

\providebool{british@hyphen}
\providebool{english@ordinalmonthday}
\providebool{british@dateformat}

% US English (\l@english) is default
% Initialize its settings
\def\english@variant{english}
\british@hyphenfalse
\english@ordinalmonthdayfalse
\british@dateformatfalse

% Option ordinalmonthday
\define@boolkey{english}[english@]{ordinalmonthday}[true]{}

\define@choicekey*+{english}{variant}[\xpg@val\xpg@nr]{uk,british,us,american,usmax,australian,newzealand,canadian}[us]{%
   \ifcase\xpg@nr\relax
      % uk:
      \british@hyphentrue
      \british@dateformattrue
      \english@ordinalmonthdaytrue
      \SetLanguageKeys{english}{babelname=british,bcp47=en-GB,bcp47-language=en,bcp47-region=GB}%
      \xpg@info{Option: English, variant=british}%
   \or
      % british:
      \british@hyphentrue
      \british@dateformattrue
      \english@ordinalmonthdaytrue
      \SetLanguageKeys{english}{babelname=british,bcp47=en-GB,bcp47-language=en,bcp47-region=GB}%
      \xpg@info{Option: english variant=british}%
   \or
      % us:
      \british@hyphenfalse
      \british@dateformatfalse
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=american,bcp47=en-US,bcp47-language=en,bcp47-region=US}%
      \xpg@info{Option: English, variant=american}%
   \or
      % american:
      \british@hyphenfalse
      \british@dateformatfalse
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=american,bcp47=en-US,bcp47-language=en,bcp47-region=US}%
      \xpg@info{Option: English, variant=american}%
   \or
      % usmax:
      \british@hyphenfalse
      \british@dateformatfalse
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=american,bcp47=en-US,bcp47-language=en,bcp47-region=US}%
      \xpg@info{Option: english variant=american (with additional patterns)}%
      \xpg@ifdefined{usenglishmax}{}%
         {\xpg@warning{No hyphenation patterns were loaded for "US English Max"\MessageBreak
                       I will use the standard patterns for US English instead}%
          \adddialect\l@usenglishmax\l@english\relax%
         }%
      \def\english@variant{usenglishmax}%
   \or
      % australian:
      % These use the british hyphenation patterns
      % but date formats without ordinals
      \british@hyphentrue
      \british@dateformattrue
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=australian,bcp47=en-AU,bcp47-language=en,bcp47-region=AU}%
      \xpg@info{Option: English, variant=australian}%
      \adddialect\l@australian\l@english%
   \or
      % newzealand:
      % These use the british hyphenation patterns
      % but date formats without ordinals
      \british@hyphentrue
      \british@dateformattrue
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=newzealand,bcp47=en-NZ,bcp47-language=en,bcp47-region=NZ}%
      \xpg@info{Option: English, variant=newzealand}%
      \adddialect\l@newzealand\l@english%
   \or
      % canadian:
      % This is currently equivalent to usenglish (as in babel)
      \british@hyphenfalse
      \british@dateformatfalse
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=canadian,bcp47=en-CA,bcp47-language=en,bcp47-region=CA}%
      \xpg@info{Option: English, variant=american}%
      \adddialect\l@canadian\l@english%
   \fi
   \ifbritish@hyphen
      \xpg@ifdefined{ukenglish}{}%
         {\xpg@warning{No hyphenation patterns were loaded for British English\MessageBreak
                       I will use the patterns for US English instead}%
          \adddialect\l@ukenglish\l@english\relax%
         }%
      \def\english@variant{ukenglish}%
   \fi
}{\xpg@warning{Unknown English variant `#1'}}

% Register default options
\xpg@initialize@gloss@options{english}{variant=us,ordinalmonthday=false}
% Register alias options
\xpg@set@alias@values{english}{variant}{us}{american}
\xpg@set@alias@values{english}{variant}{uk}{british}

\ifxetex
   % Check if \l@english is defined. If not, try to set it to some variety
   % (specific order as in the csv list below), or null language if everything fails
   \xpg@ifdefined{english}{}{%
      \def\do##1{%
         \xpg@ifdefined{#1}%
            {\csletcs{l@english}{l@#1}\listbreak}%
            {%
               \xpg@warning{No hyphenation patterns for English found"\MessageBreak
                            I will use the 'null' language instead}%
               \adddialect\l@english0
            }%
      }%
      \docsvlist{british, american, usenglishmax, australian, newzealand}
      \xpg@ifdefined{english}{}{}
   }%
\fi

\def\english@language{%
   \polyglossia@setup@language@patterns{\english@variant}%
}%

\def\captionsenglish{%
   \def\prefacename{Preface}%
   \def\refname{References}%
   \def\abstractname{Abstract}%
   \def\bibname{Bibliography}%
   \def\chaptername{Chapter}%
   \def\appendixname{Appendix}%
   \def\contentsname{Contents}%
   \def\listfigurename{List of Figures}%
   \def\listtablename{List of Tables}%
   \def\indexname{Index}%
   \def\figurename{Figure}%
   \def\tablename{Table}%
   \def\partname{Part}%
   \def\enclname{encl}%
   \def\ccname{cc}%
   \def\headtoname{To}%
   \def\pagename{Page}%
   \def\seename{see}%
   \def\alsoname{see also}%
   \def\proofname{Proof}%
}

\def\dateenglish{%
   \def\english@day{%
     \ifenglish@ordinalmonthday
       \ifcase\day\or
        1st\or 2nd\or 3rd\or 4th\or 5th\or
        6th\or 7th\or 8th\or 9th\or 10th\or
        11th\or 12th\or 13th\or 14th\or 15th\or
        16th\or 17th\or 18th\or 19th\or 20th\or
        21st\or 22nd\or 23rd\or 24th\or 25th\or
        26th\or 27th\or 28th\or 29th\or 30th\or
        31st\fi
     \else\number\day\fi}%
     \def\english@month{\ifcase\month\or
      January\or February\or March\or April\or May\or June\or
      July\or August\or September\or October\or November\or December\fi}%
   \def\today{%
    \ifbritish@dateformat
      \english@day\space\english@month\space\number\year
    \else
      \english@month\space\english@day,\space\number\year
    \fi}%
}

%    \end{macrocode}
% \iffalse
%</gloss-english.ldf>
%<*gloss-eo.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-eo.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-eo.ldf}[polyglossia: module for eo (Esperanto)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{esperanto}

%    \end{macrocode}
% \iffalse
%</gloss-eo.ldf>
%<*gloss-es-ES.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-es-ES.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-es-ES.ldf}[polyglossia: module for es-ES (Spain's Spanish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{spanish}

%    \end{macrocode}
% \iffalse
%</gloss-es-ES.ldf>
%<*gloss-es-MX.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-es-MX.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-es-MX.ldf}[polyglossia: module for es-MX (Mexican Spanish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{spanish}

%    \end{macrocode}
% \iffalse
%</gloss-es-MX.ldf>
%<*gloss-es.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-es.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-es.ldf}[polyglossia: module for es (Spanish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{spanish}

%    \end{macrocode}
% \iffalse
%</gloss-es.ldf>
%<*gloss-esperanto.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-esperanto.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-esperanto.ldf}[polyglossia: module for Esperanto]
\PolyglossiaSetup{esperanto}{
  bcp47=eo,
  bcp47-language=eo,
  bcp47-script=Latn,
  hyphennames={esperanto},
  hyphenmins={2,2},
  langtag=NTO,
  fontsetup=true,
  %TODO localalph={esperanto@alph,esperanto@Alph}
}

% BCP-47 compliant aliases
\setlanguagealias*{esperanto}{eo}

\def\captionsesperanto{%
   \def\refname{Citaĵoj}%
   \def\abstractname{Resumo}%
   \def\bibname{Bibliografio}%
   \def\prefacename{Antaŭparolo}%
   \def\chaptername{Ĉapitro}%
   \def\appendixname{Apendico}%
   \def\contentsname{Enhavo}%
   \def\listfigurename{Listo de figuroj}%
   \def\listtablename{Listo de tabeloj}%
   \def\indexname{Indekso}%
   \def\figurename{Figuro}%
   \def\tablename{Tabelo}%
   %\def\thepart{}%
   %\def\partname{}%
   \def\pagename{Paĝo}%
   \def\seename{vidu}%
   \def\alsoname{Parto}%
   \def\enclname{Aldono(j)}%
   \def\ccname{Kopie al}%
   \def\headtoname{Al}%
   \def\proofname{Pruvo}%
   \def\glossaryname{Glosaro}%
   }
\def\dateesperanto{%   
   \def\today{\number\day{–a}~de~\ifcase\month\or
    januaro\or februaro\or marto\or aprilo\or majo\or junio\or
    julio\or aŭgusto\or septembro\or oktobro\or novembro\or
    decembro\fi,\space \number\year}%
   \def\hodiau{la \today}%
   \def\hodiaun{la \number\day{–an}~de~\ifcase\month\or
      januaro\or februaro\or marto\or aprilo\or majo\or junio\or
      julio\or aŭgusto\or septembro\or oktobro\or novembro\or
      decembro\fi, \space \number\year}%
    }
\def\esperanto@alph#1{%
   \ifcase#1\or a\or b\or c\or ĉ\or d\or e\or f\or g\or ĝ\or
     h\or ĥ\or i\or j\or ĵ\or k\or l\or m\or n\or o\or
     p\or r\or s\or ŝ\or t\or u\or ŭ\or v\or z\else\xpg@ill@value{#1}{esperanto@alph}\fi}%
\def\esperanto@Alph#1{%
   \ifcase#1\or A\or B\or C\or Ĉ\or D\or E\or F\or G\or Ĝ\or
     H\or Ĥ\or I\or J\or Ĵ\or K\or L\or M\or N\or O\or
     P\or R\or S\or Ŝ\or T\or U\or Ŭ\or V\or Z\else\xpg@ill@value{#1}{esperanto@Alph}\fi}%

\def\esperanto@numbers{%
   \let\@Alph\esperanto@Alph%
   \let\@alph\esperanto@alph%
 }

\def\noesperanto@numbers{%
   \let\@Alph\latin@Alph% 
   \let\@alph\latin@alph%
}

%    \end{macrocode}
% \iffalse
%</gloss-esperanto.ldf>
%<*gloss-estonian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-estonian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-estonian.ldf}[polyglossia: module for Estonian]
\PolyglossiaSetup{estonian}{
  bcp47=et,
  bcp47-language=et,
  bcp47-region=EE,
  bcp47-script=Latn,
  hyphennames={estonian},
  hyphenmins={2,2},
  langtag=ETI,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{estonian}{et}

\def\captionsestonian{%
   \def\refname{Viited}%
   \def\abstractname{Kokkuvõte}%
   \def\bibname{Kirjandus}%
   \def\prefacename{Sissejuhatus}%
   \def\chaptername{Peatükk}%
   \def\appendixname{Lisa}%
   \def\contentsname{Sisukord}%
   \def\listfigurename{Joonised}%
   \def\listtablename{Tabelid}%
   \def\indexname{Indeks}%
   \def\figurename{Joonis}%
   \def\tablename{Tabel}%
   %\def\thepart{}%
   \def\partname{Osa}%
   \def\pagename{Lk.}%
   \def\seename{vt.}%
   \def\alsoname{vt. ka}%
   \def\enclname{Lisa(d)}%
   \def\ccname{Koopia(d)}%
   %\def\headtoname{}%
   \def\proofname{Korrektuur}%
   \def\glossaryname{Glossary}% <-- need translation
   }
\def\dateestonian{%
   \def\today{\number\day.\space\ifcase\month\or
    jaanuar\or veebruar\or märts\or aprill\or mai\or juuni\or
    juuli\or august\or september\or oktoober\or november\or
    detsember\fi\space\number\year.\space a.}}

%    \end{macrocode}
% \iffalse
%</gloss-estonian.ldf>
%<*gloss-et.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-et.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-et.ldf}[polyglossia: module for et (Estonian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{estonian}

%    \end{macrocode}
% \iffalse
%</gloss-et.ldf>
%<*gloss-eu.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-eu.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-eu.ldf}[polyglossia: module for eu (Basque)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{basque}

%    \end{macrocode}
% \iffalse
%</gloss-eu.ldf>
%<*gloss-fa.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fa.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fa.ldf}[polyglossia: module for fa (Persian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{persian}

%    \end{macrocode}
% \iffalse
%</gloss-fa.ldf>
%<*gloss-farsi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-farsi.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-farsi.ldf}[polyglossia: module for Farsi]

% We only provide this gloss for babel compatibility.
% The proper English language name is Persian.

\xpg@load@master@language{persian}

%    \end{macrocode}
% \iffalse
%</gloss-farsi.ldf>
%<*gloss-fi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fi.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fi.ldf}[polyglossia: module for fi (Finnish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{finnish}

%    \end{macrocode}
% \iffalse
%</gloss-fi.ldf>
%<*gloss-finnish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-finnish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-finnish.ldf}[polyglossia: module for Finnish]
\PolyglossiaSetup{finnish}{
  bcp47=fi,
  bcp47-language=fi,
  bcp47-region=FI,
  bcp47-script=Latn,
  hyphennames={finnish},
  hyphenmins={2,2},
  langtag=FIN,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{finnish}{fi}

\define@boolkey{finnish}[finnish@]{babelshorthands}[true]{}

\define@boolkey{finnish}[finnish@]{schoolhyphens}[true]{}

% Register default options
\xpg@initialize@gloss@options{finnish}{babelshorthands=false,schoolhyphens=false}

\ifsystem@babelshorthands
  \setkeys{finnish}{babelshorthands=true}
\else
  \setkeys{finnish}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
    \input{babelsh.def}%
    \initiate@active@char{"}%
    \shorthandoff{"}%
}{}

\def\finnish@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{finnish}%
  \declare@shorthand{finnish}{"-}{\nobreak-\bbl@allowhyphens}
  \declare@shorthand{finnish}{"|}{\textormath{\penalty\@M\discretionary{-}{}{\kern.03em}}{}}%
  \declare@shorthand{finnish}{""}{\hskip\z@skip}%
  \declare@shorthand{finnish}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{finnish}{"=}{\penalty\@M-\hskip\z@skip}%
  \declare@shorthand{finnish}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
}

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

\def\captionsfinnish{%
   \def\refname{Viitteet}%
   \def\abstractname{Tiivistelmä}%
   \def\bibname{Kirjallisuutta}%
   \def\prefacename{Esipuhe}%
   \def\chaptername{Luku}%
   \def\appendixname{Liite}%
   \def\contentsname{Sisällys}%
   \def\listfigurename{Kuvat}%
   \def\listtablename{Taulukot}%
   \def\indexname{Hakemisto}%
   \def\figurename{Kuva}%
   \def\tablename{Taulukko}%
   %\def\thepart{}%
   \def\partname{Osa}%
   \def\pagename{Sivu}%
   \def\seename{katso}%
   \def\alsoname{katso myös}%
   \def\enclname{Liitteet}%
   \def\ccname{Jakelu}%
   \def\headtoname{Vastaanottaja}%
   \def\proofname{Todistus}%
   \def\glossaryname{Sanasto}%
}

\def\finnish@language{%
  \iffinnish@schoolhyphens
      \xpg@ifdefined{schoolfinnish}{%
         \polyglossia@setup@language@patterns{schoolfinnish}%
      }{%
           \xpg@warning{Finnish 'School' hyphenation patterns (schoolfinnish) not available.\MessageBreak
	                I will use the standard patterns for Finnish instead}%
	   \polyglossia@setup@language@patterns{finnish}%
     }%
  \else
      \polyglossia@setup@language@patterns{finnish}%
  \fi
}

\def\datefinnish{%
   \def\today{\number\day.~\ifcase\month\or
    tammikuuta\or helmikuuta\or maaliskuuta\or huhtikuuta\or
    toukokuuta\or kesäkuuta\or heinäkuuta\or elokuuta\or
    syyskuuta\or lokakuuta\or marraskuuta\or joulukuuta\fi
    \space\number\year}}

\def\noextras@finnish{%
  \iffinnish@babelshorthands\nofinnish@shorthands\fi%
}

\def\blockextras@finnish{%
  \iffinnish@babelshorthands\finnish@shorthands\else\nofinnish@shorthands\fi%
}

\def\inlineextras@finnish{%
  \iffinnish@babelshorthands\finnish@shorthands\else\nofinnish@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-finnish.ldf>
%<*gloss-fr-CA-u-sd-canb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fr-CA-u-sd-canb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fr-CA-u-sd-canb.ldf}[polyglossia: module for fr-CA-u-sd-canb (Canadian French, Acadian subvariety)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{french}

%    \end{macrocode}
% \iffalse
%</gloss-fr-CA-u-sd-canb.ldf>
%<*gloss-fr-CA.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fr-CA.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fr-CA.ldf}[polyglossia: module for fr-CA (Canadian French)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{french}

%    \end{macrocode}
% \iffalse
%</gloss-fr-CA.ldf>
%<*gloss-fr-CH.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fr-CH.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fr-CH.ldf}[polyglossia: module for fr-CH (Swiss French)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{french}

%    \end{macrocode}
% \iffalse
%</gloss-fr-CH.ldf>
%<*gloss-fr-FR.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fr-FR.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fr-FR.ldf}[polyglossia: module for fr-FR (France's French)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{french}

%    \end{macrocode}
% \iffalse
%</gloss-fr-FR.ldf>
%<*gloss-fr.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fr.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fr.ldf}[polyglossia: module for fr (French)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{french}

%    \end{macrocode}
% \iffalse
%</gloss-fr.ldf>
%<*gloss-french.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-french.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-french.ldf}[polyglossia: module for French]

\PolyglossiaSetup{french}{%
  bcp47=fr-FR,
  bcp47-language=fr,
  bcp47-region=FR,
  bcp47-script=Latn,
  language=French,
  script=Latin,
  langtag=FRA,
  hyphennames={french,francais},
  frenchspacing=true,
  indentfirst=true,
  hyphenmins={2,2},
  fontsetup=true}

% BCP-47 compliant aliases
\setlanguagealias*{french}{fr}
\setlanguagealias*[variant=french]{french}{fr-FR}
\setlanguagealias*[variant=acadian]{french}{fr-CA-u-sd-canb}
\setlanguagealias*[variant=canadian]{french}{fr-CA}
\setlanguagealias*[variant=swiss]{french}{fr-CH}

% Babel aliases
\setlanguagealias[variant=acadian]{french}{acadian}
\setlanguagealias[variant=canadian]{french}{canadien}

\def\french@variant{french}
\define@choicekey*+{french}{variant}[\xpg@val\xpg@nr]{french,canadian,acadian,swiss}[french]{%
   \ifcase\xpg@nr\relax
      % french:
      \def\french@variant{french}%
      \SetLanguageKeys{french}{babelname=french,bcp47=fr-FR,bcp47-language=fr,bcp47-region=FR}%
      \french@thincolonspacefalse
   \or
      % canadian:
      \def\french@variant{canadien}%
      \SetLanguageKeys{french}{babelname=canadien,bcp47=fr-CA,bcp47-language=fr,bcp47-region=CA,bcp47-extension-u=sd-caqc}%
      \xpg@ifdefined{canadien}{}%
      {\xpg@warning{No hyphenation patterns were loaded for "French (Canada)"\MessageBreak
        I will use the standard patterns for French instead}%
      \adddialect\l@canadien\l@french\relax}%
      \french@thincolonspacefalse
   \or
      % acadian:
      \def\french@variant{acadian}%
      \SetLanguageKeys{french}{babelname=acadian,bcp47=fr-CA-u-sd-canb,bcp47-language=fr,bcp47-region=CA,bcp47-extension-u=sd-canb}%
      \xpg@ifdefined{acadian}{}%
      {\xpg@warning{No hyphenation patterns were loaded for "French (Canada, Acadian)"\MessageBreak
        I will use the standard patterns for French instead}%
      \adddialect\l@acadian\l@french\relax}%
      \french@thincolonspacefalse
   \or
      % swiss:
      \def\french@variant{swissfrench}%
      \SetLanguageKeys{french}{babelname=french,bcp47=fr-CH,bcp47-language=fr,bcp47-region=CH}%
      \adddialect\l@swissfrench\l@french\relax%
      \french@thincolonspacetrue
   \fi
   \xpg@info{Option: French, variant=\xpg@val}%
}{\xpg@warning{Unknown French variant `#1'}}


\def\french@language{%
   \polyglossia@setup@language@patterns{\french@variant}%
}%

\ifluatex
  \directlua{require('polyglossia-french')}%
\else
  \newXeTeXintercharclass\french@openbrackets % ( [ {
  \newXeTeXintercharclass\french@closebrackets % ) ] }
  \newXeTeXintercharclass\french@questionexclamation % ! ? et autres
  \newXeTeXintercharclass\french@punctthin % ; (et :)
  \newXeTeXintercharclass\french@punctthick % :
  \newXeTeXintercharclass\french@punctguillstart % « ‹
  \newXeTeXintercharclass\french@punctguillend % » ›
\fi

\def\xpg@unskip{\ifhmode\ifdim\lastskip>\z@\unskip\fi\fi}

% Save original footnote definition
% Do this at the end of the preamble to catch other
% packages' footnote changes (#391)
\AtEndPreamble{%
  \let\xpg@orig@makefntext\@makefntext
}

\define@boolkey{french}[french@]{frenchfootnote}[true]{}

\define@boolkey{french}[french@]{autospacing}[true]{}
\french@autospacingtrue

\define@boolkey{french}[french@]{frenchpart}[true]{}
\french@frenchparttrue

\newif\iffrench@autospaceguillemets
\define@boolkey{french}[french@]{autospaceguillemets}[true]{}
\french@autospaceguillemetstrue

\newif\iffrench@thincolonspace
\define@boolkey{french}[french@]{thincolonspace}[true]{}
\french@thincolonspacefalse

% Backwards compatibility
\define@boolkey{french}[french@]{automaticspacesaroundguillemets}[true]{%
   \iffrench@automaticspacesaroundguillemets
       \setkeys{french}{autospaceguillemets=true}%
   \else
       \setkeys{french}{autospaceguillemets=false}%
   \fi
}

% name is for compatibility with babel
\let\french@ttfamilyORI\ttfamily
\DeclareRobustCommand\french@ttfamilyFB{\nofrench@punctuation\french@ttfamilyORI}

% Allow to switch on autospacing in ttfamily context
\define@boolkey{french}[french@]{autospacetypewriter}[true]{}
\french@autospacetypewriterfalse

% This is how babel-french has it
\define@boolkey{french}[french@]{OriginalTypewriter}[true]{%
   \iffrench@OriginalTypewriter
       \setkeys{french}{autospacetypewriter=false}%
   \else
       \setkeys{french}{autospacetypewriter=true}%
   \fi
}

% Configuration of item labels
\def\french@itemi{\textemdash}
\def\french@itemii{\textemdash}
\def\french@itemiii{\textemdash}
\def\french@itemiv{\textemdash}

\define@key{french}{itemlabels}[\textemdash]{%
  \def\french@itemi{#1}
  \def\french@itemii{#1}
  \def\french@itemiii{#1}
  \def\french@itemiv{#1}
}

\define@key{french}{itemlabeli}[\textemdash]{%
  \def\french@itemi{#1}
}

\define@key{french}{itemlabelii}[\textemdash]{%
  \def\french@itemii{#1}
}

\define@key{french}{itemlabeliii}[\textemdash]{%
  \def\french@itemiii{#1}
}

\define@key{french}{itemlabeliv}[\textemdash]{%
  \def\french@itemiv{#1}
}

\define@boolkey{french}[french@]{frenchitemlabels}[true]{}

% Register default options
\xpg@initialize@gloss@options{french}{variant=french,autospacing=true,thincolonspace=false,
                                      autospaceguillemets=true,autospacetypewriter=false,
                                      frenchfootnote=false,frenchitemlabels=false,
                                      itemlabels=\textemdash,itemlabeli=\textemdash,itemlabelii=\textemdash,
                                      itemlabeliii=\textemdash,itemlabeliv=\textemdash}
% Register alias options
\xpg@set@alias@values{french}{variant}{canadian}{acadian}


\def\french@fontsetup{%
  \unless\iffrench@autospacetypewriter
    \let\ttfamily\french@ttfamilyFB
  \fi
}


\def\nofrench@fontsetup{%
  \let\ttfamily\french@ttfamilyORI
}

\def\xpg@french@thinsp{\kern 0.5\fontdimen2\font\nobreak\hskip\z@skip}

\def\french@punctuation{%
    \lccode"2019="2019
    \ifluatex
      \iffrench@thincolonspace
        \iffrench@autospaceguillemets
          \directlua{polyglossia.activate_french_punct(true, true)}%
        \else
          \directlua{polyglossia.activate_french_punct(true, false)}%
        \fi
      \else
        \iffrench@autospaceguillemets
          \directlua{polyglossia.activate_french_punct(false, true)}%
        \else
          \directlua{polyglossia.activate_french_punct(false, false)}%
        \fi
      \fi
    \else
      \XeTeXinterchartokenstate=1
      \XeTeXcharclass `\! \french@questionexclamation
      \XeTeXcharclass `\? \french@questionexclamation
      \XeTeXcharclass `\‼ \french@questionexclamation
      \XeTeXcharclass `\⁇ \french@questionexclamation
      \XeTeXcharclass `\⁈ \french@questionexclamation
      \XeTeXcharclass `\⁉ \french@questionexclamation
      \XeTeXcharclass `\‽ \french@questionexclamation % U+203D (interrobang)
      \XeTeXcharclass `\; \french@punctthin
      \iffrench@thincolonspace
        \XeTeXcharclass `\: \french@punctthin
      \else
        \XeTeXcharclass `\: \french@punctthick
      \fi
      \XeTeXcharclass `\« \french@punctguillstart
      \XeTeXcharclass `\» \french@punctguillend
      \XeTeXcharclass `\‹ \french@punctguillstart
      \XeTeXcharclass `\› \french@punctguillend
      \XeTeXcharclass `\( \french@openbrackets
      \XeTeXcharclass `\) \french@closebrackets
      \XeTeXcharclass `\[ \french@openbrackets
      \XeTeXcharclass `\] \french@closebrackets
      \XeTeXcharclass `\{ \french@openbrackets
      \XeTeXcharclass `\} \french@closebrackets
      \XeTeXcharclass `\⟨ \french@openbrackets
      \XeTeXcharclass `\⟩ \french@closebrackets
      \XeTeXinterchartoks \z@ \french@questionexclamation = {\xpg@french@thinsp}%
      \XeTeXinterchartoks \z@ \french@punctthin = {\xpg@french@thinsp}%
      \XeTeXinterchartoks \z@ \french@punctthick = {\nobreakspace}%
      \XeTeXinterchartoks \xpg@boundaryclass \french@questionexclamation = {\xpg@unskip\xpg@french@thinsp}%
      \XeTeXinterchartoks \xpg@boundaryclass \french@punctthin = {\xpg@unskip\xpg@french@thinsp}%
      \XeTeXinterchartoks \xpg@boundaryclass \french@punctthick = {\xpg@unskip\nobreakspace}%
      \iffrench@autospaceguillemets
        \let\xpg@french@guillspace\xpg@french@thinsp%
        \XeTeXinterchartoks \french@punctguillstart \z@ = {\xpg@french@guillspace}% "«a" -> "«\,a"
        \XeTeXinterchartoks \french@punctguillstart \french@punctguillstart = {\xpg@french@guillspace}% "«‹" -> "«\,‹"
 %      \XeTeXinterchartoks \z@ \french@punctguillstart = {\nobreakspace}% "a«" unchanged?
 %      \XeTeXinterchartoks \french@punctguillend \z@ = {\nobreakspace}% "»a" unchanged?
        \XeTeXinterchartoks \z@ \french@punctguillend = {\xpg@french@guillspace}% "a»" -> "a\,»"
        \XeTeXinterchartoks \french@punctguillstart \xpg@boundaryclass = {\xpg@french@guillspace\ignorespaces}% "«  " -> "«\,"
        \XeTeXinterchartoks \xpg@boundaryclass \french@punctguillend = {\xpg@unskip\xpg@french@guillspace}% "  »" -> "\,»"
        \XeTeXinterchartoks \french@closebrackets \french@punctguillend = {\xpg@french@guillspace}% ")»" -> ")\,»"
        \XeTeXinterchartoks \french@questionexclamation \french@punctguillend  = {\xpg@french@guillspace}% "?»" -> "?\,»"
        \XeTeXinterchartoks \french@punctthin \french@punctguillend  = {\xpg@french@guillspace}% ";»" -> ";\,»"
        \XeTeXinterchartoks \french@punctguillend \french@punctguillend  = {\xpg@french@guillspace}% "›»" -> "›\,»"
     \else
       \def\xpg@french@guillspace{}%
     \fi
     \XeTeXinterchartoks \french@punctguillend \french@questionexclamation = {\xpg@french@thinsp}% "»?" -> "»\,?"
     \XeTeXinterchartoks \french@punctguillend \french@punctthin = {\xpg@french@thinsp}% "»;" -> "»\,;"
     \XeTeXinterchartoks \french@punctguillend \french@punctthick = {\nobreakspace}% "»:" -> "» :"
     \XeTeXinterchartoks \french@questionexclamation \french@punctthin = {\xpg@french@thinsp}% "?;" -> "?\,;"
     \XeTeXinterchartoks \french@questionexclamation \french@punctthick = {\xpg@french@thinsp}% "?:" -> "?\,:"
     \XeTeXinterchartoks \french@openbrackets \french@questionexclamation = {\xpg@unskip}% "(?" -> "(?" and not "( ?"
     \XeTeXinterchartoks \french@openbrackets \french@punctthin = {\xpg@unskip}% "(;" -> "(;" and not "( ;"
     \XeTeXinterchartoks \french@punctthin \french@closebrackets = {\xpg@unskip}% "?)" -> "?)" (code not need, just for symetry with previous one)
     \XeTeXinterchartoks \french@closebrackets \french@punctthin = {\xpg@french@thinsp}% ")?" -> ")\,?"
     \XeTeXinterchartoks \french@closebrackets \french@punctthick = {\nobreakspace}% "):" -> ") :"
    \fi
}

\def\nofrench@punctuation{%
    \lccode"2019=\z@
    \ifluatex
      \directlua{polyglossia.deactivate_french_punct()}%
    \else
      \XeTeXcharclass `\! \z@
      \XeTeXcharclass `\? \z@
      \XeTeXcharclass `\‼ \z@
      \XeTeXcharclass `\⁇ \z@
      \XeTeXcharclass `\⁈ \z@
      \XeTeXcharclass `\⁉ \z@
      \XeTeXcharclass `\‽ \z@
      \XeTeXcharclass `\; \z@
      \XeTeXcharclass `\: \z@
      \XeTeXcharclass `\« \z@
      \XeTeXcharclass `\» \z@
      \XeTeXcharclass `\‹ \z@
      \XeTeXcharclass `\› \z@
      \XeTeXcharclass `\( \z@
      \XeTeXcharclass `\) \z@
      \XeTeXcharclass `\[ \z@
      \XeTeXcharclass `\] \z@
      \XeTeXcharclass `\{ \z@
      \XeTeXcharclass `\} \z@
      \XeTeXcharclass `\⟨ \z@
      \XeTeXcharclass `\⟩ \z@
      \XeTeXinterchartokenstate=0
    \fi
}

\def\captionsfrench{%
   \def\refname{Références}%
   \def\abstractname{Résumé}%
   \def\bibname{Bibliographie}%
   \def\prefacename{Préface}%
   \def\chaptername{Chapitre}%
   \def\appendixname{Annexe}%
   \def\contentsname{Table des matières}%
   \def\listfigurename{Table des figures}%
   \def\listtablename{Liste des tableaux}%
   \def\indexname{Index}%
   \def\figurename{\textsc{Fig.}}%
   \def\tablename{\textsc{Tab.}}%
   \iffrench@frenchpart
     \def\partname{partie}%
   \else
     \def\partname{Partie}%
   \fi%
   \def\pagename{page}%
   \def\seename{voir}%
   \def\alsoname{voir aussi}%
   \def\enclname{P.~J. }%
   \def\ccname{Copie à }%
   \def\headtoname{}%
   \def\proofname{Démonstration}%
}

\def\datefrench{%
   \def\today{\ifx\ier\undefined\def\ier{er}\fi
      \ifnum\day=1\relax 1\ier%
      \else \number\day\fi
      \space \ifcase\month%
      \or janvier\or février\or mars\or avril\or mai\or juin\or
      juillet\or août\or septembre\or octobre\or novembre\or
      décembre\fi
      \space \number\year}}

\def\xpg@french@part{\ifcase\value{part}\or Première\or Deuxième\or%
   Troisième\or Quatrième\or Cinquième\or Sixième\or%
   Septième\or Huitième\or Neuvième\or Dixième\or Onzième\or%
   Douzième\or Treizième\or Quatorzième\or Quinzième\or%
   Seizième\or Dix-septième\or Dix-huitième\or Dix-neuvième\or%
   Vingtième\fi}%

\def\french@capsformat{%
   % Change part heading
   % With titlesec
   \ifcsdef{titleformat}{%
     \ifcsdef{NR@part}{% Hyperref (nameref)
        \let\xpg@save@part@format\NR@part%
        \patchcmd{\NR@part}%
                  {\partname\nobreakspace\thepart}%
                  {\xpg@french@part\nobreakspace\partname}%
                  {}%
                  {\xpg@warning{Failed to patch part for French}}%
     }{% not hyperref
       \ifcsdef{@part}{%
          \let\xpg@save@part@format\@part%
          \patchcmd{\@part}%
                    {\partname\nobreakspace\thepart}%
                    {\xpg@french@part\nobreakspace\partname}%
                    {}%
                    {\xpg@warning{Failed to patch part for French}}%
       }{}%
     }%
   }{% (not \ifdefined\titleformat)
     % With KOMA
     \ifcsdef{sectionformat}{%
        \ifcsdef{partformat}{%
          \let\xpg@save@part@format\partformat%
          \renewcommand{\partformat}{\xpg@french@part~\partname}%
        }{}%
     }{%  (not \ifdefined\sectionformat)
       % With memoir
       \ifcsdef{@memptsize}{%
         \ifcsdef{NR@part}{% Hyperref (nameref)
           \let\xpg@save@part@format\NR@part%
           \patchcmd{\NR@part}{\printpartname \partnamenum \printpartnum}%
                            {\partnamefont\xpg@french@part\partnamenum\printpartname}%
                            {}%
                            {\xpg@warning{Failed to patch part for French}}%
          }{% not hyperref
            \ifcsdef{@part}{%
              \let\xpg@save@part@format\@part%
              \patchcmd{\@part}{\printpartname \partnamenum \printpartnum}%
                               {\partnamefont\xpg@french@part\partnamenum\printpartname}%
                               {}%
                               {\xpg@warning{Failed to patch part for French}}%
             }{}%
          }%
       }{%  (not \ifdefined\@memptsize)
         % With standard classes
         \ifcsdef{NR@part}{% Hyperref
           \let\xpg@save@part@format\NR@part%
           \patchcmd{\NR@part}%
                    {\partname\nobreakspace\thepart}%
                    {\xpg@french@part\nobreakspace\partname}%
                    {}%
                    {\xpg@warning{Failed to patch part for French}}%
         }{% not hyperref
            \ifcsdef{@part}{%
              \let\xpg@save@part@format\@part%
              \patchcmd{\@part}%
                       {\partname\nobreakspace\thepart}%
                       {\xpg@french@part\nobreakspace\partname}%
                       {}%
                       {\ifcsdef{part}{\xpg@warning{Failed to patch part for French}}{}}%
            }{}%  (end \ifdefined \NR@part)
         }%  (end \ifdefined\@part)
       }% (end \ifdefined\@memptsize)
     }% (end \ifdefined\sectionformat)
   }% (end \ifdefined\titleformat)
}

\def\nofrench@capsformat{%
   % Reset chapter and part heading
   \ifcsdef{titleformat}{%
      % With titlesec
     \ifcsdef{xpg@save@part@format}{%
        \ifcsdef{NR@part}{%
            \let\NR@part\xpg@save@part@format%
        }{%
            \let\@part\xpg@save@part@format%
        }%
     }{}%
   }{% (not \ifdefined\titleformat)
     \ifcsdef{sectionformat}{%
        % With KOMA
        \ifcsdef{xpg@save@part@format}{%
           \let\partformat\xpg@save@part@format
        }{}%
     }{%
        % With memoir and standard classes
        \ifcsdef{xpg@save@part@format}{%
           \ifcsdef{NR@part}{%
              \let\NR@part\xpg@save@part@format%
           }{%
              \let\@part\xpg@save@part@format%
           }%
        }{}%
     }% (end \ifdefined\sectionformat)
   }% (end \ifdefined\titleformat)
}

\newif\if@xpg@french@footnote@set
\@xpg@french@footnote@setfalse
\def\set@french@footnote{%
  % Set French footnote once if requested
  \if@xpg@french@footnote@set%
  \else%
   \iffrench@frenchfootnote%
      \ifdefstring{\xpg@main@language}{french}{%
         \ifx\@makefntext\undefined\else%
             \long\def\french@makefntext##1{%
                \parindent1em \noindent\quad%
                \ifx\@thefnmark\empty\else%
                \@thefnmark.\space\fi ##1%
             }%
             \let\@makefntext\french@makefntext%
         \fi%
      }{\xpg@warning{Option 'frenchfootnote' only supported if French is main language!}}%
    \else%
       \let\@makefntext\xpg@orig@makefntext%
    \fi%
    \@xpg@french@footnote@settrue%
  \fi%
}

\newif\if@xpg@french@itemlabels@set
\@xpg@french@itemlabels@setfalse
\def\set@french@itemlabels{%
  % Set French itemlabels once if requested
  \if@xpg@french@itemlabels@set%
  \else%
     \iffrench@frenchitemlabels
      \ifdefstring{\xpg@main@language}{french}{%
         \renewcommand{\labelitemi}{\french@itemi}%
         \renewcommand{\labelitemii}{\french@itemii}%
         \renewcommand{\labelitemiii}{\french@itemiii}%
         \renewcommand{\labelitemiv}{\french@itemiv}%
      }{\xpg@warning{Option 'frenchitemlabels' only supported if French is main language!}}%
    \else
       \let\@makefntext\xpg@orig@makefntext
    \fi
    \@xpg@french@itemlabels@settrue%
  \fi%
}

\def\noextras@french{%
   \nofrench@punctuation%
   \nofrench@fontsetup%
   \nofrench@capsformat%
}

\def\blockextras@french{%
   % Set French itemlabels and footnote,
   % if so requested, once in the document body
   \ifx\@onlypreamble\@notprerr%
     \set@french@footnote%
     \set@french@itemlabels%
   \fi%
   \iffrench@autospacing%
      \french@punctuation%
   \fi%
   \french@fontsetup%
   \iffrench@frenchpart%
     \french@capsformat%
   \fi%
}

\def\inlineextras@french{%
   \iffrench@autospacing
      \french@punctuation%
   \fi
   \french@fontsetup%
}

\def\NoAutoSpacing{%
  \nofrench@punctuation%
}

\def\AutoSpacing{%
  \french@punctuation%
}

\def\ier{\textsuperscript{er}}
\def\iers{\textsuperscript{ers}}
\def\iere{\textsuperscript{re}}
\def\ieres{\textsuperscript{res}}
\def\ieme{\textsuperscript{e}}
\def\iemes{\textsuperscript{es}}
\def\nd{\textsuperscript{nd}}
\def\nds{\textsuperscript{nds}}
\def\nde{\textsuperscript{nde}}
\def\ndes{\textsuperscript{ndes}}
\def\no{\textsuperscript{o}}
\def\nos{\textsuperscript{os}}

\def\mme{M\textsuperscript{me}\space}
\def\mmes{M\textsuperscript{mes}\space}
\def\mr{M.\space}
\def\mrs{MM.\space}

%    \end{macrocode}
% \iffalse
%</gloss-french.ldf>
%<*gloss-friulan.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-friulan.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-friulan.ldf}[polyglossia: module for Friulian]

% We only provide this gloss for babel compatibility.

\xpg@load@master@language{friulian}

%    \end{macrocode}
% \iffalse
%</gloss-friulan.ldf>
%<*gloss-friulian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-friulian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-friulian.ldf}[polyglossia: module for Friulian]

\PolyglossiaSetup{friulian}{%
  bcp47=fur,
  bcp47-language=fur,
  bcp47-script=Latn,
  language=Friulian,
  babelname=friulan,
  hyphennames={friulan,furlan},
  hyphenmins={2,2},
  langtag=FRL,
  indentfirst=false,
  fontsetup=true,
  frenchspacing=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{friulian}{fur}

% Babel and backwards compat. alias
\setlanguagealias{friulian}{friulan}

\def\captionsfriulian{%
    \def\prefacename{Prefazion}%
    \def\refname{Riferiments}%
    \def\abstractname{Somari}%
    \def\bibname{Bibliografie}%
    \def\chaptername{Cjapitul}%
    \def\appendixname{Zonte}%
    \def\contentsname{Tabele gjenerâl}%
    \def\listfigurename{Liste des figuris}%
    \def\listtablename{Liste des tabelis}%
    \def\indexname{Tabele analitiche}%
    \def\figurename{Figure}%
    \def\tablename{Tabele}%
    \def\partname{Part}%
    \def\enclname{Zonte(is)}%
    \def\ccname{Cun copie a}%
    \def\headtoname{Par}%
    \def\pagename{Pagjine}%
    \def\seename{cjale}%
    \def\alsoname{cjale ancje}%
    \def\proofname{Dimostrazion}%
    \def\glossaryname{Glossari}%
  }
  
\def\datefriulian{%
  \def\today{\number\day\space di\space\ifcase\month\or
      Genâr\or Fevrâr\or Març\or Avril\or Mai\or Jugn\or
      Lui\or Avost\or Setembar\or Otobar\or Novembar\or Dicembar%
      \fi\space dal\space\number\year}}

\AtEndPreamble{% the user or the class might define different values
  \edef\xpgfu@savedvalues{%
    \clubpenalty=\the\clubpenalty\space
    \@clubpenalty=\the\@clubpenalty\space
    \widowpenalty=\the\widowpenalty\space
    \finalhyphendemerits=\the\finalhyphendemerits}
}


\def\noextras@friulian{%
   \lccode\string"2019=\z@
}

\def\blockextras@friulian{%
   \lccode\string"2019=\string"2019
   \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000
   \finalhyphendemerits=50000000
}

\def\inlineextras@friulian{%
   \lccode\string"2019=\string"2019
}

%    \end{macrocode}
% \iffalse
%</gloss-friulian.ldf>
%<*gloss-fur.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fur.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-fur.ldf}[polyglossia: module for fur (Friulian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{friulian}

%    \end{macrocode}
% \iffalse
%</gloss-fur.ldf>
%<*gloss-ga.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ga.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ga.ldf}[polyglossia: module for ga (Gaelic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{gaelic}

%    \end{macrocode}
% \iffalse
%</gloss-ga.ldf>
%<*gloss-gaelic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-gaelic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-gaelic.ldf}[polyglossia: module for Gaelic]

\PolyglossiaSetup{gaelic}{
  bcp47=ga,
  bcp47-language=ga,
  bcp47-script=Latn,
  language=Irish,
  babelname=irish,
  hyphennames={irish},
  hyphenmins={2,2},
  langtag=IRI,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*[variant=irish]{gaelic}{ga}
\setlanguagealias*[variant=scottish]{gaelic}{gd} 
% Babel aliases
\setlanguagealias[variant=irish]{gaelic}{irish}
\setlanguagealias[variant=scottish]{gaelic}{scottish}

\def\gaelic@variant{irish}
\define@choicekey*+{gaelic}{variant}[\xpg@val\xpg@nr]{irish,scottish}[irish]{%
   \ifcase\xpg@nr\relax
      % irish:
      \gdef\gaelic@variant{irish}%
      \SetLanguageKeys{gaelic}{language=Irish,langtag=IRI,babelname=irish,bcp47=ga,bcp47-language=ga}%
      \xpg@fontsetup@latin{gaelic}%
   \or
      % scottish:
      \gdef\gaelic@variant{scottish}%
      \SetLanguageKeys{gaelic}{language=Gaelic,langtag=GAE,babelname=scottish,bcp47=gd,bcp47-language=gd}%
      \xpg@fontsetup@latin{gaelic}%
   \fi
   \xpg@info{Option: gaelic, variant=\xpg@val}%
}{\xpg@warning{Unknown gaelic variant `#1'}}

% Register default options
\xpg@initialize@gloss@options{gaelic}{variant=irish}

\def\captionsgaelic@irish{%
   \def\refname{Tagairtí}%
   \def\abstractname{Achoimre}%
   \def\bibname{Leabharliosta}%
   \def\prefacename{Réamhrá}%    <-- also "Brollach"
   \def\refname{Tagairtí}%
   \def\chaptername{Tagairtí}%
   \def\appendixname{Aguisín}%
   \def\contentsname{Clár Ábhair}%
   \def\listfigurename{Léaráidí}%
   \def\listtablename{Táblaí}%
   \def\indexname{Innéacs}%
   \def\figurename{Léaráid}%
   \def\tablename{Tábla}%
   %\def\thepart{}%
   \def\partname{Cuid}%
   \def\pagename{Leathanach}%
   \def\seename{féach}%
   \def\alsoname{féach freisin}%
   \def\enclname{faoi iamh}%
   \def\ccname{cc}%
   \def\headtoname{Go}%
   \def\proofname{Cruthúnas}%
   \def\glossaryname{Glossary}%
}

\def\captionsgaelic@scottish{%
   \def\refname{Iomraidh}%
   \def\abstractname{Brìgh}%
   \def\bibname{Leabhraichean}%
   \def\prefacename{Preface}%    <-- needs translation
   \def\chaptername{Caibideil}%
   \def\appendixname{Ath-sgr`ıobhadh}%
   \def\contentsname{Clàr-obrach}%
   \def\listfigurename{Liosta Dhealbh}%
   \def\listtablename{Liosta Chlàr}%
   \def\indexname{Clàr-innse}%
   \def\figurename{Dealbh}%
   \def\tablename{Clàr}%
   %\def\thepart{}%
   \def\partname{Cuid}%
   \def\pagename{t.d.}%
   \def\seename{see}%    <-- needs translation
   \def\alsoname{see also}%    <-- needs translation
   \def\enclname{a-staigh}%
   \def\ccname{lethbhreac gu}%
   \def\headtoname{gu}%
   \def\proofname{Proof}%    <-- needs translation 
   \def\glossaryname{Glossary}%    <-- needs translation
}

\def\captionsgaelic{%
  \csname captionsgaelic@\gaelic@variant\endcsname%
}

\def\dategaelic@irish{%
   \def\today{%
    \number\day\space \ifcase\month\or
    Eanáir\or Feabhra\or Márta\or Aibreán\or
    Bealtaine\or Meitheamh\or Iúil\or Lúnasa\or
    Meán Fómhair\or Deireadh Fómhair\or
    Mí na Samhna\or Mí na Nollag\fi
    \space \number\year}%
}

\def\dategaelic@scottish{%
   \def\today{%
    \number\day\space \ifcase\month\or
    am Faoilteach\or an Gearran\or am Màrt\or an Giblean\or
    an Cèitean\or an t-Òg mhios\or an t-Iuchar\or
    Lùnasdal\or an Sultuine\or an Dàmhar\or
    an t-Samhainn\or an Dubhlachd\fi
    \space \number\year}%
}

\def\dategaelic{%
  \csname dategaelic@\gaelic@variant\endcsname%
}

%    \end{macrocode}
% \iffalse
%</gloss-gaelic.ldf>
%<*gloss-galician.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-galician.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-galician.ldf}[polyglossia: module for Galician]
\PolyglossiaSetup{galician}{
  bcp47=gl,
  bcp47-language=gl,
  bcp47-region=ES,
  bcp47-script=Latn,
  hyphennames={galician},
  hyphenmins={2,2},
  langtag=GAL,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{galician}{gl}

\def\captionsgalician{%
   \def\refname{Referencias}%
   \def\abstractname{Resumo}%
   \def\bibname{Bibliografía}%
   \def\prefacename{Prefacio}%
   \def\chaptername{Capítulo}%
   \def\appendixname{Apéndice}%
   \def\contentsname{Índice Xeral}%
   \def\listfigurename{Índice de Figuras}%
   \def\listtablename{Índice de Táboas}%
   \def\indexname{Índice de Materias}%
   \def\figurename{Figura}%
   \def\tablename{Táboa}%
   %\def\thepart{}%
   \def\partname{Parte}%
   \def\pagename{Páxina}%
   \def\seename{véxase}%
   \def\alsoname{véxase tamén}%
   \def\enclname{Adxunto}%
   \def\ccname{Copia a}%
   \def\headtoname{A}%
   \def\proofname{Demostración}%
   \def\glossaryname{Glosario}%
   }
\def\dategalician{%
   \def\today{\number\day~de\space\ifcase\month\or
    xaneiro\or febreiro\or marzo\or abril\or maio\or xuño\or
    xullo\or agosto\or setembro\or outubro\or novembro\or decembro\fi
    \space de~\number\year}}

%    \end{macrocode}
% \iffalse
%</gloss-galician.ldf>
%<*gloss-gd.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-gd.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-gd.ldf}[polyglossia: module for gd (Gaelic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{gaelic}

%    \end{macrocode}
% \iffalse
%</gloss-gd.ldf>
%<*gloss-georgian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-georgian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-georgian.ldf}[polyglossia: module for Georgian]

\PolyglossiaSetup{georgian}{
  bcp47=ka,
  bcp47-language=ka,
  bcp47-script=Geor,
  script=Georgian,
  scripttag=geor,
  langtag=KAT,
  hyphennames={georgian},
  fontsetup=true,
  localnumeral=georgiannumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{georgian}{ka}

\newif\ifgeorgian@numerals
\define@key{georgian}{numerals}[arabic]{%
   \ifstrequal{#1}{georgian}%
      {\georgian@numeralstrue%
       \SetLanguageKeys{georgian}{bcp47-extension-u=nu-geor}%
      }%
      {\georgian@numeralsfalse%
       \SetLanguageKeys{georgian}{bcp47-extension-u=nu-latn}%
      }%
}

\define@boolkey{georgian}[georgian@]{babelshorthands}[true]{}

\define@boolkey{georgian}[georgian@]{oldmonthnames}[true]{}

% Register default options
\xpg@initialize@gloss@options{georgian}{babelshorthands=false,oldmonthnames=false,numerals=arabic}

\ifsystem@babelshorthands
  \setkeys{georgian}{babelshorthands=true}
\else
  \setkeys{georgian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\georgian@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{georgian}%
  \declare@shorthand{georgian}{"`}{„}%
  \declare@shorthand{georgian}{"'}{“}%
  \declare@shorthand{georgian}{"<}{«}%
  \declare@shorthand{georgian}{">}{»}%
  \declare@shorthand{georgian}{""}{\hskip\z@skip}%
  \declare@shorthand{georgian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{georgian}{"=}{\nobreak-\hskip\z@skip}%
  \declare@shorthand{georgian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
  \declare@shorthand{georgian}{"-}{%
    \def\georgian@sh@tmp{%
      \if\georgian@sh@next-\expandafter\georgian@sh@emdash%
      \else\expandafter\georgian@sh@hyphen\fi%
    }%
    \futurelet\georgian@sh@next\georgian@sh@tmp}%
  \def\georgian@sh@hyphen{%
    \nobreak\-\bbl@allowhyphens}%
  \def\georgian@sh@emdash##1##2{\cdash-##1##2}%
  \def\cdash##1##2##3{\def\tempx@{##3}%
  \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
   \ifx\tempx@\tempa@\@Acdash\else
    \ifx\tempx@\tempb@\@Bcdash\else
     \ifx\tempx@\tempc@\@Ccdash\else
      \errmessage{Wrong usage of cdash}\fi\fi\fi}%
  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
    \cyrdash\hskip.2em\ignorespaces}%
  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
   \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
  \def\@Ccdash{\leavevmode
   \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
  \ifx\cyrdash\undefined
    \def\cyrdash{\hbox to.8em{\textendash\hss\textendash}}%
  \fi
  \declare@shorthand{georgian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

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

\def\captionsgeorgian{%
    \def\prefacename{წინასიტყვაობა}%
    \def\refname{ლიტერატურა}%
    \def\abstractname{ანოტაცია}%
    \def\bibname{ლიტერატურა}%
    \def\chaptername{თავი}%
    \def\appendixname{დანართი}%
    \@ifundefined{thechapter}
      {\def\contentsname{შინაარსი}}%
      {\def\contentsname{შინაარსი}}%
    \let\tocname=\contentsname
    \def\listfigurename{სურათი}%
    \def\listtablename{ცხრილი}%
    \def\indexname{საძიებელი}%
    \def\authorname{სახელთა საძიებელი}%
    \def\figurename{სურ.}%
    \def\tablename{ცხრ.}%
    \def\partname{ნაწილი}%
    \def\enclname{ჩათვ.}%
    \def\ccname{წყარ.}%
    \def\headtoname{შ.}%
    \def\pagename{გვ.}%
    \def\seename{იხ.}%
    \def\alsoname{იხ.\ ასევე}%
    \def\proofname{დამტკიცება}%
    \def\glossaryname{ტერმინები}%
}%

\def\dategeorgian{%
   \def\today{\number\day~\ifcase\month\or
    იანვარი\or
    თებერვალი\or
    მარტი\or
    აპრილი\or
    მაისი\or
    ივნისი\or
    ივლისი\or
    აგვისტო\or
    სექტემბერი\or
    ოქტომბერი\or
    ნოემბერი\or
    დეკემბერი\fi
    \space \number\year~წ.}%
    \ifgeorgian@oldmonthnames
       \dategeorgian@old%
    \fi
}

\def\dategeorgian@old{%
   \def\today{\number\day~\ifcase\month\or
    აპნისი\or
    სურწყუნისი\or
    მირკანი\or
    იგრიკა\or
    ვარდობისთვე\or
    თიბათვე\or
    მკათათვე\or
    მარიამობისთვე\or
    ახალწლისა ენკენისთვე\or
    ღვინობისთვე\or
    გიორგობისთვე\or
    ქრისტეშობისთვე\fi
    \space \number\year~წ.}%
}

\def\georgian@numbers{%
   \ifgeorgian@numerals%
     \def\georgian@alph##1{\expandafter\georgiannumeral\expandafter{\the##1}}%
     \let\@alph\georgian@@alph%
   \fi
}

\def\nogeorgian@numbers{%
   \let\@alph\latin@alph%
   \let\georgian@alph\@undefined%
}

\def\georgian@globalnumbers{%
  \ifgeorgian@numerals
    \let\@arabic\georgiannumber%
    \renewcommand\thefootnote{\localnumeral*{footnote}}%
    \renewcommand\theequation{\localnumeral*{equation}}%
  \fi
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\nogeorgian@globalnumbers{
   \let\@arabic\xpg@save@arabic%
}

\newcommand{\georgiannumerals}[2]{%
  \ifgeorgian@numerals
     \georgiannumber{#2}%
  \else
     #2%
  \fi%
}

\protected\def\georgiannumber#1{\expandafter\@georgiannumber\expandafter{\number#1}}
\def\@georgiannumber#1{%
  \ifnum#1<\@ne\space\geor@ill@value{#1}%
  \else
    \ifnum#1<10\expandafter\geor@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\geor@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\geor@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\geor@num@iv\number#1%
          \else
             \space\geor@ill@value{#1}%
          \fi
        \fi
      \fi
    \fi
  \fi
}

\let\georgiannumeral=\georgiannumber
\def\geor@num@i#1{% 1--9
  \ifcase#1\or ა\or ბ\or გ\or დ\or ე\or ვ\or ზ\or ჱ\or თ\fi}
\def\geor@num@ii#1{% 10--90
  \ifcase#1\or ი\or კ\or ლ\or მ\or ნ\or ჲ\or ო\or პ\or ჟ\fi
  \geor@num@i}
\def\geor@num@iii#1{% 100--900
  \ifcase#1\or რ\or ს\or ტ\or ჳ\or ფ\or ქ\or ღ\or ყ\or შ\fi
  \geor@num@ii}
\def\geor@num@iv#1{% 1000--9000
  \ifcase#1\or ჩ\or ც\or ძ\or წ\or ჭ\or ხ\or ჴ\or ჯ\or ჰ\fi
  \geor@num@iii}
\def\geor@ill@value#1{\xpg@warning{Illegal value (#1) for Georgian numeral}[$#1$]}

\def\noextras@georgian{%
   \ifgeorgian@numerals\nogeorgian@numbers\fi%
   \ifgeorgian@babelshorthands\nogeorgian@shorthands\fi%
}

\def\blockextras@georgian{%
   \ifgeorgian@numerals\georgian@numbers\else\nogeorgian@numbers\fi%
   \ifgeorgian@babelshorthands\georgian@shorthands\else\nogeorgian@shorthands\fi%
}

\def\inlineextras@georgian{%
   \ifgeorgian@babelshorthands\georgian@shorthands\else\nogeorgian@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-georgian.ldf>
%<*gloss-german.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-german.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-german.ldf}[polyglossia: module for German]

\PolyglossiaSetup{german}{
  bcp47=de-DE,
  bcp47-language=de,
  bcp47-region=DE,
  bcp47-variant=1996,
  bcp47-script=Latn,
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
  langtag=DEU,
  babelname=ngerman
}

% BCP-47 compliant aliases
\setlanguagealias*{german}{de}
\setlanguagealias*[variant=swiss,spelling=new]{german}{de-CH}
\setlanguagealias*[variant=austrian,spelling=new]{german}{de-AT}
\setlanguagealias*[variant=german,spelling=new]{german}{de-DE}
\setlanguagealias*[variant=swiss,spelling=new,script=blackletter]{german}{de-Latf-CH}
\setlanguagealias*[variant=german,spelling=new,script=blackletter]{german}{de-Latf-DE}
\setlanguagealias*[variant=austrian,spelling=new,script=blackletter]{german}{de-Latf-AT}
\setlanguagealias*[variant=austrian,spelling=old]{german}{de-AT-1901}
\setlanguagealias*[variant=swiss,spelling=new]{german}{de-CH-1996}
\setlanguagealias*[variant=austrian,spelling=new]{german}{de-AT-1996}
\setlanguagealias*[variant=german,spelling=old]{german}{de-DE-1901}
\setlanguagealias*[variant=swiss,spelling=old,script=blackletter]{german}{de-Latf-CH-1901}
\setlanguagealias*[variant=swiss,spelling=old]{german}{de-CH-1901}
\setlanguagealias*[variant=austrian,spelling=old,script=blackletter]{german}{de-Latf-AT-1901}
\setlanguagealias*[variant=swiss,spelling=new,script=blackletter]{german}{de-Latf-CH-1996}
\setlanguagealias*[script=blackletter]{german}{de-Latf}
\setlanguagealias*[variant=german,spelling=new]{german}{de-DE-1996}
\setlanguagealias*[variant=german,spelling=old,script=blackletter]{german}{de-Latf-DE-1901}
\setlanguagealias*[variant=german,spelling=new,script=blackletter]{german}{de-Latf-DE-1996}
\setlanguagealias*[variant=austrian,spelling=new,script=blackletter]{german}{de-Latf-AT-1996}

% Babel aliases
\setlanguagealias[variant=austrian,spelling=old]{german}{austrian}
\setlanguagealias[variant=austrian,spelling=new]{german}{naustrian}
\setlanguagealias[variant=german,spelling=old]{german}{germanb}
\setlanguagealias[variant=german,spelling=new]{german}{ngerman}
\setlanguagealias[variant=swiss,spelling=old]{german}{swissgerman}
\setlanguagealias[variant=swiss,spelling=new]{german}{nswissgerman}

\newif\if@german@oldspelling
\@german@oldspellingfalse
\define@choicekey*+{german}{spelling}[\xpg@val\xpg@nr]{new,old,1901,1996}[new]{%
   \ifcase\xpg@nr\relax
      % new:
      \@german@oldspellingfalse
   \or
      % old:
      \@german@oldspellingtrue
   \or
      % 1901:
      \@german@oldspellingtrue
   \or
      % 1996:
      \@german@oldspellingfalse
   \fi
   \german@set@babelname%
   \xpg@info{Option: German, spelling=\xpg@val}%
}{\xpg@warning{Unknown German spelling `#1'}}

\newif\if@austrian@locale
\@austrian@localefalse
\newif\if@swiss@locale
\@swiss@localefalse
\define@choicekey*+{german}{variant}[\xpg@val\xpg@nr]{german,austrian,swiss}[german]{%
   \ifcase\xpg@nr\relax
      % german:
      \@swiss@localefalse%
      \@austrian@localefalse%
   \or
      % austrian:
      \@austrian@localetrue%
      \@swiss@localefalse%
   \or
      % swiss:
      \@swiss@localetrue%
      \@austrian@localefalse%
      \xpg@ifdefined{swissgerman}{}%
         {%
           \xpg@warning{No hyphenation patterns were loaded for "Swiss German (Old Spelling)"\MessageBreak
	                I will use the standard patterns for German (old spelling) instead}%
	                \adddialect\l@swissgerman\l@german\relax%
         }%
   \fi
   \german@set@babelname%
   \xpg@info{Option: German, variant=\xpg@val}%
}{\xpg@warning{Unknown German variant `#1'}}

\def\german@set@babelname{%
  \if@german@oldspelling
     \if@swiss@locale
         \if@german@blackletter
           \SetLanguageKeys{german}{babelname=swissgerman,bcp47=de-Latf-CH-1901,bcp47-language=de,bcp47-region=CH,bcp47-variant=1901,bcp47-script=Latf}%
         \else
           \SetLanguageKeys{german}{babelname=swissgerman,bcp47=de-CH-1901,bcp47-language=de,bcp47-region=CH,bcp47-variant=1901,bcp47-script=Latn}%
         \fi
     \else
     \if@austrian@locale
         \if@german@blackletter
            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-Latf-AT-1901,bcp47-language=de,bcp47-region=AT,bcp47-variant=1901,bcp47-script=Latf}%
         \else
            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-AT-1901,bcp47-language=de,bcp47-region=AT,bcp47-variant=1901,bcp47-script=Latn}%
         \fi
     \else
         \if@german@blackletter
            \SetLanguageKeys{german}{babelname=german,bcp47=de-Latf-DE-1901,bcp47-script=Latf,bcp47-language=de,bcp47-region=DE,bcp47-variant=1901,bcp47-script=Latf}%
         \else
            \SetLanguageKeys{german}{babelname=german,bcp47=de-DE-1901,bcp47-language=de,bcp47-region=DE,bcp47-variant=1901,bcp47-script=Latn}%
         \fi
     \fi\fi
  \else
     \if@swiss@locale
         \if@german@blackletter
           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-Latf-CH,bcp47-language=de,bcp47-region=CH,bcp47-variant=1996,bcp47-script=Latf}%
         \else
           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-CH,bcp47-language=de,bcp47-region=CH,bcp47-variant=1996,bcp47-script=Latn}%
         \fi
     \else
     \if@austrian@locale
         \if@german@blackletter
           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-Latf-AT,bcp47-language=de,bcp47-region=AT,bcp47-variant=1996,bcp47-script=Latf}%
         \else
           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-AT,bcp47-language=de,bcp47-region=AT,bcp47-variant=1996,bcp47-script=Latn}%
         \fi
     \else
         \if@german@blackletter
           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-Latf-DE,bcp47-language=de,bcp47-region=DE,bcp47-variant=1996,bcp47-script=Latf}%
         \else
           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-DE,bcp47-language=de,bcp47-region=DE,bcp47-variant=1996,bcp47-script=Latn}%
         \fi
     \fi\fi
  \fi
}

\newif\if@german@blackletter
\define@choicekey*+{german}{script}[\xpg@val\xpg@nr]{latin,blackletter,fraktur}[latin]{%
   \ifcase\xpg@nr\relax
      % latin:
      \@german@blackletterfalse%
   \or
      % blackletter:
      \@german@blacklettertrue%
   \or
      % fraktur:
      \@german@blacklettertrue%
   \fi
   \german@set@babelname%
   \xpg@info{Option: German, script=\xpg@val}%
}{\xpg@warning{Unknown German script `#1'}}

\define@boolkey{german}[german@]{capitaleszett}[true]{%
  \ifgerman@capitaleszett
     % MakeUppercase capitalizes the eszett (U+00DF) with U+1E9E
     \SetLanguageKeys{german}{bcp47-casing=de-x-eszett,bcp47-extension-x=eszett}
  \else
     % Capitalize eszett as <SS>
     \SetLanguageKeys{german}{bcp47-casing=de,bcp47-extension-x={}}
  \fi
}


% Option defunc'ed, as both XeTeX and LuaTeX meanwhile
% use the experimental German hyphenation patterns by default.
\define@boolkey{german}[german@]{latesthyphen}[true]{}

\define@boolkey{german}[german@]{babelshorthands}[true]{}

\setkeys{german}{spelling,script,variant}

% Register default options
\xpg@initialize@gloss@options{german}{variant=german,spelling=new,script=latin,babelshorthands=false}
% Register alias options
\xpg@set@alias@values{german}{spelling}{new}{1996}
\xpg@set@alias@values{german}{spelling}{old}{1901}
\xpg@set@alias@values{german}{script}{blackletter}{fraktur}

\ifsystem@babelshorthands
  \setkeys{german}{babelshorthands=true}
\else
  \setkeys{german}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\german@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{german}%
  \declare@shorthand{german}{"`}{„}%
  \declare@shorthand{german}{"'}{“}%
  \declare@shorthand{german}{"<}{«}%
  \declare@shorthand{german}{">}{»}%
  \declare@shorthand{german}{"c}{\textormath{\bbl@disc@german ck}{c}}%
  \declare@shorthand{german}{"C}{\textormath{\bbl@disc@german CK}{C}}%
  \declare@shorthand{german}{"F}{\textormath{\bbl@disc@german F{FF}}{F}}%
  \declare@shorthand{german}{"l}{\textormath{\bbl@disc@german l{ll}}{l}}%
  \declare@shorthand{german}{"L}{\textormath{\bbl@disc@german L{LL}}{L}}%
  \declare@shorthand{german}{"m}{\textormath{\bbl@disc@german m{mm}}{m}}%
  \declare@shorthand{german}{"M}{\textormath{\bbl@disc@german M{MM}}{M}}%
  \declare@shorthand{german}{"n}{\textormath{\bbl@disc@german n{nn}}{n}}%
  \declare@shorthand{german}{"N}{\textormath{\bbl@disc@german N{NN}}{N}}%
  \declare@shorthand{german}{"p}{\textormath{\bbl@disc@german p{pp}}{p}}%
  \declare@shorthand{german}{"P}{\textormath{\bbl@disc@german P{PP}}{P}}%
  \declare@shorthand{german}{"r}{\textormath{\bbl@disc@german r{rr}}{r}}%
  \declare@shorthand{german}{"R}{\textormath{\bbl@disc@german R{RR}}{R}}%
  \declare@shorthand{german}{"t}{\textormath{\bbl@disc@german t{tt}}{t}}%
  \declare@shorthand{german}{"T}{\textormath{\bbl@disc@german T{TT}}{T}}%
  \declare@shorthand{german}{"f}{\texorpdfstring{\textormath{\bbl@discff}{f}}{f}}%
  \def\bbl@discff{\penalty\@M
    \afterassignment\bbl@insertff \cslet{bbl@nextff}{ }}%
  \def\bbl@insertff{%
    \if f\bbl@nextff
      \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
    {\relax\discretionary{ff-}{f}{ff}\allowhyphens}{f\bbl@nextff}}%
  \cslet{bbl@nextff}{f}%
  \declare@shorthand{german}{"-}{\nobreak\-\nobreak\hskip\z@skip}%
  \declare@shorthand{german}{"|}{\textormath{\penalty\@M\discretionary{-}{}{\kern.03em}}{}}%
  \declare@shorthand{german}{""}{\hskip\z@skip}%
  \declare@shorthand{german}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{german}{"=}{\penalty\@M-\hskip\z@skip}%
  \declare@shorthand{german}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
  \def\ck{\allowhyphens\discretionary{k-}{k}{ck}\allowhyphens}%
}

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

\def\captions@german{%
  \def\prefacename{Vorwort}%
  \def\refname{Literatur}%
  \def\abstractname{Zusammenfassung}%
  \def\bibname{Literaturverzeichnis}%
  \def\chaptername{Kapitel}%
  \def\appendixname{Anhang}%
  \def\contentsname{Inhaltsverzeichnis}%
  \def\listfigurename{Abbildungsverzeichnis}%
  \def\listtablename{Tabellenverzeichnis}%
  \def\indexname{Index}%
  \def\figurename{Abbildung}%
  \def\tablename{Tabelle}%
  \def\partname{Teil}%
  \def\enclname{Anlage(n)}%
  \def\ccname{Verteiler}%
  \def\headtoname{An}%
  \def\pagename{Seite}%
  \def\seename{siehe}%
  \def\alsoname{siehe auch}%
  \def\proofname{Beweis}%
  \def\glossaryname{Glossar}%
}
\def\date@german{%   
  \def\today{\number\day.%
    \space \ifcase\month%
    \or\if@austrian@locale Jänner\else Januar\fi\or Februar\or März\or%
    April\or Mai\or Juni\or Juli\or August\or September\or Oktober\or%
    November\or Dezember\fi
    \space \number\year}%
}

\def\captions@german@austrian{%
  \def\enclname{Beilage(n)}%
}

\def\captions@german@swiss{%
  \def\enclname{Beilage(n)}%
}

%%Strings for Fraktur contributed by Gerrit <z0idberg . gmx . de>
\def\captions@german@blackletter{%
  \captions@german%
  \def\abstractname{Zuſammenfaſſung}%
  \def\seename{ſiehe}%
  \def\alsoname{ſiehe auch}%
  \def\glossaryname{Gloſſar}%
}

\def\date@german@blackletter{%
  \def\today{\number\day.%
    \space \ifcase\month%
    \or\if@austrian@locale Jänner\else Januar\fi\or Februar\or März\or%
    April\or Mai\or Juni\or Juli\or Auguſt\or September\or Oktober\or%
    November\or Dezember\fi
    \space \number\year}%
}

\def\captionsgerman{%
  \if@german@blackletter\captions@german@blackletter\else\captions@german\fi
  \if@austrian@locale\captions@german@austrian\fi
  \if@swiss@locale\captions@german@swiss\fi
}

\def\dategerman{%
  \if@german@blackletter\date@german@blackletter\else\date@german\fi
}

\def\german@language{%
  \if@german@oldspelling
      \if@swiss@locale
          \polyglossia@setup@language@patterns{swissgerman}%
      \else
          \polyglossia@setup@language@patterns{german}%
      \fi
      \if@austrian@locale
         \adddialect\l@austrian\l@german%
      \fi
  \else
      \polyglossia@setup@language@patterns{ngerman}%
      \if@austrian@locale
         \adddialect\l@naustrian\l@ngerman%
      \fi
      \if@swiss@locale
         \adddialect\l@nswissgerman\l@ngerman%
      \fi
  \fi
}

\def\noextras@german{%
  \ifgerman@babelshorthands\nogerman@shorthands\fi%
}

\def\blockextras@german{%
  \ifgerman@babelshorthands\german@shorthands\else\nogerman@shorthands\fi%
}

\def\inlineextras@german{%
  \ifgerman@babelshorthands\german@shorthands\else\nogerman@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-german.ldf>
%<*gloss-germanb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-germanb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-germanb.ldf}[polyglossia: module for German (old spelling)]

% We provide this as a babel alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-germanb.ldf>
%<*gloss-gl.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-gl.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-gl.ldf}[polyglossia: module for gl (Galician)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{galician}

%    \end{macrocode}
% \iffalse
%</gloss-gl.ldf>
%<*gloss-grc.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-grc.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-grc.ldf}[polyglossia: module for grc (Greek)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{greek}

%    \end{macrocode}
% \iffalse
%</gloss-grc.ldf>
%<*gloss-greek.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-greek.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-greek.ldf}[polyglossia: module for Greek]

\PolyglossiaSetup{greek}{
  bcp47=el-monoton,
  bcp47-language=el,
  bcp47-variant=monoton,
  bcp47-script=Grek,
  bcp47-extension-u=nu-grek,
  bcp47-casing=el,
  script=Greek,
  scripttag=grek,
  langtag=ELL,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
  localnumeral=greeknumerals,
  Localnumeral=Greeknumerals
  %TODO localalph={greek@alph,greek@Alph}
}

% BCP-47 compliant aliases
\setlanguagealias*[variant=ancient]{greek}{grc}
\setlanguagealias*[varant=polytonic]{greek}{el-polyton}
\setlanguagealias*[variant=monotonic]{greek}{el-monoton}
\setlanguagealias*{greek}{el}

% Babel aliases
\setlanguagealias[variant=polytonic]{greek}{polutonikogreek}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% The code in this file was initially adapted from the antomega
%% module for greek. Currently large parts of it derive from the 
%% package xgreek.sty (c) Apostolos Syropoulos 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% this file imported from xgreek fixes the \lccode and \uccode of Greek letters:
\input{xgreek-fixes.def}

\def\greek@variant{monogreek}

\newif\if@greek@ancient\@greek@ancientfalse
\newif\if@greek@poly\@greek@polyfalse

\define@choicekey*+{greek}{variant}[\xpg@val\xpg@nr]{monotonic,mono,polytonic,poly,ancient,ancientgreek}[monotonic]{%
   \xpg@ifdefined{greek}{}{%
      \xpg@nopatterns{greek}%
      \adddialect\l@greek\l@nohyphenation
   }%
   \ifcase\xpg@nr\relax
      % monotonic:
      \@greek@polyfalse
      \@greek@ancientfalse
   \or
      % mono:
      \@greek@polyfalse
      \@greek@ancientfalse
   \or
      % polytonic:
      \@greek@polytrue
      \@greek@ancientfalse
   \or
      % poly:
      \@greek@polytrue
      \@greek@ancientfalse
   \or
      % ancient:
      \@greek@polyfalse
      \@greek@ancienttrue
   \or
      % ancientgreek:
      \@greek@polyfalse
      \@greek@ancienttrue
   \fi
   \greek@set@langdata
   \xpg@info{Option: Greek, variant=\xpg@val}%
}{\xpg@warning{Unknown Greek variant `#1'}}


\def\greek@set@langdata{%
   \if@greek@ancient
       \xpg@ifdefined{ancientgreek}{}%
           {\xpg@warning{No hyphenation patterns were loaded for Ancient Greek\MessageBreak
	                 I will use the patterns loaded for \string\l@greek\space instead}%
            \adddialect\l@ancientgreek\l@greek\relax}%
       \def\greek@variant{ancientgreek}%
       \def\captionsgreek{\ancientgreekcaptions}%
       \def\dategreek{\dateancientgreek}%
       \SetLanguageKeys{greek}{babelname=greek,bcp47=grc,bcp47-language=grc,bcp47-variant={}}%
   \else
      \if@greek@poly
          \xpg@ifdefined{polygreek}{}%
              {\xpg@warning{No hyphenation patterns were loaded for Polytonic Greek\MessageBreak
	                    I will use the patterns loaded for \string\l@greek\space instead}%
               \adddialect\l@polygreek\l@greek\relax}%
          \def\greek@variant{polygreek}%
          \def\captionsgreek{\polygreekcaptions}%
          \def\dategreek{\datepolygreek}%
          \SetLanguageKeys{greek}{babelname=polutonikogreek,bcp47=el-polyton,bcp47-language=el,bcp47-variant=polyton}%
      \else% monotonic greek
          \xpg@ifdefined{monogreek}{}%
              {\xpg@warning{No hyphenation patterns were loaded for Monotonic Greek\MessageBreak
	                    I will use the patterns loaded for \string\l@greek\space instead}%
               \adddialect\l@monogreek\l@greek\relax}%
          \def\greek@variant{monogreek}% monotonic
          \def\captionsgreek{\monogreekcaptions}%
          \def\dategreek{\datemonogreek}%
          \SetLanguageKeys{greek}{babelname=greek,bcp47=el-monoton,bcp47-language=el,bcp47-variant=monoton}%
      \fi%   
   \fi%
}


\def\greek@language{%
  \polyglossia@setup@language@patterns{\greek@variant}%
}


\newif\if@greek@numerals
\define@choicekey*+{greek}{numerals}[\xpg@val\xpg@nr]{greek,arabic}[greek]{%
   \ifcase\xpg@nr\relax
      % greek:
      \@greek@numeralstrue%
      \SetLanguageKeys{greek}{bcp47-extension-u=nu-grek}%
   \or
      % arabic:
      \@greek@numeralsfalse%
      \SetLanguageKeys{greek}{bcp47-extension-u=nu-latn}%
   \fi
   \xpg@info{Option: Greek, numerals=\xpg@val}%
}{\xpg@warning{Unknown Greek numerals value `#1'}}


\define@boolkey{greek}[greek@]{capitaliota}[true]{%
  \ifgreek@capitaliota
     % \MakeUppercase converts the ypogegrammeni (subscript muted iota) to capital iota
     \SetLanguageKeys{greek}{bcp47-casing=el-x-iota,bcp47-extension-x=iota}
  \else
     % \MakeUppercase retains the subscript versions (default)
     \SetLanguageKeys{greek}{bcp47-casing=el,bcp47-extension-x={}}
  \fi
}

\define@boolkey{greek}{attic}[true]{\xpg@warning{Greek option `attic' is no longer required.}}

% Register default options
\xpg@initialize@gloss@options{greek}{variant=monotonic,numerals=greek}
% Register alias options
\xpg@set@alias@values{greek}{variant}{monotonic}{mono}
\xpg@set@alias@values{greek}{variant}{polytonic}{poly}

\def\monogreekcaptions{%
   \def\refname{Αναφορές}%
   \def\abstractname{Περίληψη}%
   \def\bibname{Βιβλιογραφία}%
   \def\prefacename{Πρόλογος}%
   \def\chaptername{Κεφάλαιο}%
   \def\appendixname{Παράρτημα}%
   \def\contentsname{Περιεχόμενα}%
   \def\listfigurename{Κατάλογος σχημάτων}%
   \def\listtablename{Κατάλογος πινάκων}%
   \def\indexname{Ευρετήριο}%
   \def\figurename{Σχήμα}%
   \def\tablename{Πίνακας}%
   \def\partname{Μέρος}%
   \def\pagename{Σελίδα}%
   \def\seename{βλέπε}%
   \def\alsoname{βλέπε επίσης}%
   \def\enclname{Συνημμένα}%
   \def\ccname{Κοινοποίηση}%
   \def\headtoname{Προς}%
   \def\proofname{Απόδειξη}%
   \def\glossaryname{Γλωσσάρι}}%

\def\datemonogreek{%   
   \def\today{\number\day\space%
      \greek@month%
      \space\number\year}%
   \def\greektoday{\greeknumber\day\space%
      \greek@month%
      \space\greeknumber\year}%
   \def\Greektoday{\Greeknumber\day\space%
      \greek@month%
      \space\Greeknumber\year}%
   \def\greek@month{\ifcase\month\or%
      Ιανουαρίου\or
      Φεβρουαρίου\or
      Μαρτίου\or
      Απριλίου\or
      Μαΐου\or
      Ιουνίου\or
      Ιουλίου\or
      Αυγούστου\or
      Σεπτεμβρίου\or
      Οκτωβρίου\or
      Νοεμβρίου\or
      Δεκεμβρίου\fi}}%

\def\polygreekcaptions{%
   \def\refname{Ἀναφορές}%
   \def\abstractname{Περίληψη}%
   \def\bibname{Βιβλιογραφία}%
   \def\prefacename{Πρόλογος}%
   \def\chaptername{Κεφάλαιο}%
   \def\appendixname{Παράρτημα}%
   \def\contentsname{Περιεχόμενα}%
   \def\listfigurename{Κατάλογος σχημάτων}%
   \def\listtablename{Κατάλογος πινάκων}%
   \def\indexname{Εὑρετήριο}%
   \def\figurename{Σχῆμα}%
   \def\tablename{Πίνακας}%
   \def\partname{Μέρος}%
   \def\pagename{Σελίδα}%
   \def\seename{βλέπε}%
   \def\alsoname{βλέπε ἐπίσης}%
   \def\enclname{Συνημμένα}%
   \def\ccname{Κοινοποίηση}%
   \def\headtoname{Πρὸς}%
   \def\proofname{Ἀπόδειξη}}%

\def\datepolygreek{%   
   \def\today{\number\day\space%
      \greek@month%
      \space\number\year}%
   \def\greektoday{\greeknumber\day\space%
      \greek@month%
      \space\greeknumber\year}%
   \def\Greektoday{\Greeknumber\day\space%
      \greek@month%
      \space\Greeknumber\year}%
   \def\greek@month{\ifcase\month\or%
      Ἰανουαρίου\or
      Φεβρουαρίου\or
      Μαρτίου\or
      Ἀπριλίου\or
      Μαΐου\or
      Ἰουνίου\or
      Ἰουλίου\or
      Αὐγούστου\or
      Σεπτεμβρίου\or
      Ὀκτωβρίου\or
      Νοεμβρίου\or
      Δεκεμβρίου\fi}}%

% this is copied verbatim from xgreek.sty:      
\def\ancientgreekcaptions{%
  \def\prefacename{Προοίμιον}%
  \def\refname{Αναφοραί}%
  \def\abstractname{Περίληψις}%
  \def\bibname{Βιβλιογραφία}%
  \def\chaptername{Κεφάλαιον}%
  \def\appendixname{Παράρτημα}%
  \def\contentsname{Περιεχόμενα}%
  \def\listfigurename{Κατάλογος σχημάτων}%
  \def\listtablename{Κατάλογος πινάκων}%
  \def\indexname{Εὑρετήριον}%
  \def\figurename{Σχήμα}%
  \def\tablename{Πίναξ}%
  \def\partname{Μέρος}%
  \def\enclname{Συνημμένως}%
  \def\ccname{Κοινοποίησις}%
  \def\headtoname{Πρὸς}%
  \def\pagename{Σελὶς}%
  \def\seename{ὅρα}%
  \def\alsoname{ὅρα ὡσαύτως}%
  \def\proofname{Ἀπόδειξις}%
  \def\glossaryname{Γλωσσάριον}%
  \def\refname{Ἀναφοραὶ}%
  \def\indexname{Εὑρετήριο}%
  \def\figurename{Σχῆμα}%
  \def\headtoname{Πρὸς}}%

\def\dateancientgreek{%
  \def\today{\number\day\space%
      \greek@month%
      \space\number\year}%
   \def\greektoday{\greeknumber\day\space%
      \greek@month%
      \space\greeknumber\year}%
   \def\Greektoday{\Greeknumber\day\space%
      \greek@month%
      \space\Greeknumber\year}%
   \def\greek@month{\ifcase\month\or%
      Ἰανουαρίου\or
      Φεβρουαρίου\or
      Μαρτίου\or
      Ἀπριλίου\or
      Μαΐου\or
      Ἰουνίου\or
      Ἰουλίου\or
      Αὐγούστου\or
      Σεπτεμβρίου\or
      Ὀκτωβρίου\or
      Νοεμβρίου\or
      Δεκεμβρίου\fi}}

% the code for alphabetic numbers and attic numerals 
\newrobustcmd\anw@print{}
\newrobustcmd\anw@false{%
  \renewrobustcmd\anw@print{}}
\newrobustcmd\anw@true{%
   \renewrobustcmd\anw@print{ʹ}}
\anw@true

% Use \providecommand here as the ldf file might
% be reloaded via politunikogreek.
\providecommand{\greeknumerals}[2]{\greeknumber{#2}}
\providecommand{\Greeknumerals}[2]{\Greeknumber{#2}}

\protected\def\greeknumber#1{\expandafter\@greeknumber\expandafter{\number#1}}
\def\@greeknumber#1{%
  \ifnum#1<\@ne\space\gr@ill@value{#1}%
  \else
    \ifnum#1<10\expandafter\gr@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\gr@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\gr@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\gr@num@iv\number#1%
          \else
            \ifnum#1<100000\expandafter\gr@num@v\number#1%
            \else
              \ifnum#1<1000000\expandafter\gr@num@vi\number#1%
              \else
                \space\gr@ill@value{#1}%
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}
\protected\def\Greeknumber#1{\expandafter\@Greeknumber\expandafter{\number#1}}
\def\@Greeknumber#1{%
  \ifnum#1<\@ne\space\gr@ill@value{#1}%
  \else
    \ifnum#1<10\expandafter\gr@Num@i\number#1%
    \else
      \ifnum#1<100\expandafter\gr@Num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\gr@Num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\gr@Num@iv\number#1%
          \else
            \ifnum#1<100000\expandafter\gr@Num@v\number#1%
            \else
              \ifnum#1<1000000\expandafter\gr@Num@vi\number#1%
              \else
                \space\gr@ill@value{#1}%
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
}
\let\greeknumeral=\greeknumber
\let\Greeknumeral=\Greeknumber
\def\gr@num@i#1{%
  \ifcase#1\or α\or β\or γ\or δ\or ε\or ϛ\or ζ\or η\or θ\fi
  \ifnum#1=\z@\else\anw@true\fi\anw@print}
\def\gr@num@ii#1{%
  \ifcase#1\or ι\or κ\or λ\or μ\or ν\or ξ\or ο\or π\or ϟ\fi
  \ifnum#1=\z@\else\anw@true\fi\gr@num@i}
\def\gr@num@iii#1{%
  \ifcase#1\or ρ\or σ\or τ\or υ\or φ\or χ\or ψ\or ω\or ϡ\fi
  \ifnum#1=\z@\anw@false\else\anw@true\fi\gr@num@ii}
\def\gr@num@iv#1{%
  \ifnum#1=\z@\else ͵\fi
  \ifcase#1\or α\or β\or γ\or δ\or ε\or Ϛ\or ζ\or η\or θ\fi
  \gr@num@iii}
\def\gr@num@v#1{%
  \ifnum#1=\z@\else ͵\fi
  \ifcase#1\or ι\or κ\or λ\or μ\or ν\or ξ\or ο\or π\or ϟ\fi
  \gr@num@iv}
\def\gr@num@vi#1{%
  ͵\ifcase#1\or ρ\or σ\or τ\or υ\or φ\or χ\or ψ\or ω\or ϡ\fi
  \gr@num@v}
\def\gr@Num@i#1{%
  \ifcase#1 \or Α\or Β\or Γ\or Δ\or Ε\or Ϛ\or Ζ\or Η\or θ\fi
  \ifnum#1=\z@\else\anw@true\fi\anw@print}
\def\gr@Num@ii#1{%
  \ifcase#1 \or Ι\or Κ\or Λ\or Μ\or Ν\or Ξ\or Ο\or Π\or \MakeUppercase{ϟ}\fi
  \ifnum#1=\z@\else\anw@true\fi\gr@Num@i}
\def\gr@Num@iii#1{%
  \ifcase#1 \or Ρ\or Σ\or Τ\or Υ\or Φ\or Χ\or Ψ\or Ω\or \MakeUppercase{ϡ}\fi
  \ifnum#1=\z@\anw@false\else\anw@true\fi\gr@Num@ii}
\def\gr@Num@iv#1{%
  \ifnum#1=\z@\else ͵\fi
  \ifcase#1 \or Α\or Β\or Γ\or Δ\or Ε\or \MakeUppercase{Ϛ}\or Ζ\or Η\or θ\fi
  \gr@Num@iii}
\def\gr@Num@v#1{%
  \ifnum#1=\z@\else ͵\fi
  \ifcase#1 \or Ι\or Κ\or Λ\or Μ\or Ν\or Ξ\or Ο\or Π\or \MakeUppercase{ϟ}\fi
\gr@Num@iv}
  \def\gr@Num@vi#1{%
͵ \ifcase#1 \or Ρ\or Σ\or Τ\or Υ\or Φ\or Χ\or Ψ\or Ω\or \MakeUppercase{ϡ}\fi
  \gr@Num@v}
\def\gr@ill@value#1{\xpg@warning{Illegal value (#1) for Greek numeral}[$#1$]}

%%%% Attic numerals (no longer optional)
\newcount\@attic@num
\DeclareRobustCommand*{\@@atticnum}[1]{%
        \@attic@num#1\relax
        \ifnum\@attic@num<\@ne%
          \space%
          \xpg@warning{Illegal value (\the\@attic@num) for acrophonic Attic numeral}%
        \else\ifnum\@attic@num>249999%
          \space%
	  \xpg@warning{Illegal value (\the\@attic@num) for acrophonic Attic numeral}%
        \else
            \@whilenum\@attic@num>49999\do{%
               \char"10147\advance\@attic@num-50000}%
            \@whilenum\@attic@num>9999\do{%
               M\advance\@attic@num-\@M}%
            \ifnum\@attic@num>4999%
               \char"10146\advance\@attic@num-5000%
            \fi\relax
            \@whilenum\@attic@num>999\do{%
               Χ\advance\@attic@num-\@m}%
            \ifnum\@attic@num>499%
               \char"10145\advance\@attic@num-500%
            \fi\relax
            \@whilenum\@attic@num>99\do{%
               Η\advance\@attic@num-100}%
            \ifnum\@attic@num>49%
               \char"10144\advance\@attic@num-50%
            \fi\relax
            \@whilenum\@attic@num>9\do{%
               Δ\advance\@attic@num by-10}%
            \@whilenum\@attic@num>4\do{%
               Π\advance\@attic@num-5}%
            \ifcase\@attic@num\or Ι\or ΙΙ\or ΙΙΙ\or ΙΙΙΙ\fi%
   \fi\fi}
\def\@atticnum#1{%
     \expandafter\@@atticnum\expandafter{\the#1}}
\def\atticnumeral#1{%
     \@attic@num#1\relax
     \@atticnum{\@attic@num}}
\let\atticnum=\atticnumeral

\def\greek@numbers{%
   \if@greek@numerals
      \def\greek@alph##1{\expandafter\greeknumeral\expandafter{\the##1}}%
      \def\greek@Alph##1{\expandafter\Greeknumeral\expandafter{\the##1}}%
      \let\@alph\greek@alph%
      \let\@Alph\greek@Alph%
   \fi}

\def\nogreek@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
  \let\greek@alph\@undefined%
  \let\greek@Alph\@undefined%
  }

%    \end{macrocode}
% \iffalse
%</gloss-greek.ldf>
%<*gloss-he.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-he.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-he.ldf}[polyglossia: module for he (Hebrew)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{hebrew}

%    \end{macrocode}
% \iffalse
%</gloss-he.ldf>
%<*gloss-hebrew.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hebrew.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-hebrew.ldf}[polyglossia: module for Hebrew]

\RequireBidi
\RequirePackage{hebrewcal}

\PolyglossiaSetup{hebrew}{
  bcp47=he,
  bcp47-language=hr,
  bcp47-region=HE,
  bcp47-script=Hebr,
  script=Hebrew,
  direction=RL,
  scripttag=hebr,
  langtag=IWR,
  hyphennames={nohyphenation},
  fontsetup=true,
  localnumeral=hebrewnumerals
  %TODO localalph={hebrewnumeral,Hebrewnumeral}
  %digits = hebrewnumber
}

% BCP-47 compliant aliases
\setlanguagealias*{hebrew}{he}

% hebrewcal options
\define@key{hebrew}{marcheshvan}[true]{\setkeys{hebrewcal}{marcheshvan=#1}}
\define@key{hebrew}{transliteration}[alt]{\setkeys{hebrewcal}{transliteration=#1}}
\define@key{hebrew}{fullyear}[true]{\setkeys{hebrewcal}{fullyear=#1}}

\newif\if@calendar@hebrew
\define@choicekey*+{hebrew}{calendar}[\xpg@val\xpg@nr]{hebrew,gregorian}[gregorian]{%
   \ifcase\xpg@nr\relax
      % hebrew:
      \@calendar@hebrewtrue%
   \or
      % gregorian:
      \@calendar@hebrewfalse%
   \fi
   \xpg@info{Option: Hebrew, calendar=\xpg@val}%
}{\xpg@warning{Unknown Hebrew calendar `#1'}}

\newif\if@hebrew@numerals
\define@choicekey*+{hebrew}{numerals}[\xpg@val\xpg@nr]{hebrew,arabic}[arabic]{%
   \ifcase\xpg@nr\relax
      % hebrew:
      \@hebrew@numeralstrue%
      \SetLanguageKeys{hebrew}{bcp47-extension-u=nu-hebr}%
   \or
      % arabic:
      \@hebrew@numeralsfalse%
      \SetLanguageKeys{hebrew}{bcp47-extension-u=nu-latn}%
   \fi
   \xpg@info{Option: Hebrew, numerals=\xpg@val}%
}{\xpg@warning{Unknown Hebrew numerals value `#1'}}

\setkeys{hebrew}{numerals}

% Register default options
\xpg@initialize@gloss@options{hebrew}{numerals=arabic,calendar=gregorian,marcheshvan=false,fullyear=false}

\def\captionshebrew{%
  \def\prefacename{מבוא}%
  \def\refname{מקורות}%
  \def\abstractname{תקציר}%
  \def\bibname{ביבליוגרפיה}%
  \def\chaptername{פרק}%
  \def\appendixname{נספח}%
  \def\contentsname{תוכן העניינים}%
  \def\listfigurename{רשימת האיורים}%
  \def\listtablename{רשימת הטבלאות}%
  \def\indexname{מפתח}%
  \def\figurename{איור}%
  \def\tablename{טבלה}%
  \def\partname{חלק}%
  \def\enclname{רצ"ב}%
  \def\ccname{העתקים}%
  \def\headtoname{אל}%
  \def\pagename{עמוד}%
  \def\psname{נ.ב.}%
  \def\seename{ראה}%
  \def\alsoname{ראה גם}% check
  \def\proofname{הוכחה}
  \def\glossaryname{מילון מונחים}% check
}
\def\datehebrew{%
  \def\today{%
    \if@calendar@hebrew%
      \hebrewtoday%
    \else%
      \hebrewnumber\day%
      \space ב\hebrewgregmonth{\month}\space%
      \hebrewnumber\year%
     \fi%
  }%
}

\def\hebrewgregmonth#1{\ifcase#1%
  \or ינואר% יאנואר
    \or פברואר\or מרץ% מרס / מארס
    \or אפריל\or מאי% מי
    \or יוני\or יולי\or אוגוסט %אבגוסט
    \or ספטמבר\or אוקטובר\or נובמבר\or דצמבר\fi}

\input{babel-hebrewalph.def}

\newcommand{\hebrewnumerals}[2]{\hebrewnumber{#2}}

\def\hebrewnumber#1{%
   \if@hebrew@numerals
     \hebrewnumeral{#1}%
   \else
     \number#1%
   \fi
}

\ifxetex
  % Bidi inserts an RTL mark (0x200f) between number and number separator (- .),
  % forcing numbers to RTL. This is wrong for Hebrew.
  % So we defunc the respective command with XeTeX.
  \let\xpg@orig@DigitsDotDashInterCharToks\DigitsDotDashInterCharToks%

  \def\hebrew@ltr@numbers{%
    \renewcommand*{\DigitsDotDashInterCharToks}{}%
  }

  \def\nohebrew@ltr@numbers{%
    % Restore bidi's \DigitsDotDashInterCharToks
    \let\DigitsDotDashInterCharToks\xpg@orig@DigitsDotDashInterCharToks%
  }
\else
  % Only dummy commands (nothing to do here) for LuaTeX
  \def\hebrew@ltr@numbers{}
  \def\nohebrew@ltr@numbers{}
\fi%

\def\hebrew@numbers{%
   \let\@alph\hebrewnumeral%
   \let\@Alph\Hebrewnumeral%
   % Prevent bidi from setting the numbers RTL
   \hebrew@ltr@numbers%
}

\def\nohebrew@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
  % Restore previous bidi numbers definition
  \nohebrew@ltr@numbers%
}

\def\hebrew@globalnumbers{%
   \let\@arabic\hebrewnumber%
   \renewcommand\thefootnote{\localnumeral*{footnote}}%
   % Prevent bidi from setting the numbers RTL
   \hebrew@ltr@numbers%
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\nohebrew@globalnumbers{%
  \let\@arabic\xpg@save@arabic%
}

%    \end{macrocode}
% \iffalse
%</gloss-hebrew.ldf>
%<*gloss-hi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hi.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-hi.ldf}[polyglossia: module for hi (Hindi)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{hindi}

%    \end{macrocode}
% \iffalse
%</gloss-hi.ldf>
%<*gloss-hindi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hindi.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
% UTF-8 strings kindly provided by Zdenĕk Wagner, 10-03-2008
% with corrections and additional contributions by Anshuman Pandey
% TODO: add option for velthuis transliteration with link to
% Velthuis Devanagari project.

\ProvidesFile{gloss-hindi.ldf}[polyglossia: module for Hindi]
\RequirePackage{devanagaridigits}
\PolyglossiaSetup{hindi}{
  bcp47=hi,
  bcp47-language=hi,
  bcp47-script=Deva,
  script=Devanagari,
  scripttag=deva,
  langtag=HIN,
%%  hyphennames={hindi,!sanskrit}, TODO: implement fallback patterns (with ! prefix)
  fontsetup=true,
  localnumeral=hindinumerals
  %TODO nouppercase=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{hindi}{hi}

\ifx\l@hindi\@undefined%
  \ifx\l@sanskrit\@undefined%
    \xpg@nopatterns{Hindi}%
    \adddialect\l@hindi\l@nohyphenation%
  \else
    \xpg@warning{No hyphenation patterns were loaded for Hindi\MessageBreak
    I will use the patterns for Sanskrit instead}
    \adddialect\l@hindi\l@sanskrit%
  \fi
\fi

\def\hindi@language{%
  \polyglossia@setup@language@patterns{hindi}%
}

\newif\ifhindi@devanagari@numerals
\hindi@devanagari@numeralstrue
\define@choicekey*+{hindi}{numerals}[\xpg@val\xpg@nr]{Devanagari,Western}[Devanagari]{%
   \ifcase\xpg@nr\relax
      % Devanagari:
      \hindi@devanagari@numeralstrue%
      \SetLanguageKeys{hindi}{bcp47-extension-u=nu-deva}%
   \or
      % Western:
      \hindi@devanagari@numeralsfalse%
      \SetLanguageKeys{hindi}{bcp47-extension-u=nu-latn}%
   \fi
   \xpg@info{Option: Hindi, numerals=\xpg@val}%
}{\xpg@warning{Unknown Hindi numeral `#1'}}

% Register default options
\xpg@initialize@gloss@options{hindi}{numerals=devanagari}

\newcommand{\hindinumerals}[2]{\hindinumber{#2}}

\def\hindinumber#1{%
  \ifhindi@devanagari@numerals
    \devanagaridigits{\number#1}%
  \else
    \number#1%
  \fi}

\def\captionshindi{%
     \def\abstractname{सारांश}%
     \def\appendixname{परिशिष्ट}%
     \def\bibname{संदर्भ ग्रंथ}%
     \def\ccname{}%
     \def\chaptername{अध्याय}%
     \def\contentsname{विषय सूची}%
     \def\enclname{}%
     \def\figurename{चित्र}% रेखाचित्र
     \def\headpagename{पृष्ठ}%
     \def\headtoname{}%
     \def\indexname{सूची}%
     %              सूचक
     %              अनुक्रमणिका
     %              अनुक्रमणि
     \def\listfigurename{चित्रों की सूची}%
     \def\listtablename{तालिकाओं की सूची}%
     \def\pagename{पृष्ठ}%
     \def\partname{खण्ड}%
     \def\prefacename{प्रस्तावना}% प्राक्कथन
     \def\refname{हवाले}%
     \def\tablename{तालिका}%
     \def\seename{देखिए}%
     \def\alsoname{और देखिए}%
     \def\alsoseename{और देखिए}%
}
\def\datehindi{%
  \def\today{\hindinumber\day\space\ifcase\month\or
    जनवरी\or
    फ़रवरी\or
    मार्च\or
    अपरैल\or
    मई\or
    जून\or
    जलाई\or
    अगस्त\or
    सितम्बर\or
    अक्तूबर\or
    नवम्बर\or
    दिसम्बर\fi
    \space\hindinumber\year}%
}

%    \end{macrocode}
% \iffalse
%</gloss-hindi.ldf>
%<*gloss-hr.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hr.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-hr.ldf}[polyglossia: module for hr (Croatian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{croatian}

%    \end{macrocode}
% \iffalse
%</gloss-hr.ldf>
%<*gloss-hsb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hsb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-hsb.ldf}[polyglossia: module for hsb (Higher Sorbian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{sorbian}

%    \end{macrocode}
% \iffalse
%</gloss-hsb.ldf>
%<*gloss-hu.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hu.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-hu.ldf}[polyglossia: module for hu (Hungarian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{hungarian}

%    \end{macrocode}
% \iffalse
%</gloss-hu.ldf>
%<*gloss-hungarian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hungarian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-hungarian.ldf}[polyglossia: module for Hungarian]

\PolyglossiaSetup{hungarian}{
  bcp47=hu,
  bcp47-language=hu,
  bcp47-region=HU,
  bcp47-script=Latn,
  babelname=magyar,
  hyphennames={hungarian,magyar},
  langtag=HUN,
  hyphenmins={2,2},
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{hungarian}{hu}

\frenchspacing

% Babel and backwards compat. alias
\setlanguagealias{hungarian}{magyar}

\newif\if@hungarian@swapcaptions
\newif\if@hungarian@swapheadings
\newif\if@hungarian@swapheaders
\define@choicekey*+{hungarian}{swapstrings}[\xpg@val\xpg@nr]{all,captions,headings,headers,hheaders,none}[all]{%
   \ifcase\xpg@nr\relax
      % all:
      \@hungarian@swapcaptionstrue%
      \@hungarian@swapheadingstrue%
      \@hungarian@swapheaderstrue%
   \or
      % captions:
      \@hungarian@swapcaptionstrue%
      \@hungarian@swapheadingsfalse%
      \@hungarian@swapheadersfalse%
   \or
      % headings:
      \@hungarian@swapcaptionsfalse%
      \@hungarian@swapheadingstrue%
      \@hungarian@swapheadersfalse%
   \or
      % headers:
      \@hungarian@swapcaptionsfalse%
      \@hungarian@swapheadingsfalse%
      \@hungarian@swapheaderstrue%
   \or
      % hheaders:
      \@hungarian@swapcaptionsfalse%
      \@hungarian@swapheadingstrue%
      \@hungarian@swapheaderstrue%
   \or
      % none:
      \@hungarian@swapcaptionsfalse%
      \@hungarian@swapheadingsfalse%
      \@hungarian@swapheadersfalse%
   \fi
   \xpg@info{Option: Hungarian, swapstrings=\xpg@val}%
}{\xpg@warning{Unknown Hungarian swapstrings value `#1'}}

% Force punctuation: 1) after section type counters; 2) after @chapapp in the running head
\define@boolkey{hungarian}[hungarian@]{forceheadingpunctuation}[true]{}

% Register default options
% forceheadinpunctuatin is recommended, but the default value is false for compatibility reasons
\xpg@initialize@gloss@options{hungarian}{swapstrings=all,
                                         forceheadingpunctuation=false}


\def\hungarian@language{%
   \polyglossia@setup@language@patterns{hungarian}%
   \xpg@ifdefined{hungarian}{\adddialect\l@magyar\l@hungarian}{}%
}%

\def\captionshungarian{%
   \def\refname{Hivatkozások}%
   \def\abstractname{Kivonat}%
   \def\bibname{Irodalomjegyzék}%
   \def\prefacename{Előszó}%
   \def\chaptername{fejezet}%
   \def\appendixname{Függelék}%
   \def\contentsname{Tartalomjegyzék}%
   \def\listfigurename{Ábrák jegyzéke}%
   \def\listtablename{Táblázatok jegyzéke}%
   \def\indexname{Tárgymutató}%
   \def\figurename{ábra}%
   \def\tablename{táblázat}%
   %\def\thepart{}%
   \def\partname{rész}%
   \def\pagename{oldal}%
   \def\seename{lásd}%
   \def\alsoname{lásd még}%
   \def\enclname{Melléklet}%
   \def\ccname{Körlevél–címzettek}%
   \def\headtoname{Címzett}%
   \def\proofname{Bizonyítás}%
   \def\glossaryname{Szójegyzék}%
}

\def\datehungarian{%   
   \def\today{%
    \number\year.\nobreakspace\ifcase\month\or
    január\or február\or március\or
    április\or május\or június\or
    július\or augusztus\or szeptember\or
    október\or november\or december\fi
    \space\number\day.}%
   \def\ondatehungarian{%
    \number\year.\nobreakspace\ifcase\month\or
    január\or február\or március\or
    április\or május\or június\or
    július\or augusztus\or szeptember\or
    október\or november\or december\fi
      \space\ifcase\day\or
      1-jén\or  2-án\or  3-án\or  4-én\or  5-én\or
      6-án\or  7-én\or  8-án\or  9-én\or 10-én\or
     11-én\or 12-én\or 13-án\or 14-én\or 15-én\or
     16-án\or 17-én\or 18-án\or 19-én\or 20-án\or
     21-én\or 22-én\or 23-án\or 24-én\or 25-én\or
     26-án\or 27-én\or 28-án\or 29-én\or 30-án\or
     31-én\fi}%
   \let\ontoday\ondatehungarian%
   \let\ondatemagyar\ondatehungarian%
}

% Save original capsformats
\let\xpg@save@fnum@table\fnum@table
\let\xpg@save@fnum@figure\fnum@figure

\def\hungarian@capsformat{%
  %
  % Change captions
  \if@hungarian@swapcaptions
     % change 'ábra x.x' to 'x.x. ábra'
     \def\fnum@figure{\thefigure.~\figurename}
     %
     % change 'táblázat x.x' to 'x.x. táblázat'
     \def\fnum@table{\thetable.~\tablename}
  \fi
  %
  % change chapter and part headings
  \if@hungarian@swapheadings
     % With titlesec
     \ifcsdef{titleformat}{%
       \ifcsdef{NR@part}{% Hyperref (nameref)
            \let\xpg@save@part@format\NR@part%
            \patchcmd{\NR@part}%
                      {\partname\nobreakspace\thepart}%
                      {\thepart.\nobreakspace\partname}%
                      {}%
                      {\xpg@warning{Failed to patch part for Hungarian}}%
       }{% not hyperref
         \ifcsdef{@part}{%
            \let\xpg@save@part@format\@part%
            \patchcmd{\@part}%
                      {\partname\nobreakspace\thepart}%
                      {\thepart.\nobreakspace\partname}%
                      {}%
                      {\xpg@warning{Failed to patch part for Hungarian}}%
         }{}%
       }
       \ifcsdef{chapter}{%
          \titleformat\chapter[display]%
             {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}
             {\thechapter.\space\@chapapp}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}
       }{}%
     }{% (not \ifdefined\titleformat)
       % With KOMA
       \ifcsdef{sectionformat}{%
          \ifcsdef{partformat}{%
            \let\xpg@save@part@format\partformat%
            \renewcommand{\partformat}{\thepart.~\partname}%
          }{}%
          \ifcsdef{chapterformat}{%
            \let\xpg@save@chap@format\chapterformat%
            \renewcommand{\chapterformat}{\mbox{\thechapter\autodot%
                                          \IfUsePrefixLine{\nobreakspace\chapapp}{\enskip}}}%
          }{}%
       }{%  (not \ifdefined\sectionformat)
         % With memoir
         \ifcsdef{@memptsize}{%
           \ifcsdef{@makechapterhead}{%
              \let\xpg@save@chap@format\@makechapterhead%
              \patchcmd{\@makechapterhead}{\printchaptername \chapternamenum \printchapternum}%
                       {\printchapternum.\chapternamenum\printchaptername}%
                       {}%
                       {\xpg@warning{Failed to patch chapter for Hungarian}}%
           }{}%
           \ifcsdef{NR@part}{% Hyperref (nameref)
                \let\xpg@save@part@format\NR@part%
                \patchcmd{\NR@part}{\printpartname \partnamenum \printpartnum}%
                                 {\printpartnum.\partnamenum\printpartname}%
                                 {}%
                                 {\xpg@warning{Failed to patch part for Hungarian}}%
           }{% not hyperref
             \ifcsdef{@part}{%
                \let\xpg@save@part@format\@part%
                \patchcmd{\@part}{\printpartname \partnamenum \printpartnum}%
                                 {\printpartnum.\partnamenum\printpartname}%
                                 {}%
                                 {\xpg@warning{Failed to patch part for Hungarian}}%
             }{}%
           }%
         }{%  (not \ifdefined\@memptsize)
           % With standard classes
            \ifcsdef{@makechapterhead}{%
              \let\xpg@save@chap@format\@makechapterhead%
              \patchcmd{\@makechapterhead}%
                       {\@chapapp\space \thechapter}%
                       {\thechapter.\space \@chapapp}%
                       {}%
                       {\xpg@warning{Failed to patch chapter for Hungarian}}%
            }{}%
            \ifcsdef{NR@part}{% Hyperref (nameref)
              \let\xpg@save@part@format\NR@part%
              \patchcmd{\NR@part}%
                       {\partname\nobreakspace\thepart}%
                       {\thepart.\nobreakspace\partname}%
                       {}%
                       {\xpg@warning{Failed to patch part for Hungarian}}%
            }{% not hyperref
              \ifcsdef{@part}{%
                \let\xpg@save@part@format\@part%
                \patchcmd{\@part}%
                         {\partname\nobreakspace\thepart}%
                         {\thepart.\nobreakspace\partname}%
                         {}%
                         {\ifcsdef{part}{\xpg@warning{Failed to patch part for Hungarian}}{}}%
              }{}%  (end \ifdefined\@part)
            }% (end not hyperref)
          }% (end \ifdefined\@memptsize)
        }% (end \ifdefined\sectionformat)
     }% (end \ifdefined\titleformat)
  \fi% (end \if@hungarian@swapheadings)
  %
  % Change running headers
  \if@hungarian@swapheaders
    \ifcsdef{chapterformat}{%
      % With KOMA
      \let\xpg@save@chaptermark@format\chaptermarkformat%
      \renewcommand*\chaptermarkformat{%
         \thechapter\autodot\ \IfChapterUsesPrefixLine{\chapapp\@hungarian@forced@dot\enskip}{}}
    }{% (not \ifdefined\chapterformat)
      \ifcsdef{@memptsize}{%
        % With memoir
        \let\xpg@save@chaptermark@format\chaptermark%
        \renewcommand*\chaptermark[1]{%
          \markboth{\memUChead{%
            \ifnum \c@secnumdepth >\m@ne
              \ifbool{@mainmatter}{%
                \thechapter.\ \@chapapp\@hungarian@forced@dot\ %
              }{}%
            \fi
            ##1}}{}}%
      }{% (not \ifdefined\@memptsize)
        % With standard classes
        \ifcsdef{chaptermark}{%
          \ifpatchable{\chaptermark}%
               {\@chapapp\ \thechapter.}%
               {\let\xpg@save@chaptermark@format\chaptermark%
                \patchcmd{\chaptermark}%
                    {\@chapapp\ \thechapter.}%
                    {\thechapter.\ \@chapapp\@hungarian@forced@dot}%
                    {}%
                    {\xpg@warning{Failed to patch chaptermark for Hungarian}}}%
               {}%
        }{}% (end \ifdefined\chaptermark)
      }% (end \ifdefined\@memptsize)
    }% (end \ifdefined\chapterformat)
  \fi% (end \if@hungarian@swapheaders)
}

\def\nohungarian@capsformat{%
   %
   % Reset changes of \hungarian@capsformat
   \let\fnum@table\xpg@save@fnum@table%
   \let\fnum@figure\xpg@save@fnum@figure%
   %
   % Reset chapter and part heading
   \ifcsdef{titleformat}{%
      % With titlesec
     \ifcsdef{xpg@save@part@format}{%
        \ifcsdef{NR@part}{%
            \let\NR@part\xpg@save@part@format%
        }{%
            \let\@part\xpg@save@part@format%
        }%
     }{}%
     \ifcsdef{chapter}{%
        \titleformat\chapter[display]%
          {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}
          {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}
     }{}%
   }{% (not \ifdefined\titleformat)
     \ifcsdef{sectionformat}{%
        % With KOMA
        \ifcsdef{xpg@save@part@format}{%
           \let\partformat\xpg@save@part@format
        }{}%
        \ifcsdef{xpg@save@chap@format}{%
           \let\chapterformat\xpg@save@chap@format
        }{}%
     }{%
        % With memoir and standard classes
        \ifcsdef{xpg@save@part@format}{%
           \ifcsdef{NR@part}{%
               \let\NR@part\xpg@save@part@format%
           }{%
               \let\@part\xpg@save@part@format%
           }%
        }{}%
        \ifcsdef{xpg@save@chap@format}{%
          \let\@makechapterhead\xpg@save@chap@format
        }{}%
     }% (end \ifdefined\sectionformat)
   }% (end \ifdefined\titleformat)
  %
  % Reset headers
  \ifcsdef{chaptermarkformat}{%
     % With KOMA
     \ifcsdef{xpg@save@chaptermark@format}{%
       \let\chaptermarkformat\xpg@save@chaptermark@format%
     }{}%
  }{%
     \ifcsdef{chaptermark}{%
       % With memoir and standard classes
       \ifcsdef{xpg@save@chaptermark@format}{%
         \let\chaptermark\xpg@save@chaptermark@format%
       }{}%
     }{}% (end \ifdefined\chaptermark)
  }% (end \ifdefined\chapterformat)
}
% Hungarian needs 1) trailing dots in chapter headings; 2) trailing dot in section, subsection, etc, counters
\def\@hungarian@forced@dot{}
\def\xpg@save@autodot{}
\ifdef{\KOMAScript}{%
    \providecommand*\autodot{}%
    \let\xpg@save@autodot\autodot%
}{}
% The following is based on some ideas from gloss-russian.ldf
\def\hungarian@sectsformat{%
  \ifhungarian@forceheadingpunctuation%
   \ifdef{\KOMAScript}{%
      \renewcommand*\autodot{.}%
   }{%
      \def\@seccntformat##1{\csname pre##1\endcsname%
         \csname the##1\endcsname%
         \csname post##1\endcsname}%
       \def\@aftersepkern{\hspace{0.5em}}%
       \def\postchapter{.\@aftersepkern}%
       \def\postsection{.\@aftersepkern}%
       \def\postsubsection{.\@aftersepkern}%
       \def\postsubsubsection{.\@aftersepkern}%
       \def\postparagraph{.\@aftersepkern}%
       \def\postsubparagraph{.\@aftersepkern}%
       \def\prechapter{}%
       \def\presection{}%
       \def\presubsection{}%
       \def\presubsubsection{}%
       \def\preparagraph{}%
       \def\presubparagraph{}%
    }%
   \def\@hungarian@forced@dot{.}
  \fi%
}
%
\def\nohungarian@sectsformat{%
  \ifhungarian@forceheadingpunctuation%
    \ifdef{\KOMAScript}{%
       \let\autodot\xpg@save@autodot%
    }{%
       \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
    }%
  \fi%
  \def\@hungarian@forced@dot{}
}
%
\def\blockextras@hungarian{%
   \hungarian@capsformat%
   \hungarian@sectsformat%
}
%
\def\noextras@hungarian{%
   \nohungarian@capsformat%
   \nohungarian@sectsformat%
   \let\ontoday\@undefined%
}
%
%    \end{macrocode}
% \iffalse
%</gloss-hungarian.ldf>
%<*gloss-hy.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hy.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-hy.ldf}[polyglossia: module for hy (Armenian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{armenian}

%    \end{macrocode}
% \iffalse
%</gloss-hy.ldf>
%<*gloss-ia.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ia.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ia.ldf}[polyglossia: module for ia (Interlingua)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{interlingua}

%    \end{macrocode}
% \iffalse
%</gloss-ia.ldf>
%<*gloss-icelandic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-icelandic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-icelandic.ldf}[polyglossia: module for Icelandic]
\PolyglossiaSetup{icelandic}{
  bcp47=is,
  bcp47-language=is,
  bcp47-script=Latn,
  hyphennames={icelandic},
  hyphenmins={2,2},
  langtag=ISL,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{icelandic}{is}

\def\captionsicelandic{%
   \def\refname{Heimildir}%
   \def\abstractname{Útdráttur}%
   \def\bibname{Heimildir}%
   \def\prefacename{Formáli}%
   \def\chaptername{Kafli}%
   \def\appendixname{Viðauki}%
   \def\contentsname{Efnisyfirlit}%
   \def\listfigurename{Myndaskrá}%
   \def\listtablename{Töfluskrá}%
   \def\indexname{Atriðisorðaskrá}%
   \def\figurename{Mynd}%
   \def\tablename{Tafla}%
   %\def\thepart{}%
   \def\partname{Hluti}%
   \def\pagename{Blaðsíða}%
   \def\seename{Sjá}%
   \def\alsoname{Sjá einnig}%
   \def\enclname{Hjálagt}%
   \def\ccname{Samrit}%
   \def\headtoname{Til:}%
   \def\proofname{Sönnun}%
   \def\glossaryname{Orðalisti}%
   }

\def\dateicelandic{%
   \def\today{\number\day.~\ifcase\month\or
    janúar\or febrúar\or mars\or apríl\or maí\or
    júní\or júlí\or ágúst\or september\or
    október\or nóvember\or desember\fi
    \space\number\year}%
    }

%    \end{macrocode}
% \iffalse
%</gloss-icelandic.ldf>
%<*gloss-id.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-id.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-id.ldf}[polyglossia: module for id (Malay)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{malay}

%    \end{macrocode}
% \iffalse
%</gloss-id.ldf>
%<*gloss-interlingua.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-interlingua.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-interlingua.ldf}[polyglossia: module for Interlingua]
\PolyglossiaSetup{interlingua}{
  bcp47=ia,
  bcp47-language=ia,
  bcp47-script=Latn,
  hyphennames={interlingua},
  hyphenmins={2,2},
  langtag=INA,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{interlingua}{ia}

\def\captionsinterlingua{%
   \def\refname{Referentias}%
   \def\abstractname{Summario}%
   \def\bibname{Bibliographia}%
   \def\prefacename{Prefacio}%
   \def\chaptername{Capitulo}%
   \def\appendixname{Appendice}%
   \def\contentsname{Contento}%
   \def\listfigurename{Lista de figuras}%
   \def\listtablename{Lista de tabellas}%
   \def\indexname{Indice}%
   \def\figurename{Figura}%
   \def\tablename{Tabella}%
   \def\partname{Parte}%
   %\def\thepart{}%
   \def\pagename{Pagina}%
   \def\seename{vide}%
   \def\alsoname{vide etiam}%
   \def\enclname{Incluso}%
   \def\ccname{Copia}%
   \def\headtoname{A}%
   \def\proofname{Prova}%
   \def\glossaryname{Glossario}%
   }
\def\dateinterlingua{%
   \def\today{le~\number\day\space de \ifcase\month\or
    januario\or februario\or martio\or april\or maio\or junio\or
    julio\or augusto\or septembre\or octobre\or novembre\or
    decembre\fi
    \space \number\year}}

%    \end{macrocode}
% \iffalse
%</gloss-interlingua.ldf>
%<*gloss-irish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-irish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-irish.ldf}[polyglossia: module for Irish]

% We only provide this gloss for babel compatibility. Since irish is 
% a gaelic variety, we use 'gaelic' with variant 'irish' now.

\xpg@load@master@language{gaelic}

%    \end{macrocode}
% \iffalse
%</gloss-irish.ldf>
%<*gloss-is.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-is.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-is.ldf}[polyglossia: module for is (Icelandic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{icelandic}

%    \end{macrocode}
% \iffalse
%</gloss-is.ldf>
%<*gloss-it.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-it.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-it.ldf}[polyglossia: module for it (Italian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{italian}

%    \end{macrocode}
% \iffalse
%</gloss-it.ldf>
%<*gloss-italian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-italian.ldf}
%    \begin{macrocode}
% !TEX encoding = UTF-8 Unicode
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-italian.ldf}[polyglossia: module for Italian]
\PolyglossiaSetup{italian}{
  bcp47=it,
  bcp47-language=it,
  bcp47-region=IT,
  bcp47-script=Latn,
  hyphennames={italian},
  hyphenmins={2,2},
  langtag=ITA,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{italian}{it}


%%% CHANGES START %%% by Enrico Gregorio
\define@boolkey{italian}[italian@]{babelshorthands}[true]{}

% Register default options
\xpg@initialize@gloss@options{italian}{babelshorthands=false}

\ifsystem@babelshorthands
  \setkeys{italian}{babelshorthands=true}
\else
  \setkeys{italian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\italian@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{italian}%
  \declare@shorthand{italian}{"}{%
    \relax\ifmmode
      \def\xpgit@next{''}%
    \else
      \def\xpgit@next{\futurelet\xpgit@temp\xpgit@cwm}%
    \fi
  \xpgit@next}%
}

%%% By Enrico Gregorio and Claudio Beccari %%%
\def\xpgit@@cwm{\nobreak\discretionary{-}{}{}\nobreak\hskip\z@skip}
\def\xpgit@cwm{\let\xpgit@@next\relax
  \ifcat\noexpand\xpgit@temp a%
    \def\xpgit@@next{\xpgit@@cwm}%
  \else
    \if\noexpand\xpgit@temp \string|%
      \def\xpgit@@next##1{\xpgit@@cwm}%
    \else
      \if\noexpand\xpgit@temp \string<%
        \def\xpgit@@next##1{«\ignorespaces}%
      \else
        \if\noexpand\xpgit@temp \string>%
          \def\xpgit@@next##1{\unskip »}%
        \else
          \if\noexpand\xpgit@temp\string/%
            \def\xpgit@@next##1{\slash}%
          \else
            \ifx\xpgit@temp"%
              \def\xpgit@@next##1{?}%
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
  \xpgit@@next}

\def\noitalian@shorthands{%
  \xpg@deactivate@shorthands%
}
%%% CHANGES END %%%

%%% ORIGINAL %%% by Claudio Beccari
\def\captionsitalian{%
  \def\prefacename{Prefazione}%
  \def\refname{Riferimenti bibliografici}%
  \def\abstractname{Sommario}%
  \def\bibname{Bibliografia}%
  \def\chaptername{Capitolo}%
  \def\appendixname{Appendice}%
  \def\contentsname{Indice}%
  \def\listfigurename{Elenco delle figure}%
  \def\listtablename{Elenco delle tabelle}%
  \def\indexname{Indice analitico}%
  \def\figurename{Figura}%
  \def\tablename{Tabella}%
  \def\partname{Parte}%
  \def\enclname{Allegati}%
  \def\ccname{e~p.~c.}%
  \def\headtoname{Per}%
  \def\pagename{Pag.}%    % in Italian the abbreviation is preferred
  \def\seename{vedi}%
  \def\alsoname{vedi anche}%
  \def\proofname{Dimostrazione}%
  \def\glossaryname{Glossario}%
   }
\def\dateitalian{%
   \def\today{\number\day~\ifcase\month\or
    gennaio\or febbraio\or marzo\or aprile\or maggio\or giugno\or
    luglio\or agosto\or settembre\or ottobre\or novembre\or
    dicembre\fi\space \number\year}}
%%% ORIGINAL END %%%

%%% CHANGES START %%% by Enrico Gregorio
\let\xpgit@savedvalues\empty
\AtEndPreamble{% the user or the class might define different values
  \edef\xpgit@savedvalues{%
    \clubpenalty=\the\clubpenalty\space
    \@clubpenalty=\the\@clubpenalty\space
    \widowpenalty=\the\widowpenalty\space
    \finalhyphendemerits=\the\finalhyphendemerits}
}


\def\noextras@italian{%
   \lccode\string"2019=\z@%
   \ifitalian@babelshorthands\noitalian@shorthands\fi%
   \xpgit@savedvalues%
}

\def\blockextras@italian{%
   \lccode\string"2019=\string"2019%
   \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
   \finalhyphendemerits=50000000%
   \ifitalian@babelshorthands\italian@shorthands\else\noitalian@shorthands\fi%
}

\def\inlineextras@italian{%
   \lccode\string"2019=\string"2019%
   \ifitalian@babelshorthands\italian@shorthands\else\noitalian@shorthands\fi%
}
%%% CHANGES END %%%
%    \end{macrocode}
% \iffalse
%</gloss-italian.ldf>
%<*gloss-ja.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ja.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ja.ldf}[polyglossia: module for ja (Japanese)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{japanese}

%    \end{macrocode}
% \iffalse
%</gloss-ja.ldf>
%<*gloss-japanese.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-japanese.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-japanese.ldf}[polyglossia: module for Japanese]

\PolyglossiaSetup{japanese}{
	bcp47=ja,
	bcp47-language=ja,
	bcp47-region=JP,
	bcp47-script=Hrkt,
	script=CJK,
	language=Japanese,
	langtag=JAN,
	hyphennames={nohyphenation},
	frenchspacing=false,
	fontsetup=true,
	localnumeral=japanesenumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{japanese}{ja}

\def\japanese@capsformat{%
	\def\@seccntformat##1{%
		\csname pre##1\endcsname%
		\csname the##1\endcsname%
		\csname post##1\endcsname%
	}%
	\def\postsection{節\space}%
	\def\postsubsection{節\space}%
	\def\postsubsubsection{節\space}%
	\def\presection{第}%
	\def\presubsection{第}%
	\def\presubsubsection{第}%
}

\def\captionsjapanese{%
	\def\refname{参考文献}%
	\def\abstractname{概要}%
	\def\bibname{文献目録}%
	\def\prefacename{端書き}%
	\def\chaptername##1##2{第##1##2 章}%
	\def\appendixname{付録}%
	\def\contentsname{目次}%
	\def\listfigurename{図目次}%
	\def\listtablename{表目次}%
	\def\indexname{索引}%
	\def\figurename{図}%
	\def\tablename{表}%
	\def\partname##1##2{第##1##2 部}%
	\def\pagename##1##2{第##1##2 頁}%
	\def\seename{参照}%
	\def\alsoname{参照}%
	\def\enclname{添付}%
	\def\ccname{同報}%
	\def\headtoname{宛先}%
	\def\proofname{証明}%
	\def\glossaryname{用語集}%
 }

\newif\if@WameiReki \@WameiRekifalse%
\newif\if@WameiTosi \@WameiTosifalse%
\newif\if@WameiTuki \@WameiTukifalse%
\newif\if@WameiHi \@WameiHifalse%
\newif\if@IzumoTuki \@IzumoTukifalse%
\newcount\c@TempJNum%

\def\@JapaneseDigit#1{%
	\ifcase#1\or 一\or 二\or 三\or 四\or 五\or%
		六\or 七\or 八\or 九\or 十\or%
		十一\or 十二\or 十三\or 十四\or 十五\or%
		十六\or 十七\or 十八\or 十九\or 廿\or%
		廿一\or 廿二\or 廿三\or 廿四\or 廿五\or%
		廿六\or 廿七\or 廿八\or 廿九\or 丗\or%
		丗一\or 丗二\or 丗三\or 丗四\or 丗五\or%
		丗六\or 丗七\or 丗八\or 丗九\or 四十\or%
		四十一\or 四十二\or 四十三\or 四十四\or 四十五\or%
		四十六\or 四十七\or 四十八\or 四十九\or 五十\or%
		五十一\or 五十二\or 五十三\or 五十四\or 五十五\or%
		五十六\or 五十七\or 五十八\or 五十九\or 六十\or%
		六十一\or 六十二\or 六十三\or 六十四\or 六十五\or%
		六十六\or 六十七\or 六十八\or 六十九\or 七十\or%
		七十一\or 七十二\or 七十三\or 七十四\or 七十五\or%
		七十六\or 七十七\or 七十八\or 七十九\or 八十\or%
		八十一\or 八十二\or 八十三\or 八十四\or 八十五\or%
		八十六\or 八十七\or 八十八\or 八十九\or 九十\or%
		九十一\or 九十二\or 九十三\or 九十四\or 九十五\or%
		九十六\or 九十七\or 九十八\or 九十九%
	\else
		\@ctrerr%
	\fi\relax%
}

\def\@JapaneseNum#1{%
	\c@TempJNum=#1\divide\c@TempJNum by 1000\relax%
	\ifnum\c@TempJNum=\z@\c@TempJNum=#1%
		\divide\c@TempJNum by 100\relax%
		\ifnum\c@TempJNum=\z@\@JapaneseDigit{#1}\relax%
		\else
			\ifcase\c@TempJNum\or 百\or 二百\or 三百\or 四百\or 五百\or
				六百\or 七百\or 八百\or 九百%
			\fi
			\c@TempJNum=#1\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@JapaneseDigit\c@TempJNum\relax%
		\fi%
	\else
		\ifcase\c@TempJNum\or 千\or 二千\or 三千\or 四千\or 五千\or
			六千\or 七千\or 八千\or 九千%
		\fi
		\c@TempJNum=#1\divide\c@TempJNum by 1000\multiply\c@TempJNum by -1000\advance\c@TempJNum#1\divide\c@TempJNum by 100\relax%
		\ifnum\c@TempJNum=\z@\c@TempJNum=#1%
			\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@JapaneseDigit\c@TempJNum\relax%
		\else
			\ifcase\c@TempJNum\or 百\or 二百\or 三百\or 四百\or 五百\or
				六百\or 七百\or 八百\or 九百%
			\fi
			\c@TempJNum=#1\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@JapaneseDigit\c@TempJNum\relax%
		\fi
	\fi
}

\def\@japanesenumber#1{%
	\@tempcnta=#1%
	\ifnum\@tempcnta=\z@{〇}%
	\else
		\ifnum\@tempcnta<\z@{負}%
			\multiply\@tempcnta by -1%
		\fi
		\@tempcntb=\@tempcnta\divide\@tempcntb by 10000\relax%
		\ifnum\@tempcntb=\z@\@JapaneseNum%
			\@tempcnta%
		\else
			\@tempcntb=\@tempcnta\divide\@tempcntb by 100000000\relax%
			\ifnum\@tempcntb=\z@\@tempcntb=\@tempcnta%
				\divide\@tempcntb by 10000%
				\@JapaneseNum\@tempcntb{万}\@tempcntb=\@tempcnta%
				\divide\@tempcntb by 10000\multiply\@tempcntb by -10000%
				\advance\@tempcntb\@tempcnta\relax\@JapaneseNum\@tempcntb%
			\else
				\@JapaneseNum\@tempcntb{億}\@tempcntb=\@tempcnta%
				\divide\@tempcntb by 100000000\multiply\@tempcntb by -100000000%
				\advance\@tempcntb\@tempcnta\divide\@tempcntb by 10000\relax%
				\ifnum\@tempcntb=\z@%
				\else
					\@JapaneseNum\@tempcntb{万}%
				\fi
				\@tempcntb=\@tempcnta\divide\@tempcntb by 10000%
				\multiply\@tempcntb by -10000\advance\@tempcntb\@tempcnta%
				\@JapaneseNum\@tempcntb%
			\fi
		\fi
	\fi
}

\def\japanesenumber#1{%
	\expandafter\@japanesenumber\csname c@#1\endcsname%
}

\newcommand{\japanesenumerals}[2]{\@japanesenumber{#2}}

\def\datejapanese{%
	{%
		\ifnum\year<1868%
			\xdef\the@WarekiCur{}%
		\else
			\ifnum\year<1912%
				\xdef\the@WarekiCur{明治}\advance\year-1867\relax%
			\else
				\ifnum\year<1926%
					\xdef\the@WarekiCur{大正}\advance\year-1911\relax%
  				\else
					\ifnum\year<1989%
						\xdef\the@WarekiCur{昭和}\advance\year-1925\relax%
  					\else
						\xdef\the@WarekiCur{平成}\advance\year-1988\relax%
					\fi
				\fi
			\fi
		\fi
		\xdef\the@WameiTosi{\the\year}%
	}%
	\def\西暦{\@WameiRekifalse \@WameiTukifalse \@WameiHifalse}%
	\def\和暦{\@WameiRekitrue \@WameiTosifalse \@WameiTukifalse \@WameiHifalse}%
	\def\和名暦{\@WameiTositrue \@WameiTukitrue \@WameiHitrue}%
	\def\数字暦{\@WameiTosifalse \@WameiTukifalse \@WameiHifalse}%
	\def\出雲月{\@IzumoTukitrue}%
	\def\大和月{\@IzumoTukifalse}%
	\def\today{%
		\if@WameiReki%
			\the@WarekiCur%
			\if@WameiTosi%
				\@JapaneseNum\the@WameiTosi%
			\else
				\,\the@WameiTosi%
			\fi
		\else
			\number\year\,%
		\fi
		{年}%
		\if@WameiTuki%
			\ifcase\month\or 睦月\or 如月\or 弥生\or 卯月\or 皐月\or
				水無月\or 文月\or 葉月\or 長月\or
				\if@IzumoTuki 神在月\else 神無月\fi
				\or 霜月\or 師走%
			\fi
		\else
			\,\number\month\,%
		{月}%
		\fi
		\if@WameiHi%
			\@JapaneseNum\day%
		\else
			\,\number\day\,%
		\fi
		{日}%
	}%
}

\def\noextras@japanese{%
	\japanese@capsformat%
}

\def\blockextras@japanese{%
	\japanese@capsformat%
}

\def\inlineextras@japanese{%
	\japanese@capsformat%
}
% Based on contributions of Toru Inagaki, Norio Iwase, François Charette

%    \end{macrocode}
% \iffalse
%</gloss-japanese.ldf>
%<*gloss-ka.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ka.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ka.ldf}[polyglossia: module for ka (Georgian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{georgian}

%    \end{macrocode}
% \iffalse
%</gloss-ka.ldf>
%<*gloss-kannada.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kannada.ldf}
%    \begin{macrocode}
%% gloss-kannada.ldf
%% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%%
%% Copyright 2011 Aravinda VK <hallimanearavind AT gmail.com>,
%%                Shankar Prasad <prasad.mvs AT gmail.com>,
%%                Team Sanchaya <dev AT lists.sanchaya.net>
%
% 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 Aravinda VK <hallimanearavind AT gmail.com>.
%
% This work consists of the file gloss-kannada.ldf
\ProvidesFile{gloss-kannada.ldf}[polyglossia: module for Kannada]

\PolyglossiaSetup{kannada}{
  bcp47=kn,
  bcp47-language=kn,
  bcp47-region=IN,
  bcp47-script=Knda,
  script=Kannada,
  scripttag=knda,
  langtag=KAN,
  hyphennames={kannada},
  hyphenmins={2,2}, 
  fontsetup=true,
  localnumeral=kannadanumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{kannada}{kn}

%% Defining Kannada digits equivalents to english
\def\kannadadigits#1{\expandafter\@kannada@digits #1@}
\def\@kannada@digits#1{%
  \ifx @#1% then terminate
  \else
    \ifx0#1೦\else\ifx1#1೧\else\ifx2#1೨\else\ifx3#1೩\else\ifx4#1೪\else\ifx5#1೫\else\ifx6#1೬\else\ifx7#1೭\else\ifx8#1೮\else\ifx9#1೯\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@kannada@digits
  \fi
}

%% \kannada@numerals variable will be set to true or false depending on the option provided in \setmainlanguage
%% \kannada@numerals true by default or when we set \setmainlanguage[numerals=Kannada]{kannada}
%% \kannada@numerals false when we set \setmainlanguage[numerals=Western]{kannada}
\def\tmp@western{Western}
\newif\ifkannada@numerals
\kannada@numeralstrue

\define@key{kannada}{numerals}[Kannada]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@western
    \kannada@numeralsfalse
  \fi}

  
\def\captionskannada{%
  \def\prefacename{ಮುನ್ನುಡಿ}%
  \def\refname{ಉಲ್ಲೇಖಗಳು}%
  \def\abstractname{ಸಾರಾಂಶ}%
  \def\bibname{ಗ್ರಂಥಸೂಚಿ}%
  \def\chaptername{ಅಧ್ಯಾಯ}%
  \def\appendixname{ಅನುಬಂಧ}%
  \def\contentsname{ವಿಷಯಗಳು}%
  \def\listfigurename{ಚಿತ್ರಗಳ ಪಟ್ಟಿ}%
  \def\listtablename{ಕೋಷ್ಟಕಗಳ ಪಟ್ಟಿ}%
  \def\indexname{ಸೂಚಿ}%
  \def\figurename{ಚಿತ್ರ}%
  \def\tablename{ಕೋಷ್ಟಕ}%
  \def\partname{ಭಾಗ}%
  \def\enclname{encl}%
  \def\ccname{cc}%
  \def\headtoname{ಗೆ}%
  \def\pagename{ಪುಟ}%
  \def\seename{ನೋಡು}%
  \def\alsoname{ಇದನ್ನೂ ಸಹ ನೋಡು}%
  \def\proofname{ಕರಡುಪ್ರತಿ}%
}

\def\datekannada{%
  \def\kannadamonth{%
    \ifcase\month\or
    ಜನವರಿ\or
    ಫೆಬ್ರವರಿ\or
    ಮಾರ್ಚ್\or
    ಏಪ್ರಿಲ್\or
    ಮೇ\or
    ಜೂನ್\or
    ಜುಲೈ\or
    ಆಗಷ್ಟ್\or
    ಸೆಪ್ಟೆಂಬರ್\or
    ಅಕ್ಟೋಬರ್\or
    ನವಂಬರ್\or
    ಡಿಸಂಬರ್\fi}%
  \def\today{\kannadanumber\day\space\kannadamonth\space\kannadanumber\year}%
}

\newcommand{\kannadanumerals}[2]{\kannadanumber{#2}}

%% Based on the settings displays respective numbers
\def\kannadanumber#1{%
  \ifkannada@numerals
  \kannadadigits{\number#1}%
  \else
  \number#1%
  \fi
}

%    \end{macrocode}
% \iffalse
%</gloss-kannada.ldf>
%<*gloss-khmer.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-khmer.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-khmer.ldf}[polyglossia: module for Khmer]
\PolyglossiaSetup{khmer}{
  bcp47=km,
  bcp47-language=km,
  bcp47-region=KH,
  bcp47-script=Khmr,
  script=Khmer,%
  scripttag=khmr,%
  langtag=KHM,%
  hyphennames={nohyphenation},%
  fontsetup=true,%
  localnumeral=khmernumerals%
}
\newif\if@khmer@numerals
\def\tmp@khmer{khmer}
\define@key{khmer}{numerals}[arabic]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@khmer%
    \@khmer@numeralstrue%
    \SetLanguageKeys{khmer}{bcp47-extension-u=nu-khmr}%
  \else%
    \@khmer@numeralsfalse%
    \SetLanguageKeys{khmer}{bcp47-extension-u=nu-latn}%
   \fi%
}
\setkeys{khmer}{numerals}
\def\captionskhmer{%
  \def\prefacename{អារម្ភកថា}%
  \def\refname{ឯកសារយោង}%
  \def\abstractname{សង្ខេប}%
  \def\bibname{គន្ថនិទ្ទេស}%
  \def\chaptername{ជំពូក}%
  \def\appendixname{សេចក្ដីបន្ថែម}%
  \def\contentsname{មាតិការ}%
  \def\listfigurename{បញ្ជីរូបភាព}%
  \def\listtablename{បញ្ជីតារាង}%
  \def\indexname{សន្ទស្សន៍}%
  \def\figurename{រូប}%
  \def\tablename{តារាង}%
  \def\partname{ផ្នែក}%
  \def\pagename{ទំព័រ}%
  \def\seename{មើល}%
  \def\alsoname{មើលបន្ថែម}%
  \def\enclname{ឯកសារភ្ជាប់}%
  \def\ccname{ចម្លងជួន}%
  \def\headtoname{ផ្ញើរទៅ}%
  \def\proofname{សម្រាយ}%
  \def\glossaryname{សទានុក្រម}%
}
\def\datekhmer{%
  \def\khmer@month{%
    \ifcase\month\or%
    មករា\or%
    កុម្ភៈ\or%
    មិនា\or%
    មេសា\or%
    ឧសភា\or%
    មិថុនា\or%
    កក្កដា\or%
    សីហា\or%
    កញ្ញា\or%
    តុលា\or%
    វិច្ឆិកា\or%
    ធ្នូ\fi}%
  \def\today{\khmernumber\day\space\khmer@month\space\khmernumber\year}%
}
\def\khmerdigits#1{\expandafter\@khmer@digits #1@}
\def\@khmer@digits#1{%
  \ifx @#1% then terminate
  \else\ifx0#1០%
  \else\ifx1#1១%
  \else\ifx2#1២%
  \else\ifx3#1៣%
  \else\ifx4#1៤%
  \else\ifx5#1៥%
  \else\ifx6#1៦%
  \else\ifx7#1៧%
  \else\ifx8#1៨%
  \else\ifx9#1៩%
  \else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@khmer@digits%
    \fi
}

\newcommand{\khmernumerals}[2]{\khmernumber{#2}}

\def\khmernumber#1{%
  \if@khmer@numerals%
    \khmerdigits{\number#1}%
  \else%
    \number#1%
  \fi}
\def\khmer@globalnumbers{%
  \let\orig@arabic\@arabic%
  \let\@arabic\khmernumber%
  \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
}
\def\nokhmer@globalnumbers{%
  \let\@arabic\orig@arabic%
}
\def\thepart{\arabic{part}}
\def\@khmeralph#1{%
\ifcase#1%
\or ក\or ខ\or គ\or ឃ\or ង%
\or ច\or ឆ\or ជ\or ឈ\or ញ%
\or ដ\or ឋ\or ឌ\or ឍ\or ណ%
\or ត\or ថ\or ទ\or ធ\or ន%
\or ប\or ផ\or ព\or ភ\or ម%
\or យ\or រ\or ល\or វ\or ស\or ហ\or ឡ\or អ%
\else\xpg@ill@value{#1}{@khmeralph}\fi}
\def\khmerAlph#1{\expandafter\@khmerAlph\csname c@#1\endcsname}
\def\@khmerAlph#1{%
\ifcase#1%
\or ក\or ខ\or គ\or ឃ\or ង%
\or ច\or ឆ\or ជ\or ឈ\or ញ%
\or ដ\or ឋ\or ឌ\or ឍ\or ណ%
\or ត\or ថ\or ទ\or ធ\or ន%
\or ប\or ផ\or ព\or ភ\or ម%
\or យ\or រ\or ល\or វ\or ស\or ហ\or ឡ\or អ%
\else\xpg@ill@value{#1}{@khmeralph}\fi}
\def\khmer@numbers{%
  \if@khmer@numerals
    \let\@alph\@khmeralph%
    \let\@Alph\@khmerAlph%
  \fi%
}
\def\nokhmer@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}
\def\blockextras@khmer{%
  \XeTeXlinebreaklocale "kh" % 
  \XeTeXlinebreakskip = 0pt plus 1pt minus 1pt
%  \let\orig@baselinestretch\baselinestretch%
%  \renewcommand{\baselinestretch}{1.2}% not work
}
\def\noblockextras@khmer{% 
  \XeTeXlinebreaklocale "en"%
%  \let\baselinestretch\orig@baselinestretch%
}
\@ifclassloaded{beamer}{%
  \usefonttheme{professionalfonts}%
  \def\factname{ស្វ័យសត្យ}%
  \def\lemmaname{បទគន្លិះ}%
  \def\theoremname{ទ្រឹស្ដីបទ}%
  \def\corollaryname{អនុសាធ្យ}%
  \def\problemname{ចំណោទ}%
  \def\solutionname{ដំណោះស្រាយ}%
  \def\definitionname{និយមន័យ}%
  \def\examplename{ឧទាហរណ៏}%
  \uselanguage{khmer}%
  \languagepath{khmer}%
  \deftranslation[to=khmer]{Fact}{\factname}%
  \deftranslation[to=khmer]{Lemma}{\lemmaname}%
  \deftranslation[to=khmer]{Theorem}{\theoremname}%
  \deftranslation[to=khmer]{Corollary}{\corollaryname}%
  \deftranslation[to=khmer]{Problem}{\problemname}%
  \deftranslation[to=khmer]{Solution}{\solutionname}%
  \deftranslation[to=khmer]{Definition}{\definitionname}%
  \deftranslation[to=khmer]{Definitions}{\definitionname}%
  \deftranslation[to=khmer]{Example}{\examplename}%
  \deftranslation[to=khmer]{Examples}{\examplename}%
  \AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
    {\noexpand\headcommand{\noexpand\def\noexpand%
    \inserttotalframenumber{\localnumeral*{framenumber}}}}}}%
}{}
%    \end{macrocode}
% \iffalse
%</gloss-khmer.ldf>
%<*gloss-km.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-km.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-km.ldf}[polyglossia: module for km (Khmer)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{khmer}

%    \end{macrocode}
% \iffalse
%</gloss-km.ldf>
%<*gloss-kmr-Arab.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kmr-Arab.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-kmr-Arab.ldf}[polyglossia: module for kmr-Arab (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-kmr-Arab.ldf>
%<*gloss-kmr-Latn.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kmr-Latn.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-kmr-Latn.ldf}[polyglossia: module for kmr-Latn (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-kmr-Latn.ldf>
%<*gloss-kmr.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kmr.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-kmr.ldf}[polyglossia: module for kmr (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-kmr.ldf>
%<*gloss-kn.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kn.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-kn.ldf}[polyglossia: module for kn (Kannada)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kannada}

%    \end{macrocode}
% \iffalse
%</gloss-kn.ldf>
%<*gloss-ko.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ko.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ko.ldf}[polyglossia: module for ko (Korean)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{korean}

%    \end{macrocode}
% \iffalse
%</gloss-ko.ldf>
%<*gloss-korean.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-korean.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-korean.ldf}[polyglossia: module for Korean]

\PolyglossiaSetup{korean}{
  bcp47=ko,
  bcp47-language=ko,
  bcp47-script=Kore,
  script=Hangul,
  scripttag=hang,
  language=Korean,
  langtag=KOR,
  hyphennames={nohyphenation},
  frenchspacing=true,
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*{korean}{ko}

% variant : plain (0), classic (1), or modern (2)
\define@choicekey{korean}{variant}[\xpg@val\xpg@nr]{plain,classic,modern}[plain]{%
    \let\xpg@korean@variant\xpg@nr
}
% captions : hangul (0) or hanja (1)
\define@choicekey{korean}{captions}[\xpg@val\xpg@nr]{hangul,hanja}[hangul]{%
    \let\xpg@korean@captions\xpg@nr
}
% swapstrings: all (0), headings (1), headers (2), or none (3)
\newif\if@korean@swapheadings
\newif\if@korean@swapheaders
\define@choicekey*+{korean}{swapstrings}[\xpg@val\xpg@nr]{all,headings,headers,none}[all]{%
   \ifcase\xpg@nr\relax
      % all:
      \@korean@swapheadingstrue%
      \@korean@swapheaderstrue%
   \or
      % headings:
      \@korean@swapheadingstrue%
      \@korean@swapheadersfalse%
   \or
      % headers:
      \@korean@swapheadingsfalse%
      \@korean@swapheaderstrue%
   \or
      % none:
      \@korean@swapheadingsfalse%
      \@korean@swapheadersfalse%
   \fi
   \xpg@info{Option: Korean, swapstrings=\xpg@val}%
}{\xpg@warning{Unknown Korean swapstrings value `#1'}}

% Register default options
\xpg@initialize@gloss@options{korean}{variant=plain,swapstrings=all,captions=hangul}

\def\captionskorean{%
    \ifcase\xpg@korean@captions\relax
        \captions@korean@hangul
    \else
        \captions@korean@hanja
    \fi
    \def\seename{$\rightarrow$}%
    \def\alsoname{$\Rightarrow$}%
}
\def\captions@korean@hangul{%
    \def\koreanTHEname{제}%
    \def\partname{편}%
    \def\chaptername{장}%
    \def\refname{참고문헌}%
    \def\abstractname{요약}%
    \def\bibname{참고문헌}%
    \def\prefacename{서문}%
    \def\appendixname{부록}%
    \def\contentsname{차례}%
    \def\listfigurename{그림 차례}%
    \def\listtablename{표 차례}%
    \def\indexname{찾아보기}%
    \def\figurename{그림}%
    \def\tablename{표}%
    \def\pagename{페이지}%
    \def\enclname{동봉}%
    \def\proofname{증명}%
    \def\headtoname{수신:}%
    \def\ccname{사본}%
    \def\glossaryname{용어집}%
}
\def\captions@korean@hanja{%
    \def\koreanTHEname{第}%
    \def\partname{篇}%
    \def\chaptername{章}%
    \def\refname{參考文獻}%
    \def\abstractname{要約}%
    \def\bibname{參考文獻}%
    \def\prefacename{序文}%
    \def\appendixname{附錄}%
    \def\contentsname{目次}%
    \def\listfigurename{圖版 目次}%
    \def\listtablename{表 目次}%
    \def\indexname{索引}%
    \def\figurename{圖版}%
    \def\tablename{表}%
    \def\pagename{面}%
    \def\enclname{同封}%
    \def\proofname{證明}%
    \def\headtoname{受信:}%
    \def\ccname{寫本}%
    \def\glossaryname{用語集}%
}

\def\korean@appendix@chapapp{\appendixname}% to exclude appendix

\def\korean@headingsformat{%
  % change chapter and part headings
  \if@korean@swapheadings
    % With titlesec
    \ifcsdef{titleformat}{%
      \ifcsdef{NR@part}{% Hyperref (nameref)
        \let\xpg@save@part@format\NR@part
        \patchcmd{\NR@part}%
                 {\partname\nobreakspace\thepart}%
                 {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                 {}%
                 {\xpg@warning{Failed to patch part for Korean}}%
      }{% not hyperref
        \ifcsdef{@part}{%
            \let\xpg@save@part@format\@part
            \patchcmd{\@part}%
                     {\partname\nobreakspace\thepart}%
                     {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                     {}%
                     {\xpg@warning{Failed to patch part for Korean}}%
        }{}%
      }
      \ifcsdef{chapter}{%
        \titleformat\chapter[display]%
          {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}%
          {%
            \ifx\@chapapp\korean@appendix@chapapp
              \appendixname\space \thechapter
            \else
              \koreanTHEname\space \thechapter\space \@chapapp
            \fi
          }{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}%
      }{}%
    }{% (not \ifdefined\titleformat)
      % With KOMA
      \ifcsdef{sectionformat}{%
        \ifcsdef{partformat}{%
          \let\xpg@save@part@format\partformat
          \renewcommand*{\partformat}{\koreanTHEname~\thepart~\partname}%
        }{}%
        \ifcsdef{chapterformat}{%
          \let\xpg@save@chap@format\chapterformat
          \renewcommand*{\chapterformat}{\mbox{%
            \IfChapterUsesPrefixLine
            {%
              \ifx\@chapapp\korean@appendix@chapapp
                \chapapp\nobreakspace \thechapter\autodot
              \else
                \koreanTHEname\nobreakspace \thechapter\nobreakspace \chapapp\autodot
              \fi
            }%
            {\thechapter\autodot\enskip}%
          }}%
        }{}%
      }{% (not \ifdefined\sectionformat)
        % With memoir
        \ifcsdef{@memptsize}{%
          \ifcsdef{@makechapterhead}{%
            \let\xpg@save@chap@format\@makechapterhead
            \patchcmd{\@makechapterhead}%
                     {\printchaptername \chapternamenum \printchapternum}%
                     {%
                       \ifx\@chapapp\korean@appendix@chapapp
                         \printchaptername\relax\chapternamenum \printchapternum
                       \else
                         \printkoreanchapterthe \printchapternum\chapternamenum \printchaptername
                       \fi
                     }%
                     {}%
                     {\xpg@warning{Failed to patch chapter for Korean}}%
            \ifdefined\printkoreanchapterthe\else
              \def\printkoreanchapterthe{%
                \ifpatchable\printchaptername\@chapapp
                  {\chapnamefont\koreanTHEname\chapternamenum}{}}%
            \fi
          }{}%
          \ifcsdef{NR@part}{% Hyperref (nameref)
            \let\xpg@save@part@format\NR@part
            \patchcmd{\NR@part}%
                     {\printpartname \partnamenum \printpartnum}%
                     {\printkoreanpartthe \printpartnum\partnamenum \printpartname}%
                     {}%
                     {\xpg@warning{Failed to patch part for Korean}}%
            \ifdefined\printkoreanpartthe\else
              \def\printkoreanpartthe{\partnamefont\koreanTHEname\partnamenum}%
            \fi
          }{% not hyperref
            \ifcsdef{@part}{%
              \let\xpg@save@part@format\@part
              \patchcmd{\@part}%
                       {\printpartname \partnamenum \printpartnum}%
                       {\printkoreanpartthe \printpartnum\partnamenum \printpartname}%
                       {}%
                       {\xpg@warning{Failed to patch part for Korean}}%
              \ifdefined\printkoreanpartthe\else
                \def\printkoreanpartthe{\partnamefont\koreanTHEname\partnamenum}%
              \fi
            }{}%
          }%
        }{% (not \ifdefined\@memptsize)
          % With standard classes
          \ifcsdef{@makechapterhead}{%
            \let\xpg@save@chap@format\@makechapterhead
            \patchcmd{\@makechapterhead}%
                     {\@chapapp\space \thechapter}%
                     {%
                       \ifx\@chapapp\korean@appendix@chapapp
                         \appendixname\space \thechapter
                       \else
                         \koreanTHEname\space \thechapter\space \@chapapp
                       \fi
                     }%
                     {}%
                     {\xpg@warning{Failed to patch chapter for Korean}}%
          }{}%
          \ifcsdef{NR@part}{% Hyperref (nameref)
            \let\xpg@save@part@format\NR@part
            \patchcmd{\NR@part}%
                     {\partname\nobreakspace\thepart}%
                     {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                     {}%
                     {\xpg@warning{Failed to patch part for Korean}}%
          }{% not hyperref
            \ifcsdef{@part}{%
              \ifpatchable{\@part}%
                   {\partname\nobreakspace\thepart}%
                   {\let\xpg@save@part@format\@part
                    \patchcmd{\@part}%
                             {\partname\nobreakspace\thepart}%
                             {\koreanTHEname\nobreakspace \thepart\nobreakspace \partname}%
                             {}%
                             {\ifcsdef{part}{\xpg@warning{Failed to patch part for Korean}}{}}}%
                   {}%
            }{}%  (end \ifdefined\@part)
          }% (end not hyperref)
        }% (end \ifdefined\@memptsize)
      }% (end \ifdefined\sectionformat)
    }% (end \ifdefined\titleformat)
  \fi % (end \if@korean@swapheadings)
  %
  % Change running headers
  \if@korean@swapheaders
    \ifcsdef{chapterformat}{%
      % With KOMA
      \let\xpg@save@chaptermark@format\chaptermarkformat
      \renewcommand*\chaptermarkformat{%
        \IfChapterUsesPrefixLine
        {%
          \ifx\@chapapp\korean@appendix@chapapp
            \chapapp\ \thechapter\autodot
          \else
            \koreanTHEname\ \thechapter\ \chapapp\autodot
          \fi
        }%
        {\thechapter\autodot}%
        \enskip
      }%
    }{% (not \ifdefined\chapterformat)
      \ifcsdef{@memptsize}{%
        % With memoir
        \let\xpg@save@chaptermark@format\chaptermark
        \patchcmd{\chaptermark}%
                 {\@chapapp\ \@nameuse{thechapter}}%
                 {%
                   \ifx\@chapapp\korean@appendix@chapapp
                     \appendixname\ \@nameuse{thechapter}%
                   \else
                     \koreanTHEname\ \@nameuse{thechapter}\ \@chapapp
                   \fi
                 }%
                 {}%
                 {\xpg@warning{Failed to patch chaptermark for Korean}}%
      }{% (not \ifdefined\@memptsize)
        % With standard classes
        \ifcsdef{chaptermark}{%
          \ifpatchable{\chaptermark}%
               {\@chapapp\ \thechapter}%
               {\let\xpg@save@chaptermark@format\chaptermark
                \patchcmd{\chaptermark}%
                         {\@chapapp\ \thechapter}%
                         {%
                           \ifx\@chapapp\korean@appendix@chapapp
                             \appendixname\ \thechapter
                           \else
                             \koreanTHEname\ \thechapter\ \@chapapp
                           \fi
                         }%
                         {}%
                         {\xpg@warning{Failed to patch chaptermark for Korean}}}%
               {}%
        }{}% (end \ifdefined\chaptermark)
      }% (end \ifdefined\@memptsize)
    }% (end \ifdefined\chapterformat)
  \fi % (end \if@korean@swapheaders)
}

\def\nokorean@headingsformat{%
  % Reset chapter and part heading
  \ifcsdef{titleformat}{%
    % With titlesec
    \ifcsdef{xpg@save@part@format}{%
      \ifcsdef{NR@part}{%
        \let\NR@part\xpg@save@part@format
      }{%
        \let\@part\xpg@save@part@format
      }%
    }{}%
    \ifcsdef{chapter}{%
      \titleformat\chapter[display]%
        {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}%
        {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}%
    }{}%
  }{% (not \ifdefined\titleformat)
    \ifcsdef{sectionformat}{%
      % With KOMA
      \ifcsdef{xpg@save@part@format}{%
        \let\partformat\xpg@save@part@format
      }{}%
      \ifcsdef{xpg@save@chap@format}{%
        \let\chapterformat\xpg@save@chap@format
      }{}%
    }{%
      % With memoir and standard classes
      \ifcsdef{xpg@save@part@format}{%
        \ifcsdef{NR@part}{%
          \let\NR@part\xpg@save@part@format
        }{%
          \let\@part\xpg@save@part@format
        }%
      }{}%
      \ifcsdef{xpg@save@chap@format}{%
        \let\@makechapterhead\xpg@save@chap@format
      }{}%
    }% (end \ifdefined\sectionformat)
  }% (end \ifdefined\titleformat)
  %
  % Reset headers
  \ifcsdef{chaptermarkformat}{%
    % With KOMA
    \ifcsdef{xpg@save@chaptermark@format}{%
      \let\chaptermarkformat\xpg@save@chaptermark@format
    }{}%
  }{%
    \ifcsdef{chaptermark}{%
      % With memoir and standard classes
      \ifcsdef{xpg@save@chaptermark@format}{%
        \let\chaptermark\xpg@save@chaptermark@format
      }{}%
    }{}% (end \ifdefined\chaptermark)
  }% (end \ifdefined\chapterformat)
}

\def\datekorean{%
    \ifcase\xpg@korean@captions\relax
        \def\today{\the\year 년 \the\month 월 \the\day 일}%
    \else
        \def\today{\the\year 年 \the\month 月 \the\day 日}%
    \fi
}

\def\koreanAlph#1{\expandafter\@koreanAlph\csname c@#1\endcsname}
\def\@koreanAlph#1{%
    \ifcase#1\or 가\or 나\or 다\or 라\or 마\or 바\or 사\or 아\or 자\or
    차\or 카\or 타\or 파\or 하\else\xpg@ill@value{#1}{@koreanAlph}\fi
}

\def\koreanalph#1{\expandafter\@koreanalph\csname c@#1\endcsname}
\def\@koreanalph#1{%
    \ifcase#1\or ㄱ\or ㄴ\or ㄷ\or ㄹ\or ㅁ\or ㅂ\or ㅅ\or ㅇ\or ㅈ\or
    ㅊ\or ㅋ\or ㅌ\or ㅍ\or ㅎ\else\xpg@ill@value{#1}{@koreanalph}\fi
}

\def\korean@numbers{%
    \let\@alph\@koreanalph
    \let\@Alph\@koreanAlph
}
\def\nokorean@numbers{%
    \let\@alph\latin@alph
    \let\@Alph\latin@Alph
}
\let\nokorean@globalnumbers\nokorean@numbers

\ifxetex
    \def\inlineextras@korean{%
        \ifcase\xpg@korean@variant\relax
            \XeTeXinterchartokenstate\z@
            \XeTeXlinebreakpenalty 50
        \or
            \setvariantkoreaninterchartoks
            \setvariantkoreancharclasses
            \def\XPGKOhalfdim{\dimexpr.5em\relax}%
            \XeTeXinterchartokenstate\@ne
            \XeTeXlinebreakpenalty \z@
        \else
            \setvariantkoreaninterchartoks
            \setvariantkoreancharclasses
            \def\XPGKOhalfdim{\dimexpr.5\fontdimen\tw@\font\relax}%
            \XeTeXinterchartokenstate\@ne
            \XeTeXlinebreakpenalty 50
        \fi
        \XeTeXlinebreakskip 0pt plus.05em minus .01em
        \XeTeXlinebreaklocale "ko"
    }
    \def\noextras@korean{%
        \ifcase\xpg@korean@variant\relax
        \else
            \unsetvariantkoreaninterchartoks
            \unsetvariantkoreancharclasses
        \fi
        \XeTeXinterchartokenstate\z@
        \XeTeXlinebreakpenalty\z@
        \XeTeXlinebreakskip\z@skip
        \XeTeXlinebreaklocale "en"
        \noextras@korean@common
    }
\else % luatex
    \def\inlineextras@korean{\xpg@attr@korean\xpg@korean@variant\relax}
    \def\noextras@korean{%
        \unsetattribute\xpg@attr@korean
        \noextras@korean@common
    }
\fi

\def\blockextras@korean{%
    \inlineextras@korean
    \korean@headingsformat
}

\def\noextras@korean@common{%
    \nokorean@headingsformat
}

\ifluatex % luatex
\protected\def\inhibitglue{\hskip\z@skip}
\ifdefined\newattribute\else
    \let\newattribute\newluatexattribute
    \let\unsetattribute\unsetluatexattribute
\fi
\newattribute\xpg@attr@korean
\newattribute\xpg@attr@autojosa
% user commands for Josa
% Josa : particles in Korean grammar that immediately follow a noun or pronoun.
%        Josa might vary depending on previous character.
\protected\def\rieul{\global\let\xpg@josa@zwang\@ne}
\protected\def\jung {\global\let\xpg@josa@zwang\tw@}
\protected\def\jong {\global\let\xpg@josa@zwang\thr@@}
\protected\def\은{\begingroup\xpg@attr@autojosa\xpg@josa@zwang 은\endgroup\xpg@reset@josa}
\let\는\은
\protected\def\을{\begingroup\xpg@attr@autojosa\xpg@josa@zwang 을\endgroup\xpg@reset@josa}
\let\를\을
\protected\def\와{\begingroup\xpg@attr@autojosa\xpg@josa@zwang 와\endgroup\xpg@reset@josa}
\let\과\와
\protected\def\가{\begingroup\xpg@attr@autojosa\xpg@josa@zwang 가\endgroup\xpg@reset@josa}
\protected\def\이{\begingroup\xpg@attr@autojosa\xpg@josa@zwang 이\endgroup\xpg@reset@josa}
\protected\def\라{\이 라}
\protected\def\으{\begingroup\xpg@attr@autojosa\xpg@josa@zwang 으\endgroup\xpg@reset@josa}
\protected\def\로{\으 로}
\def\xpg@reset@josa {\global\let\xpg@josa@zwang\z@}\xpg@reset@josa
% load lua file for korean
\directlua{ require "polyglossia-korean" }
%    \end{macrocode}
% \iffalse
%</gloss-korean.ldf>
%<*gloss-ku-Arab.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ku-Arab.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ku-Arab.ldf}[polyglossia: module for ku-Arab (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-ku-Arab.ldf>
%<*gloss-ku-Latn.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ku-Latn.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ku-Latn.ldf}[polyglossia: module for ku-Latn (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-ku-Latn.ldf>
%<*gloss-ku.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ku.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ku.ldf}[polyglossia: module for ku (Kurdish)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-ku.ldf>
%<*gloss-kurdish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kurdish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
% Created on September 1, 2019
% Last updated on May 17, 2020
% Sina Ahmadi (ahmadi.sina@outlook.com)
% For more information, visit the Kurdish XeLaTeX Users Group at https://github.com/KurdishXeLaTeX
\ProvidesFile{gloss-kurdish.ldf}[polyglossia: module for Kurdish]

\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{farsical}
\RequirePackage{hijrical}

\PolyglossiaSetup{kurdish}{
  bcp47=ckb,
  bcp47-language=ckb,
  bcp47-script=Arab,
  bcp47-casing=ckb-Arab,
  script=Arabic,
  direction=RL,
  scripttag=arab,
  langtag=KUR,
  hyphennames={nohyphenation},
  fontsetup=true,
  localnumeral=kurdishnumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{kurdish}{ku}
\setlanguagealias*[variant=kurmanji,script=latin]{kurdish}{kmr-Latn}
\setlanguagealias*[variant=sorani]{kurdish}{ckb}
\setlanguagealias*[variant=kurmanji,script=arabic]{kurdish}{kmr-Arab}
\setlanguagealias*[script=latin]{kurdish}{ku-Latn}
\setlanguagealias*[variant=sorani,script=arabic]{kurdish}{ckb-Arab}
\setlanguagealias*[variant=sorani,script=latin]{kurdish}{ckb-Latn}
\setlanguagealias*[script=arabic]{kurdish}{ku-Arab}
\setlanguagealias*[variant=kurmanji]{kurdish}{kmr}

% Babel aliases
\setlanguagealias[variant=kurmanji]{kurdish}{kurmanji}

\newif\if@kurdish@kurmanji
\def\kurdish@variant{sorani}
\define@choicekey*+{kurdish}{variant}[\xpg@val\xpg@nr]{sorani,kurmanji}[sorani]{%
   \ifcase\xpg@nr\relax
      % sorani:
      \def\kurdish@variant{sorani}%
      \@kurdish@kurmanjifalse%
   \or
      % kurmanji:
      \def\kurdish@variant{kurmanji}%
      \@kurdish@kurmanjitrue%
   \fi
   \kurdish@set@variety%
   \xpg@info{Option: kurdish, variant=\xpg@val}%
}{\xpg@warning{Unknown Kurdish variant `#1'}}

\newif\if@kurdish@latin
\newif\if@kurdish@arabic
\define@choicekey*+{kurdish}{script}[\xpg@val\xpg@nr]{arabic,latin}{%
   \ifcase\xpg@nr\relax
      % arabic:
      \@kurdish@latinfalse%
      \@kurdish@arabictrue%
   \or
      % latin:
      \@kurdish@latintrue%
      \@kurdish@arabicfalse%
   \fi
   \kurdish@set@variety%
   \xpg@info{Option: kurdish, script=\xpg@val}%
}{\xpg@warning{Unknown Kurdish script `#1'}}


\newif\if@western@numerals
\newif\if@force@western@numerals
\def\kurdish@script{arabic}
\def\kurdish@pattern{nohyphenation}

\def\kurdish@set@variety{%
  \if@kurdish@latin% latin explicitly set
     \@western@numeralstrue%
     \if@kurdish@kurmanji
         \def\kurdish@pattern{kurmanji}%
         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji,bcp47=kmr-Latn,bcp47-language=kmr,bcp47-script=Latn,bcp47-casing=kmr-Latn}%
     \else
         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurdish,bcp47=ckb-Arab,bcp47-language=ckb,bcp47-script=Arab,bcp47-casing=ckb-Arab}%
     \fi
     \def\kurdish@script{latin}
     \xpg@fontsetup@latin{kurdish}%
  \else
     \if@kurdish@arabic% arabic explicitly set
        \if@kurdish@kurmanji
            \if@force@western@numerals\else\@western@numeralsfalse\fi%
            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurmanji,bcp47=kmr-Arab,bcp47-language=kmr,bcp47-script=Arab,bcp47-casing=kmr-Arab}%
            \def\kurdish@script{arabic}%
        \else
            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=ckb-Arab,bcp47-language=ckb,bcp47-script=Arab,bcp47-casing=ckb-Arab}%
        \fi
        \xpg@fontsetup@nonlatin{kurdish}%
     \else% sorani=arabic, kurmanji=latin
        \if@kurdish@kurmanji
            \@western@numeralstrue%
            \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurmanji,bcp47=kmr-Latn,bcp47-language=kmr,bcp47-script=Latn,bcp47-casing=kmr-Latn}%
            \xpg@fontsetup@latin{kurdish}%
            \def\kurdish@script{latin}
        \else
            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=ckb-Arab,bcp47-language=ckb,bcp47-script=Arab,bcp47-casing=ckb-Arab}%
            \xpg@fontsetup@nonlatin{kurdish}%
        \fi
     \fi
  \fi
}

\newif\if@western@numerals
\define@choicekey*+{kurdish}{numerals}[\xpg@val\xpg@nr]{eastern,western}[eastern]{%
   \ifcase\xpg@nr\relax
      % eastern:
      \@western@numeralsfalse%
   \or
      % western:
      \@western@numeralstrue%
      \@force@western@numeralstrue%
   \fi
   \xpg@info{Option: Kurdish, numerals=\xpg@val}%
}{\xpg@warning{Unknown Kurdish numerals option `#1'}}

\newif\ifkurdish@customsep\kurdish@customsepfalse
\def\xpg@sepmark{}
\define@key{kurdish}{sectionsep}[.]{%
   \kurdish@customseptrue%
   \gdef\xpg@sepmark{#1}%
}

%this is needed for \abjad in arabicnumbers.sty
\define@boolkey{kurdish}[kurdish@]{abjadjimnotail}[true]{%
  \ifkurdish@abjadjimnotail
    \abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi%
}

% NOT YET USED
\define@key{kurdish}{locale}[default]{%
  \def\@kurdish@locale{#1}}

%TODO add option for CALENDAR

% Register default options
\xpg@initialize@gloss@options{kurdish}{variant=sorani,locale=default,script=arabic,abjadjimnotail=false,numerals=eastern}

\def\kurdish@language{%
   \polyglossia@setup@language@patterns{\kurdish@pattern}%
}%

\def\kurdishNativemonth#1{\ifcase#1%
  \or رێبەندان\or رەشەمێ\or خاكەلێوە\or گوڵان\or جۆزەردان\or پووشپەڕ\or خەرمانان\or گەلاوێژ\or رەزبەر\or گەڵارێزان\or سەرماوەز\or بەفرانبار\fi}
\def\kurdishmonth#1{\ifcase#1%
  \or كانوونی دووهەم\or شوبات\or ئازار\or نیسان\or ئایار\or حوزەیران\or تەممووز\or ئاب\or ئەیلوول\or تشرینی یەكەم\or تشرینی دووهەم\or كانوونی یەكەم\fi}

%\Hijritoday is now locale-aware and will format the date with this macro:
\DefineFormatHijriDate{kurdish}{%
  \@ensure@RTL{%
    \kurdishnumber{\value{Hijriday}}\space\HijriMonthArabic{\value{Hijrimonth}}\space\kurdishnumber{\value{Hijriyear}}%
  }%
}

\def\captionskurdish@sorani@arabic{%
  \def\prefacename{\@ensure@RTL{پێشەكی}}%
  \def\refname{\@ensure@RTL{سەرچاوەکان}}%
  \def\abstractname{\@ensure@RTL{پوختە}}%
  \def\bibname{\@ensure@RTL{کتێبنامە}}%
  \def\chaptername{\@ensure@RTL{بەندی}}%
  \def\appendixname{\@ensure@RTL{پاشکۆ}}%
  \def\contentsname{\@ensure@RTL{نێوەڕۆک}}%
  \def\listfigurename{\@ensure@RTL{لیستی وێنەکان}}%
  \def\listtablename{\@ensure@RTL{لیستی خشتەکان}}%
  \def\indexname{\@ensure@RTL{پێنوێن}}%
  \def\figurename{\@ensure@RTL{وێنەی}}%
  \def\tablename{\@ensure@RTL{خشتەی}}%
  \def\partname{\@ensure@RTL{بەشی}}%
  \def\enclname{\@ensure@RTL{هاوپێچ}}%
  \def\ccname{\@ensure@RTL{ڕوونووس}}%
  \def\headtoname{\@ensure@RTL{بۆ}}%
  \def\pagename{\@ensure@RTL{لاپەڕە}}%
  \def\seename{\@ensure@RTL{چاو لێکەن}}%
  \def\alsoname{\@ensure@RTL{هەروەها چاو لێکەن}}%
  \def\proofname{\@ensure@RTL{سەلماندن}}%
  \def\glossaryname{\@ensure@RTL{فەرهەنگۆک}}%
}

\def\captionskurdish@sorani@latin{%
  \def\prefacename{Pêşekî}%
  \def\refname{Serçawekan}%
  \def\abstractname{Puxte}%
  \def\bibname{Kitêbname}%
  \def\chaptername{Bendî}%
  \def\appendixname{Paşko}%
  \def\contentsname{Nêweřok}%
  \def\listfigurename{Lîstî Wênekan}%
  \def\listtablename{Lîstî Xiştekan}%
  \def\indexname{Pêřist}%
  \def\figurename{Wêney}%
  \def\tablename{Xiştey}%
  \def\partname{Beşî}%
  \def\enclname{Hawpêç}%
  \def\ccname{Řûnûs}%
  \def\headtoname{Bo}%
  \def\pagename{Lapeře}%
  \def\seename{Çaw lêken}%
  \def\alsoname{Herweha çaw lêken}%
  \def\proofname{Selmandin}%
  \def\glossaryname{Ferhengok}%
}

\def\captionskurdish@kurmanji@latin{%
  \def\prefacename{Peşgotin}%
  \def\refname{Jêder}%
  \def\abstractname{Kurtebîr}%
  \def\bibname{Çavkanîya Pirtukan}%
  \def\chaptername{Serê}%
  \def\appendixname{Tebînîya}%
  \def\contentsname{Navêrok}%
  \def\listfigurename{Hejmara Dimena}%
  \def\listtablename{Hejmara Kevalen}%
  \def\indexname{Endeks}%
  \def\figurename{Dimenê}%
  \def\tablename{Kevala}%
  \def\partname{Bêşa}%
  \def\enclname{Dumahik}%
  \def\ccname{Belavker}%
  \def\headtoname{Ji bo}%
  \def\pagename{Rûpelê}%
  \def\seename{binêra}%
  \def\alsoname{li vêya jî binêra}%
  \def\proofname{Delîl}%
  \def\glossaryname{Çavkanîya lêkolînê}%
}

\def\captionskurdish@kurmanji@arabic{%
  \def\prefacename{\@ensure@RTL{پێشگۆتن}}%
  \def\refname{\@ensure@RTL{ژێدەر}}%
  \def\abstractname{\@ensure@RTL{کورتەبیر}}%
  \def\bibname{\@ensure@RTL{چاڤکانییا پرتووکان}}%
  \def\chaptername{\@ensure@RTL{سەرێ}}%
  \def\appendixname{\@ensure@RTL{پاشکۆ}}%
  \def\contentsname{\@ensure@RTL{ناڤێرۆک}}%
  \def\listfigurename{\@ensure@RTL{هەژمارا دیمەنا}}%
  \def\listtablename{\@ensure@RTL{هەژمارا کەڤالێن}}%
  \def\indexname{\@ensure@RTL{پێرست}}%
  \def\figurename{\@ensure@RTL{دیمەنێ}}%
  \def\tablename{\@ensure@RTL{کەڤالا}}%
  \def\partname{\@ensure@RTL{بەشا}}%
  \def\enclname{\@ensure@RTL{دوماهک}}%
  \def\ccname{\@ensure@RTL{بەلاڤکەر}}%
  \def\headtoname{\@ensure@RTL{ژ بۆ}}%
  \def\pagename{\@ensure@RTL{رووپەلێ}}%
  \def\seename{\@ensure@RTL{بنێرا}}%
  \def\alsoname{\@ensure@RTL{لە ڤێیا ژ بنێرا}}%
  \def\proofname{\@ensure@RTL{دەلیل}}%
  \def\glossaryname{\@ensure@RTL{چاڤکانییا لێکۆلینێ}}%
}

\def\captionskurdish{%
  \csname captionskurdish@\kurdish@variant @\kurdish@script\endcsname%
}

\def\datekurdish@sorani@arabic{%
   \def\today{\@ensure@RTL{\kurdishnumber\day{ی}\space\kurdishmonth{\month}{ی}\space\kurdishnumber\year}}%
}

\def\datekurdish@sorani@latin{%
  \def\today{%
     \number\day ~\ifcase\month\or
      \januaryname\or \februaryname\or \marchname\or \aprilname\or
      \mayname\or \junename\or \julyname\or \augustname\or
      \septembername\or \octobername\or \novembername\or
      \decembername\or \@ctrerr\fi~\number\year}%
  \def\ontoday{%
      \number\day î~\ifcase\month\or
      \januaryname\or \februaryname\or \marchname\or \aprilname\or
      \mayname\or \junename\or \julyname\or \augustname\or
      \septembername\or \octobername\or \novembername\or
      \decembername\or \@ctrerr\fi î~\number\year}%
  \def\januaryname{Kanûnî Yekem}%
  \def\februaryname{Şubat}%
  \def\marchname{Azar}%
  \def\aprilname{Nîsan}%
  \def\mayname{Ayar}%
  \def\junename{Huzeyran}%
  \def\julyname{Temmûz}%
  \def\augustname{Ab}%
  \def\septembername{Eylûl}%
  \def\octobername{Tişrînî Yekem}%
  \def\novembername{Tişrînî Dûhem}%
  \def\decembername{Kanûnî Dûhem}%
}

\def\datekurdish@kurmanji@latin{%
  \def\today{%
     \number\day ~\ifcase\month\or
      \januaryname\or \februaryname\or \marchname\or \aprilname\or
      \mayname\or \junename\or \julyname\or \augustname\or
      \septembername\or \octobername\or \novembername\or
      \decembername\or \@ctrerr\fi~\number\year}%
  \def\ontoday{%
      \number\day ê~\ifcase\month\or
      \januaryname\or \februaryname\or \marchname\or \aprilname\or
      \mayname\or \junename\or \julyname\or \augustname\or
      \septembername\or \octobername\or \novembername\or
      \decembername\or \@ctrerr\fi ê~\number\year}%
  \def\januaryname{Çileya Paşîn}%
  \def\februaryname{Sibat}%
  \def\marchname{Adar}%
  \def\aprilname{Nîsan}%
  \def\mayname{Gulan}%
  \def\junename{Hezîran}%
  \def\julyname{Tîrmeh}%
  \def\augustname{Tebax}%
  \def\septembername{Îlon}%
  \def\octobername{Çiriya Pêşîn}%
  \def\novembername{Çiriya Paşîn}%
  \def\decembername{Çileya Pêşîn}%
}

\def\kurdishmonthkurmanji#1{\ifcase#1%
  چلەیا پاشین \or شبات \or ئادار \or نیسان \or گولان \or حەزیران \or تیرمەهـ \or تەباخ \or ئیلۆن \or چریا پێشین \or چریا پاشین \or چلەیا پێشین\fi}

\def\datekurdish@kurmanji@arabic{%
   \def\today{\@ensure@RTL{\kurdishnumber\day\space\kurdishmonthkurmanji{\month}\space\kurdishnumber\year}}%
}

% TODO: babel-kurmanji has these "alternative" month names
% How to integrate them ("montnames=alternative" is not really good)?
% It seems the month name question is all but straightforward:
% https://en.wikipedia.org/wiki/Kurdish_calendar#Names
%\def\datekurdish@kurmanji@alternate{%
%  \datekurdish@kurmanji
%  \def\januaryname{Rêbendan}%
%  \def\februaryname{Reşemih}%
%  \def\aprilname{Cotan}%           % Avrêl
%  \def\junename{Pûşper}%
%  \def\augustname{Gelavêj}%
%  \def\septembername{Gelarezan}%   % Rezber
%  \def\octobername{Kewçêr}%
%  \def\novembername{Sermawez}%
%  \def\decembername{Berfandar}%
%}

\def\datekurdish{%
  \csname datekurdish@\kurdish@variant @\kurdish@script\endcsname%
}

% Use \providecommand here as the ldf file might
% be reloaded via BCP.
\providecommand{\kurdishnumerals}[2]{\kurdishnumber{#2}}

\def\kurdishnumber#1{%
  \if@western@numerals
    \number#1%
  \else
    \xpg@if@char@available{06F0}%
          {\@ensure@LTR{\farsidigits{\number#1}}}%
          {\@ensure@LTR{\arabicdigits{\number#1}}}%
  \fi
}

%\def\kurdishnum#1{\expandafter\kurdishnumber\csname c@#1\endcsname}
%\def\kurdishbracenum#1{(\expandafter\kurdishnumber\csname c@#1\endcsname)}
%\def\kurdishornatebracenum#1{\char"FD3E\expandafter\kurdishnumber\csname c@#1\endcsname\char"FD3F}
%\def\kurdishalph#1{\expandafter\@farsialph\csname c@#1\endcsname}

\def\kurdish@numbers{%
  \if@western@numerals%
  \else%
     \let\@alph\abjad%
     \let\@Alph\abjad%
  \fi%
}

\def\nokurdish@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
}

\def\kurdish@globalnumbers{%
   \let\@arabic\kurdishnumber%
   \renewcommand\thefootnote{\localnumeral*{footnote}}%
   \renewcommand\theequation{\localnumeral*{equation}}%
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\nokurdish@globalnumbers{
   \let\@arabic\xpg@save@arabic%
   \renewcommand\thefootnote{\protect\number{\c@footnote}}%
}

\def\kurdish@xetex@capsformat{%
  \let\xpg@save@sepmark\@SepMark%
  \SepMark{\xpg@sepmark}
}

\def\nokurdish@xetex@capsformat{%
   \ifcsdef{xpg@save@sepmark}{%
     \SepMark{\xpg@save@sepmark}
   }{}%
}

\def\kurdish@luatex@capsformat{%
  %
  % change chapter and part headings
  \ifkurdish@customsep
     \ifcsdef{chapter}{%
        \let\xpg@save@thesection\thesection%
        \renewcommand*\thesection{\thechapter\xpg@sepmark\@arabic\c@section}
        \let\xpg@save@theequation\theequation%
        \renewcommand*\theequation{%
	    \ifnum \c@chapter>\z@ \thechapter\xpg@sepmark\fi\@arabic\c@equation}
        \let\xpg@save@thefigure\thefigure%
	\renewcommand*\thefigure{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@figure}
        \let\xpg@save@thetable\thetable%
	\renewcommand*\thetable{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@table}
     }{}
     \let\xpg@save@thesubsection\thesubsection%
     \renewcommand\thesubsection
	{\thesection\xpg@sepmark\@arabic\c@subsection}
     \let\xpg@save@thesubsubsection\thesubsubsection%
     \renewcommand\thesubsubsection{\thesubsection\xpg@sepmark\@arabic\c@subsubsection}
     \let\xpg@save@theparagraph\theparagraph%
     \renewcommand\theparagraph
         {\thesubsubsection\xpg@sepmark\@arabic\c@paragraph}
     \let\xpg@save@thesubparagraph\thesubparagraph%
     \renewcommand\thesubparagraph{\theparagraph\xpg@sepmark\@arabic\c@subparagraph}
  \fi% (end \ifkurdish@customsep)
}

\def\nokurdish@luatex@capsformat{%
   \ifcsdef{xpg@save@thesection}{%
        \let\thesection\xpg@save@thesection%
   }{}%
   \ifcsdef{xpg@save@theequation}{%
        \let\theequation\xpg@save@theequation%
   }{}%
   \ifcsdef{xpg@save@thefigure}{%
        \let\thefigure\xpg@save@thefigure%
   }{}%
   \ifcsdef{xpg@save@thetable}{%
        \let\thetable\xpg@save@thetable%
   }{}%
   \ifcsdef{xpg@save@thesubsection}{%
        \let\thesubsection\xpg@save@thesubsection%
   \ifcsdef{xpg@save@thesubsubsection}{%
        \let\thesubsubsection\xpg@save@thesubsubsection%
   }{}%
   }{}%
   \ifcsdef{xpg@save@theparagraph}{%
        \let\theparagraph\xpg@save@theparagraph%
   }{}%
   \ifcsdef{xpg@save@thesubparagraph}{%
        \let\thesubparagraph\xpg@save@thesubparagraph%
   }{}%
}

\def\blockextras@kurdish{%
   \ifkurdish@customsep
      \ifxetex
        \kurdish@xetex@capsformat
      \else
        \kurdish@luatex@capsformat
      \fi   
   \fi
}
%
\def\noextras@kurdish{%
    \ifkurdish@customsep
      \ifxetex
        \nokurdish@xetex@capsformat
      \else
        \nokurdish@luatex@capsformat
      \fi   
   \fi
}

%    \end{macrocode}
% \iffalse
%</gloss-kurdish.ldf>
%<*gloss-kurmanji.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kurmanji.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-kurmanji.ldf}[polyglossia: module for Kurmanji Kurdish]

% We provide this gloss for babel compatibility.

\xpg@load@master@language{kurdish}

%    \end{macrocode}
% \iffalse
%</gloss-kurmanji.ldf>
%<*gloss-la-x-classic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-la-x-classic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-la-xclassic.ldf}[polyglossia: module for la-xclassic (Latin)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{latin}

%    \end{macrocode}
% \iffalse
%</gloss-la-x-classic.ldf>
%<*gloss-la-x-ecclesia.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-la-x-ecclesia.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-la-xecclesiastic.ldf}[polyglossia: module for la-xecclesiastic (Latin)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{latin}

%    \end{macrocode}
% \iffalse
%</gloss-la-x-ecclesia.ldf>
%<*gloss-la-x-medieval.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-la-x-medieval.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-la-xmedieval.ldf}[polyglossia: module for la-xmedieval (Latin)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{latin}

%    \end{macrocode}
% \iffalse
%</gloss-la-x-medieval.ldf>
%<*gloss-la.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-la.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-la.ldf}[polyglossia: module for la (Latin)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{latin}

%    \end{macrocode}
% \iffalse
%</gloss-la.ldf>
%<*gloss-lao.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lao.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-lao.ldf}[polyglossia: module for Lao]

\PolyglossiaSetup{lao}{
  bcp47=lo,
  bcp47-language=lo,
  bcp47-script=Laoo,
  script=Lao,
  scripttag=lao,
  langtag=LAO,
  hyphennames={lao},
  hyphenmins={1,1},
  fontsetup=true,
  localnumeral=laonumerals
  %TODO localalph={xxx@alph,xxx@Alph}
  %TODO localdigits=laonumber
}

% BCP-47 compliant aliases
\setlanguagealias*{lao}{lo}

\newif\if@lao@numerals
\def\tmp@lao{lao}
\define@key{lao}{numerals}[arabic]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@lao\@lao@numeralstrue\else
	  \@lao@numeralsfalse\fi
}

% Register default options
\xpg@initialize@gloss@options{lao}{numerals=arabic}

% Translations provided by Brian Wilson <bountonw at gmail.com>
\def\captionslao{%
  \def\prefacename{ຄໍານໍາ}%
  \def\refname{ໜັງສືອ້າງອີງ}%
  \def\abstractname{ບົດຫຍໍ້ຄວາມ}%
  \def\bibname{ເອກະສານອ້າງອີງ}%
  \def\chaptername{ບົດທີ}%
  \def\appendixname{ພາກຄັດຕິດ}%
  \def\contentsname{ສາລະບານ}%
  \def\listfigurename{ສາລະບານຮູບ}%
  \def\listtablename{ສາລະບານຕາຕະລາງ}%
  \def\indexname{ດັດຊະນີ}%
  \def\figurename{ຮູບທີ}%
  \def\tablename{ຕາຕະລາງທີ}%
  \def\partname{ພາກ}%
  \def\pagename{ໜ້າ}%
  \def\seename{ອ່ານ}%
  \def\alsoname{ອ່ານເພີ່ມ}%
  \def\enclname{ເອກະສານປະກອບ}%
  \def\ccname{ສໍາເນົາເຖິງ}%
  \def\headtoname{ຮຽນ}%
  \def\proofname{ຂໍ້ພິສູດ}%
  \def\glossaryname{ປະມວນສັບ}% 
}
\def\datelao{%   
   \def\lao@month{%
     \ifcase\month\or
      ມັງກອນ\or
      ກຸມພາ\or
      ມີນາ\or
      ເມສາ\or
      ພຶດສະພາ\or
      ມິຖຸນາ\or
      ກໍລະກົດ\or
      ສິງຫາ\or
      ກັນຍາ\or
      ຕຸລາ\or
      ພະຈິກ\or
      ທັນວາ\fi}%
   \def\today{\laonumber\day \space \lao@month \space \laonumber\year}%
}

\def\laodigits#1{\expandafter\@lao@digits #1@}
\def\@lao@digits#1{%
  \ifx @#1% then terminate
  \else
    \ifx0#1໐\else\ifx1#1໑\else\ifx2#1໒\else\ifx3#1໓\else\ifx4#1໔\else\ifx5#1໕\else\ifx6#1໖\else\ifx7#1໗\else\ifx8#1໘\else\ifx9#1໙\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@lao@digits
  \fi
}

\newcommand{\laonumerals}[2]{\laonumber{#2}}

\def\laonumber#1{%
  \if@lao@numerals
    \laodigits{\number#1}%
  \else
    \number#1%
  \fi}

\def\lao@globalnumbers{%
   \let\orig@arabic\@arabic%
   \let\@arabic\laonumber%
   \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
}
\def\nolao@globalnumbers{%
   \let\@arabic\orig@arabic%
}

%    \end{macrocode}
% \iffalse
%</gloss-lao.ldf>
%<*gloss-latin.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latin.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin]

\ExplSyntaxOn

\PolyglossiaSetup {latin}
  {
    bcp47 = la,
    bcp47-language = la,
    bcp47-script = Latn,
    hyphenmins = {2,2},
    frenchspacing = true,
    fontsetup = true,
    langtag = LAT
  }

% BCP-47 compliant aliases
\setlanguagealias*{latin}{la}
\setlanguagealias*[variant=classic]{latin}{la-x-classic}
\setlanguagealias*[variant=ecclesiastic]{latin}{la-x-ecclesia}
\setlanguagealias*[variant=medieval]{latin}{la-x-medieval}

% Babel aliases
\setlanguagealias[variant=classic]{latin}{classiclatin}
\setlanguagealias[variant=ecclesiastic]{latin}{ecclesiasticlatin}
\setlanguagealias[variant=medieval]{latin}{medievallatin}


%%%%% Variables and commands concerning spelling

\bool_new:N \l_polyglossia_latin_use_j_bool
\bool_new:N \l_polyglossia_latin_use_v_bool
\bool_new:N \l_polyglossia_latin_use_ligatures_bool
\bool_new:N \l_polyglossia_latin_capitalize_month_bool

\cs_new:Npn \polyglossia_latin_classical_character_codes:
  {
    \char_set_lccode:nn {`\V} {`\u}
    \char_set_uccode:nn {`\u} {`\V}
    \char_set_uccode:nn {`\ú} {`\V}
    \char_set_uccode:nn {`\ū} {`\V}
    \char_set_uccode:nn {`\ŭ} {`\V}
  }

\cs_new:Npn \polyglossia_latin_modern_character_codes:
  {
    \char_set_lccode:nn {`\V} {`\v}
    \char_set_uccode:nn {`\u} {`\U}
    \char_set_uccode:nn {`\ú} {`\Ú}
    \char_set_uccode:nn {`\ū} {`\Ū}
    \char_set_uccode:nn {`\ŭ} {`\Ŭ}
  }


%%%%% Messages and commands concerning hyphenation

\msg_new:nnn {polyglossia} {latin / missing modern patterns}
  {
    The~hyphenation~patterns~for~modern~Latin~were~not~found~\msg_line_context:.
  }

\msg_new:nnn {polyglossia} {latin / missing patterns}
  {
    The~"#1"~hyphenation~patterns~were~not~found~\msg_line_context:.~
    I~will~use~the~patterns~for~modern~Latin~instead.
  }

\cs_new:Npn \polyglossia_latin_use_modern_patterns:
  {
    \xpg@ifdefined {latin}
      {
        \def \latin@language
          {
            \polyglossia@setup@language@patterns {latin}
            \str_case:Vn \l_polyglossia_latin_variant_str
              {
                {classic}      { \adddialect \l@classiclatin \l@latin }
                {medieval}     { \adddialect \l@medievallatin \l@latin }
                {ecclesiastic} { \adddialect \l@ecclesiasticlatin \l@latin }
              }
          }
      }
      {
        \msg_warning:nn {polyglossia} {latin / missing modern patterns}
        \str_case:Vn \l_polyglossia_latin_variant_str
          {
            {classic}      { \adddialect \l@classiclatin \l@nohyphenation }
            {medieval}     { \adddialect \l@medievallatin \l@nohyphenation }
            {modern}       { \adddialect \l@latin \l@nohyphenation }
            {ecclesiastic} { \adddialect \l@ecclesiasticlatin \l@nohyphenation }
          }
      }
  }

\cs_new:Npn \polyglossia_latin_set_patterns:n #1
% #1 may be "classiclatin" or "liturgicallatin"
  {
    \xpg@ifdefined {#1}
      {
        \def \latin@language
          {
            \polyglossia@setup@language@patterns {#1}
            \str_case:Vn \l_polyglossia_latin_variant_str
              {
                {classic}      {
                                 \str_if_eq:nnF {#1} {classiclatin}
                                   {
                                     \adddialect \l@classiclatin  { \use:c {l@#1} }
                                   }
                               }
                {medieval}     { \adddialect \l@medievallatin { \use:c {l@#1} } }
                {modern}       { \adddialect \l@latin { \use:c {l@#1} } }
                {ecclesiastic} { \adddialect \l@ecclesiasticlatin { \use:c {l@#1} } }
              }
          }
      }
      {
        \msg_warning:nnn {polyglossia} {latin / missing patterns} {#1}
        \polyglossia_latin_use_modern_patterns:
      }
  }


%%%%% Settings for the spacing of the punctuation for ecclesiastical Latin

\bool_new:N \g_polyglossia_latin_punctuation_spacing_bool

\sys_if_engine_luatex:TF
  {
    \directlua { require('polyglossia-latin') }
  }
  {
    \newXeTeXintercharclass \g_polyglossia_latin_question_exclamation_class
    \newXeTeXintercharclass \g_polyglossia_latin_colon_semicolon_class
    \newXeTeXintercharclass \g_polyglossia_latin_opening_guillemet_class
    \newXeTeXintercharclass \g_polyglossia_latin_closing_guillemet_class
    \newXeTeXintercharclass \g_polyglossia_latin_opening_bracket_class
    \newXeTeXintercharclass \g_polyglossia_latin_closing_bracket_class

    \cs_new:Npn \polyglossia_latin_insert_punctuation_space:
      {
        \nobreak
        \skip_horizontal:n { 0.08333 \fontdimen6 \font } % 1/12 quad
      }
    \cs_new:Npn \polyglossia_latin_replace_preceding_space:
      {
        \dim_compare:nNnT {\lastskip} > {\c_zero_dim} {\unskip}
        \polyglossia_latin_insert_punctuation_space:
      }
    \cs_new:Npn \polyglossia_latin_replace_following_space:
      {
        \polyglossia_latin_insert_punctuation_space:
        \ignorespaces
      }
  }

\cs_new:Npn \polyglossia_latin_punctuation_spacing:
  {
    \sys_if_engine_luatex:TF
      {
        \directlua { polyglossia.activate_latin_punct() }
      }
      {
        \XeTeXinterchartokenstate = 1
        \XeTeXcharclass `\! \g_polyglossia_latin_question_exclamation_class
        \XeTeXcharclass `\? \g_polyglossia_latin_question_exclamation_class
        \XeTeXcharclass `\‼ \g_polyglossia_latin_question_exclamation_class
        \XeTeXcharclass `\⁇ \g_polyglossia_latin_question_exclamation_class
        \XeTeXcharclass `\⁈ \g_polyglossia_latin_question_exclamation_class
        \XeTeXcharclass `\⁉ \g_polyglossia_latin_question_exclamation_class
        \XeTeXcharclass `\‽ \g_polyglossia_latin_question_exclamation_class
        \XeTeXcharclass `\; \g_polyglossia_latin_colon_semicolon_class
        \XeTeXcharclass `\: \g_polyglossia_latin_colon_semicolon_class
        \XeTeXcharclass `\« \g_polyglossia_latin_opening_guillemet_class
        \XeTeXcharclass `\» \g_polyglossia_latin_closing_guillemet_class
        \XeTeXcharclass `\‹ \g_polyglossia_latin_opening_guillemet_class
        \XeTeXcharclass `\› \g_polyglossia_latin_closing_guillemet_class
        \XeTeXcharclass `\( \g_polyglossia_latin_opening_bracket_class
        \XeTeXcharclass `\) \g_polyglossia_latin_closing_bracket_class
        \XeTeXcharclass `\[ \g_polyglossia_latin_opening_bracket_class
        \XeTeXcharclass `\] \g_polyglossia_latin_closing_bracket_class
        \XeTeXcharclass `\{ \g_polyglossia_latin_opening_bracket_class
        \XeTeXcharclass `\} \g_polyglossia_latin_closing_bracket_class
        \XeTeXcharclass `\⟨ \g_polyglossia_latin_opening_bracket_class
        \XeTeXcharclass `\⟩ \g_polyglossia_latin_closing_bracket_class

        % question or exclamation mark followed by a closing guillemet
        \XeTeXinterchartoks \g_polyglossia_latin_question_exclamation_class \g_polyglossia_latin_closing_guillemet_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % question or exclamation mark followed by a colon or semicolon
        \XeTeXinterchartoks \g_polyglossia_latin_question_exclamation_class \g_polyglossia_latin_colon_semicolon_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % colon or semicolon followed by a closing guillemet
        \XeTeXinterchartoks \g_polyglossia_latin_colon_semicolon_class \g_polyglossia_latin_closing_guillemet_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % closing bracket followed by a question or exclamation mark
        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_question_exclamation_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % closing bracket followed by a colon or semicolon
        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_colon_semicolon_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % closing bracket followed by a closing guillemet
        \XeTeXinterchartoks \g_polyglossia_latin_closing_bracket_class \g_polyglossia_latin_closing_guillemet_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % opening guillemet followed by a space
        \XeTeXinterchartoks \g_polyglossia_latin_opening_guillemet_class \xpg@boundaryclass =
          {
            \polyglossia_latin_replace_following_space:
          }
        % opening guillemet followed by an opening guillemet
        \XeTeXinterchartoks \g_polyglossia_latin_opening_guillemet_class \g_polyglossia_latin_opening_guillemet_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % opening guillemet followed by an ordinary character
        \XeTeXinterchartoks \g_polyglossia_latin_opening_guillemet_class \z@ =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % closing guillemet followed by a closing guillemet
        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_closing_guillemet_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % closing guillemet followed by a question or exclamation mark
        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_question_exclamation_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % closing guillemet followed by a colon or semicolon
        \XeTeXinterchartoks \g_polyglossia_latin_closing_guillemet_class \g_polyglossia_latin_colon_semicolon_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % space followed by a question or exclamation mark
        \XeTeXinterchartoks \xpg@boundaryclass \g_polyglossia_latin_question_exclamation_class =
          {
            \polyglossia_latin_replace_preceding_space:
          }
        % space followed by a colon or semicolon
        \XeTeXinterchartoks \xpg@boundaryclass \g_polyglossia_latin_colon_semicolon_class =
          {
            \polyglossia_latin_replace_preceding_space:
          }
        % space followed by closing guillemet
        \XeTeXinterchartoks \xpg@boundaryclass \g_polyglossia_latin_closing_guillemet_class =
          {
            \polyglossia_latin_replace_preceding_space:
          }
        % ordinary character followed by a question or exclamation mark
        \XeTeXinterchartoks \z@ \g_polyglossia_latin_question_exclamation_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % ordinary character followed by a colon or semicolon
        \XeTeXinterchartoks \z@ \g_polyglossia_latin_colon_semicolon_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
        % ordinary character followed by closing guillemet
        \XeTeXinterchartoks \z@ \g_polyglossia_latin_closing_guillemet_class =
          {
            \polyglossia_latin_insert_punctuation_space:
          }
      }
  }

\cs_new:Npn \polyglossia_latin_no_punctuation_spacing:
  {
    \sys_if_engine_luatex:TF
      {
        \directlua { polyglossia.deactivate_latin_punct() }
      }
      {
        \XeTeXcharclass `\! \z@
        \XeTeXcharclass `\? \z@
        \XeTeXcharclass `\‼ \z@
        \XeTeXcharclass `\⁇ \z@
        \XeTeXcharclass `\⁈ \z@
        \XeTeXcharclass `\⁉ \z@
        \XeTeXcharclass `\‽ \z@
        \XeTeXcharclass `\; \z@
        \XeTeXcharclass `\: \z@
        \XeTeXcharclass `\« \z@
        \XeTeXcharclass `\» \z@
        \XeTeXcharclass `\‹ \z@
        \XeTeXcharclass `\› \z@
        \XeTeXcharclass `\( \z@
        \XeTeXcharclass `\) \z@
        \XeTeXcharclass `\[ \z@
        \XeTeXcharclass `\] \z@
        \XeTeXcharclass `\{ \z@
        \XeTeXcharclass `\} \z@
        \XeTeXcharclass `\⟨ \z@
        \XeTeXcharclass `\⟩ \z@
        \XeTeXinterchartokenstate = 0
      }
  }


%%%%% Messages and commands concerning footnotes

% Save original footnote definition
% Do this at the end of the preamble to catch other
% packages' footnote changes (#391)
\AtEndPreamble{%
  \cs_if_exist:NT \@makefntext
    {
      \cs_set_eq:NN \polyglossia_latin_original_footnote:n \@makefntext
    }
}

% This is the footnote style as defined by the "ecclesiastic" package.
\cs_new:Npn \polyglossia_latin_variant_footnote:n #1
  {
    \parindent 1em
    \noindent
    \hbox { \normalfont \@thefnmark . }
    \enspace #1
  }

\msg_new:nnn {polyglossia} {latin / ineffective footnote option}
  {
    The~option~"ecclesiasticfootnotes"~is~ineffective~\msg_line_context:
    \c_space_tl as~Latin~is~not~the~main~language.
  }

\cs_new:Npn \polyglossia_latin_apply_footnote_option:
  {
    \str_if_eq:VnTF \xpg@main@language {latin}
      {
        \cs_if_exist:NT \@makefntext
          {
            \iflatin@ecclesiasticfootnotes
              \let \@makefntext \polyglossia_latin_variant_footnote:n
            \else
              \let \@makefntext \polyglossia_latin_original_footnote:n
            \fi
          }
      }
      {
        \iflatin@ecclesiasticfootnotes
          \msg_warning:nn {polyglossia} {latin / ineffective footnote option}
        \fi
      }
  }

\define@boolkey {latin} [latin@] {ecclesiasticfootnotes} [true]
  {
    \token_if_eq_meaning:NNTF \@onlypreamble \@notprerr
      {
        % within the document
        \polyglossia_latin_apply_footnote_option:
      }
      {
        % within the preamble
        % The application of the option has to be postponed as the main
        % language may be undefined when the option is called.
        \AtBeginDocument { \polyglossia_latin_apply_footnote_option: }
      }
  }


%%%%% Language variants: classic, medieval, modern, and ecclesiastic

\str_new:N \l_polyglossia_latin_variant_str

\msg_new:nnn {polyglossia} {latin / language variant}
  {
    Activating~Latin~language~variant~"#1"~\msg_line_context:.
  }

\msg_new:nnn {polyglossia} {latin / illegal language variant}
  {
    The~Latin~language~variant~"#1"~is~undefined~\msg_line_context:.
  }

\cs_new:Npn \polyglossia_latin_classic_settings:
  {
    \bool_set_false:N \l_polyglossia_latin_use_j_bool
    \bool_set_false:N \l_polyglossia_latin_use_v_bool
    \bool_set_false:N \l_polyglossia_latin_use_ligatures_bool
    \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
    \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
    \str_set:Nn \l_polyglossia_latin_variant_str {classic}
    \SetLanguageKeys {latin} { babelname = classiclatin, bcp47 = la-x-classic, bcp47-extension-x = classic }
    \polyglossia_latin_set_patterns:n {classiclatin}
  }

\cs_new:Npn \polyglossia_latin_medieval_settings:
  {
    \bool_set_false:N \l_polyglossia_latin_use_j_bool
    \bool_set_false:N \l_polyglossia_latin_use_v_bool
    \bool_set_true:N \l_polyglossia_latin_use_ligatures_bool
    \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
    \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
    \str_set:Nn \l_polyglossia_latin_variant_str {medieval}
    \SetLanguageKeys {latin} { babelname = medievallatin, bcp47 = la-x-medieval, bcp47-extension-x = medieval, bcp47-casing = la-x-medieval }
    \polyglossia_latin_use_modern_patterns:
  }

\cs_new:Npn \polyglossia_latin_modern_settings:
  {
    \bool_set_false:N \l_polyglossia_latin_use_j_bool
    \bool_set_true:N \l_polyglossia_latin_use_v_bool
    \bool_set_false:N \l_polyglossia_latin_use_ligatures_bool
    \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
    \bool_set_false:N \l_polyglossia_latin_punctuation_spacing_bool
    \str_set:Nn \l_polyglossia_latin_variant_str {modern}
    \SetLanguageKeys {latin} { babelname = latin, bcp47 = la }
    \polyglossia_latin_use_modern_patterns:
  }

\cs_new:Npn \polyglossia_latin_ecclesiastic_settings:
  {
    \bool_set_false:N \l_polyglossia_latin_use_j_bool
    \bool_set_true:N \l_polyglossia_latin_use_v_bool
    \bool_set_true:N \l_polyglossia_latin_use_ligatures_bool
    \bool_set_false:N \l_polyglossia_latin_capitalize_month_bool
    \bool_set_true:N \l_polyglossia_latin_punctuation_spacing_bool
    \str_set:Nn \l_polyglossia_latin_variant_str {ecclesiastic}
    \SetLanguageKeys {latin} { babelname = ecclesiasticlatin, bcp47 = la-x-ecclesia, bcp47-extension-x = ecclesia }
    \polyglossia_latin_use_modern_patterns:
  }

\define@key{latin}{variant}
  {
    \str_case:nnF {#1}
      {
        {classic}
        {
          \msg_info:nnn {polyglossia} {latin / language variant} {classic}
          \polyglossia_latin_classic_settings:
        }
        {medieval}
        {
          \msg_info:nnn {polyglossia} {latin / language variant} {medieval}
          \polyglossia_latin_medieval_settings:
        }
        {modern}
        {
          \msg_info:nnn {polyglossia} {latin / language variant} {modern}
          \polyglossia_latin_modern_settings:
        }
        {ecclesiastic}
        {
          \msg_info:nnn {polyglossia} {latin / language variant} {ecclesiastic}
          \polyglossia_latin_ecclesiastic_settings:
        }
      }
      {
        \msg_warning:nnn {polyglossia} {latin / illegal language variant} {#1}
      }
  }


%%%%% Boolean options concerning spelling

\define@boolkey{latin}[latin@]{usej}[true]
  {
    \iflatin@usej
      \bool_set_true:N \l_polyglossia_latin_use_j_bool
    \else
      \bool_set_false:N \l_polyglossia_latin_use_j_bool
    \fi
  }

\define@boolkey{latin}[latin@]{capitalizemonth}[true]
  {
    \iflatin@capitalizemonth
      \bool_set_true:N \l_polyglossia_latin_capitalize_month_bool
    \else
      \bool_set_false:N \l_polyglossia_latin_capitalize_month_bool
    \fi
  }


%%%%% Hyphenation variants: classic, liturgical, and modern

\msg_new:nnn {polyglossia} {latin / hyphenation variant}
  {
    Activating~hyphenation~patterns~for~#1~Latin~\msg_line_context:.
  }

\msg_new:nnn {polyglossia} {latin / illegal hyphenation variant}
  {
    The~Latin~hyphenation~variant~"#1"~is~undefined~\msg_line_context:.
  }

\define@key {latin} {hyphenation}
  {
    \str_case:nnTF {#1}
      {
        {classic}    { \polyglossia_latin_set_patterns:n {classiclatin} }
        {liturgical} { \polyglossia_latin_set_patterns:n {liturgicallatin} }
        {modern}     { \polyglossia_latin_use_modern_patterns: }
      }
      {
        \msg_info:nnn {polyglossia} {latin / hyphenation variant} {#1}
      }
      {
        \msg_warning:nnn {polyglossia} {latin / illegal hyphenation variant} {#1}
      }
  }


%%%%% Latin captions and date

\def \captionslatin
  {
    \def \prefacename
      {
        \bool_if:NTF \l_polyglossia_latin_use_ligatures_bool {Præfatio} {Praefatio}
      }
    \def \refname {Conspectus~librorum}
    \def \abstractname {Summarium}
    \def \bibname {Conspectus~librorum}
    \def \chaptername {Caput}
    \def \appendixname {Additamentum}
    \def \contentsname {Index}
    \def \listfigurename {Conspectus~descriptionum}
    \def \listtablename {Conspectus~tabularum}
    \def \indexname {Index~rerum~notabilium}
    \def \figurename {Descriptio}
    \def \tablename {Tabula}
    \def \partname {Pars}
    \def \enclname {Additur}
    \def \ccname {Exemplar}
    \def \headtoname {\ignorespaces}
    \def \pagename {charta}
    \def \seename {cfr.}
    \def \alsoname {cfr.}
    \def \proofname {Demonstratio}
    \def \glossaryname {Glossarium}
  }

\cs_new:Npn \polyglossia_latin_month_name:
  {
    \tl_set:Nx \l_tmpa_tl
      {
        \int_case:nn { \month }
          {
            {1} { \bool_if:NTF \l_polyglossia_latin_use_j_bool {januarii} {ianuarii} }
            {2} {februarii}
            {3} {martii}
            {4} {aprilis}
            {5} { \bool_if:NTF \l_polyglossia_latin_use_j_bool {maji} {maii} }
            {6} { \bool_if:NTF \l_polyglossia_latin_use_j_bool {junii} {iunii} }
            {7} { \bool_if:NTF \l_polyglossia_latin_use_j_bool {julii} {iulii} }
            {8} {augusti}
            {9} {septembris}
            {10} {octobris}
            {11} { \bool_if:NTF \l_polyglossia_latin_use_v_bool {novembris} {nouembris} }
            {12} {decembris}
          }
      }
    \bool_if:NTF \l_polyglossia_latin_capitalize_month_bool
      {
        \text_titlecase:n { \l_tmpa_tl }
      }
      {
        \l_tmpa_tl
      }
  }

\def \datelatin
  {
    \def \today
      {
        \int_to_Roman:n { \day }
        \c_space_tl
        \polyglossia_latin_month_name:
        \c_space_tl
        \int_to_Roman:n { \year }
      }
  }


%%%%% Latin shorthands

\define@boolkey{latin}[latin@]{babelshorthands}[true]
  {
  }

\define@boolkey{latin}[latin@]{prosodicshorthands}[true]
  {
  }

% Register default options
\xpg@initialize@gloss@options{latin}{variant=modern,hyphenation=modern,babelshorthands=false,
                                     prosodicshorthands=false,ecclesiasticfootnotes=false,
                                     usej=false,capitalizemonth=true}

\ifsystem@babelshorthands
  \setkeys{latin}{babelshorthands=true}
\else
  \setkeys{latin}{babelshorthands=false}
\fi

\ExplSyntaxOff % babelsh.def does not support expl3 syntax
\ifcsundef{initiate@active@char}{\input{babelsh.def}}{}
\ExplSyntaxOn

\initiate@active@char {"}
\initiate@active@char {'}
\initiate@active@char {^}
\initiate@active@char {=}

\shorthandoff {"}
\shorthandoff {'}
\shorthandoff* {^}
\shorthandoff {=}

% The active = character may cause problems with key=value interfaces.
% We have to make sure here that no problems can occur outside a Latin
% prosodic shorthand environment.
% The active ^ character may cause problems with TeX's ^^xx convention
% for hexadecimal input. We have to make sure here that no problems can
% occur outside a Latin prosodic shorthand environment.
% The active ' character may cause problems with the unicode-math package
% (in case Latin is used as a secondary language, see #394). We have to
% turn it off if Latin is not the main language.

% For the aux file:
\protected@write \@auxout { }
  {
    \shorthandoff {=}
    \shorthandoff* {^} % #582
  }

\AtBeginDocument
  {
    \str_if_eq:VnTF \xpg@main@language {latin}
      {
        \iflatin@prosodicshorthands
        \else
          \shorthandoff {=}
          \shorthandoff* {^}
        \fi
      }
      {
        % The following command should not be called if the main language
        % defines a = shorthand. However, there are no languages besides
        % Latin defining such a shorthand in polyglossia.
        \shorthandoff {=}
        % The following command should not be called if the main language
        % defines a ^ shorthand. However, there are no languages besides
        % Latin defining such a shorthand in polyglossia.
        \shorthandoff* {^}
        % The following command should not be called if the main language
        % defines a ' shorthand. However, there are no languages besides
        % Latin defining such a shorthand in polyglossia.
        \shorthandoff {'}
      }
  }

\cs_new:Npn \polyglossia_latin_shorthands:
  {
    \def \language@group {latin}
    \xpg@activate@shorthands ["]
    \declare@shorthand {latin} {"}
      {
        \mode_if_math:TF
          {
            \token_to_str:N "
          }
          {
            \polyglossia_latin_apply_quotemark:N
          }
      }
    % The ' shorthand is normally turned off to avoid problems with the unicode-math
    % package. We have to turn it on here.
    \shorthandon {'}
    \xpg@activate@shorthands [']
    \declare@shorthand {latin} {'}
      {
        \mode_if_math:TF
          {
            \active@math@prime % defined in "latex.ltx"
            % This definition is differing from the primes of the unicode-math package.
            % TO DO: Make sure that the appearance of primes is the same as with the
            % unicode-math package if this package is loaded.
          }
          {
            \polyglossia_latin_put_acute:N
          }
      }
  }

\cs_new:Npn \polyglossia_latin_prosodic_shorthands:
  {
    \def \language@group {latin}
    % The '=' and '^' shorthands are normally turned off to avoid problems with
    % key=value interfaces and TeX's ^^xx convention for hexadecimal input. We
    % turn them on here to enable prosodic shorthands.
    \shorthandon {=}
    \bbl@activate {=}
    \declare@shorthand {latin} {=}
      {
        \mode_if_math:TF
          {
            \token_to_str:N =
          }
          {
            \polyglossia_latin_put_macron:N
          }
      }
    \shorthandon {^}
    \bbl@activate {^}
    \declare@shorthand {latin} {^}
      {
        \mode_if_math:TF
          {
            \token_to_str:N ^
          }
          {
            \polyglossia_latin_put_breve:N
          }
      }
  }

\cs_new:Npn \polyglossia_latin_apply_quotemark:N #1
  {
    \str_case:nnF {#1}
      {
        {A} { \polyglossia_latin_ligature_shorthand:Nnn E { Æ }
                {
                  \polyglossia_latin_ligature_shorthand:Nnn e { Æ }
                    {
                      \polyglossia_latin_allow_hyphens: A
                    }
                }
            }
        {a} { \polyglossia_latin_ligature_shorthand:Nnn e { æ }
                {
                  \polyglossia_latin_allow_hyphens: a
                }
            }
        {O} { \polyglossia_latin_ligature_shorthand:Nnn E { Œ }
                {
                  \polyglossia_latin_ligature_shorthand:Nnn e { Œ }
                    {
                      \polyglossia_latin_allow_hyphens: O
                    }
                }
            }
        {o} { \polyglossia_latin_ligature_shorthand:Nnn e { œ }
                {
                  \polyglossia_latin_allow_hyphens: o
                }
            }
        {|} { \polyglossia_latin_allow_hyphens: }
        {<} { « }
        {>} { » }
      }
      {
        \tl_if_single_token:nTF {#1}
          {
            \token_if_letter:NTF #1 { \polyglossia_latin_allow_hyphens: }
              {
                \polyglossia_latin_if_ligature_command:NTF #1 { \polyglossia_latin_allow_hyphens: }
                  {
                    \token_to_str:N "
                  }
              }
          }
          {
            \token_to_str:N "
          }
          #1
      }
  }

\cs_new:Npn \polyglossia_latin_put_acute:N #1
  {
    \str_case:nnF {#1}
      {
        {A} { \polyglossia_latin_ligature_shorthand:Nnn E { Ǽ }
                {
                  \polyglossia_latin_ligature_shorthand:Nnn e { Ǽ } { Á }
                }
            }
        {a} { \polyglossia_latin_ligature_shorthand:Nnn e { ǽ } { á } }
        {E} { É }
        {e} { é }
        {I} { Í }
        {i} { í }
        {O} { \polyglossia_latin_ligature_shorthand:Nnn E { \'Œ }
                {
                  \polyglossia_latin_ligature_shorthand:Nnn e { \'Œ } { Ó }
                }
            }
        {o} { \polyglossia_latin_ligature_shorthand:Nnn e { \'œ } { ó } }
        {U} { Ú }
        {u} { ú }
        {V} { \' V } % V may be a vowel, but lowercase v is never used as a vowel.
        {Y} { Ý }
        {y} { ý }
        {Æ} { Ǽ }
        {æ} { ǽ }
        {Œ} { \'Œ }
        {œ} { \'œ }
      }
      {
        \tl_if_single_token:nTF {#1}
          {
            \polyglossia_latin_if_ligature_command:NTF #1 { \' }
              {
                \token_to_str:N '
              }
          }
          {
            \token_to_str:N '
          }
          #1
      }
  }

\cs_new:Npn \polyglossia_latin_put_macron:N #1
  {
    \str_case:nnF {#1}
      {
        {A} { \polyglossia_latin_ligature_macron:NNnn AE { Ǣ }
                {
                  \polyglossia_latin_ligature_macron:NNnn Ae { Ǣ }
                    {
                      \polyglossia_latin_diphthong_macron:NNn AU
                        {
                          \polyglossia_latin_diphthong_macron:NNn Au { Ā }
                        }
                    }
                }
            }
        {a} { \polyglossia_latin_ligature_macron:NNnn ae { ǣ }
                {
                  \polyglossia_latin_diphthong_macron:NNn au { ā }
                }
            }
        {E} { \polyglossia_latin_diphthong_macron:NNn EU
                {
                  \polyglossia_latin_diphthong_macron:NNn Eu { Ē }
                }
            }
        {e} { \polyglossia_latin_diphthong_macron:NNn eu { ē } }
        {I} { Ī }
        {i} { ī }
        {O} { \polyglossia_latin_ligature_macron:NNnn OE { \=Œ }
                {
                  \polyglossia_latin_ligature_macron:NNnn Oe { \=Œ } { Ō }
                }
            }
        {o} { \polyglossia_latin_ligature_macron:NNnn oe { \=œ } { ō } }
        {U} { Ū }
        {u} { ū }
        {V} { \= V } % V may be a vowel, but lowercase v is never used as a vowel.
        {Y} { Ȳ }
        {y} { ȳ }
      }
      {
        \tl_if_single_token:nTF {#1}
          {
            \polyglossia_latin_if_ligature_command:NTF #1 { \= }
              {
                \token_to_str:N =
              }
          }
          {
            \token_to_str:N =
          }
        #1
      }
  }

\cs_new:Npn \polyglossia_latin_put_breve:N #1
  {
    \str_case:nnF {#1}
      {
        {A} { Ă }
        {a} { ă }
        {E} { Ĕ }
        {e} { ĕ }
        {I} { Ĭ }
        {i} { ĭ }
        {O} { Ŏ }
        {o} { ŏ }
        {U} { Ŭ }
        {u} { ŭ }
        {V} { \u{V} } % V may be a vowel, but lowercase v is never used as a vowel.
        {Y} { \u{Y} }
        {y} { \u{y} }
      }
      {
        \token_to_str:N ^
        #1
      }
  }


\cs_new:Npn \polyglossia_latin_allow_hyphens:
  {
    \bbl@allowhyphens
    \discretionary {-} {} {}
    \bbl@allowhyphens
  }

\cs_new:Npn \polyglossia_latin_ligature_shorthand:Nnn #1#2#3
% #1: second letter of ligature (E or e)
% #2: ligature character
% #3: non-ligature code
  {
    \bool_if:NTF \l_polyglossia_latin_use_ligatures_bool
      {
        \peek_meaning_remove:NTF #1 {#2} {#3}
      }
      {
        #3
      }
  }

\msg_new:nnn {polyglossia} {latin / no-double-macron-font}
  {
    The~combining~double~macron~(U+035E)~is~not~available~in~the~current~
    font.~The~diphthong~is~typeset~without~macron~ \msg_line_context: .
  }

\cs_new:Npn \polyglossia_latin_diphthong_macron:NNn #1#2#3
% #1: first character of diphthong
% #2: second character of diphthong
% #3: non-diphthong code
  {
    \peek_meaning:NTF #2
      {
        #1
        \iffontchar \font "35E \relax % U+035E: combining double macron
          \char "35E \relax
        \else
          \msg_warning:nn {polyglossia} {latin / no-double-macron-font}
        \fi
      }
      {
        #3
      }
  }

\cs_new:Npn \polyglossia_latin_ligature_macron:NNnn #1#2#3#4
% #1: first character of diphthong
% #2: second character of diphthong
% #3: ligature code
% #4: false code
  {
    \polyglossia_latin_ligature_shorthand:Nnn #2 {#3}
      {
        \polyglossia_latin_diphthong_macron:NNn #1 #2 {#4}
      }
  }

% The following conditional tests if the argument is a ligature command (\AE,
% \ae, \OE, or \oe).
\prg_new_conditional:Npnn \polyglossia_latin_if_ligature_command:N #1 {TF}
  {
    \token_if_eq_meaning:NNTF #1 \AE { \prg_return_true: }
      {
        \token_if_eq_meaning:NNTF #1 \ae { \prg_return_true: }
          {
            \token_if_eq_meaning:NNTF #1 \OE { \prg_return_true: }
              {
                \token_if_eq_meaning:NNTF #1 \oe { \prg_return_true: }
                  {
                    \prg_return_false:
                  }
              }
          }
      }
  }

\cs_new:Npn \polyglossia_latin_no_shorthands:
  {
    \xpg@deactivate@shorthands ["]
    \xpg@deactivate@shorthands [']
  }

\cs_new:Npn \polyglossia_latin_no_prosodic_shorthands:
  {
    \bbl@deactivate {=}
    \bbl@deactivate {^}
    % The active '=' character may cause problems with key=value interfaces.
    % We have to make sure here that no problems can occur outside a Latin
    % prosodic shorthand environment.
    \shorthandoff {=}
    % The active '^' character may cause problems with TeX's ^^xx convention
    % for hexadecimal input. We have to make sure here that no problems can
    % occur outside a Latin prosodic shorthand environment.
    \shorthandoff* {^}
  }


%%%%% Further settings

\let \xpgla@savedvalues \empty

\AtEndPreamble
  {
    \edef \xpgla@savedvalues
      {
        \clubpenalty = \the \clubpenalty \space
        \@clubpenalty = \the \@clubpenalty \space
        \widowpenalty = \the \widowpenalty \space
        \finalhyphendemerits = \the \finalhyphendemerits
      }
  }

\def \noextras@latin
  {
    \iflatin@babelshorthands
      \polyglossia_latin_no_shorthands:
    \fi
    \iflatin@prosodicshorthands
      \polyglossia_latin_no_prosodic_shorthands:
    \fi
    \xpgla@savedvalues
    \polyglossia_latin_no_punctuation_spacing:
    \polyglossia_latin_modern_character_codes:
  }

\cs_new:Npn \polyglossia_latin_inline_extras:
  {
    \bool_if:NF \l_polyglossia_latin_use_v_bool
      {
        \polyglossia_latin_classical_character_codes:
      }
    \bool_if:NT \l_polyglossia_latin_punctuation_spacing_bool
      {
        \polyglossia_latin_punctuation_spacing:
      }
    \iflatin@babelshorthands
      \polyglossia_latin_shorthands:
    \else
      \polyglossia_latin_no_shorthands:
    \fi
    \iflatin@prosodicshorthands
      \polyglossia_latin_prosodic_shorthands:
    \else
      \polyglossia_latin_no_prosodic_shorthands:
    \fi
  }

\def \blockextras@latin
  {
    % The following four values were overtaken from the Italian language module.
    % It is unclear why they were chosen.
    \clubpenalty = 3000
    \@clubpenalty = 3000
    \widowpenalty = 3000
    \finalhyphendemerits = 50000000
    \polyglossia_latin_inline_extras:
  }

\def \inlineextras@latin
  {
    \polyglossia_latin_inline_extras:
  }


%% Default settings

\polyglossia_latin_modern_settings:

\ExplSyntaxOff

%%   Copyright (C) Claudio Beccari 2013-2016
%%   Copyright (C) Élie Roux 2016-2019
%%   Copyright (C) Keno Wehr 2019-2022
%%
%%   Permission is hereby granted, free of charge, to any person obtaining
%%   a copy of this software and associated documentation files
%%   (the "Software"), to deal in the Software without restriction, including
%%   without limitation the rights to use, copy, modify, merge, publish,
%%   distribute, sublicense, and/or sell copies of the Software, and to permit
%%   persons to whom the Software is furnished to do so, subject to the following
%%   conditions:
%%
%%   The above copyright notice and this permission notice shall be included in
%%   all copies or substantial portions of the Software.
%%
%%   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
%%   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
%%   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
%%   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
%%   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
%%   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
%%   IN THE SOFTWARE.
%%
%% End of file `gloss-latin.ldf'.
%    \end{macrocode}
% \iffalse
%</gloss-latin.ldf>
%<*gloss-latinclassic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latinclassic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-latinclassic.ldf}[polyglossia: module for classic Latin]

% We provide this as a babel alias

\xpg@load@master@language{latin}

%    \end{macrocode}
% \iffalse
%</gloss-latinclassic.ldf>
%<*gloss-latinecclesiastic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latinecclesiastic.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-latinecclesiastic.ldf}[polyglossia: module for ecclesiastic Latin]

% We provide this as a babel alias

\xpg@load@master@language{latin}

%    \end{macrocode}
% \iffalse
%</gloss-latinecclesiastic.ldf>
%<*gloss-latinmedieval.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latinmedieval.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-latinmedieval.ldf}[polyglossia: module for medieval Latin]

% We provide this as a babel alias

\xpg@load@master@language{latin}

%    \end{macrocode}
% \iffalse
%</gloss-latinmedieval.ldf>
%<*gloss-latvian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latvian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-latvian.ldf}[polyglossia: module for Latvian]
\PolyglossiaSetup{latvian}{
  bcp47=lv,
  bcp47-language=lv,
  bcp47-region=LV,
  bcp47-script=Latn,
  hyphennames={latvian},
  hyphenmins={2,2},
  langtag=LVI,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{latvian}{lv}

\def\captionslatvian{%
   \def\prefacename{Priekšvārds}%
   \def\refname{Literatūras saraksts}%
   \def\abstractname{Anotācija}%
   \def\bibname{Literatūra}%
   \def\chaptername{Nodaļa}%
   \def\appendixname{Pielikums}%
   \def\contentsname{Saturs}%
   \def\listfigurename{Attēlu saraksts}%
   \def\listtablename{Tabulu saraksts}%
   \def\indexname{Index}%
   \def\figurename{Att.}%
   \def\tablename{Tabula}%
   \def\partname{Daļa}%
   \def\enclname{encl}%
   \def\ccname{cc}%
   \def\headtoname{To}%
   \def\pagename{lpp.}%
   \def\seename{sk.}%
   \def\alsoname{sk. arī}%
   \def\proofname{Pierādījums}%
   }
\def\datelatvian{%
   \def\today{%
      \number\year.\thinspace gada%
      \space\number\day.\thinspace%
      \ifcase\month\or%
      janvārī\or februārī\or martā\or%
      aprīlī\or maijā\or jūnijā\or%
      jūlijā\or augustā\or septembrī\or%
      oktobrī\or novembrī\or decembrī\fi}}

%    \end{macrocode}
% \iffalse
%</gloss-latvian.ldf>
%<*gloss-lithuanian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lithuanian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
% Translated by Paulius Sladkevičius <komsas@gmail.com>

\ProvidesFile{gloss-lithuanian.ldf}[polyglossia: module for Lithuanian]
\PolyglossiaSetup{lithuanian}{
  bcp47=lt,
  bcp47-language=lt,
  bcp47-region=LT,
  bcp47-script=Latn,
  hyphennames={lithuanian},
  hyphenmins={2,2},
  langtag=LTH,
  indentfirst=true,
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*{lithuanian}{lt}

\def\captionslithuanian{%
   \def\prefacename{Pratarmė}%
   \def\refname{Literatūra}%
   \def\abstractname{Santrauka}%
   \def\bibname{Literatūra}%
   \def\chaptername{Skyrius}%
   \def\appendixname{Priedas}%
   \def\contentsname{Turinys}%
   \def\listfigurename{Iliustracijų sąrašas}%
   \def\listtablename{Lentelių sąrašas}%
   \def\indexname{Rodyklė}%
   \def\figurename{pav.}%
   \def\tablename{lentelė}%
   \def\partname{Dalis}%
   \def\enclname{Įdėta}%
   \def\ccname{Kopijos}%
   \def\headtoname{Kam}% TODO empty in babel?
   \def\pagename{puslapis}%
   \def\seename{žiūrėk}%
   \def\alsoname{taip pat}%
   \def\proofname{Įrodymas}%
   \def\glossaryname{Terminų žodynas}%
}

\def\datelithuanian{%
   \def\lithuanianmonth{\ifcase\month\or
      sausio\or
      vasario\or
      kovo\or
      balandžio\or
      gegužės\or
      birželio\or
      liepos\or
      rugpjūčio\or
      rugsėjo\or
      spalio\or
      lapkričio\or
      gruodžio\fi}%
   \def\today{\number\year~m.~\lithuanianmonth~\number\day~d.}%
}

\def\blockextras@lithuanian{%
  \let\fnum@figure@orig\fnum@figure
  \def\fnum@figure{\thefigure\nobreakspace\figurename}%
  \let\fnum@table@orig\fnum@table
  \def\fnum@table{\thetable\nobreakspace\tablename}%
}

\def\noextras@lithuanian{%
  \let\fnum@figure\fnum@figure@orig
  \let\fnum@table\fnum@table@orig
}

%    \end{macrocode}
% \iffalse
%</gloss-lithuanian.ldf>
%<*gloss-lo.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lo.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-lo.ldf}[polyglossia: module for lo (Lao)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{lao}

%    \end{macrocode}
% \iffalse
%</gloss-lo.ldf>
%<*gloss-lowersorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lowersorbian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-lowersorbian.ldf}[polyglossia: module for Lower Sorbian]

% We provide this as a babel alias

\xpg@load@master@language{sorbian}

%    \end{macrocode}
% \iffalse
%</gloss-lowersorbian.ldf>
%<*gloss-lsorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lsorbian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-lsorbian.ldf}[polyglossia: module for Lower Sorbian]

% We only provide this gloss for babel compatibility. Since lsorbian is 
% a sorbian variety, we use 'sorbian' with variant 'lower' now.

\xpg@load@master@language{sorbian}

%    \end{macrocode}
% \iffalse
%</gloss-lsorbian.ldf>
%<*gloss-lt.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lt.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-lt.ldf}[polyglossia: module for lt (Lithuanian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{lithuanian}

%    \end{macrocode}
% \iffalse
%</gloss-lt.ldf>
%<*gloss-lv.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lv.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-lv.ldf}[polyglossia: module for lv (Latvian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{latvian}

%    \end{macrocode}
% \iffalse
%</gloss-lv.ldf>
%<*gloss-macedonian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-macedonian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-macedonian.ldf}[polyglossia: module for Macedonian]
\PolyglossiaSetup{macedonian}{
  bcp47=mk,
  bcp47-language=mk,
  bcp47-script=Cyrl,
  script=Cyrillic,
  scripttag=cyrl,
  langtag=MKD,
  hyphennames={macedonian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup
}

% BCP-47 compliant aliases
\setlanguagealias*{macedonian}{mk}

\def\macedonian@Alph#1{%
   \ifcase#1\or
   А\or Б\or В\or Г\or Д\or Ѓ\or Е\or
   Ж\or З\or Ѕ\or И\or Ј\or К\or Л\or 
   Љ\or М\or Н\or Њ\or О\or П\or Р\or
   С\or Т\or Ќ\or У\or Ф\or Х\or Ц\or
   Ч\or Џ\or Ш\else
   \xpg@ill@value{#1}{macedonian@Alph}\fi}%

\def\macedonian@alph#1{%
   \ifcase#1\or
   а\or б\or в\or г\or д\or ѓ\or е\or
   ж\or з\or ѕ\or и\or ј\or к\or л\or
   љ\or м\or н\or њ\or о\or п\or р\or
   с\or т\or ќ\or у\or ф\or х\or ц\or
   ч\or џ\or ш\else
   \xpg@ill@value{#1}{macedonian@alph}\fi}%

\def\macedonian@numbers{%
   \let\@Alph\macedonian@Alph%
   \let\@alph\macedonian@alph%
 }

\def\nomacedonian@numbers{%
   \let\@Alph\latin@Alph%
   \let\@alph\latin@alph%
}

\def\captionsmacedonian{%
   \def\refname{Литература}%
   \def\abstractname{Апстракт}%
   \def\bibname{Библиографија}%
   \def\prefacename{Предговор}%
   \def\chaptername{Глава}%
   \def\appendixname{Прилог}%
   \def\contentsname{Содржина}%
   \def\listfigurename{Листа на слики}%
   \def\listtablename{Листа на табели}%
   \def\indexname{Индекс}%
   \def\figurename{Слика}%
   \def\tablename{Табела}%
   %\def\thepart{}%
   \def\partname{Поглавје}%
   \def\pagename{стр.}%
   \def\seename{види}%
   \def\alsoname{види исто така}%
   \def\enclname{Прилог}%
   %\def\ccname{cc}%
   %\def\headtoname{}%
   \def\proofname{Доказ}%
   \def\glossaryname{Терминолошки речник}%
   }
\def\datemacedonian{%
   \def\today{\number\day~\ifcase\month\or
       јануари\or
       февруари\or
       март\or
       април\or
       мај\or
       јуни\or
       јули\or
       август\or
       септември\or
       октомври\or
       ноември\or
       декември\fi%
       \ \number\year~г.}%
    \def\month@Roman{\expandafter\@Roman\month}%
    \def\todayRoman{\number\day.\,\month@Roman.\,\number\year~г.}%
    }

%    \end{macrocode}
% \iffalse
%</gloss-macedonian.ldf>
%<*gloss-magyar.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-magyar.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-magyar.ldf}[polyglossia: module for Hungarian (Magyar)]

% We only provide this gloss for babel compatibility.

\xpg@load@master@language{hungarian}

%    \end{macrocode}
% \iffalse
%</gloss-magyar.ldf>
%<*gloss-malay.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-malay.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-malay.ldf}[polyglossia: module for Malay]

\RequirePackage{hijrical}

\PolyglossiaSetup{malay}{%
  bcp47=id,
  bcp47-language=id,
  bcp47-script=Latn,
  language=Malay,
  langtag=MLY,
  hyphennames={malay,melayu,bahasam,bahasai,indonesian,indon,bahasa},
  hyphenmins={2,2},
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*[variant=malaysian]{malay}{zsm}
\setlanguagealias*[variant=indonesian]{malay}{id}

% Babel aliases
\setlanguagealias[variant=indonesian]{malay}{bahasai}
\setlanguagealias[variant=malaysian]{malay}{bahasa}

% Backwards compat. alias
\setlanguagealias[variant=malaysian]{malay}{bahasam}

\providebool{malay@melayu}
\malay@melayufalse
\def\malay@variant{malay}
\define@choicekey*+{malay}{variant}[\xpg@val\xpg@nr]{indonesian,malaysian}[malaysian]{%
   \ifcase\xpg@nr\relax
      % indonesian:
      \def\malay@variant{indonesian}%
      \malay@melayufalse
   \or
      % malaysian:
      \def\malay@variant{malay}%
      \malay@melayutrue
   \fi
   \ifmalay@melayu
      \SetLanguageKeys{malay}{language=Malay,langtag=MLY,babelname=bahasam,bcp47=zsm,bcp47-language=zsm}%
      \xpg@fontsetup@latin{malay}%
      % Check if \l@malay is defined. If not, try to set it to some variety
      % (specific order as in the csv list below), or null language if everything fails
      \xpg@ifdefined{malay}{}{%
        \def\do##1{%
            \xpg@ifdefined{##1}%
              {\csletcs{l@malay}{l@##1}\listbreak}%
              {}%
        }%
        \docsvlist{melayu,bahasam,bahasai,indonesian,indon,bahasa}
        \xpg@ifdefined{malay}{}{%
                 \xpg@warning{No hyphenation patterns for Malay (Malaysian) found\MessageBreak
                              I will use the 'null' language instead}%
                 \adddialect\l@malay0%
        }%
      }%
   \else
      \SetLanguageKeys{malay}{language=Indonesian,langtag=IND,babelname=bahasa,bcp47=id,bcp47-language=id}%
      \xpg@fontsetup@latin{malay}%
      % Check if \l@indonesian is defined. If not, try to set it to some variety
      % (specific order as in the csv list below), or null language if everything fails
      \xpg@ifdefined{indonesian}{}{%
        \def\do##1{%
           \xpg@ifdefined{##1}%
              {\csletcs{l@indonesian}{l@##1}\listbreak}%
              {}%
        }%
        \docsvlist{indon,bahasai,bahasam,malay,melayu,bahasa}
        \xpg@ifdefined{indonesian}{}{%
                 \xpg@warning{No hyphenation patterns for Malay (Indonesian) found\MessageBreak
                              I will use the 'null' language instead}%
                 \adddialect\l@indonesian0
        }%
      }%
   \fi
   \xpg@info{Option: malay, variant=\xpg@val}%
}{\xpg@warning{Unknown malay variant `#1'}}

% Register default options
\xpg@initialize@gloss@options{malay}{variant=malaysian}


\def\malay@language{%
   \polyglossia@setup@language@patterns{\malay@variant}%
}%


\def\captionsmalay@indonesian{%
   \def\refname{Pustaka}%
   \def\abstractname{Ringkasan}%
   \def\bibname{Bibliografi}%
   \def\prefacename{Pendahuluan}%
   \def\chaptername{Bab}%
   \def\appendixname{Lampiran}%
   \def\contentsname{Daftar Isi}%
   \def\listfigurename{Daftar Gambar}%
   \def\listtablename{Daftar Tabel}%
   \def\indexname{Indeks}%
   \def\figurename{Gambar}%
   \def\tablename{Tabel}%
   %\def\thepart{}%
   \def\partname{Bagian}%
   \def\pagename{Halaman}%
   \def\seename{lihat}%
   \def\alsoname{lihat juga}%
   \def\enclname{Lampiran}%
   \def\ccname{cc}%
   \def\headtoname{Kepada}%
   \def\proofname{Bukti}%
   \def\glossaryname{Daftar Istilah}%
}

\def\captionsmalay@malay{%
   \def\refname{Rujukan}%
   \def\abstractname{Abstrak}%
   \def\bibname{Bibliografi}%
   \def\prefacename{Pendahuluan}%
   \def\chaptername{Bab}%
   \def\appendixname{Lampiran}%
   \def\contentsname{Kandungan}%
   \def\listfigurename{Senarai Rajah}%
   \def\listtablename{Senarai Jadual}%
   \def\indexname{Indeks}%
   \def\figurename{Rajah}%
   \def\tablename{Jadual}%
   \def\thepart{}%
   \def\partname{Bahagian}%
   \def\pagename{Halaman}%
   \def\seename{lihat}%
   \def\alsoname{lihat juga}%
   \def\enclname{Lampiran}%
   \def\ccname{salinan kpd}%
   \def\headtoname{Kepada}%
   \def\proofname{Bukti}%
   \def\glossaryname{Senarai Istilah}%
}

\def\captionsmalay{%
  \csname captionsmalay@\malay@variant\endcsname%
}

\def\datemalay@indonesian{%
   \def\today{\number\day~\ifcase\month\or
    Januari\or Februari\or Maret\or April\or Mei\or Juni\or
    Juli\or Agustus\or September\or Oktober\or November\or Desember\fi
    \space \number\year}}

\def\datemalay@malay{%
   \def\bahasam@day{%
      \ifcase\day\or%
        1hb\or 2hb\or 3hb\or 4hb\or 5hb\or%
        6hb\or 7hb\or 8hb\or 9hb\or 10hb\or%
        11hb\or 12hb\or 13hb\or 14hb\or 15hb\or%
        16hb\or 17hb\or 18hb\or 19hb\or 20hb\or%
        21hb\or 22hb\or 23hb\or 24hb\or 25hb\or%
        26hb\or 27hb\or 28hb\or 29hb\or 30hb\or%
        31hb\fi}%
   \def\today{\bahasam@day~\ifcase\month\or
    Januari\or Februari\or Mac\or April\or Mei\or Jun\or
    Julai\or Ogos\or September\or Oktober\or November\or Disember\fi
    \space \number\year}}

\def\datemalay{%
  \csname datemalay@\malay@variant\endcsname%
}

% Hijri calendar localizations
\def\hijrimonthmalay@indonesian#1{%
  \ifcase#1%
  \or Muharram\or Safar\or Rabiul awal\or Rabiul akhir\or Jumadil awal\or Jumadil akhir\or Rajab%
  \or Sya'ban\or Ramadhan\or Syawal\or Dzulkaidah\or Dzulhijjah\fi%
}

\def\hijrimonthmalay@malay#1{%
  \ifcase#1%
  \or Muharram\or Safar\or Rabiulawal\or Rabiulakhir\or Jamadilawal\or Jamadilakhir\or Rejab%
  \or Syaaban\or Ramadan\or Syawal\or Zulkaedah\or Zulhijah\fi%
}

\def\hijrimonthmalay{%
  \csname hijrimonthmalay@\malay@variant\endcsname%
}

%\Hijritoday is now locale-aware and will format the date with this macro:
\DefineFormatHijriDate{malay}{%
  \number\value{Hijriday}\space\hijrimonthmalay{\value{Hijrimonth}}\space\number\value{Hijriyear}}

%    \end{macrocode}
% \iffalse
%</gloss-malay.ldf>
%<*gloss-malayalam.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-malayalam.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-malayalam.ldf}[polyglossia: module for Malayalam]

% Translations provided by Kevin & Siji, 01-11-2009

\PolyglossiaSetup{malayalam}{
  bcp47=ml,
  bcp47-language=ml,
  bcp47-script=Mlym,
  script=Malayalam,
  scripttag=mlym,
  langtag=MAL, %FIXME there is also MLR for "Malayalam Reformed"
  hyphennames={malayalam},
  hyphenmins={2,2}, %FIXME
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{malayalam}{ml}

\def\captionsmalayalam{%
     \def\abstractname{സാരാംശം}%
     \def\appendixname{ശിഷ്ടം}%
     \def\bibname{}% (?)
     \def\ccname{}%
     \def\chaptername{അദ്ധ്യായം}%
     \def\contentsname{ഉള്ളടക്കം}%
     \def\enclname{}%
     \def\figurename{ചിത്രം}% रेखाचित्र
     \def\headpagename{}%
     \def\headtoname{}%
     \def\indexname{സൂചിക}%
     \def\listfigurename{ചിത്രസൂചിക}%
     \def\listtablename{പട്ടികകളുടെ സൂചിക}%
     \def\pagename{}%
     \def\partname{ഭാഗം}%
     \def\prefacename{}% 
     \def\refname{}%
     \def\tablename{പട്ടിക}%
     \def\seename{കാണുക}%
     \def\alsoname{ഇതും കാണുക}%
     \def\alsoseename{ഇതും കാണുക}%
}
\def\datemalayalam{%
   \def\today{\number\year\space\ifcase\month\or
     ജനുവരി\or
     ഫിബ്രുവരി\or
     മാർച്ച്\or
     ഏപ്രിൽ\or
     മെയ്\or
     ജൂൺ\or
     ജൂലായ്\or
     ആഗസ്ത്\or
     സെപ്തംബർ\or
     ഒക്ടോബർ\or
     നവംബർ\or
     ഡിസംബർ\fi
     \space\number\day}%
}

%    \end{macrocode}
% \iffalse
%</gloss-malayalam.ldf>
%<*gloss-marathi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-marathi.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
% Translations provided by Abhijit Navale <abhi_navale@live.in>
% Ordinals (1-100) added by Niranjan Tambe <niranjanvikastambe@gmail.com> on 14th December, 2019
% TODO implement Hindu calendar (not used in day-to-day practice)

\ProvidesFile{gloss-marathi.ldf}[polyglossia: module for Marathi]

\RequirePackage{devanagaridigits}

\PolyglossiaSetup{marathi}{
  bcp47=mr,
  bcp47-language=mr,
  bcp47-script=Deva,
  script=Devanagari,
  scripttag=deva,
  langtag=MAR,
  hyphennames={marathi},
  hyphenmins={2,2},%CHECK
  fontsetup=true,
  localnumeral=marathinumerals
  %TODO nouppercase=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{marathi}{mr}

\newif\ifmarathi@devanagari@numerals
\marathi@devanagari@numeralstrue

\define@choicekey*+{marathi}{numerals}[\xpg@val\xpg@nr]{Western,Devanagari}[Devanagari]{%
   \ifcase\xpg@nr\relax
      % Western:
      \marathi@devanagari@numeralsfalse%
      \SetLanguageKeys{marathi}{bcp47-extension-u=nu-latn}%
   \or
      % Devanagari:
      \marathi@devanagari@numeralstrue%
      \SetLanguageKeys{marathi}{bcp47-extension-u=nu-deva}%
   \fi
   \xpg@info{Option: Marathi, numerals=\xpg@val}%
}{\xpg@warning{Unknown Marathi numerals value `#1'}}

% Register default options
\xpg@initialize@gloss@options{marathi}{numerals=Devanagari}

\newcommand{\marathinumerals}[2]{\marathinumber{#2}}

\def\marathinumber#1{%
  \ifmarathi@devanagari@numerals
    \devanagaridigits{\number#1}%
  \else
    \number#1%
  \fi%
}

\def\captionsmarathi{%
   \def\refname{संदर्भ}%
   \def\abstractname{सारांश}%
   \def\bibname{संदर्भसूची}%
   \def\prefacename{प्रस्तावना}%
   \def\chaptername{प्रकरण}%
   \def\appendixname{परिशिष्ट}%
   \def\contentsname{अनुक्रमणिका}%
   \def\listfigurename{आकृत्यांची सूची}%
   \def\listtablename{कोष्टकसूची}%
   \def\indexname{सूची}%
   \def\figurename{आकृती}%
   \def\tablename{कोष्टक}%
   \def\partname{खंड}%
   \def\pagename{पृष्ठ}%
   \def\seename{पाहा}%
   \def\alsoname{हेदेखील पाहा}%
   \def\enclname{समाविष्ट}%
   \def\ccname{प्रत}%
   \def\headtoname{प्रति}%
   \def\proofname{सिद्धता}%
   \def\glossaryname{संज्ञांची सूची}%
   \def\authorsand{आणि}%
}

\def\datemarathi{%
   \def\marathimonth{%
     \ifcase\month\or
                जानेवारी\or
                फेब्रुवारी\or
                मार्च\or
                एप्रिल\or
                मे\or
                जून\or
                जुलै\or
               ऑगस्ट\or
               सप्टेंबर\or
               ऑक्टोबर\or
               नोव्हेंबर\or
               डिसेंबर%
     \fi%
   }%
   \def\today{%
     \marathinumber\day\space\marathimonth\space\marathinumber\year%
   }%
}

\def\devanagari@akshar#1{\ifcase#1\or अ\or आ\or इ\or ई\or उ\or ऊ\or ऋ\or ऌ\or ए\or ॲ\or ऐ\or ओ\or ऑ\or औ\or अं\or अः\else\@ctrerr\fi}

\def\devanagari@alph#1{%
    \ifcase#1\or क\or ख\or ग\or घ\or ङ\or च\or छ\or ज\or झ\or ञ\or ट\or ठ\or ड\or ढ\or ण\or त\or थ\or द%
       \or ध\or न\or प\or फ\or ब\or भ\or म\or य\or र\or ल\or व\or श\or ष\or स\or ह\or ळ\or क्ष \or ज्ञ \else\@ctrerr%
    \fi%
}

\def\devanagari@letter#1{%
  \ifcase#1\or एक\or दोन\or तीन\or चार\or पाच\or सहा\or सात\or आठ\or नऊ\or दहा\or अकरा\or बारा\or तेरा\or चौदा%
    \or पंधरा\or सोळा\or सतरा\or अठरा\or एकोणीस\or वीस\or एकवीस\or बावीस\or तेवीस\or चोवीस\or पंचवीस\or सव्वीस\or सत्तावीस\or अठ्ठावीस%
    \or एकोणतीस\or तीस\or एकतीस\or बत्तीस\or तेहतीस \or चौतीस \or पस्तीस \or छत्तीस \or सदतीस \or अडतीस \or एकोणचाळीस \or चाळीस %
    \or एकेचाळीस \or बेचाळीस \or त्रेचाळीस \or चव्वेचाळीस \or पंचेचाळीस \or शेहेचाळीस \or सत्तेचाळीस \or अठ्ठेचाळीस \or एकोणपन्नास \or पन्नास %
    \or एकावन्न \or बावन्न \or त्रेपन्न \or चौपन्न \or पंचावन्न \or छप्पन्न\or सत्तावन्न \or अठ्ठावन्न \or एकोणसाठ \or साठ \or एकसष्ट \or बासष्ट \or त्रेसष्ट %
    \or चौसष्ट \or पासष्ट \or सहासष्ट \or सदुष्ट \or अडुसष्ट \or एकोणसत्तर\or सत्तर \or एकाहत्तर \or बाहत्तर \or त्र्याहत्तर \or चौऱ्याहत्तर \or पंचाहत्तर %
    \or शाहत्तर \or सत्त्याहत्तर \or अठ्ठ्याहत्तर \or एकोणऐंशी \or ऐंशी\or एक्याऐंशी \or ब्याऐंशी \or त्र्याऐंशी \or चौऱ्याऐंशी \or पंच्याऐंशी \or श्याऐंशी \or सत्त्याऐंशी %
    \or अठ्ठ्याऐंशी \or एकोणनव्वद \or नव्वद \or एक्याण्णव\or ब्याण्णव \or त्र्याण्णव \or चौऱ्याण्णव \or पंचाण्णव \or शहाण्णव \or सत्त्याण्णव \or अठ्याण्णव %
    \or नव्याण्णव \or शंभर\else\@ctrerr%
  \fi%
}

\let\xpg@save@roman\@roman
\let\xpg@save@Roman\@Roman

\def\marathi@numbers{%
  \let\@alph\devanagari@akshar
  \let\@Alph\devanagari@letter
  \let\@roman\devanagari@alph
  \let\@Roman\devanagari@letter
}

\def\nomarathi@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
  \let\@roman\xpg@save@roman
  \let\@Roman\xpg@save@Roman
}

%    \end{macrocode}
% \iffalse
%</gloss-marathi.ldf>
%<*gloss-mk.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-mk.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-mk.ldf}[polyglossia: module for mk (Macedonian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{macedonian}

%    \end{macrocode}
% \iffalse
%</gloss-mk.ldf>
%<*gloss-ml.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ml.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ml.ldf}[polyglossia: module for ml (Malayalam)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{malayalam}

%    \end{macrocode}
% \iffalse
%</gloss-ml.ldf>
%<*gloss-mn.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-mn.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-mn.ldf}[polyglossia: module for mn (Mongolian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{mongolian}

%    \end{macrocode}
% \iffalse
%</gloss-mn.ldf>
%<*gloss-mongolian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-mongolian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-mongolian.ldf}[polyglossia: module for Mongolian]

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{mongolian}{
  bcp47=mn,
  bcp47-language=mn,
  bcp47-script=Cyrl,
  script=Cyrillic,
  scripttag=cyrl,
  langtag=MNG,
  hyphennames={mongolian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup,
  localnumeral=mongoliannumerals,
  Localnumeral=Mongoliannumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{mongolian}{mn}

% This file is derived from mongolian-babel. which
% provides support for Mongolian (Khalkha variety)
% with Cyrillic script
% TODO: Implement script=mongolian and maybe other
%       variants of Mongolian

\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals
\define@choicekey*+{mongolian}{numerals}[\xpg@val\xpg@nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
   \ifcase\xpg@nr\relax
      % arabic:
      \cyrillic@numeralsfalse%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic-trad:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
   \or
      % cyrillic-alph:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralstrue%
   \fi
   \xpg@info{Option: Mongolian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Mongolian numerals value `#1'}}

\define@boolkey{mongolian}[mongolian@]{babelshorthands}[true]{}

% Register default options
\xpg@initialize@gloss@options{mongolian}{babelshorthands=false,numerals=arabic}

\ifsystem@babelshorthands
  \setkeys{mongolian}{babelshorthands=true}
\else
  \setkeys{mongolian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\mongolian@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{mongolian}%
  \declare@shorthand{mongolian}{"`}{„}%
  \declare@shorthand{mongolian}{"'}{“}%
  \declare@shorthand{mongolian}{"<}{«}%
  \declare@shorthand{mongolian}{">}{»}%
  \declare@shorthand{mongolian}{""}{\hskip\z@skip}%
  \declare@shorthand{mongolian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{mongolian}{"=}{\nobreak-\hskip\z@skip}%
  \declare@shorthand{mongolian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
  \declare@shorthand{mongolian}{"-}{%
     \def\mongolian@sh@tmp{%
       \if\mongolian@sh@next-\expandafter\mongolian@sh@emdash%
       \else\expandafter\mongolian@sh@hyphen\fi%
     }%
     \futurelet\mongolian@sh@next\mongolian@sh@tmp%
  }%
  \def\mongolian@sh@hyphen{%
    \nobreak\-\bbl@allowhyphens}%
  \def\mongolian@sh@emdash##1##2{\cdash-##1##2}%
  \def\cdash##1##2##3{\def\tempx@{##3}%
  \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
   \ifx\tempx@\tempa@\@Acdash\else
    \ifx\tempx@\tempb@\@Bcdash\else
     \ifx\tempx@\tempc@\@Ccdash\else
      \errmessage{Wrong usage of cdash}\fi\fi\fi}%
  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
    \cyrdash\hskip.2em\ignorespaces}%
  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
   \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
  \def\@Ccdash{\leavevmode
   \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
  \ifx\cyrdash\undefined
    \def\cyrdash{\hbox to.8em{\textendash\hss\textendash}}%
  \fi
  \declare@shorthand{mongolian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

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

% Taken from babel-mongolian
\def\captionsmongolian{%
   \def\prefacename{Өмнөх үг}%
   \def\refname{Ашигласан ном}%
   \def\abstractname{Удиртгал}%
   \def\bibname{Номзүй}%
   \def\chaptername{Бүлэг}%
   \def\appendixname{Хавсралт}%
   \ifcsundef{thechapter}%
     {\def\contentsname{Агуулга}}%
     {\def\contentsname{Гарчиг}}%
   \def\listfigurename{Зургийн жагсаалт}%
   \def\listtablename{Хүснэгтийн жагсаалт}%
   \def\indexname{Товъёг}%
   \def\authorname{Нэрийн хэлхээ}%
   \def\figurename{Зураг}%
   \def\tablename{Хүснэгт}%
   \def\partname{Хэсэг}%
   \def\enclname{Ишлэл}%
   \def\ccname{э.с.}%
   \def\headtoname{}%
   \def\pagename{тал}%
   \def\seename{талд үз}%
   \def\alsoname{мөн талд үз}%
   \def\proofname{Баталгаа}%
}

\def\datemongolian{%
  \def\today{\number\year~оны \ifcase\month\or
  1-р\or 2-р\or 3-р\or 4-р\or 5-р\or 6-р\or
  7-р\or 8-р\or 9-р\or 10-р\or 11-р\or 12-р\fi
  ~сарын \number\day}}

\newcommand{\mongoliannumerals}[2]{\mongoliannumber{#2}}
\newcommand{\Mongoliannumerals}[2]{\Mongoliannumber{#2}}

\def\mongoliannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \mongolian@asbuk@alph{#1}%
    \else
      \cyr@alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\def\Mongoliannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \mongolian@asbuk@Alph{#1}%
    \else
      \cyr@Alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\let\mongoliannumeral=\mongoliannumber
\let\Mongoliannumeral=\Mongoliannumber

\def\Asbuk#1{\expandafter\mongolian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\mongolian@asbuk@alph\csname c@#1\endcsname}

\def\AsbukTrad#1{\expandafter\cyr@Alph\csname c@#1\endcsname}
\def\asbukTrad#1{\expandafter\cyr@alph\csname c@#1\endcsname}

% This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
% thus ends at 30.
\def\mongolian@asbuk@Alph#1{\ifcase#1\or
   А\or Б\or В\or Г\or Д\or Е\or Ж\or
   З\or И\or К\or Л\or М\or Н\or О\or
   П\or Р\or С\or Т\or У\or Ф\or Х\or
   Ц\or Ч\or Ш\or Щ\or Э\or Ю\or Я%
   \else\xpg@ill@value{#1}{mongolian@asbuk@Alph}\fi%
}

\def\mongolian@asbuk@alph#1{\ifcase#1\or
   а\or б\or в\or г\or д\or е\or ж\or
   з\or и\or к\or л\or м\or н\or о\or
   п\or р\or с\or т\or у\or ф\or х\or
   ц\or ч\or ш\or щ\or э\or ю\or я%
   \else\xpg@ill@value{#1}{mongolian@asbuk@alph}\fi%
}

\def\mongolian@numbers{%
   \let\latin@alph\@alph
   \let\latin@Alph\@Alph
   \ifcyrillic@numerals%
     \def\mongolian@alph##1{\expandafter\mongoliannumeral\expandafter{\the##1}}%
     \def\mongolian@Alph##1{\expandafter\Mongoliannumeral\expandafter{\the##1}}%
      \let\@alph\mongolian@alph%
      \let\@Alph\mongolian@Alph%
   \fi
}

\def\nomongolian@numbers{%
   \let\@alph\latin@alph%
   \let\@Alph\latin@Alph%
}

\def\noextras@mongolian{%
   \ifcyrillic@numerals\nomongolian@numbers\fi%
   \ifmongolian@babelshorthands\nomongolian@shorthands\fi%
}

\def\blockextras@mongolian{%
   \ifcyrillic@numerals\mongolian@numbers\else\nomongolian@numbers\fi%
   \ifmongolian@babelshorthands\mongolian@shorthands\else\nomongolian@shorthands\fi%
}

\def\inlineextras@mongolian{%
   \ifmongolian@babelshorthands\mongolian@shorthands\else\nomongolian@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-mongolian.ldf>
%<*gloss-mr.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-mr.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-mr.ldf}[polyglossia: module for mr (Marathi)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{marathi}

%    \end{macrocode}
% \iffalse
%</gloss-mr.ldf>
%<*gloss-naustrian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-naustrian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-naustrian.ldf}[polyglossia: module for Austrian German (current spelling)]

% We provide this as a babel alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-naustrian.ldf>
%<*gloss-nb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-nb.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-nb.ldf}[polyglossia: module for nb (Norwegian)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{norwegian}

%    \end{macrocode}
% \iffalse
%</gloss-nb.ldf>
%<*gloss-newzealand.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-newzealand.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-newzealand.ldf}[polyglossia: module for Newzealand English]

% We provide this as a babel alias

\xpg@load@master@language{english}

%    \end{macrocode}
% \iffalse
%</gloss-newzealand.ldf>
%<*gloss-ngerman.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ngerman.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ngerman.ldf}[polyglossia: module for German (current spelling)]

% We provide this as a babel alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-ngerman.ldf>
%<*gloss-nko.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-nko.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-nko.ldf}[Polyglossia: module for N’Ko]
\PolyglossiaSetup{nko}{%
  bcp47=nko,
  bcp47-language=nko,
  bcp47-script=Nkoo,
  script=N'ko,
  scripttag=nko~,
  langtag=NKO,
  fontsetup=true,
  hyphennames={nohyphenation},
  direction=RL,
  localnumeral=nkonumerals
}

\RequirePackage{nkonumbers}%

\newcommand{\nkonumerals}[2]{\nkonumber{#2}}

\def\captionsnko{%
  \def\prefacename{ߢߍߛߓߍ}%
  \def\refname{ߞߐߡߊߛߙߋ}%
  \def\abstractname{ߓߊߕߐߡߐ߲}%
  \def\bibname{ߟߍߙߊߥߙߍߟߐ߲߲}%
  \def\chaptername{ߛߌ߰ߘߊ}%
  \def\appendixname{ߘߋ߬ߙߋ}%
  \def\contentsname{ߞߣߐߘߐ}%
  \def\listfigurename{ߢߊ ߟߎ߬ ߛߙߍߘߍ}%
  \def\listtablename{ߦߌ߬ߘߊ߬ߥߟߊ ߟߎ߬ ߛߙߍߘߍ}%
  \def\indexname{ߛߙߍߘߍ}%
  \def\figurename{ߢߊ}%
  \def\tablename{ߦߌ߬ߘߊ߬ߥߟߊ}%
  \def\partname{ߛߌ߰ߘߊ߬ߙߋ߲}%
  \def\enclname{ߝߍ߬ߕߊ}%
  \def\ccname{ߓߊ ߘߏ߫ ߘߌ߫}%
  \def\headtoname{ߞߊߕߙߍ߬}%
  \def\pagename{ߞߐߜߍ}%
  \def\seename{ߡߊߝߟߍ߫}%
  \def\alsoname{ߝߟߍߡߊߛߊ߬ߦߌ߬}%
  \def\proofname{ߦߌ߬ߘߊ߬ߞߏ}%
  \def\glossaryname{ߞߘߐߝߐߟߊ߲}%
}%

% In n'ko, this is an example of date :
% ߂߀߁߃ ߞߏ߲ߞߏߜߍ ߕߟߋ߬ ߁߈ (RTL)
% ( 18 February 2013 )
% The word "ߕߟߋ߬" is mandatory between month name and day number.
% Replace "ߕߟߋ߬" by "ߕߋ߬ߟߋ߫" if and only if day = 2 or day = 3 or day = 9 
% or (day >= 20 and day <= 29).

\newcommand*\nkodayprefix[1]{%
  \ifnum\numexpr#1=2 ߕߋ߬ߟߋ߫\else%
     \ifnum\numexpr#1=3 ߕߋ߬ߟߋ߫\else%
        \ifnum\numexpr#1=9 ߕߋ߬ߟߋ߫\else%
           \ifnum\numexpr#1>19\ifnum\numexpr#1<30 ߕߋ߬ߟߋ߫\else ߕߟߋ߬\fi\else ߕߟߋ߬\fi%
        \fi%
     \fi%
  \fi%
}

\newcommand*\nkoday[1]{%
  % If day = 1, put above "߁", NKO_COMBINING_SHORT_RISING_TONE
  \ifnum\numexpr#1=1 ߁߭\else%
    \nkonumber{#1}
  \fi
}

\def\datenko{%
  \def\today{%
    \nkonumber{\year}\space
    \ifcase\month
    \or ߓߌ߲ߠߊߥߎߟߋ߲%
    \or ߞߏ߲ߞߏߜߍ%
    \or ߕߙߊߓߊ%
    \or ߞߏ߲ߞߏߘߌ߬ߓߌ%
    \or ߘߓߊ߬ߕߊ%
    \or ߥߊ߬ߛߌߥߊ߬ߙߊ%
    \or ߞߊ߬ߙߌߝߐ߭%
    \or ߘߓߊ߬ߓߌߟߊ%
    \or ߕߎߟߊߝߌ߲%
    \or ߞߏ߲ߓߌߕߌ߮%
    \or ߣߍߣߍߓߊ%
    \or ߞߏ߬ߟߌ߲߬ߞߏߟߌ߲\fi
    \space\nkodayprefix{\number\day}
    \space\nkoday{\day}
  }%
}%

%    \end{macrocode}
% \iffalse
%</gloss-nko.ldf>
%<*gloss-norsk.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-norsk.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-norsk.ldf}[polyglossia: module for Norwegian (Bokmal)]

% We only provide this gloss for babel compatibility. Since norsk is 
% actually norwegian bokmal, we use 'norwegian' with variant 'bokmal' now.

\xpg@load@master@language{norwegian}

%    \end{macrocode}
% \iffalse
%</gloss-norsk.ldf>
%<*gloss-norwegian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-norwegian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-norwegian.ldf}[polyglossia: module for Norwegian]
\PolyglossiaSetup{norwegian}{
  bcp47=nn,
  bcp47-language=nn,
  bcp47-script=Latn,
  hyphennames={nynorsk},
  langtag=NYN,
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=false,
}

% BCP-47 compliant aliases
\setlanguagealias*[variant=bokmal]{norwegian}{nb}
\setlanguagealias*[variant=nynorsk]{norwegian}{nn} 
% Babel and backwards compat. aliases
\setlanguagealias[variant=bokmal]{norwegian}{norsk}
\setlanguagealias[variant=nynorsk]{norwegian}{nynorsk}

\def\norwegian@variant{nynorsk}
\define@choicekey*+{norwegian}{variant}[\xpg@val\xpg@nr]{nynorsk,bokmal}[nynorsk]{%
   \ifcase\xpg@nr\relax
      % nynorsk:
      \def\norwegian@variant{nynorsk}%
      \SetLanguageKeys{norwegian}{langtag=NYN,babelname=nynorsk,bcp47=nn,bcp47-language=nn}%
      \xpg@fontsetup@latin{norwegian}%
   \or
      % bokmal:
      \def\norwegian@variant{norsk}%
      \SetLanguageKeys{norwegian}{langtag=NOR,babelname=norsk,bcp47=nb,bcp47-language=nb}%
      \xpg@fontsetup@latin{norwegian}%
   \fi
   \xpg@info{Option: norwegian, variant=\xpg@val}%
}{\xpg@warning{Unknown norwegian variant `#1'}}


% Register default options
\xpg@initialize@gloss@options{norwegian}{variant=nynorsk}


\def\norwegian@language{%
   \polyglossia@setup@language@patterns{\norwegian@variant}%
}%

\def\captionsnorwegian@nynorsk{%
   \def\refname{Referansar}%
   \def\abstractname{Sammendrag}%
   \def\bibname{Litteratur}%
   \def\prefacename{Forord}%
   \def\chaptername{Kapittel}%
   \def\appendixname{Tillegg}%
   \def\contentsname{Innhald}%
   \def\listfigurename{Figurar}%
   \def\listtablename{Tabellar}%
   \def\indexname{Register}%
   \def\figurename{Figur}%
   \def\tablename{Tabell}%
   %\def\thepart{}% <<<
   \def\partname{Del}%
   \def\pagename{Side}%
   \def\seename{Sjå}%
   \def\alsoname{Sjå òg}%
   \def\enclname{Vedlegg}%
   \def\ccname{Kopi til}%
   \def\headtoname{Til}%
   \def\proofname{Bevis}%
   \def\glossaryname{Ordliste}%
}

\def\captionsnorwegian@norsk{%
   \def\refname{Referanser}%
   \def\abstractname{Sammendrag}%
   \def\bibname{Bibliografi}%
   \def\prefacename{Forord}%
   \def\chaptername{Kapittel}%
   \def\appendixname{Tillegg}%
   \def\contentsname{Innhold}%
   \def\listfigurename{Figurer}%
   \def\listtablename{Tabeller}%
   \def\indexname{Register}%
   \def\figurename{Figur}%
   \def\tablename{Tabell}%
   %\def\thepart{}% <<<
   \def\partname{Del}%
   \def\pagename{Side}%
   \def\seename{Se}%
   \def\alsoname{Se også}%
   \def\enclname{Vedlegg}%
   \def\ccname{Kopi sendt}%
   \def\headtoname{Til}%
   \def\proofname{Bevis}%
   \def\glossaryname{Ordliste}%
}

\def\captionsnorwegian{%
  \csname captionsnorwegian@\norwegian@variant\endcsname%
}

\def\datenorwegian@nynorsk{%   
   \def\today{\number\day.~\ifcase\month\or
    januar\or februar\or mars\or april\or mai\or juni\or
    juli\or august\or september\or oktober\or november\or desember
    \fi\space\number\year}%
}

\def\datenorwegian@norsk{%   
   \def\today{\number\day.~\ifcase\month\or
    januar\or februar\or mars\or april\or mai\or juni\or
    juli\or august\or september\or oktober\or november\or
    desember\fi\space\number\year}%
}

\def\datenorwegian{%
  \csname datenorwegian@\norwegian@variant\endcsname%
}

%    \end{macrocode}
% \iffalse
%</gloss-norwegian.ldf>
%<*gloss-nswissgerman.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-nswissgerman.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-nswissgerman.ldf}[polyglossia: module for Swiss German (current spelling)]

% We provide this as a babel alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-nswissgerman.ldf>
%<*gloss-nynorsk.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-nynorsk.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-nynorsk.ldf}[polyglossia: module for Norwegian (Nynorsk)]

% We only provide this gloss for babel compatibility. Since nynorsk is 
% a norwegian variety, we use 'norwegian' with variant 'nynorsk' now.

\xpg@load@master@language{norwegian}

%    \end{macrocode}
% \iffalse
%</gloss-nynorsk.ldf>
%<*gloss-occitan.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-occitan.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
%%
%% This is file `gloss-occitan.ldf',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% gloss-occitan.dtx  (with options: `ldf')
%%   ------------------------------------------------------------------
%%   The gloss-occitan module for polyglossia
%%   Copyright (C) 2016 Cédric Valmary
%%   All rights reserved
%% 
%%   Licence information appended
%% 
%%   Created by Cédric Valmary: cvalmary at yahoo dot fr
%%   of Tot en òc <http://www.totenoc.eu/>
%% 
\ProvidesFile{gloss-occitan.ldf}[polyglossia: module for Occitan]

\PolyglossiaSetup{occitan}{
  bcp47=oc,
  bcp47-language=oc,
  bcp47-script=Latn,
  hyphennames={occitan},
  langtag=OCI,
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{occitan}{oc}

\define@boolkey{occitan}[occitan@]{babelshorthands}[true]{}

\ifsystem@babelshorthands
  \setkeys{occitan}{babelshorthands=true}
\else
  \setkeys{occitan}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\occitan@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{occitan}%
  \declare@shorthand{occitan}{"}{%
    \relax\ifmmode
      \def\xpgoc@next{''}%
    \else
      \def\xpgoc@next{\futurelet\xpgoc@temp\xpgoc@cwm}%
    \fi
  \xpgoc@next}%
}
\def\xpgoc@@cwm{\nobreak\discretionary{-}{}{}\nobreak\hskip\z@skip}
\def\xpgoc@ponchinterior{%
      \nobreak\discretionary{-}{}{\mbox{$\cdot$}}\nobreak\hskip\z@skip}
\def\xpgoc@cwm{\let\xpgoc@@next\relax
  \ifcat\noexpand\xpgoc@temp a%
                         \def\xpgoc@@next{\xpgoc@@cwm}%
  \else
    \if\noexpand\xpgoc@temp \string|%
      \def\xpgoc@@next##1{\xpgoc@@cwm}%
    \else
      \if\noexpand\xpgoc@temp \string<%
        \def\xpgoc@@next##1{«\ignorespaces}%
      \else
        \if\noexpand\xpgoc@temp \string>%
          \def\xpgoc@@next##1{\unskip»}%
        \else
          \if\noexpand\xpgoc@temp\string/%
            \def\xpgoc@@next##1{\slash}%
          \else
            \if\noexpand\xpgoc@temp\string.%
              \def\xpgoc@@next##1{\xpgoc@ponchinterior}%
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
  \xpgoc@@next%
}

\def\nooccitan@shorthands{%
  \xpg@deactivate@shorthands%
}
\def\captionsoccitan{%
   \def\refname{Referéncias}%
   \def\abstractname{Resumit}%
   \def\bibname{Bibliografia}%
   \def\prefacename{Prefaci}%
   \def\chaptername{Capítol}%
   \def\appendixname{Annèx}%
   \def\contentsname{Ensenhador}%
   \def\listfigurename{Taula de las figuras}%
   \def\listtablename{Taula dels tablèus}%
   \def\indexname{Indèx}%
   \def\figurename{Figura}%
   \def\tablename{Tablèu}%
   %\def\thepart{}%
   \def\partname{Partida}%
   \def\pagename{Pagina}%
   \def\seename{vejatz}%
   \def\alsoname{vejatz tanben}%
   \def\enclname{Pèça junta}%
   \def\ccname{còpia a}%
   \def\headtoname{A}%
   \def\proofname{Demostracion}%
   \def\glossaryname{Glossari}%
}
\def\dateoccitan{%
   \def\occitanmonth{\ifcase\month\or
      de~genièr\or
      de~febrièr\or
      de~març\or
      d'abril\or
      de~mai\or
      de~junh\or
      de~julhet\or
      d'agost\or
      de~setembre\or
      d'octobre\or
      de~novembre\or
      de~decembre\fi
   }%
   \def\occitanday{\ifcase\day\or
      1èr\else% primièr
      \number\day\fi% all other numbers
   }%
   \def\today{\occitanday\space \occitanmonth\space de~\number\year}%
}
\let\xpgoc@savedvalues\empty
\AtEndPreamble{% the user or the class might define different values
  \edef\xpgoc@savedvalues{%
    \clubpenalty=\the\clubpenalty\space
    \@clubpenalty=\the\@clubpenalty\space
    \widowpenalty=\the\widowpenalty\space
    \finalhyphendemerits=\the\finalhyphendemerits}
}
\def\noextras@occitan{%
   \lccode\string"2019=\z@%
   \ifoccitan@babelshorthands\nooccitan@shorthands\fi%
   \xpgoc@savedvalues%
}
\def\blockextras@occitan{%
   \lccode\string"2019=\string"2019%
   \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
   \finalhyphendemerits=50000000%
   \ifoccitan@babelshorthands\occitan@shorthands\else\nooccitan@shorthands\fi%
}

\def\inlineextras@occitan{%
   \lccode\string"2019=\string"2019%
   \ifoccitan@babelshorthands\occitan@shorthands\else\nooccitan@shorthands\fi%
}
%% Distributable under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%% 
%% This work is "author-maintained"
%% The maintainer is Cédric Valmary
%% 
%%
%% End of file `gloss-occitan.ldf'.
%    \end{macrocode}
% \iffalse
%</gloss-occitan.ldf>
%<*gloss-pa.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-pa.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-pa.ldf}[polyglossia: module for pa (Punjabi)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{punjabi}

%    \end{macrocode}
% \iffalse
%</gloss-pa.ldf>
%<*gloss-persian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-persian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-persian.ldf}[polyglossia: module for Persian]

\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{farsical}
\RequirePackage{hijrical}
\PolyglossiaSetup{persian}{
  bcp47=fa,
  bcp47-language=fa,
  bcp47-script=Arab,
  babelname=farsi,
  script=Arabic,
  direction=RL,
  scripttag=arab,
  langtag=FAR,
  hyphennames={nohyphenation},
  fontsetup=true,
  localnumeral=farsinumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{persian}{fa}

% Babel and backwards compat. alias
\setlanguagealias{persian}{farsi}

\newif\if@western@numerals
\define@choicekey*+{persian}{numerals}[\xpg@val\xpg@nr]{eastern,western}[eastern]{%
   \ifcase\xpg@nr\relax
      % eastern:
      \@western@numeralsfalse%
      \SetLanguageKeys{persian}{bcp47-extension-u=nu-arab}%
   \or
      % western:
      \@western@numeralstrue%
      \SetLanguageKeys{persian}{bcp47-extension-u=nu-latn}%
   \fi
   \xpg@info{Option: Persian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Persian numerals option `#1'}}

\newif\ifpersian@customsep\persian@customsepfalse
\def\xpg@sepmark{}
\define@key{persian}{sectionsep}[.]{%
   \persian@customseptrue%
   \gdef\xpg@sepmark{#1}%
}

%this is needed for \abjad in arabicnumbers.sty
\define@boolkey{persian}[persian@]{abjadjimnotail}[true]{%
  \ifpersian@abjadjimnotail
    \abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi}

% NOT YET USED
\define@key{persian}{locale}[default]{%
  \def\@persian@locale{#1}}

%TODO add option for CALENDAR

% Register default options
\xpg@initialize@gloss@options{persian}{locale=default,numerals=eastern,abjadjimnotail=false}

\def\farsigregmonth#1{\ifcase#1%
  \or ژانویه\or فوریه\or مارس\or آوریل\or مه\or ژوئن\or ژوئیه\or اوت\or سپتامبر\or اکتبر\or نوامبر\or دسامبر\fi}
\def\farsimonth#1{\ifcase#1%
  \or کانون ثانی\or شباط\or اذار%%or ادار
    \or نیسان\or ایار\or حزیران\or تموز\or آب\or ایلول\or تشرین اول\or تشرین ثانی\or کانون اول\fi}

%\Hijritoday is now locale-aware and will format the date with this macro:
\DefineFormatHijriDate{persian}{\@ensure@RTL{%
\farsinumber{\value{Hijriday}}\space\HijriMonthArabic{\value{Hijrimonth}}\space\farsinumber{\value{Hijriyear}}}}

\def\captionspersian{%
\def\prefacename{\@ensure@RTL{پیشگفتار}}%
\def\refname{\@ensure@RTL{مراجع}}%
\def\abstractname{\@ensure@RTL{چکیده}}%
\def\bibname{\@ensure@RTL{کتاب‌نامه}}%
\def\chaptername{\@ensure@RTL{فصل}}%
\def\appendixname{\@ensure@RTL{پیوست}}%
\def\contentsname{\@ensure@RTL{فهرست مطالب}}%
\def\listfigurename{\@ensure@RTL{لیست تصاویر}}%
\def\listtablename{\@ensure@RTL{لیست جداول}}%
\def\indexname{\@ensure@RTL{نمایه}}%
\def\figurename{\@ensure@RTL{شكل}}%
\def\tablename{\@ensure@RTL{جدول}}%
\def\partname{\@ensure@RTL{بخش}}%
\def\enclname{\@ensure@RTL{پیوست}}%
\def\ccname{\@ensure@RTL{رونوشت}}%
\def\headtoname{\@ensure@RTL{به}}%
\def\pagename{\@ensure@RTL{صفحة}}%
\def\seename{\@ensure@RTL{ببینید}}%
\def\alsoname{\@ensure@RTL{نیز ببینید}}%
\def\proofname{\@ensure@RTL{برهان}}%
\def\glossaryname{\@ensure@RTL{دانش‌نامه}}%
}
\def\datepersian{%
   \def\today{\@ensure@RTL{\farsinumber\day\space\farsigregmonth{\month}\space\farsinumber\year}}%
}

\newcommand{\farsinumerals}[2]{\farsinumber{#2}}

\def\farsinumber#1{%
  \if@western@numerals
    \number#1%
  \else
    \xpg@if@char@available{06F0}%
          {\@ensure@LTR{\farsidigits{\number#1}}}%
          {\@ensure@LTR{\arabicdigits{\number#1}}}%
  \fi
}

%\def\farsinum#1{\expandafter\farsinumber\csname c@#1\endcsname}
%\def\farsibracenum#1{(\expandafter\farsinumber\csname c@#1\endcsname)}
%\def\farsiornatebracenum#1{\char"FD3E\expandafter\farsinumber\csname c@#1\endcsname\char"FD3F}
%\def\farsialph#1{\expandafter\@farsialph\csname c@#1\endcsname}

\def\persian@numbers{%
   \let\@alph\abjad%
   \let\@Alph\abjad%
}

\def\nopersian@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
}

\def\persian@globalnumbers{%
   \let\@arabic\farsinumber%
   \renewcommand\thefootnote{\localnumeral*{footnote}}%
   \renewcommand\theequation{\localnumeral*{equation}}%
}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\nopersian@globalnumbers{
   \let\@arabic\xpg@save@arabic%
}

\def\persian@xetex@capsformat{%
  \let\xpg@save@sepmark\@SepMark%
  \SepMark{\xpg@sepmark}
}

\def\nopersian@xetex@capsformat{%
   \ifcsdef{xpg@save@sepmark}{%
     \SepMark{\xpg@save@sepmark}
   }{}%
}

\def\persian@luatex@capsformat{%
  %
  % change chapter and part headings
  \ifpersian@customsep
     \ifcsdef{chapter}{%
        \let\xpg@save@thesection\thesection%
        \renewcommand*\thesection{\thechapter\xpg@sepmark\@arabic\c@section}
        \let\xpg@save@theequation\theequation%
        \renewcommand*\theequation{%
	    \ifnum \c@chapter>\z@ \thechapter\xpg@sepmark\fi\@arabic\c@equation}
        \let\xpg@save@thefigure\thefigure%
	\renewcommand*\thefigure{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@figure}
        \let\xpg@save@thetable\thetable%
	\renewcommand*\thetable{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@table}
     }{}
     \let\xpg@save@thesubsection\thesubsection%
     \renewcommand\thesubsection
	{\thesection\xpg@sepmark\@arabic\c@subsection}
     \let\xpg@save@thesubsubsection\thesubsubsection%
     \renewcommand\thesubsubsection{\thesubsection\xpg@sepmark\@arabic\c@subsubsection}
     \let\xpg@save@theparagraph\theparagraph%
     \renewcommand\theparagraph
         {\thesubsubsection\xpg@sepmark\@arabic\c@paragraph}
     \let\xpg@save@thesubparagraph\thesubparagraph%
     \renewcommand\thesubparagraph{\theparagraph\xpg@sepmark\@arabic\c@subparagraph}
  \fi% (end \ifpersiancustomsep)
}

\def\nopersian@luatex@capsformat{%
   \ifcsdef{xpg@save@thesection}{%
        \let\thesection\xpg@save@thesection%
   }{}%
   \ifcsdef{xpg@save@theequation}{%
        \let\theequation\xpg@save@theequation%
   }{}%
   \ifcsdef{xpg@save@thefigure}{%
        \let\thefigure\xpg@save@thefigure%
   }{}%
   \ifcsdef{xpg@save@thetable}{%
        \let\thetable\xpg@save@thetable%
   }{}%
   \ifcsdef{xpg@save@thesubsection}{%
        \let\thesubsection\xpg@save@thesubsection%
   \ifcsdef{xpg@save@thesubsubsection}{%
        \let\thesubsubsection\xpg@save@thesubsubsection%
   }{}%
   }{}%
   \ifcsdef{xpg@save@theparagraph}{%
        \let\theparagraph\xpg@save@theparagraph%
   }{}%
   \ifcsdef{xpg@save@thesubparagraph}{%
        \let\thesubparagraph\xpg@save@thesubparagraph%
   }{}%
}

\def\blockextras@persian{%
   \ifpersian@customsep
      \ifxetex
        \persian@xetex@capsformat
      \else
        \persian@luatex@capsformat
      \fi   
   \fi
}
%
\def\noextras@persian{%
    \ifpersian@customsep
      \ifxetex
        \nopersian@xetex@capsformat
      \else
        \nopersian@luatex@capsformat
      \fi   
   \fi
}

%    \end{macrocode}
% \iffalse
%</gloss-persian.ldf>
%<*gloss-piedmontese.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-piedmontese.ldf}
%    \begin{macrocode}
% !TEX encoding = UTF-8 Unicode
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-piedmontese.ldf}[2013/02/12 v1.0 polyglossia: module for Piedmontese]
\makeatletter
\PolyglossiaSetup{piedmontese}{
  bcp47=pms,
  bcp47-language=pms,
  bcp47-script=Latn,
  hyphennames={piedmontese},
  hyphenmins={2,2},
  langtag=PMS,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{piedmontese}{pms}

\define@boolkey{piedmontese}[piedmontese@]{babelshorthands}[true]{}

\ifsystem@babelshorthands
  \setkeys{piedmontese}{babelshorthands=true}
\else
  \setkeys{piedmontese}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\piedmontese@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{piedmontese}%
  \declare@shorthand{piedmontese}{"}{%
    \relax\ifmmode
      \def\xpgpms@next{''}%
    \else
      \def\xpgpms@next{\futurelet\xpgpms@temp\xpgpms@cwm}%
    \fi
  \xpgpms@next}%
}

\def\xpgpms@@cwm{\nobreak\discretionary{-}{}{}\nobreak\hskip\z@skip}
\def\xpgpms@cwm{\let\xpgpms@@next\relax
\ifcat\noexpand\xpgpms@temp a%
    \def\xpgpms@@next{\pms@@cwm}%
\else
    \ifx\xpgpms@temp/%
        \def\xpgpms@@next{\bbl@allowhyphens/\bbl@allowhyphens\@gobble}%
    \else
        \ifx\xpgpms@temp-%
           \def\xpgpms@@next{\bbl@allowhyphens-\bbl@allowhyphens\@gobble}%
        \else
            \ifx\xpgpms@temp"%
                \def\xpgpms@@next{``\expandafter\@gobble\string}%
            \fi
        \fi
    \fi
\xpgpms@@next}

\def\nopiedmontese@shorthands{%
  \xpg@deactivate@shorthands%
}
\@namedef{captions\CurrentOption}{%
    \def\prefacename{Prefassion}%
    \def\refname{Riferiment}%
    \def\abstractname{Somari}%
    \def\bibname{Bibliografìa}%
    \def\chaptername{Capìtol}%
    \def\appendixname{Gionta}%
    \def\contentsname{Tàula}%
    \def\listfigurename{Lista dle figure}%
    \def\listtablename{Lista dle tabele}%
    \def\indexname{Tàula analìtica}%
    \def\figurename{Figura}%
    \def\tablename{Tabela}%
    \def\partname{Part}%
    \def\enclname{Gionta/e}%
    \def\ccname{Con còpia a}%
    \def\headtoname{Për}%
    \def\pagename{Pàgina}%
    \def\seename{vëd}%
    \def\alsoname{vëd anche}%
    \def\proofname{Dimostrassion}%
    \def\glossaryname{Glossari}%
}
\@namedef{date\CurrentOption}{%
    \def\today{\number\day\space\ifcase\month\or
      ëd gené\or ëd fevré\or ëd mars\or d'avril\or ëd maj\or ëd giugn\or
      ëd luj\or d'agost\or dë stèmber\or d'otóber\or ëd novèmber\or dë dzèmber%
      \fi\space dal\space\number\year}}
      
\AtEndPreamble{% 
  \edef\xpgpms@savedvalues{%
    \clubpenalty=\the\clubpenalty\space
    \@clubpenalty=\the\@clubpenalty\space
    \widowpenalty=\the\widowpenalty\space
    \finalhyphendemerits=\the\finalhyphendemerits}
}


\def\noextras@piedmontese{%
   \lccode\string"2019=\z@%
   \ifpiedmontese@babelshorthands\nopiedmontese@shorthands\fi%
   \xpgpms@savedvalues%
}

\def\blockextras@piedmontese{%
   \lccode\string"2019=\string"2019%
   \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000%
   \finalhyphendemerits=50000000%
   \ifpiedmontese@babelshorthands\piedmontese@shorthands\else\nopiedmontese@shorthands\fi%
}

\def\inlineextras@piedmontese{%
   \lccode\string"2019=\string"2019%
   \ifpiedmontese@babelshorthands\piedmontese@shorthands\else\nopiedmontese@shorthands\fi%
}
%%% CHANGES END %%%
%    \end{macrocode}
% \iffalse
%</gloss-piedmontese.ldf>
%<*gloss-polish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-polish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-polish.ldf}[polyglossia: module for Polish]

\PolyglossiaSetup{polish}{
  bcp47=pl,
  bcp47-language=pl,
  bcp47-script=Latn,
  hyphennames={polish},
  hyphenmins={2,2},
  langtag=PLK,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{polish}{pl}

\ifluatex
  \RequirePackage{luavlna}
\fi

\define@boolkey{polish}[polish@]{babelshorthands}[true]{}

\define@boolkey{polish}[polish@]{splithyphens}[true]{}

\define@boolkey{polish}[polish@]{vlna}[true]{}

% Register default options
\xpg@initialize@gloss@options{polish}{babelshorthands=false,splithyphens=true,vlna=true}

\ifsystem@babelshorthands
  \setkeys{polish}{babelshorthands=true}
\else
  \setkeys{polish}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\let\xpg@hyphen@char-
\def\polish@@splhyphen#1{%
  \def\polish@sh@tmp{%
       \ifx\polish@sh@next\xpg@hyphen@char#1%
       \else\expandafter\polish@@@splhyphen{#1}\fi%
     }%
     \futurelet\polish@sh@next\polish@sh@tmp%
}

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

\def\polish@splhyphen{%
  \polish@@splhyphen{-}%
}

\def\polish@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{polish}%
  \declare@shorthand{polish}{"=}{\polish@splhyphen}%
  \declare@shorthand{polish}{""}{\hskip\z@skip}%
  \declare@shorthand{polish}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{polish}{"-}{\nobreak\-\bbl@allowhyphens}%
  \declare@shorthand{polish}{"|}{%
      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
      \bbl@allowhyphens}{}%
  }%
  \declare@shorthand{polish}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
  \declare@shorthand{polish}{"`}{„}%
  \declare@shorthand{polish}{"'}{”}%
  \declare@shorthand{polish}{"<}{«}%
  \declare@shorthand{polish}{">}{»}%
}

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

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

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

\def\nopolish@hyphens{%
    \ifluatex
      \AfterPreamble{\disablesplithyphens{polish}}%
    \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\polish@nointerchartoks{\let\polish@interchartoks\polish@PreCSpreposition}%
    \def\polish@PreCSpreposition{%
       \def\next{}%
       \ifnum\catcode`\ =10 % nothing will be done in verbatim
       \ifmmode % nothing in math
       \else
          \let\polish@interchartoks\polish@nointerchartoks
          \let\next\polish@ExamineCSpreposition
       \fi\fi
       \next%
    }%
    \def\polish@ExamineCSpreposition #1{#1\futurelet\next\polish@ProcessCSpreposition}%
    \def\polish@ProcessCSpreposition{\ifx\next\polish@XeTeXspace\nobreak\fi}%
    \futurelet\polish@XeTeXspace{ }\polish@nointerchartoks
\fi

\def\polish@vlna{%
    \ifluatex
       \singlechars{polish}{AaIiOoUuWwZz}%
       \preventsingleon
    \else
        % Code taken and adapted from xevlna.sty
        \XeTeXinterchartokenstate=1
        \XeTeXcharclass `\( \polish@openpunctuation
        \XeTeXcharclass `\[ \polish@openpunctuation
        \XeTeXcharclass `\„ \polish@openpunctuation
        \XeTeXcharclass `\« \polish@openpunctuation
        \XeTeXcharclass `\W \polish@nonsyllabicpreposition
        \XeTeXcharclass `\w \polish@nonsyllabicpreposition
        \XeTeXcharclass `\Z \polish@nonsyllabicpreposition
        \XeTeXcharclass `\z \polish@nonsyllabicpreposition
        \XeTeXcharclass `\O \polish@nonsyllabicpreposition
        \XeTeXcharclass `\o \polish@nonsyllabicpreposition
        \XeTeXcharclass `\U \polish@nonsyllabicpreposition
        \XeTeXcharclass `\u \polish@nonsyllabicpreposition
        \XeTeXcharclass `\A \polish@nonsyllabicpreposition
        \XeTeXcharclass `\a \polish@nonsyllabicpreposition
        \XeTeXcharclass `\I \polish@nonsyllabicpreposition
        \XeTeXcharclass `\i \polish@nonsyllabicpreposition
        \XeTeXinterchartoks \polish@boundary \polish@nonsyllabicpreposition {\polish@interchartoks}%
        \XeTeXinterchartoks \polish@openpunctuation \polish@nonsyllabicpreposition {\polish@interchartoks}%
    \fi
}

\def\nopolish@vlna{%
    \ifluatex
        \preventsingleoff
    \else
        \XeTeXcharclass`\(\z@
        \XeTeXcharclass`\[\z@
        \XeTeXcharclass`\„\z@
        \XeTeXcharclass`\«\z@
        \XeTeXcharclass`\W\z@
        \XeTeXcharclass`\w\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\captionspolish{%
  \def\prefacename{Przedmowa}%
  \def\refname{Literatura}%
  \def\abstractname{Streszczenie}%
  \def\bibname{Bibliografia}%
  \def\chaptername{Rozdział}%
  \def\appendixname{Dodatek}%
  \def\contentsname{Spis treści}%
  \def\listfigurename{Spis rysunków}%
  \def\listtablename{Spis tabel}%
  \def\indexname{Indeks}%
  \def\figurename{Rysunek}%
  \def\tablename{Tabela}%
  \def\partname{Część}%
  \def\enclname{Załącznik}%
  \def\ccname{Kopie:}%
  \def\headtoname{Do}%
  \def\pagename{Strona}%
  \def\seename{Zobacz}%
  \def\alsoname{Zobacz też}%
  \def\proofname{Dowód}%
  \def\glossaryname{Słowniczek}%
}

\def\datepolish{%
  \def\today{\number\day\space\ifcase\month\or
      stycznia\or lutego\or marca\or kwietnia\or maja\or czerwca\or
      lipca\or sierpnia\or września\or października\or
      listopada\or grudnia\fi\space
      \number\year}%
}

\def\noextras@polish{%
  \ifpolish@babelshorthands\nopolish@shorthands\fi%
  \nopolish@hyphens%
  \nopolish@vlna%
  \ifxetex\XeTeXinterchartokenstate=0\fi%
}

\def\blockextras@polish{%
  \ifpolish@babelshorthands\polish@shorthands\else\nopolish@shorthands\fi%
  \ifpolish@vlna\polish@vlna\else\nopolish@vlna\fi%
  \ifpolish@splithyphens\polish@hyphens\else\nopolish@hyphens\fi%
}

\def\inlineextras@polish{%
  \ifpolish@babelshorthands\polish@shorthands\else\nopolish@shorthands\fi%
  \ifpolish@vlna\polish@vlna\else\nopolish@vlna\fi%
  \ifpolish@splithyphens\polish@hyphens\else\nopolish@hyphens\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-polish.ldf>
%<*gloss-polutonikogreek.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-polutonikogreek.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-polutonikogreek.ldf}[polyglossia: module for polytonic Greek]

% We provide this as a babel alias

\xpg@load@master@language{greek}

%    \end{macrocode}
% \iffalse
%</gloss-polutonikogreek.ldf>
%<*gloss-portuges.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-portuges.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-portuges.ldf}[polyglossia: module for Portuguese]

% We only provide this gloss for backwards compatibility. The name
% 'portuges' was selected in accordance with babel (which probably
% introduced it in 8.3 filename times). Since polyglossia uses full
% English language names, we use 'portuguese' now.

\xpg@load@master@language{portuguese}
     
%    \end{macrocode}
% \iffalse
%</gloss-portuges.ldf>
%<*gloss-portuguese.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-portuguese.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-portuguese.ldf}[polyglossia: module for Portuguese]

\PolyglossiaSetup{portuguese}{
  bcp47=pt-PT,
  bcp47-language=pt,
  bcp47-region=PT,
  bcp47-script=Latn,
  babelname=portuges,
  hyphennames={portuges,portuguese},
  hyphenmins={2,3},
  langtag=PTG,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*[variant=portuguese]{portuguese}{pt-PT}
\setlanguagealias*[variant=brazilian]{portuguese}{pt-BR}
\setlanguagealias*{portuguese}{pt}

% Babel aliases
\setlanguagealias[variant=portuguese]{portuguese}{portuges}
\setlanguagealias[variant=brazilian]{portuguese}{brazil}

\ifluatex
  \RequirePackage{luavlna}
\fi

\def\portuguese@variant{portuges}
\define@choicekey*+{portuguese}{variant}[\xpg@val\xpg@nr]{portuguese,brazilian}[portuguese]{%
   \ifcase\xpg@nr\relax
      % portuguese:
      \def\portuguese@variant{portuges}%
      \SetLanguageKeys{portuguese}{babelname=portuges,bcp47=pt-PT,bcp47-language=pt,bcp47-region=PT}%
   \or
      % brazilian:
      \def\portuguese@variant{brazil}%
      \SetLanguageKeys{portuguese}{babelname=brazil,bcp47=pt-BR,bcp47-language=pt,bcp47-region=BR}%
      % There are no specific brazil patterns
      \adddialect\l@brazil\l@portuges\relax%
   \fi
   \xpg@info{Option: portuguese, variant=\xpg@val}%
}{\xpg@warning{Unknown portuguese variant `#1'}}

\define@boolkey{portuguese}[portuguese@]{babelshorthands}[true]{}

\define@boolkey{portuguese}[portuguese@]{splithyphens}[true]{}

% Register default options
\xpg@initialize@gloss@options{portuguese}{variant=portuguese,
      babelshorthands=false,
      splithyphens=true}

\ifsystem@babelshorthands
  \setkeys{portuguese}{babelshorthands=true}
\else
  \setkeys{portuguese}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\let\xpg@hyphen@char-
\def\portuguese@@splhyphen#1{%
  \def\portuguese@sh@tmp{%
       \ifx\portuguese@sh@next\xpg@hyphen@char#1%
       \else\expandafter\portuguese@@@splhyphen{#1}\fi%
     }%
     \futurelet\portuguese@sh@next\portuguese@sh@tmp%
}

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

\def\portuguese@splhyphen{%
  \portuguese@@splhyphen{-}%
}

\def\portuguese@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{portuguese}%
  \declare@shorthand{portuguese}{"=}{\portuguese@splhyphen}%
  \declare@shorthand{portuguese}{""}{\hskip\z@skip}%
  \declare@shorthand{portuguese}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{portuguese}{"-}{\nobreak\-\bbl@allowhyphens}%
  \declare@shorthand{portuguese}{"|}{%
      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
      \bbl@allowhyphens}{}%
  }%
  \declare@shorthand{portuguese}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
  \declare@shorthand{portuguese}{"<}{«}%
  \declare@shorthand{portuguese}{">}{»}%
}

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

\ifxetex
  % splithyphens
  \newXeTeXintercharclass\portuguese@hyphen % -
\fi

\def\portuguese@hyphens{%
    \ifluatex
      \AfterPreamble{\enablesplithyphens{portuguese}}%
    \else
      \XeTeXinterchartokenstate=1
      \XeTeXcharclass `\- \portuguese@hyphen
      \XeTeXinterchartoks \z@ \portuguese@hyphen = {\portuguese@@splhyphen}% "-" -> "\portuguese@@splhyphen-"
    \fi%
}

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

\def\portuguese@language{%
   \polyglossia@setup@language@patterns{\portuguese@variant}%
}%

\def\captionsportuguese@portuges{%
  \def\refname{Referências}%
  \def\abstractname{Resumo}%
  \def\bibname{Bibliografia}%
  \def\prefacename{Prefácio}%
  \def\chaptername{Capítulo}%
  \def\appendixname{Apêndice}%
  \def\contentsname{Conteúdo}%
  \def\listfigurename{Lista de Figuras}%
  \def\listtablename{Lista de Tabelas}%
  \def\indexname{Índice}%
  \def\figurename{Figura}%
  \def\tablename{Tabela}%
  \def\partname{Parte}%
  \def\pagename{Página}%
  \def\seename{ver}%
  \def\alsoname{ver também}%
  \def\enclname{Anexo}%
  \def\ccname{Com cópia a}%
  \def\headtoname{Para}%
  \def\proofname{Demonstração}%
  \def\glossaryname{Glossário}%
}

\def\captionsportuguese@brazil{%
   \def\refname{Referências}%
   \def\abstractname{Resumo}%
   \def\bibname{Referências Bibliográficas}%
   \def\prefacename{Prefácio}%
   \def\chaptername{Capítulo}%
   \def\appendixname{Apêndice}%
   \def\contentsname{Sumário}%
   \def\listfigurename{Lista de Figuras}%
   \def\listtablename{Lista de Tabelas}%
   \def\indexname{Índice Remissivo}%
   \def\figurename{Figura}%
   \def\tablename{Tabela}%
   \def\partname{Parte}%
   \def\pagename{Página}%
   \def\seename{veja}%
   \def\alsoname{veja também}%
   \def\enclname{Anexo}%
   \def\ccname{Cópia para}%
   \def\headtoname{Para}%
   \def\proofname{Demonstração}%
   \def\glossaryname{Glossário}%
}

\def\captionsportuguese{%
  \csname captionsportuguese@\portuguese@variant\endcsname%
}

\def\dateportuguese@portuges{%   
  \def\today{\number\day\space de\space\ifcase\month\or
    Janeiro\or Fevereiro\or Março\or Abril\or Maio\or Junho\or
    Julho\or Agosto\or Setembro\or Outubro\or Novembro\or Dezembro\fi
    \space de\space\number\year}%
}


\def\dateportuguese@brazil{%   
   \def\today{\number\day\space de\space\ifcase\month\or
      janeiro\or fevereiro\or março\or abril\or maio\or junho\or
      julho\or agosto\or setembro\or outubro\or novembro\or dezembro%
      \fi\space de\space\number\year}%
}

\def\dateportuguese{%
  \csname dateportuguese@\portuguese@variant\endcsname%
}

\def\noextras@portuguese{%
  \ifportuguese@babelshorthands\noportuguese@shorthands\fi%
  \noportuguese@hyphens%
}

\def\blockextras@portuguese{%
  \ifportuguese@babelshorthands\portuguese@shorthands\else\noportuguese@shorthands\fi%
  \ifportuguese@splithyphens\portuguese@hyphens\else\noportuguese@hyphens\fi%
}

\def\inlineextras@portuguese{%
  \ifportuguese@babelshorthands\portuguese@shorthands\else\noportuguese@shorthands\fi%
  \ifportuguese@splithyphens\portuguese@hyphens\else\noportuguese@hyphens\fi%
}
     
%    \end{macrocode}
% \iffalse
%</gloss-portuguese.ldf>
%<*gloss-punjabi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-punjabi.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
% UTF-8 strings kindly provided by 
% Arvinder Singh Kang, <17-11-2022>
% Amanpreet Singh Brar <17-11-2022>
% Amandeep Singh Saini <17-11-2022>

\ProvidesFile{gloss-punjabi.ldf}[polyglossia: module for Panjabi/Punjabi/pa-Gurmukhi]
\RequirePackage{gurmukhidigits}
\PolyglossiaSetup{punjabi}{
  bcp47=pa,
  bcp47-language=pa,
  bcp47-script=Guru,
  script=Gurmukhi,
  scripttag=gur,
  langtag=pan,
%%  hyphennames={panjabi,punjabi,gurmukhi}, TODO: implement fallback patterns (with ! prefix)
  fontsetup=true,
  localnumeral=punjabinumerals
  %TODO nouppercase=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{punjabi}{pa}

\def\punjabi@language{%
  % patterns are spelled panjabi
  \polyglossia@setup@language@patterns{panjabi}%
}

\newif\ifpunjabi@gurmukhi@numerals
\punjabi@gurmukhi@numeralstrue
\define@choicekey*+{punjabi}{numerals}[\xpg@val\xpg@nr]{Gurmukhi,Western}[Gurmukhi]{%
   \ifcase\xpg@nr\relax
      % Gurmukhi:
      \punjabi@gurmukhi@numeralstrue%
      \SetLanguageKeys{punjabi}{bcp47-extension-u=nu-guru}%
   \or
      % Western:
      \punjabi@gurmukhi@numeralsfalse%
      \SetLanguageKeys{punjabi}{bcp47-extension-u=nu-latn}%
   \fi
   \xpg@info{Option: Punjabi, numerals=\xpg@val}%
}{\xpg@warning{Unknown Punjabi numeral `#1'}}

% Register default options
\xpg@initialize@gloss@options{punjabi}{numerals=gurmukhi}

\newcommand{\punjabinumerals}[2]{\punjabinumber{#2}}

\def\punjabinumber#1{%
  \ifpunjabi@gurmukhi@numerals
    \gurmukhidigits{\number#1}%
  \else
    \number#1%
  \fi}

\let\punjabinumeral=\punjabinumber

\def\captionspunjabi{%
     \def\abstractname{ਨਿਚੋੜ}%
     \def\appendixname{ਅੰਤਿਕਾ}%
     \def\bibname{ਪੁਸਤਕ ਸੂਚੀ}%
     \def\ccname{}%
     \def\chaptername{ਖੰਡ}%
     \def\contentsname{ਸਮਗਰੀ ਸੂਚੀ}%
     \def\enclname{ਨੱਥੀ}%
     \def\figurename{ਚਿੱਤਰ}%
     \def\headpagename{ਪਲੇਠਾ-ਪੰਨਾ}%
     \def\headtoname{}%
     \def\indexname{ਸੂਚੀ}%
     \def\listfigurename{ਚਿੱਤਰਾਂ ਦੀ ਸੂਚੀ}%
     \def\listtablename{ਸਾਰਣੀ}%
     \def\pagename{ਪੰਨਾ}%
     \def\partname{ਭਾਗ}%
     \def\prefacename{ਮੁੱਖਬੰਦ}%
     \def\refname{ਹਵਾਲੇ}%
     \def\tablename{ਸਾਰਣੀ}%
     \def\seename{ਵੇਖੋ}%
     \def\alsoname{ਹੋਰ ਵੇਖੋ}%
     \def\alsoseename{ਹੋਰ ਵੇਖੋ}%
}
\def\datepunjabi{%
  \def\today{\punjabinumber\day\space\ifcase\month\or
    ਜਨਵਰੀ\or
    ਫਰਵਰੀ\or
    ਮਾਰਚ\or
    ਅਪ੍ਰੈਲ\or
    ਮਈ\or
    ਜੂਨ\or
    ਜੁਲਾਈ\or
    ਅਗਸਤ\or
    ਸਤੰਬਰ\or
    ਅਕਤੂਬਰ\or
    ਨਵੰਬਰ\or
    ਦਸੰਬਰ\fi
    \space\punjabinumber\year}%
}

%    \end{macrocode}
% \iffalse
%</gloss-punjabi.ldf>
%<*gloss-romanian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-romanian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-romanian.ldf}[polyglossia: module for Romanian]

\PolyglossiaSetup{romanian}{
  bcp47=ro,
  bcp47-language=ro,
  bcp47-script=Latn,
  hyphennames={romanian},
  hyphenmins={2,2},
  langtag=ROM,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{romanian}{ro}

\def\captionsromanian{%
   \def\refname{Bibliografie}%
   \def\abstractname{Rezumat}%
   \def\bibname{Bibliografie}%
   \def\prefacename{Prefață}%
   \def\chaptername{Capitolul}%
   \def\appendixname{Anexa}%
   \def\contentsname{Cuprins}%
   \def\listfigurename{Listă de figuri}%
   \def\listtablename{Listă de tabele}%
   \def\indexname{Glosar}%
   \def\figurename{Figura}%
   \def\tablename{Tabela}%
   %\def\thepart{}%
   \def\partname{Partea}%
   \def\pagename{Pagina}%
   \def\seename{Vezi}%
   \def\alsoname{Vezi de asemenea}%
   \def\enclname{Anexă}%
   \def\ccname{Copie}%
   \def\headtoname{Pentru}%
   \def\proofname{Demonstrație}%
   \def\glossaryname{Glosar}%
   }

\def\dateromanian{%
  \def\today{\number\day~\ifcase\month\or
    ianuarie\or februarie\or martie\or aprilie\or mai\or
    iunie\or iulie\or august\or septembrie\or octombrie\or
    noiembrie\or decembrie\fi
    \space \number\year}%
  }

%    \end{macrocode}
% \iffalse
%</gloss-romanian.ldf>
%<*gloss-romansh.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-romansh.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-romansh.ldf}[polyglossia: module for Romansh]
\makeatletter
\PolyglossiaSetup{romansh}{%
  bcp47=rm,
  bcp47-language=rm,
  bcp47-script=Latn,
  hyphennames={romansh},
  hyphenmins={2,2},
  langtag=RMS,
  indentfirst=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{romansh}{rm}

\def\captionsromansh{%
  \def\prefacename{Prefaziun}%
  \def\refname{Bibliografia}%
  \def\abstractname{Recapitulaziun}%
  \def\bibname{Index bibliografic}%
  \def\chaptername{Chapitel}%
  \def\appendixname{Appendix}%
  \def\contentsname{Tavla dal cuntegn}%
  \def\listfigurename{Tavla da las figuras}%
  \def\listtablename{Tavla da las tabellas}%
  \def\indexname{Register da materias}%       Index?
  \def\figurename{Figura}%
  \def\tablename{Tabella}%
  \def\partname{Part}%
  \def\enclname{Agiunta(s)}%
  \def\ccname{Copia a}%
  \def\headtoname{A}%
  \def\pagename{pagina}%  
  \def\seename{vesair }%
  \def\alsoname{vesair era}%
  \def\proofname{Demonstraziun}%
  \def\glossaryname{Glossari}%
  }
  
\def\dateromansh{%
  \def\today{\ifcase\day\or1.\else ils~\number\day\fi~da~%
    \ifcase\month\or
    schaner\or favrer\or mars\or avrigl\or matg\or zercladur\or
    fanadur\or avust\or settember\or october\or november\or
    december\fi\space \number\year}}
\makeatother
%    \end{macrocode}
% \iffalse
%</gloss-romansh.ldf>
%<*gloss-russian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-russian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-russian.ldf}[polyglossia: module for Russian]

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{russian}{
  bcp47=ru,
  bcp47-language=ru,
  bcp47-variant=luna1918,
  bcp47-script=Cyrl,
  script=Cyrillic,
  scripttag=cyrl,
  langtag=RUS,
  hyphennames={russian},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup,
  localnumeral=russiannumerals,
  Localnumeral=Russiannumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{russian}{ru}
\setlanguagealias*[spelling=modern]{russian}{ru-luna1918}
\setlanguagealias*[spelling=old]{russian}{ru-petr1708}

\newif\if@russian@modern
\define@key{russian}{spelling}[modern]{%
  \ifstrequal{#1}{old}%
    {\@russian@modernfalse\SetLanguageKeys{russian}{bcp47=ru-petr1708,bcp47-variant=petr1708}}%
    {\@russian@moderntrue\SetLanguageKeys{russian}{bcp47=ru,bcp47-variant=luna1918}}%
}

\def\captionsrussian{%
   \if@russian@modern\captionsrussian@modern\else\captionsrussian@old\fi%
}%

\def\daterussian{%
   \if@russian@modern\daterussian@modern\else\daterussian@old\fi%
}%

\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals
\define@choicekey*+{russian}{numerals}[\xpg@val\xpg@nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
   \ifcase\xpg@nr\relax
      % arabic:
      \cyrillic@numeralsfalse%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{russian}{bcp47-extension-u=nu-latn}%
   \or
      % cyrillic:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{russian}{bcp47-extension-u=nu-cyrl}%
   \or
      % cyrillic-trad:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{russian}{bcp47-extension-u=nu-cyrl}%
   \or
      % cyrillic-alph:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralstrue%
      \SetLanguageKeys{russian}{bcp47-extension-u=nu-cyrl}%
   \fi
   \xpg@info{Option: Russian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Russian numerals value `#1'}}

\define@boolkey{russian}[russian@]{indentfirst}[true]{%
  \ifrussian@indentfirst
      \SetLanguageKeys{russian}{indentfirst=true}%
  \else
      \SetLanguageKeys{russian}{indentfirst=false}%
  \fi%
}

\define@boolkey{russian}[russian@]{babelshorthands}[true]{}

% Force punctuation after heading number
\define@boolkey{russian}[russian@]{forceheadingpunctuation}[true]{}

% Define some math functions
\define@boolkey{russian}[russian@]{mathfunctions}[true]{}

% Register default options
\xpg@initialize@gloss@options{russian}{babelshorthands=false,
                                       spelling=modern,
                                       numerals=arabic,
                                       indentfirst=true,
                                       forceheadingpunctuation=true,
                                       mathfunctions=true}


\ifsystem@babelshorthands
  \setkeys{russian}{babelshorthands=true}
\else
  \setkeys{russian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\russian@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{russian}%
%  \declare@shorthand{russian}{"`}{„}%
%  \declare@shorthand{russian}{"'}{“}%
%  \declare@shorthand{russian}{"<}{«}%
%  \declare@shorthand{russian}{">}{»}%
  \declare@shorthand{russian}{""}{\hskip\z@skip}%
  \declare@shorthand{russian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{russian}{"=}{\nobreak-\hskip\z@skip}%
  \declare@shorthand{russian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
  \declare@shorthand{russian}{"-}{%
    \def\russian@sh@tmp{%
      \if\russian@sh@next-\expandafter\russian@sh@emdash%
      \else\expandafter\russian@sh@hyphen\fi%
    }%
    \futurelet\russian@sh@next\russian@sh@tmp}%
  \def\russian@sh@hyphen{%
    \nobreak\-\bbl@allowhyphens}%
  \def\russian@sh@emdash##1##2{\cdash-##1##2}%
  \def\cdash##1##2##3{\def\tempx@{##3}%
  \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
   \ifx\tempx@\tempa@\@Acdash\else
    \ifx\tempx@\tempb@\@Bcdash\else
     \ifx\tempx@\tempc@\@Ccdash\else
      \errmessage{Wrong usage of cdash}\fi\fi\fi}%
  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
    \cyrdash\hskip.2em\ignorespaces}%
  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
   \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
  \def\@Ccdash{\leavevmode
   \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
  \ifx\cyrdash\undefined
    \def\cyrdash{\hbox to.8em{\textendash\hss\textendash}}%
  \fi
  \declare@shorthand{russian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

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


\def\captionsrussian@modern{%
   \def\prefacename{Предисловие}%
   \def\refname{Список литературы}%
   \def\abstractname{Аннотация}%
   \def\bibname{Литература}%
   \def\chaptername{Глава}%
   \def\appendixname{Приложение}%
   \ifcsundef{thechapter}%
     {\def\contentsname{Содержание}}%
     {\def\contentsname{Оглавление}}%
   \def\listfigurename{Список иллюстраций}%
   \def\listtablename{Список таблиц}%
   \def\indexname{Предметный указатель}%
   \def\authorname{Именной указатель}%
   \def\figurename{Рис.}%
   \def\tablename{Таблица}%
   \def\partname{Часть}%
   \def\enclname{вкл.}%
   \def\ccname{исх.}%
   \def\headtoname{вх.}%
   \def\pagename{с.}%
   \def\seename{см.}%
   \def\alsoname{см.~также}%
   \def\proofname{Доказательство}%
}
\def\daterussian@modern{%
      \def\today{\number\day%
      \space\ifcase\month\or%
      января\or
      февраля\or
      марта\or
      апреля\or
      мая\or
      июня\or
      июля\or
      августа\or
      сентября\or
      октября\or
      ноября\or
      декабря\fi%
      \space \number\year\space г.}%
}
     
\def\captionsrussian@old{%
   \def\prefacename{Предисловіе}%
   \def\refname{Примѣчанія}%
   \def\abstractname{Аннотація}%
   \def\bibname{Библіографія}%
   \def\chaptername{Глава}%
   \def\appendixname{Приложеніе}%
   \ifcsundef{thechapter}%
     {\def\contentsname{Содержаніе}}%
     {\def\contentsname{Оглавленіе}}%
   \def\listfigurename{Списокъ иллюстрацій}%
   \def\listtablename{Списокъ таблицъ}%
   \def\indexname{Предмѣтный указатель}%
   \def\authorname{Именной указатель}%
   \def\figurename{Рис.}%
   \def\tablename{Таблица}%
   \def\partname{Часть}%
   \def\enclname{вкл.}%
   \def\ccname{исх.}%
   \def\headtoname{вх.}%
   \def\pagename{с.}%
   \def\seename{см.}%
   \def\alsoname{см.~также}%
   \def\proofname{Доказательство}%
}

\def\daterussian@old{%
      \def\today{\number\day%
      \space\ifcase\month\or%
      января\or
      февраля\or
      марта\or
      апреля\or
      мая\or
      іюня\or
      іюля\or
      августа\or
      сентября\or
      октября\or
      ноября\or
      декабря\fi%
      \space \number\year\space г.}%
}

% Russian needs trailing dots in all headings
\def\xpg@save@autodot{}
\ifdef{\KOMAScript}{%
    \providecommand*\autodot{}%
    \let\xpg@save@autodot\autodot%
}

\def\russian@capsformat{%
  \ifrussian@forceheadingpunctuation%
   \ifdef{\KOMAScript}{%
      \renewcommand*\autodot{.}%
   }{%
      % The following is based on some ideas from ruscor.sty
      \def\@seccntformat##1{\csname pre##1\endcsname%
         \csname the##1\endcsname%
         \csname post##1\endcsname}%
       \def\@aftersepkern{\hspace{0.5em}}%
       \def\postchapter{.\@aftersepkern}%
       \def\postsection{.\@aftersepkern}%
       \def\postsubsection{.\@aftersepkern}%
       \def\postsubsubsection{.\@aftersepkern}%
       \def\postparagraph{.\@aftersepkern}%
       \def\postsubparagraph{.\@aftersepkern}%
       \def\prechapter{}%
       \def\presection{}%
       \def\presubsection{}%
       \def\presubsubsection{}%
       \def\preparagraph{}%
       \def\presubparagraph{}%
    }%
  \fi%
}

\def\norussian@capsformat{%
  \ifrussian@forceheadingpunctuation%
    \ifdef{\KOMAScript}{%
       \let\autodot\xpg@save@autodot%
    }{%
       \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
    }%
  \fi%
}

\newcommand{\russiannumerals}[2]{\russiannumber{#2}}
\newcommand{\Russiannumerals}[2]{\Russiannumber{#2}}

\def\russiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \russian@asbuk@alph{#1}%
    \else
      \cyr@alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\def\Russiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \russian@asbuk@Alph{#1}%
    \else
      \cyr@Alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\let\russiannumeral=\russiannumber
\let\Russiannumeral=\Russiannumber

\def\Asbuk#1{\expandafter\russian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\russian@asbuk@alph\csname c@#1\endcsname}

\def\AsbukTrad#1{\expandafter\cyr@Alph\csname c@#1\endcsname}
\def\asbukTrad#1{\expandafter\cyr@alph\csname c@#1\endcsname}


% This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
% thus ends at 30.
\def\russian@asbuk@Alph#1{\ifcase#1\or
   А\or Б\or В\or Г\or Д\or Е\or Ж\or
   З\or И\or К\or Л\or М\or Н\or О\or
   П\or Р\or С\or Т\or У\or Ф\or Х\or
   Ц\or Ч\or Ш\or Щ\or Э\or Ю\or Я%
   \else\xpg@ill@value{#1}{russian@asbuk@Alph}\fi%
}

\def\russian@asbuk@alph#1{\ifcase#1\or
   а\or б\or в\or г\or д\or е\or ж\or
   з\or и\or к\or л\or м\or н\or о\or
   п\or р\or с\or т\or у\or ф\or х\or
   ц\or ч\or ш\or щ\or э\or ю\or я%
   \else\xpg@ill@value{#1}{russian@asbuk@alph}\fi%
}

\def\russian@numbers{%
   \let\latin@alph\@alph
   \let\latin@Alph\@Alph
   \ifcyrillic@numerals%
     \def\russian@alph##1{\expandafter\russiannumeral\expandafter{\the##1}}%
     \def\russian@Alph##1{\expandafter\Russiannumeral\expandafter{\the##1}}%
     \let\@alph\russian@alph%
     \let\@Alph\russian@Alph%
   \fi
}

\def\norussian@numbers{%
   \let\@alph\latin@alph%
   \let\@Alph\latin@Alph%
}

\def\noextras@russian{%
   \norussian@capsformat%
   \ifcyrillic@numerals\norussian@numbers\fi%
   \ifrussian@babelshorthands\norussian@shorthands\fi%
}

\def\blockextras@russian{%
   \russian@capsformat%
   \ifcyrillic@numerals\russian@numbers\else\norussian@numbers\fi%
   \ifrussian@babelshorthands\russian@shorthands\else\norussian@shorthands\fi%
}

\def\inlineextras@russian{%
   \ifrussian@babelshorthands\russian@shorthands\else\norussian@shorthands\fi%
}

%%% These lines taken from russianb.ldf, part of babel package.
\AtBeginDocument{%
\ifrussian@mathfunctions%
  \def\sh    {\mathop{\operator@font sh}\nolimits}
  \def\ch    {\mathop{\operator@font ch}\nolimits}
  \def\tg    {\mathop{\operator@font tg}\nolimits}
  \def\arctg {\mathop{\operator@font arctg}\nolimits}
  \def\arcctg{\mathop{\operator@font arcctg}\nolimits}
  \def\th    {\mathop{\operator@font th}\nolimits}
  \def\ctg   {\mathop{\operator@font ctg}\nolimits}
  \def\cth   {\mathop{\operator@font cth}\nolimits}
  \def\cosec {\mathop{\operator@font cosec}\nolimits}
  \def\Prob  {\mathop{\kern\z@\mathsf{P}}\nolimits}
  \def\Variance{\mathop{\kern\z@\mathsf{D}}\nolimits}
  \def\nod   {\mathop{\mathrm{н.о.д.}}\nolimits}
  \def\nok   {\mathop{\mathrm{н.о.к.}}\nolimits}
  \def\NOD   {\mathop{\mathrm{НОД}}\nolimits}
  \def\NOK   {\mathop{\mathrm{НОК}}\nolimits}
  \def\Proj  {\mathop{\mathrm{Пр}}\nolimits}
  %\DeclareRobustCommand{\No}{№}
\fi
}

%    \end{macrocode}
% \iffalse
%</gloss-russian.ldf>
%<*gloss-sami.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-sami.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-sami.ldf}[polyglossia: module for Sami]

\PolyglossiaSetup{sami}{
  bcp47=se,
  bcp47-language=se,
  bcp47-script=Latn,
  babelname=samin,
  hyphennames={samin},
  hyphenmins={2,2},
  language={Northern Sami},
  langtag=NSM,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{sami}{se}

% Babel and backwards compat. alias
\setlanguagealias{sami}{samin}
%\setlanguagealias[variant=northern]{sami}{samin}

% TODO: Add other Sami varieties
\def\sami@variant{northern}
%\define@choicekey*+{sami}{variant}[\xpg@val\xpg@nr]{northern}[nothern]{%
%   \ifcase\xpg@nr\relax
%      % northern:
%      \def\sami@variant{samin}%
%      \SetLanguageKeys{sami}{language=Northern Sami,langtag=NSM}%
%      \xpg@fontsetup@latin{sami}%
%   \or
%      % other:
%      \def\sami@variant{}%
%      \SetLanguageKeys{sami}{language= Sami,langtag=}%
%      \xpg@fontsetup@latin{sami}%
%   \fi
%   \xpg@info{Option: sami, variant=\xpg@val}%
%}{\xpg@warning{Unknown sami variant `#1'}}


%\def\sami@language{%
%   \polyglossia@setup@language@patterns{\sami@variant}%
%}%

\def\captionssami@northern{%
   \def\refname{Čujuhusat}%
   \def\abstractname{Čoahkkáigeassu}%
   \def\bibname{Girjjálašvuohta}%
   \def\prefacename{Ovdasátni}%
   \def\chaptername{Kapihttal}%
   \def\appendixname{Čuovus}%
   \def\contentsname{Sisdoallu}%
   \def\listfigurename{Govvosat}%
   \def\listtablename{Tabeallat}%
   \def\indexname{Registtar}%
   \def\figurename{Govus}%
   \def\tablename{Tabealla}%
   \def\thepart{}%
   \def\partname{Oassi}%
   \def\pagename{Siidu}%
   \def\seename{geahča}%
   \def\alsoname{geahča maiddái}%
   \def\enclname{Mielddus}%
   \def\ccname{Kopia sáddejuvvon}%
   \def\headtoname{Vuostáiváldi}%
   \def\proofname{Duođaštus}%
   \def\glossaryname{Sátnelistu}%
}

\def\captionssami{%
  \csname captionssami@\sami@variant\endcsname%
}

\def\datesami@northern{%
  \def\today{\ifcase\month\or
    ođđajagemánu\or
    guovvamánu\or
    njukčamánu\or
    cuoŋománu\or
    miessemánu\or
    geassemánu\or
    suoidnemánu\or
    borgemánu\or
    čakčamánu\or
    golggotmánu\or
    skábmamánu\or
    juovlamánu\fi
    \space\number\day.~b.\space\number\year}%
}

\def\datesami{%
  \csname datesami@\sami@variant\endcsname%
}

%    \end{macrocode}
% \iffalse
%</gloss-sami.ldf>
%<*gloss-samin.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-samin.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-samin.ldf}[polyglossia: module for Northern Sami]

% We only provide this gloss for babel compatibility. Since samin is 
% a sami variety, we use 'sami' with variant 'northern' now.

\xpg@load@master@language{sami}

%    \end{macrocode}
% \iffalse
%</gloss-samin.ldf>
%<*gloss-sanskrit.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-sanskrit.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-sanskrit.ldf}[polyglossia: module for Sanskrit]

\RequirePackage{devanagaridigits}

\PolyglossiaSetup{sanskrit}{
  bcp47=sa-Deva,
  bcp47-language=sa,
  bcp47-script=Deva,
  bcp47-casing=sa-Deva,
  langtag=SAN,
  hyphennames={sanskrit,prakrit},
  hyphenmins={1,3},
  frenchspacing=true,
  fontsetup=false, % will be done below
  localnumeral=sanskritnumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{sanskrit}{sa}
\setlanguagealias*[script=devanagari]{sanskrit}{sa-Deva}
\setlanguagealias*[script=malayalam]{sanskrit}{sa-Mlym}
\setlanguagealias*[script=telugu]{sanskrit}{sa-Telu}
\setlanguagealias*[script=bengali]{sanskrit}{sa-Beng}
\setlanguagealias*[script=kannada]{sanskrit}{sa-Knda}
\setlanguagealias*[script=gujarati]{sanskrit}{sa-Gujr}
\setlanguagealias*[script=latin]{sanskrit}{sa-Latn}

\define@key{sanskrit}{Script}[devanagari]{%
  \ifcsdef{fontsetup@sanskrit@#1}%
    {\csname fontsetup@sanskrit@#1\endcsname}%
    {\xpg@error{`#1' is not a valid script for Sanskrit}%
  }%
}

\define@key{sanskrit}{script}[devanagari]{\setkeys{sanskrit}{Script=#1}}

\def\fontsetup@sanskrit@devanagari{%
  \SetLanguageKeys{sanskrit}{scripttag=deva,script=Devanagari,bcp47=sa-Deva,bcp47-language=sa,bcp47-script=Deva,bcp47-casing=sa-Deva}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@gujarati{%
  \SetLanguageKeys{sanskrit}{scripttag=gujr,script=Gujarati,bcp47=sa-Gujr,bcp47-language=sa,bcp47-script=Gujr,bcp47-casing=sa-Gujr}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@malayalam{%
  \SetLanguageKeys{sanskrit}{scripttag=mlym,script=Malayalam,bcp47=sa-Mlym,bcp47-language=sa,bcp47-script=Mlym,bcp47-casing=sa-Mlym}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@bengali{%
  \SetLanguageKeys{sanskrit}{scripttag=beng,script=Bengali,bcp47=sa-Beng,bcp47-language=sa,bcp47-script=Beng,bcp47-casing=sa-Beng}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@kannada{%
  \SetLanguageKeys{sanskrit}{scripttag=knda,script=Kannada,bcp47=sa-Knda,bcp47-language=sa,bcp47-script=Knda,bcp47-casing=sa-Knda}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@telugu{%
  \SetLanguageKeys{sanskrit}{scripttag=telu,script=Telugu,bcp47=sa-Relu,bcp47-language=sa,bcp47-script=Relu,bcp47-casing=sa-Relu}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@latin{%
  \SetLanguageKeys{sanskrit}{scripttag=latn,script=Latin,bcp47=sa-Latn,bcp47-language=sa,bcp47-script=Latn,bcp47-casing=sa-Latn}
  \xpg@fontsetup@latin{sanskrit}}


\newif\ifsanskrit@devanagari@numerals
\sanskrit@devanagari@numeralstrue
\define@choicekey*+{sanskrit}{numerals}[\xpg@val\xpg@nr]{devanagari,western}[devanagari]{%
   \ifcase\xpg@nr\relax
      % devanagari:
      \sanskrit@devanagari@numeralstrue%
      \SetLanguageKeys{sanskrit}{bcp47-extension-u=nu-deva}%
   \or
      % western:
      \sanskrit@devanagari@numeralsfalse%
      \SetLanguageKeys{sanskrit}{bcp47-extension-u=nu-latn}%
   \fi
   \xpg@info{Option: Sanskrit, numerals=\xpg@val}%
}{\xpg@warning{Unknown Sanskrit numeral `#1'}}


% Register default options
\xpg@initialize@gloss@options{sanskrit}{script=devanagari,numerals=devanagari}

% Use \providecommand here as the ldf file might
% be reloaded via BCP.
\providecommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}

\def\sanskritnumber#1{%
  \ifsanskrit@devanagari@numerals
    \devanagaridigits{\number#1}%
  \else
    \number#1%
  \fi%
}

\ifluatex
  \directlua{require('polyglossia-sanskrit')}%
\else
  \newXeTeXintercharclass\sanskrit@questionexclamation % ! ? ‼ ⁇ ⁈ ⁉ ‽
  \newXeTeXintercharclass\sanskrit@punctthin % : ; danda double_danda
\fi

\def\sanskrit@punctthinspace{{\unskip\thinspace}}

\def\sanskrit@punctuation{%
  \ifluatex
    \directlua{polyglossia.activate_sanskrit_punct()}%
  \else
    \XeTeXinterchartokenstate=1%
    \XeTeXcharclass `\! \sanskrit@questionexclamation
    \XeTeXcharclass `\? \sanskrit@questionexclamation
    \XeTeXcharclass `\‼ \sanskrit@questionexclamation
    \XeTeXcharclass `\⁇ \sanskrit@questionexclamation
    \XeTeXcharclass `\⁈ \sanskrit@questionexclamation
    \XeTeXcharclass `\⁉ \sanskrit@questionexclamation
    \XeTeXcharclass `\‽ \sanskrit@questionexclamation % interrobang, U+203D
    \XeTeXcharclass `\: \sanskrit@punctthin
    \XeTeXcharclass `\; \sanskrit@punctthin
    \XeTeXcharclass `\। \sanskrit@punctthin % danda, U+0964
    \XeTeXcharclass `\॥ \sanskrit@punctthin % double danda, U+0965
    \XeTeXinterchartoks \z@ \sanskrit@questionexclamation = \sanskrit@punctthinspace
    \XeTeXinterchartoks \z@ \sanskrit@punctthin = \sanskrit@punctthinspace
    \XeTeXinterchartoks \sanskrit@questionexclamation \sanskrit@punctthin = \sanskrit@punctthinspace
  \fi
}

\def\nosanskrit@punctuation{%
  \ifluatex
    \directlua{polyglossia.deactivate_sanskrit_punct()}%
  \else
    \XeTeXcharclass `\! \z@
    \XeTeXcharclass `\? \z@
    \XeTeXcharclass `\‼ \z@
    \XeTeXcharclass `\⁇ \z@
    \XeTeXcharclass `\⁈ \z@
    \XeTeXcharclass `\⁉ \z@
    \XeTeXcharclass `\‽ \z@
    \XeTeXcharclass `\: \z@
    \XeTeXcharclass `\; \z@
    \XeTeXcharclass `\। \z@
    \XeTeXcharclass `\॥ \z@
    \XeTeXinterchartokenstate=0%
  \fi
}

\def\noextras@sanskrit{%
  \nosanskrit@punctuation%
}

\def\blockextras@sanskrit{%
  \sanskrit@punctuation%
}

%    \end{macrocode}
% \iffalse
%</gloss-sanskrit.ldf>
%<*gloss-scottish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-scottish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-scottish.ldf}[polyglossia: module for Scottish Gaelic]

% We only provide this gloss for babel compatibility. Since scottish is 
% a gaelic variety, we use 'gaelic' with variant 'scottish' now.

\xpg@load@master@language{gaelic}

%    \end{macrocode}
% \iffalse
%</gloss-scottish.ldf>
%<*gloss-serbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-serbian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-serbian.ldf}[polyglossia: module for Serbian]
%TODO split into gloss-serbiancyr.ldf and gloss-serbianlat.ldf
%% load these automatically from polyglossia.sty according to the script option ??
%% same thing for all languages that have a "script" key !
%% BETTER APPROACH: see gloss-sanskrit!

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{serbian}{
  bcp47=sr-Latn,
  bcp47-language=sr,
  bcp47-variant=ekavsk,
  bcp47-script=Latn,
  bcp47-casing=sr-Latn,
  langtag=SRB,
  hyphennames={serbian},
  hyphenmins={2,2},
  frenchspacing=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
  indentfirst=true, % Правопис српскога језика, Матица српска, 2010. (измењено и допуњено, четврто издање): т. 188, под Обликовање ступца и пасуса
  fontsetup=false,
  localnumeral=serbiannumerals,
  Localnumeral=Serbiannumerals,
  babelname=serbian
  %TODO localalph
}

% BCP-47 compliant aliases
\setlanguagealias*{serbian}{sr}
\setlanguagealias*[script=cyrillic]{serbian}{sr-Cyrl}
\setlanguagealias*[script=latin]{serbian}{sr-Latn}

% Babel aliases
\setlanguagealias[script=cyrillic]{serbian}{serbianc}

\ifluatex
  \RequirePackage{luavlna}
\fi

\newif\if@serbian@cyr
\define@choicekey*+{serbian}{Script}[\xpg@val\xpg@nr]{cyrillic,latin}[cyrillic]{%
   \ifcase\xpg@nr\relax
      % cyrillic:
      \@serbian@cyrtrue
      \xpg@fontsetup@nonlatin{serbian}%
   \or
      % latin:
      \@serbian@cyrfalse
      \xpg@fontsetup@latin{serbian}%
      %TODO \def\serbian@language{\language=\l@serbianlat}%
      % or should we use Croatian patterns as a fallback for the time being???
   \fi
   \serbian@set@languagekeys%
   \xpg@info{Option: Serbian, script=\xpg@val}%
}{\xpg@warning{Unknown Serbian script `#1'}}

\define@key{serbian}{script}[cyrillic]{\setkeys{serbian}{Script=#1}}

\newif\if@serbian@ijekavian
\define@choicekey*+{serbian}{variant}[\xpg@val\xpg@nr]{ekavian,ijekavian}[ekavian]{%
   \ifcase\xpg@nr\relax
      % ekavian:
      \@serbian@ijekavianfalse%
   \or
      % ijekavian:
      \@serbian@ijekaviantrue%
   \fi
   \serbian@set@languagekeys%
   \xpg@info{Option: Serbian, variant=\xpg@val}%
}{\xpg@warning{Unknown Serbian variant `#1'}}

\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals
\define@choicekey*+{serbian}{numerals}[\xpg@val\xpg@nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
   \ifcase\xpg@nr\relax
      % arabic:
      \cyrillic@numeralsfalse%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{serbian}{bcp47-extension-u=nu-latn}%
   \or
      % cyrillic:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{serbian}{bcp47-extension-u=nu-cyrl}%
   \or
      % cyrillic-trad:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{serbian}{bcp47-extension-u=nu-cyrl}%
   \or
      % cyrillic-alph:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralstrue%
      \SetLanguageKeys{serbian}{bcp47-extension-u=nu-cyrl}%
   \fi
   \xpg@info{Option: Serbian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Serbian numerals value `#1'}}

\define@boolkey{serbian}[serbian@]{splithyphens}[true]{}

\define@boolkey{serbian}[serbian@]{datei}[true]{}

\def\serbian@set@languagekeys{%
   \if@serbian@cyr
     \if@serbian@ijekavian
        \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl-ijekavsk,bcp47-language=sr,bcp47-script=Cyrl,bcp47-variant=ijekavsk,bcp47-casing=sr-Cyrl}
     \else
        \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl,bcp47-language=sr,bcp47-script=Cyrl,bcp47-variant=ekavsk,bcp47-casing=sr-Cyrl}
     \fi
   \else
     \if@serbian@ijekavian
       \SetLanguageKeys{serbian}{scripttag=latn,script=Latin,babelname=serbian,bcp47=sr-Latn-ijekavsk,bcp47-language=sr,bcp47-script=Latn,bcp47-variant=ijekavsk,bcp47-casing=sr-Latn}
     \else
       \SetLanguageKeys{serbian}{scripttag=latn,script=Latin,babelname=serbian,bcp47=sr-Latn,bcp47-language=sr,bcp47-script=Latn,bcp47-variant=ekavsk,bcp47-casing=sr-Latn}
     \fi
   \fi%
}

\setkeys{serbian}{Script,numerals}

% Register default options
\xpg@initialize@gloss@options{serbian}{script=cyrillic,numerals=arabic,splithyphens=true}

\def\captionsserbian{%
   \if@serbian@cyr\captionsserbian@cyr\else\captionsserbian@lat\fi
}

\def\dateserbian{%
   \if@serbian@cyr\dateserbian@cyr\else\dateserbian@lat\fi
}

\def\captionsserbian@lat{%
   \def\refname{Bibliografija}%
   \def\abstractname{Sažetak}%
   \def\bibname{Literatura}%
   \def\prefacename{Predgovor}%
   \def\chaptername{Glava}%
   \def\appendixname{Dodatak}%
   \def\contentsname{Sadržaj}%
   \def\listfigurename{Spisak slika}%
   \def\listtablename{Spisak tabela}%
   \def\indexname{Registar}%
   \def\figurename{Slika}%
   \def\tablename{Tabela}%
   \def\partname{Deo}%
   \renewcommand\thepart{\ifcase\value{part}\or Prvi\or Drugi\or
      Treći\or Četvrti\or Peti\or Šesti\or Sedmi\or Osmi\or
      Deveti\or Deseti\or Jedanaesti\or Dvanaesti\or Trinaesti\or
      Četrnaesti\or Petnaesti\or Šesnaesti\or Sedamnaesti\or
      Osamnaesti\or Devetnaesti\or Dvadeseti\fi}%
   \def\pagename{Strana}%
   \def\seename{Vidi}%
   \def\alsoname{Vidi takođe}%
   \def\enclname{Prilozi}%
   \def\ccname{Kopije}%
   \def\headtoname{Prima}%
   \def\proofname{Dokaz}%
   \def\glossaryname{Rečnik nepoznatih reči}%
   \if@serbian@ijekavian%
     \def\partname{Dio}%
     \def\glossaryname{Rječnik nepoznatih riječi}%
   \fi
}

\def\month@serbian@lat{%
  \ifcase\month\or
    januar\or
    februar\or
    mart\or
    april\or
    maj\or
    \ifserbian@datei juni\else jun\fi\or
    \ifserbian@datei juli\else jul\fi\or
    avgust\or
    septembar\or
    oktobar\or
    novembar\or
    decembar%
  \fi%
}%

\def\month@serbian@lat@gen{%
  \ifcase\month\or
    januara\or
    februara\or
    marta\or
    aprila\or
    maja\or
    juna\or
    jula\or
    avgusta\or
    septembra\or
    oktobra\or
    novembra\or
    decembra%
  \fi%
}%

\def\dateserbian@lat{%  
    \def\today{\number\day.~\month@serbian@lat\ \number\year\@ifstar{}{.}}%
    \def\todayRoman{\number\day.~\@Roman\month~\number\year\@ifstar{}{.}}%
    \def\todayGen{\number\day.~\month@serbian@lat@gen\ \number\year\@ifstar{}{.}}%
    \def\todayArabic{\number\day.~\number\month.~\number\year\@ifstar{}{.}}%
}

\def\captionsserbian@cyr{%
   \def\refname{Библиографија}%
   \def\abstractname{Сажетак}%
   \def\bibname{Литература}%
   \def\prefacename{Предговор}%
   \def\chaptername{Глава}%
   \def\appendixname{Додатак}%
   \def\contentsname{Садржај}%
   \def\listfigurename{Списак слика}%
   \def\listtablename{Списак табела}%
   \def\indexname{Регистар}%
   \def\figurename{Слика}%
   \def\tablename{Табела}%
   \def\partname{Део}%
   \renewcommand\thepart{\ifcase\value{part}\or Први\or Други\or Трећи\or
   Четврти\or Пети\or Шести\or Седми\or Осми\or Девети\or Десети\or
   Једанаести\or Дванаести\or Тринаести\or Четрнаести\or Петнаести\or
   Шеснаести\or Седамнаести\or Осамнаести\or Деветнаести\or Двадесети\fi}%
   \def\pagename{Страна}%
   \def\seename{Види}%
   \def\alsoname{Види такође}%
   \def\enclname{Прилози}%
   \def\ccname{Копије}%
   \def\headtoname{Прима}%
   \def\proofname{Доказ}%
   \def\glossaryname{Речник непознатих речи}%
   \if@serbian@ijekavian%
     \def\partname{Дио}%
     \def\glossaryname{Рјечник непознатих ријечи}%
   \fi
}

\def\month@serbian@cyr{%
  \ifcase\month\or
    јануар\or
    фебруар\or
    март\or
    април\or
    мај\or
    \ifserbian@datei јуни\else јун\fi\or
    \ifserbian@datei јули\else јул\fi\or
    август\or
    септембар\or
    октобар\or
    новембар\or
    децембар%
  \fi%
}%

\def\month@serbian@cyr@gen{%
  \ifcase\month\or
    јануара\or
    фебруара\or
    марта\or
    априла\or
    маја\or
    јуна\or
    јула\or
    августа\or
    септембра\or
    октобра\or
    новембра\or
    децембра%
  \fi%
}%

\def\dateserbian@cyr{%  
    \def\today{\number\day.~\month@serbian@cyr\ \number\year\@ifstar{}{.}}%
    \def\todayRoman{\number\day.~\@Roman\month~\number\year\@ifstar{}{.}}%
    \def\todayGen{\number\day.~\month@serbian@cyr@gen\ \number\year\@ifstar{}{.}}%
    \def\todayArabic{\number\day.~\number\month.~\number\year\@ifstar{}{.}}%
}

% Use \providecommand here as the ldf file might
% be reloaded via serbianc.
\providecommand{\serbiannumerals}[2]{\serbiannumber{#2}}
\providecommand{\Serbiannumerals}[2]{\Serbiannumber{#2}}

\def\serbiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \serbian@asbuk@alph{#1}%
    \else
      \cyr@alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\def\Serbiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \serbian@asbuk@Alph{#1}%
    \else
      \cyr@Alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\let\serbiannumeral=\serbiannumber
\let\Serbiannumeral=\Serbiannumber

\def\serbian@numbers{%
   \let\latin@alph\@alph
   \let\latin@Alph\@Alph
   \ifcyrillic@numerals
     \def\serbian@alph##1{\expandafter\serbiannumeral\expandafter{\the##1}}%
     \def\serbian@Alph##1{\expandafter\Serbiannumeral\expandafter{\the##1}}%
      \let\@alph\serbian@alph%
      \let\@Alph\serbian@Alph%
   \fi
}

\def\noserbian@numbers{%
   \let\@alph\latin@alph
   \let\@Alph\latin@Alph
}

\let\xpg@hyphen@char-
\def\serbian@@splhyphen#1{%
  \def\serbian@sh@tmp{%
       \ifx\serbian@sh@next\xpg@hyphen@charx#1%
       \else\expandafter\serbian@@@splhyphen{#1}\fi%
     }%
     \futurelet\serbian@sh@next\serbian@sh@tmp%
}

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

\def\serbian@splhyphen{%
  \serbian@@splhyphen{-}%
}

\ifxetex
  % splithyphens
  \newXeTeXintercharclass\serbian@hyphen % -
  \newXeTeXintercharclass\serbian@nonsyllabicpreposition%
\fi

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

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

\def\blockextras@serbian{%
  \ifcyrillic@numerals\serbian@numbers\else\noserbian@numbers\fi%
  \ifserbian@splithyphens\serbian@hyphens\else\noserbian@hyphens\fi%
}

\def\inlineextras@serbian{%
  \ifserbian@splithyphens\serbian@hyphens\else\noserbian@hyphens\fi%
}
 
\def\noextras@serbian{%
   \ifcyrillic@numerals\noserbian@numbers\fi%
   \noserbian@hyphens%
}

\def\Asbuk#1{\expandafter\serbian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\serbian@asbuk@alph\csname c@#1\endcsname}

\def\AsbukTrad#1{\expandafter\cyr@Alph\csname c@#1\endcsname}
\def\asbukTrad#1{\expandafter\cyr@alph\csname c@#1\endcsname}

% This is a poor man's cyrillic alphanumeric.
% It just uses the alphabet and thus ends at 30.
\def\serbian@asbuk@Alph#1{\ifcase#1\or
   А\or Б\or В\or Г\or Д\or Ђ\or Е\or Ж\or
   З\or И\or Ј\or К\or Л\or Љ\or М\or Н\or
   Њ\or О\or П\or Р\or С\or Т\or Ћ\or У\or
   Ф\or Х\or Ц\or Ч\or Џ\or Ш%
   \else\xpg@ill@value{#1}{serbian@asbuk@Alph}\fi%
}

\def\serbian@asbuk@alph#1{\ifcase#1\or
   а\or б\or в\or г\or д\or ђ\or е\or ж\or
   з\or и\or ј\or к\or л\or љ\or м\or н\or
   њ\or о\or п\or р\or с\or т\or ћ\or у\or
   ф\or х\or ц\or ч\or џ\or ш%
   \else\xpg@ill@value{#1}{serbian@asbuk@alph}\fi%
}

 
%    \end{macrocode}
% \iffalse
%</gloss-serbian.ldf>
%<*gloss-serbianc.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-serbianc.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-serbianc.ldf}[polyglossia: module for Serbian (cyrillic)]

% We provide this as a babel alias

\xpg@load@master@language{serbian}

%    \end{macrocode}
% \iffalse
%</gloss-serbianc.ldf>
%<*gloss-slovak.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-slovak.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-slovak.ldf}[polyglossia: module for Slovak]

\PolyglossiaSetup{slovak}{
  bcp47=sk,
  bcp47-language=sk,
  bcp47-script=Latn,
  hyphennames={slovak},
  hyphenmins={2,2},
  langtag=SKY,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{slovak}{sk}

\ifluatex
  \RequirePackage{luavlna}
\fi

\define@boolkey{slovak}[slovak@]{babelshorthands}[true]{}

\define@boolkey{slovak}[slovak@]{splithyphens}[true]{}

\define@boolkey{slovak}[slovak@]{vlna}[true]{}

% Register default options
\xpg@initialize@gloss@options{slovak}{babelshorthands=false,splithyphens=true,vlna=true}

\ifsystem@babelshorthands
  \setkeys{slovak}{babelshorthands=true}
\else
  \setkeys{slovak}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\let\xpg@hyphen@char-
\def\slovak@@splhyphen#1{%
  \def\slovak@sh@tmp{%
       \ifx\slovak@sh@next\xpg@hyphen@char#1%
       \else\expandafter\slovak@@@splhyphen{#1}\fi%
     }%
     \futurelet\slovak@sh@next\slovak@sh@tmp%
}

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

\def\slovak@splhyphen{%
  \slovak@@splhyphen{-}%
}

\def\slovak@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{slovak}%
  \declare@shorthand{slovak}{"=}{\slovak@splhyphen}%
  \declare@shorthand{slovak}{""}{\hskip\z@skip}%
  \declare@shorthand{slovak}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{slovak}{"-}{\nobreak\-\bbl@allowhyphens}%
  \declare@shorthand{slovak}{"|}{%
      \textormath{\penalty\@M\discretionary{-}{}{\kern.03em}%
      \bbl@allowhyphens}{}%
  }%
  \declare@shorthand{slovak}{"/}{\textormath
    {\bbl@allowhyphens\discretionary{/}{}{/}\bbl@allowhyphens}{}}%
  \declare@shorthand{slovak}{"`}{„}%
  \declare@shorthand{slovak}{"'}{“}%
  \declare@shorthand{slovak}{"<}{«}%
  \declare@shorthand{slovak}{">}{»}%
}

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

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

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

\def\noslovak@hyphens{%
    \ifluatex
      \AfterPreamble{\disablesplithyphens{slovak}}%
    \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\slovak@nointerchartoks{\let\slovak@interchartoks\slovak@PreCSpreposition}%
    \def\slovak@PreCSpreposition{%
       \def\next{}%
       \ifnum\catcode`\ =10 % nothing will be done in verbatim
       \ifmmode % nothing in math
       \else
          \let\slovak@interchartoks\slovak@nointerchartoks
          \let\next\slovak@ExamineCSpreposition
       \fi\fi
       \next%
    }%
    \def\slovak@ExamineCSpreposition #1{#1\futurelet\next\slovak@ProcessCSpreposition}%
    \def\slovak@ProcessCSpreposition{\ifx\next\slovak@XeTeXspace\nobreak\fi}%
    \futurelet\slovak@XeTeXspace{ }\slovak@nointerchartoks
\fi

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

\def\noslovak@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\captionsslovak{%
   \def\refname{Referencie}%
   \def\abstractname{Abstrakt}%
   \def\bibname{Literatúra}%
   \def\prefacename{Úvod}%
   \def\chaptername{Kapitola}%
   \def\appendixname{Dodatok}%
   \def\contentsname{Obsah}%
   \def\listfigurename{Zoznam obrázkov}%
   \def\listtablename{Zoznam tabuliek}%
   \def\indexname{Index}%
   \def\figurename{Obrázok}%
   \def\tablename{Tabuľka}%
   %\def\thepart{}%
   \def\partname{Časť}%
   \def\pagename{Strana}%
   \def\seename{viď}%
   \def\alsoname{viď tiež}%
   \def\enclname{Prílohy}%
   \def\ccname{cc.}%
   \def\headtoname{Pre}% was komu
   \def\proofname{Dôkaz}%
   \def\glossaryname{Slovník}%
}

\def\dateslovak{%   
  \def\today{\number\day.~\ifcase\month\or
    januára\or februára\or marca\or apríla\or mája\or
    júna\or júla\or augusta\or septembra\or októbra\or
    novembra\or decembra\fi
    \space \number\year}%
}

\def\noextras@slovak{%
  \ifslovak@babelshorthands\noslovak@shorthands\fi%
  \noslovak@hyphens%
  \noslovak@vlna%
  \ifxetex\XeTeXinterchartokenstate=0\fi%
}

\def\blockextras@slovak{%
  \ifslovak@babelshorthands\slovak@shorthands\else\noslovak@shorthands\fi%
  \ifslovak@vlna\slovak@vlna\else\noslovak@vlna\fi%
  \ifslovak@splithyphens\slovak@hyphens\else\noslovak@hyphens\fi%
}

\def\inlineextras@slovak{%
  \ifslovak@babelshorthands\slovak@shorthands\else\noslovak@shorthands\fi%
  \ifslovak@vlna\slovak@vlna\else\noslovak@vlna\fi%
  \ifslovak@splithyphens\slovak@hyphens\else\noslovak@hyphens\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-slovak.ldf>
%<*gloss-slovene.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-slovene.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-slovene.ldf}[polyglossia: module for Slovenian]

% We provide this as a babel alias

\xpg@load@master@language{slovenian}

%    \end{macrocode}
% \iffalse
%</gloss-slovene.ldf>
%<*gloss-slovenian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-slovenian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-slovenian.ldf}[polyglossia: module for Slovenian]

\PolyglossiaSetup{slovenian}{
  bcp47=sl,
  bcp47-language=sl,
  bcp47-script=Latn,
  hyphennames={slovenian,slovene},
  babelname=slovene,
  hyphenmins={2,2},
  langtag=SLV,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{slovenian}{sl}

% Babel aliases
\setlanguagealias{slovenian}{slovene}

\define@boolkey{slovenian}[slovenian@]{localalph}[true]{}

% Register default options
\xpg@initialize@gloss@options{slovenian}{localalph=false}


\def\captionsslovenian{%
   \def\refname{Literatura}%
   \def\abstractname{Povzetek}%
   \def\bibname{Literatura}%
   \def\prefacename{Predgovor}%
   \def\chaptername{Poglavje}%
   \def\appendixname{Dodatek}%
   \def\contentsname{Kazalo}%
   \def\listfigurename{Slike}%
   \def\listtablename{Tabele}%
   \def\indexname{Stvarno kazalo}%
   \def\figurename{Slika}%
   \def\tablename{Tabela}%
   %\def\thepart{}%
   \def\partname{Del}%
   \def\pagename{Stran}%
   \def\seename{glej}%
   \def\alsoname{glej tudi}%
   \def\enclname{Priloge}%
   \def\ccname{Kopije}%
   \def\headtoname{Prejme}%
   \def\proofname{Dokaz}%
   \def\glossaryname{Slovar}%
}

\def\dateslovenian{%   
  \def\today{\number\day.~\ifcase\month\or
    januar\or februar\or marec\or april\or maj\or junij\or
    julij\or avgust\or september\or oktober\or november\or december\fi
    \space \number\year}%
}

\def\slovenian@alph#1{%
  \ifcase#1\or a\or b\or c\or č\or d\or e\or f\or g\or h\or i\or j\or k\or l\or
  m\or n\or o\or p\or r\or s\or š\or t\or u\or v\or z\or ž\else#1\fi
}
\def\slovenian@Alph#1{%
  \ifcase#1\or A\or B\or C\or Č\or D\or E\or F\or G\or H\or I\or J\or K\or L\or
  M\or N\or O\or P\or R\or S\or Š\or T\or U\or V\or Z\or Ž\else#1\fi
}

\def\abeceda#1{\expandafter\slovenian@alph\csname c@#1\endcsname}
\def\Abeceda#1{\expandafter\slovenian@Alph\csname c@#1\endcsname}

\def\extras@slovenian{%
  \ifslovenian@localalph\let\alph\abeceda\let\Alph\Abeceda\fi%
}

\def\blockextras@slovenian{\extras@slovenian}

\def\inlineextras@slovenian{\extras@slovenian}

\def\noextras@slovenian{%
  \let\alph\latinalph\let\Alph\latinAlph%
}

%    \end{macrocode}
% \iffalse
%</gloss-slovenian.ldf>
%<*gloss-sorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-sorbian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-sorbian.ldf}[polyglossia: module for Sorbian]

\PolyglossiaSetup{sorbian}{
  bcp47=hsb,
  bcp47-language=hsb,
  bcp47-script=Latn,
  language=Upper Sorbian,
  babelname=uppersorbian,
  hyphennames={usorbian,uppersorbian},
  langtag=USB,
  hyphenmins={2,2},
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*[variant=upper]{sorbian}{hsb}
\setlanguagealias*[variant=lower]{sorbian}{dsb} 
% Backwards compat. aliases
\setlanguagealias[variant=lower]{sorbian}{lsorbian}
\setlanguagealias[variant=upper]{sorbian}{usorbian}

% Babel aliases
\setlanguagealias[variant=lower]{sorbian}{lowersorbian}
\setlanguagealias[variant=upper]{sorbian}{uppersorbian}

\def\sorbian@variant{usorbian}
\define@choicekey*+{sorbian}{variant}[\xpg@val\xpg@nr]{upper,lower}[upper]{%
   \ifcase\xpg@nr\relax
      % upper:
      \def\sorbian@variant{usorbian}%
      \SetLanguageKeys{sorbian}{language=Upper Sorbian,langtag=USB,babelname=uppersorbian,bcp47=hsb,bcp47-language=hsb}%
      \xpg@fontsetup@latin{sorbian}%
      % Check if \l@usorbian is defined. If not, try to set it to some variety
      % (specific order as in the csv list below), or null language if everything fails
      \xpg@ifdefined{usorbian}{}{%
        \def\do##1{%
            \xpg@ifdefined{##1}%
              {\csletcs{l@usorbian}{l@##1}\listbreak}%
              {}%
        }%
        \docsvlist{uppersorbian}
        \xpg@ifdefined{usorbian}{}{%
                 \xpg@warning{No hyphenation patterns for Upper Sorbian found\MessageBreak
                              I will use the 'null' language instead}%
                 \adddialect\l@usorbian0%
        }
      }%
   \or
      % lower:
      \def\sorbian@variant{lsorbian}%
      \SetLanguageKeys{sorbian}{language=Lower Sorbian,langtag=LSB,babelname=lowersorbian,bcp47=dsb,bcp47-language=dsb}%
      \xpg@fontsetup@latin{sorbian}%
      % Check if \l@lsorbian is defined. If not, try to set it to some variety
      % (specific order as in the csv list below), or null language if everything fails
      \xpg@ifdefined{lsorbian}{}{%
        \def\do##1{%
           \xpg@ifdefined{##1}%
              {\csletcs{l@lsorbian}{l@##1}\listbreak}%
              {}%
        }%
        \docsvlist{lowersorbian,Lsorbian,usorbian,uppersorbian}
        \xpg@ifdefined{lsorbian}{}{%
                 \xpg@warning{No hyphenation patterns for Lower Sorbian found\MessageBreak
                              I will use the 'null' language instead}%
                 \adddialect\l@lsorbian0%
        }
     }%
   \fi
   \xpg@info{Option: sorbian, variant=\xpg@val}%
}{\xpg@warning{Unknown sorbian variant `#1'}}


\define@boolkey{sorbian}[sorbian@]{olddate}[true]{}

% Register default options
\xpg@initialize@gloss@options{sorbian}{variant=upper,olddate=false}


\def\sorbian@language{%
   \polyglossia@setup@language@patterns{\sorbian@variant}%
}%


\def\captionssorbian@lsorbian{%
   \def\refname{Referency}%
   \def\abstractname{Abstrakt}%
   \def\bibname{Literatura}%
   \def\prefacename{Zawod}%
   \def\chaptername{Kapitl}%
   \def\appendixname{Dodawki}%
   \def\contentsname{Wopśimjeśe}%
   \def\listfigurename{Zapis wobrazow}%
   \def\listtablename{Zapis tabulkow}%
   \def\indexname{Indeks}%
   \def\figurename{Wobraz}%
   \def\tablename{Tabulka}%
   %\def\thepart{}%
   \def\partname{Źěl}%
   \def\pagename{Strona}%
   \def\seename{gl.}%
   \def\alsoname{gl.~teke}%
   \def\enclname{Pśiłoga}%
   \def\ccname{CC}%
   \def\headtoname{Komu}%
   \def\proofname{Proof}%
   \def\glossaryname{Glossary}%
}

\def\captionssorbian@usorbian{%
   \def\refname{Referency}%
   \def\abstractname{Abstrakt}%
   \def\bibname{Literatura}%
   \def\prefacename{Zawod}%
   \def\chaptername{Kapitl}%
   \def\appendixname{Dodawki}%
   \def\contentsname{Wobsah}%
   \def\listfigurename{Zapis wobrazow}%
   \def\listtablename{Zapis tabulkow}%
   \def\indexname{Indeks}%
   \def\figurename{Wobraz}%
   \def\tablename{Tabulka}%
   %\def\thepart{}%
   \def\partname{Dźěl}%
   \def\pagename{Strona}%
   \def\seename{hl.}%
   \def\alsoname{hl.~tež}%
   \def\enclname{Přłoha}%
   \def\ccname{CC}%
   \def\headtoname{Komu}%
   \def\proofname{Proof}% <-- needs translation
   \def\glossaryname{Glossary}% <-- needs translation
}%

\def\captionssorbian{%
  \csname captionssorbian@\sorbian@variant\endcsname%
}

\def\datesorbian@lsorbian{%
    \def\oldtoday{%
      \number\day.~\ifcase\month\or
      wjelikego rožka\or małego rožka\or nalětnika\or
      jatšownika\or rožownika\or smažnika\or pražnika\or
      žnjeńca\or požnjeńca\or winowca\or nazymnika\or 
      godownika\fi\space \number\year}%
    \def\today{%
      \ifsorbian@olddate
        \oldtoday%
      \else
        \number\day.~\ifcase\month\or
        januara\or februara\or měrca\or apryla\or maja\or
        junija\or julija\or awgusta\or septembra\or oktobra\or
        nowembra\or decembra\fi
        \space \number\year%
      \fi
   }%
}

\def\datesorbian@usorbian{%
  \def\oldtoday{\number\day.~\ifcase\month\or
    wulkeho róžka\or małeho róžka\or nalětnika\or
    jutrownika\or róžownika\or  smažnika\or pražnika\or
    žnjenca\or požnjenca\or winowca\or nazymnika\or
    hodownika\fi \space \number\year}%
  \def\today{%
    \ifsorbian@olddate
      \oldtoday%
    \else
      \number\day.~\ifcase\month\or
      januara\or februara\or měrca\or apryla\or meje\or junija\or
      julija\or awgusta\or septembra\or oktobra\or
      nowembra\or decembra\fi
      \space \number\year%
    \fi
  }%
}

\def\datesorbian{%
  \csname datesorbian@\sorbian@variant\endcsname%
}

%    \end{macrocode}
% \iffalse
%</gloss-sorbian.ldf>
%<*gloss-spanish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-spanish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-spanish.ldf}[polyglossia: module for Spanish]

\PolyglossiaSetup{spanish}{
  bcp47=es-ES,
  bcp47-language=es,
  bcp47-region=ES,
  bcp47-script=Latn,
  hyphennames={spanish},
  hyphenmins={2,2},
  totalhyphenmin=5,
  langtag=ESP,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
  babelname=spanish
}

% BCP-47 compliant aliases
\setlanguagealias*{spanish}{es}
\setlanguagealias*[variant=mexican]{spanish}{es-MX}
\setlanguagealias*[variant=spanish]{spanish}{es-ES}

% Babel aliases
\setlanguagealias[variant=mexican]{spanish}{spanishmx}

\newif\if@spanish@mexico
\@spanish@mexicofalse
\define@choicekey*+{spanish}{variant}[\xpg@val\xpg@nr]{spanish,mexican}[spanish]{%
   \ifcase\xpg@nr\relax
      % spanish:
      \@spanish@mexicofalse%
      \SetLanguageKeys{spanish}{babelname=spanish,bcp47=es-ES,bcp47-region=ES}%
   \or
      % mexican:
      \@spanish@mexicotrue%
      \SetLanguageKeys{spanish}{babelname=spanishmx,bcp47=es-MX,bcp47-region=MX}%
   \fi
   \xpg@info{Option: spanish, variant=\xpg@val}%
}{\xpg@warning{Unknown spanish variant `#1'}}

% Localized math operators à la babel
\newif\ifspanish@accentedoperators
\newif\ifspanish@spacedoperators
\newif\ifspanish@locoperators

\define@choicekey*+{spanish}{spanishoperators}[\xpg@val\xpg@nr]{all,accented,spaced,none}[all]{%
   \ifcase\xpg@nr\relax
      % all:
      \spanish@locoperatorstrue%
      \spanish@accentedoperatorstrue%
      \spanish@spacedoperatorstrue%
   \or
      % accented:
      \spanish@locoperatorsfalse%
      \spanish@accentedoperatorstrue%
      \spanish@spacedoperatorsfalse%
   \or
      % spaced:
      \spanish@locoperatorsfalse%
      \spanish@accentedoperatorsfalse%
      \spanish@spacedoperatorstrue%
   \or
      % none:
      \spanish@locoperatorsfalse%
      \spanish@accentedoperatorsfalse%
      \spanish@spacedoperatorsfalse%
   \fi
   \xpg@info{Option: Spanish, spanishoperators=\xpg@val}%
}{\xpg@warning{Unknown spanishoperators value `#1'}}


% Register default options
\xpg@initialize@gloss@options{spanish}{variant=spanish,spanishoperators=none}

\let\xpg@save@lim\lim
\let\xpg@save@limsup\limsup
\let\xpg@save@liminf\liminf
\let\xpg@save@max\max
\let\xpg@save@min\min
\let\xpg@save@inf\inf
\let\xpg@save@bmod\bmod
\let\xpg@save@pmod\pmod

\def\spanish@accentedoperators{%
  \DeclareRobustCommand\lim{\mathop{\operator@font lím}}%
  \DeclareRobustCommand\limsup{\mathop{\operator@font lím\,sup}}%
  \DeclareRobustCommand\liminf{\mathop{\operator@font lím\,inf}}%
  \DeclareRobustCommand\max{\mathop{\operator@font máx}}%
  \DeclareRobustCommand\min{\mathop{\operator@font mín}}%
  \DeclareRobustCommand\inf{\mathop{\operator@font ínf}}%
  \DeclareRobustCommand\bmod{%
    \nonscript\mskip-\medmuskip\mkern5mu%
    \mathbin{\operator@font mód}\penalty900\mkern5mu%
    \nonscript\mskip-\medmuskip}%
  \@ifundefined{@amsmath@err}%
    {\DeclareRobustCommand\pmod[1]{%
       \allowbreak\mkern18mu({\operator@font mód}\,\,##1)}}%
    {\let\xpg@save@mod\mod
     \DeclareRobustCommand\mod[1]{\allowbreak\if@display\mkern18mu
        \else\mkern12mu\fi{\operator@font mód}\,\,##1}%
     \DeclareRobustCommand\pmod[1]{\pod{{\operator@font mód}%
        \mkern6mu##1}}}%
}

\def\nospanish@accentedoperators{%
  \let\lim\xpg@save@lim%
  \let\limsup\xpg@save@limsup%
  \let\liminf\xpg@save@liminf%
  \let\max\xpg@save@max%
  \let\min\xpg@save@min%
  \let\inf\xpg@save@inf%
  \let\bmod\xpg@save@bmod%
  \let\pmod\xpg@save@pmod%
  \@ifundefined{@amsmath@err}{}{\let\mod\xpg@save@mod}%
}

\let\xpg@save@arccos\arccos
\let\xpg@save@arcsin\arcsin
\let\xpg@save@arctan\arctan
\let\arcsen\arcsin
\let\arctg\arctan


\def\spanish@spacedoperators{%
  \DeclareRobustCommand\arccos{\mathop{\operator@font arc\,cos}\nolimits}%
  \DeclareRobustCommand\arcsin{\mathop{\operator@font arc\,sen}\nolimits}%
  \DeclareRobustCommand\arctan{\mathop{\operator@font arc\,tg}\nolimits}%
}

\def\nospanish@spacedoperators{%
  \let\arccos\xpg@save@arccos%
  \let\arcsen\arcsin%
  \let\arctg\arctan%
}


\let\xpg@save@sin\sin
\let\xpg@save@tan\tan
\let\xpg@save@sinh\sinh
\let\xpg@save@tanh\tanh
\let\sen\sin
\let\tg\tan
\let\senh\sinh
\let\tgh\tanh

\def\spanish@locoperators{%
  \DeclareRobustCommand\sin{\mathop{\operator@font sen}\nolimits}%
  \DeclareRobustCommand\tan{\mathop{\operator@font tg}\nolimits}%
  \DeclareRobustCommand\sinh{\mathop{\operator@font senh}\nolimits}%
  \DeclareRobustCommand\tanh{\mathop{\operator@font tgh}\nolimits}%
}

\def\nospanish@locoperators{%
  \let\sen\xpg@save@sin%
  \let\tg\xpg@save@tan%
  \let\sinh\xpg@save@sinh%
  \let\tanh\xpg@save@tanh%
  \let\sen\relax%
  \let\tg\relax%
  \let\senh\relax%
  \let\tgh\relax%
}

% Use \providecommand here as the ldf file might
% be reloaded via babel aliases.
\providecommand*\spanishoperator[2][]{%
  \ifx#1\\\\
    \protected@csxdef{#2}{\mathop{\operator@font #2}\nolimits}%
  \else
    \protected@csxdef{#2}{\mathop{\operator@font #1}\nolimits}%
  \fi
}

\def\captionsspanish{%
  \def\prefacename{Prefacio}%
  \def\refname{Referencias}%
  \def\abstractname{Resumen}%
  \def\bibname{Bibliografía}%
  \def\chaptername{Capítulo}%
  \def\appendixname{Apéndice}%
  \def\contentsname{Índice general}%
  \def\listfigurename{Índice de figuras}%
  \def\listtablename{Índice de cuadros}%
  \def\indexname{Índice alfabético}%
  \def\figurename{Figura}%
  \def\tablename{Cuadro}%
  \def\partname{Parte}%
  \def\enclname{Adjunto(s)}%
  \def\ccname{Copia a}%
  \def\headtoname{A}%
  \def\pagename{Página}%
  \def\seename{véase}%
  \def\alsoname{véase también}%
  \def\proofname{Prueba}%
  \def\glossaryname{Glosario}%
  \if@spanish@mexico
    \captionsspanish@mexico%
  \fi%
}

\def\captionsspanish@mexico{%
  \def\tablename{Tabla}%
}

\def\datespanish{%
  \def\today{\number\day~de~\ifcase\month\or
    enero\or febrero\or marzo\or abril\or mayo\or junio\or
    julio\or agosto\or septiembre\or octubre\or noviembre\or
    diciembre\fi\space de~\number\year}%
}

\def\noextras@spanish{%
  \nospanish@accentedoperators%
  \nospanish@spacedoperators%
  \nospanish@locoperators%
}

\def\blockextras@spanish{%
  \ifspanish@accentedoperators\spanish@accentedoperators\fi%
  \ifspanish@spacedoperators\spanish@spacedoperators\fi%
  \ifspanish@locoperators\spanish@locoperators\fi%
}

\def\inlineextras@spanish{%
  \ifspanish@accentedoperators\spanish@accentedoperators\fi%
  \ifspanish@spacedoperators\spanish@spacedoperators\fi%
  \ifspanish@locoperators\spanish@locoperators\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-spanish.ldf>
%<*gloss-spanishmx.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-spanishmx.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-spanishmx.ldf}[polyglossia: module for Mexican Spanish]

% We provide this as a babel alias

\xpg@load@master@language{spanish}

%    \end{macrocode}
% \iffalse
%</gloss-spanishmx.ldf>
%<*gloss-swedish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-swedish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-swedish.ldf}[polyglossia: module for Swedish]

\PolyglossiaSetup{swedish}{
  bcp47=sv,
  bcp47-language=sv,
  bcp47-script=Latn,
  hyphennames={swedish},
  hyphenmins={2,2},
  langtag=SVE,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{swedish}{sv}

\def\captionsswedish{%
  \def\refname{Referenser}%
  \def\abstractname{Sammanfattning}%
  \def\bibname{Litteraturförteckning}%
  \def\prefacename{Förord}%
  \def\chaptername{Kapitel}%
  \def\appendixname{Bilaga}%
  \def\contentsname{Innehåll}%
  \def\listfigurename{Figurer}%
  \def\listtablename{Tabeller}%
  \def\indexname{Sakregister}%
  \def\figurename{Figur}%
  \def\tablename{Tabell}%
  %\def\thepart{}%
  \def\partname{Del}%
  \def\pagename{Sida}%
  \def\seename{se}%
  \def\alsoname{se även}%
  \def\enclname{Bil.}%
  \def\ccname{Kopia för kännedom}%
  \def\headtoname{Till}%
  \def\proofname{Bevis}%
  \def\glossaryname{Ordlista}%
  }

\def\dateswedish{%   
  \def\today{%
    \number\day~\ifcase\month\or
    januari\or februari\or mars\or april\or maj\or juni\or
    juli\or augusti\or september\or oktober\or november\or
    december\fi
    \space\number\year}%
    \def\datesymd{%
      \def\today{\number\year-\two@digits\month-\two@digits\day}}%
    \def\datesdmy{%
     \def\today{\number\day/\number\month\space\number\year}}%
    }

%    \end{macrocode}
% \iffalse
%</gloss-swedish.ldf>
%<*gloss-swissgerman.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-swissgerman.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-swissgerman.ldf}[polyglossia: module for Swiss German (old spelling)]

% We provide this as a babel alias

\xpg@load@master@language{german}

%    \end{macrocode}
% \iffalse
%</gloss-swissgerman.ldf>
%<*gloss-syriac.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-syriac.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-syriac.ldf}[polyglossia: module for Syriac]

\RequireBidi
\RequirePackage{arabicnumbers}

\PolyglossiaSetup{syriac}{
  bcp47=syr,
  bcp47-language=syr,
  bcp47-script=Syrc,
  script=Syriac,
  scripttag=syrc,
  langtag=SYR,
  direction=RL,
  hyphennames={syriac,nohyphenation},
  fontsetup=true,
  localnumeral=syriacnumerals
  %TODO localalph
}

% BCP-47 compliant aliases
\setlanguagealias*{syriac}{syr}

\def\syriacnumber#1{\@syriacnumber{#1}}%

\newif\if@eastern@numerals
\define@choicekey*+{syriac}{numerals}[\xpg@val\xpg@nr]{eastern,western,abjad}[eastern]{%
   \ifcase\xpg@nr\relax
      % eastern:
      \@eastern@numeralstrue
      \SetLanguageKeys{syriac}{bcp47-extension-u=nu-syrc}%
   \or
      % western:
      \@eastern@numeralsfalse
      \SetLanguageKeys{syriac}{bcp47-extension-u=nu-latn}%
   \or
      % abjad:
      \let\syriacnumber\abjadsyriac%
   \fi
   \xpg@info{Option: Syriac, numerals=\xpg@val}%
}{\xpg@warning{Unknown Syriac numerals option `#1'}}

\newif\ifsyriac@customsep\syriac@customsepfalse
\def\xpg@sepmark{}
\define@key{syriac}{sectionsep}[.]{%
   \syriac@customseptrue%
   \gdef\xpg@sepmark{#1}%
}

% Register default options
\xpg@initialize@gloss@options{syriac}{numerals=western}
	
%\define@key{polyglossia}{syriaclocale}[default]{%
%	\def\@syriac@locale{#1}}
%
%\def\captionssyriac{%
%\def\prefacename{\@ensure@RTL{}}% 
%\def\refname{\@ensure@RTL{}}
%\def\abstractname{\@ensure@RTL{}}%
%\def\bibname{\@ensure@RTL{}}%
%\def\chaptername{\@ensure@RTL{}}%
%\def\appendixname{\@ensure@RTL{}}%
%\def\contentsname{\@ensure@RTL{}}
%\def\listfigurename{\@ensure@RTL{}}%
%\def\listtablename{\@ensure@RTL{}}%
%\def\indexname{\@ensure@RTL{}}%
%\def\figurename{\@ensure@RTL{}}%
%\def\tablename{\@ensure@RTL{}}%
%\def\partname{\@ensure@RTL{}}%
%\def\enclname{\@ensure@RTL{}}%
%\def\ccname{\@ensure@RTL{}}%
%\def\headtoname{\@ensure@RTL{}}%
%\def\pagename{\@ensure@RTL{}}%
%\def\seename{\@ensure@RTL{}}%
%\def\alsoname{\@ensure@RTL{}}%
%\def\proofname{\@ensure@RTL{}}%
%\def\glossaryname{\@ensure@RTL{}}%
%}

\def\datesyriac{%
  \def\syriac@month##1{\ifcase##1%
  \or ܟܢܘܢ ܐܚܪܝ\or ܫܒܛ\or ܐܕܪ\or ܢܝܣܢ\or ܐܝܪ\or ܚܙܝܪܢ\or ܬܡܘܙ\or ܐܒ\or ܐܝܠܘܠ% ܐܠܘܠ
   \or ܬܫܪܝܢ ܩܕܡ% ܬܫܪܝܢ ܩܕܝܡ
   \or ܬܫܪܝܢ ܐܚܪܝ\or ܟܢܘܢ ܩܕܡ% ܟܢܘܢ ܩܕܝܡ
   \fi}%
   \def\today{\@ensure@RTL{\syriacnumber\day{\space}%
    \syriac@month{\month}{\space}\syriacnumber\year}}%
}

\def\syriac@zero{}

\def\abjadsyriac#1{%
\ifnum#1>9999\xpg@ill@value{#1}{abjadsyriac}%
\else%
  \ifnum#1<\z@\space\xpg@ill@value{#1}{abjadsyriac}%
  \else%
    \ifnum#1<10\expandafter\abj@syr@num@i\number#1%
    \else%
      \ifnum#1<100\expandafter\abj@syr@num@ii\number#1%
      \else%
        \ifnum#1<1000\expandafter\abj@syr@num@iii\number#1%
	\else%
          \expandafter\abj@syr@num@iv\number#1%
	\fi%
      \fi%
    \fi%
  \fi%
\fi%
}
\def\abj@syr@num@i#1{%
  \ifcase#1\or\char"0710\or\char"0712\or\char"0713\or\char"0715%
 \or\char"0717\or\char"0718\or\char"0719\or\char"071A\or\char"071B\fi
  \ifnum#1=\z@\syriac@zero\fi}
\def\abj@syr@num@ii#1{%
  \ifcase#1\or\char"071D\or\char"071F\or\char"0720\or\char"0721\or\char"0722%
          \or\char"0723\or\char"0725\or\char"0726\or\char"0728\fi
  \ifnum#1=\z@\fi\abj@syr@num@i}
\def\abj@syr@num@iii#1{%
  \ifcase#1\or\char"0729\or\char"072A\or\char"072B\or\char"072C%
  \or\char"0722\char"0307\or\char"0723\char"0307\or\char"0725\char"0307%
  \or\char"0726\char"0307\or\char"0728\char"0307\fi
  \ifnum#1=\z@\fi\abj@syr@num@ii}
\def\abj@syr@num@iv#1{%
  \ifcase#1\or\char"0710\char"0748\or\char"0712\char"0748%
  \or\char"0713\char"0748\or\char"0715\char"0748%
  \or\char"0717\char"0748\or\char"0718\char"0748%
  \or\char"0719\char"0748\or\char"071A\char"0748\or\char"071B\char"0748\fi
  \ifnum#1=\z@\fi\abj@syr@num@iii}

\def\@syriacnumber#1{%
   \if@eastern@numerals
      %%% we test for the presence of one of ١٢٣٤٥٦٧٨٩٠ in the Syriac font, 
      %%% else we try \arabicfont if defined (and give a warning), 
      %%% else we fall back to the Western numerals.
      \xpg@if@char@available{0661}%
          {\@ensure@LTR{\protect\arabicdigits{\number#1}}}%
          {\@ensure@LTR{\arabicdigits{\number#1}}
           \ifcsdef{arabicfont}%
	     {\@ensure@LTR{\protect\arabicdigits{\number#1}}%
	      \xpg@warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
                           I am using \string\arabicfont instead}}%
	     {\number#1%%% <---changed from \RL{\protect\reset@font\protect\number#1}%
	      \xpg@warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
                           since \string\arabicfont is not defined, we'll use Western numerals instead}}%
          }%
   \else
     %%\RL{\protect\reset@font\number#1}%
     \number#1%
   \fi%
}

\def\syriac@numbers{%
   \let\@alph\abjadsyriac%
   \let\@Alph\abjadsyriac%
}

\def\nosyriac@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

\newcommand{\syriacnumerals}[2]{\syriacnumber{#2}}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\syriac@globalnumbers{%
  \let\@arabic\syriacnumber%
  \renewcommand\thefootnote{\localnumeral*{footnote}}%
}

\def\nosyriac@globalnumbers{%
  \let\@arabic\xpg@save@arabic%
}

\def\syriac@xetex@capsformat{%
  \let\xpg@save@sepmark\@SepMark%
  \SepMark{\xpg@sepmark}
}

\def\nosyriac@xetex@capsformat{%
   \ifcsdef{xpg@save@sepmark}{%
     \SepMark{\xpg@save@sepmark}
   }{}%
}

\def\syriac@luatex@capsformat{%
  %
  % change chapter and part headings
  \ifsyriac@customsep
     \ifcsdef{chapter}{%
        \let\xpg@save@thesection\thesection%
        \renewcommand*\thesection{\thechapter\xpg@sepmark\@arabic\c@section}
        \let\xpg@save@theequation\theequation%
        \renewcommand*\theequation{%
	    \ifnum \c@chapter>\z@ \thechapter\xpg@sepmark\fi\@arabic\c@equation}
        \let\xpg@save@thefigure\thefigure%
	\renewcommand*\thefigure{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@figure}
        \let\xpg@save@thetable\thetable%
	\renewcommand*\thetable{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@table}
     }{}
     \let\xpg@save@thesubsection\thesubsection%
     \renewcommand\thesubsection
	{\thesection\xpg@sepmark\@arabic\c@subsection}
     \let\xpg@save@thesubsubsection\thesubsubsection%
     \renewcommand\thesubsubsection{\thesubsection\xpg@sepmark\@arabic\c@subsubsection}
     \let\xpg@save@theparagraph\theparagraph%
     \renewcommand\theparagraph
         {\thesubsubsection\xpg@sepmark\@arabic\c@paragraph}
     \let\xpg@save@thesubparagraph\thesubparagraph%
     \renewcommand\thesubparagraph{\theparagraph\xpg@sepmark\@arabic\c@subparagraph}
  \fi% (end \ifsyriac@customsep)
}

\def\nosyriac@luatex@capsformat{%
   \ifcsdef{xpg@save@thesection}{%
        \let\thesection\xpg@save@thesection%
   }{}%
   \ifcsdef{xpg@save@theequation}{%
        \let\theequation\xpg@save@theequation%
   }{}%
   \ifcsdef{xpg@save@thefigure}{%
        \let\thefigure\xpg@save@thefigure%
   }{}%
   \ifcsdef{xpg@save@thetable}{%
        \let\thetable\xpg@save@thetable%
   }{}%
   \ifcsdef{xpg@save@thesubsection}{%
        \let\thesubsection\xpg@save@thesubsection%
   \ifcsdef{xpg@save@thesubsubsection}{%
        \let\thesubsubsection\xpg@save@thesubsubsection%
   }{}%
   }{}%
   \ifcsdef{xpg@save@theparagraph}{%
        \let\theparagraph\xpg@save@theparagraph%
   }{}%
   \ifcsdef{xpg@save@thesubparagraph}{%
        \let\thesubparagraph\xpg@save@thesubparagraph%
   }{}%
}

\def\blockextras@syriac{%
   \ifsyriac@customsep
      \ifxetex
        \syriac@xetex@capsformat
      \else
        \syriac@luatex@capsformat
      \fi   
   \fi
}
%
\def\noextras@syriac{%
    \ifsyriac@customsep
      \ifxetex
        \nosyriac@xetex@capsformat
      \else
        \nosyriac@luatex@capsformat
      \fi   
   \fi
}

%    \end{macrocode}
% \iffalse
%</gloss-syriac.ldf>
%<*gloss-tamil.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-tamil.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-tamil.ldf}[polyglossia: module for Tamil]

% Translations provided by Kevin & Siji, 01-11-2009

\PolyglossiaSetup{tamil}{
  bcp47=ta,
  bcp47-language=ta,
  bcp47-script=Taml,
  script=Tamil,
  scripttag=taml,
  langtag=TAM,
  hyphennames={tamil},
  hyphenmins={2,2}, %FIXME?
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{tamil}{ta}

\def\captionstamil{%
     \def\abstractname{சாராம்சம்}%
     \def\appendixname{பிற்சேர்க்கை}%பின்னிணைப்பு
     %\def\bibname{}%
     %\def\ccname{}%
     \def\chaptername{அத்தியாயம்}%
     \def\contentsname{உள்ளே}%
     %\def\enclname{}%
     \def\figurename{படம்}%
     %\def\headpagename{}%
     %\def\headtoname{}%
     \def\indexname{சுட்டி}%பொருளடக்க அட்டவணை
     \def\listfigurename{படங்களின் பட்டியல்}%
     \def\listtablename{அட்டவணை பட்டியல்}%
     %\def\pagename{}%
     \def\partname{பகுதி}%
     %\def\prefacename{}% 
     %\def\refname{}%
     \def\tablename{அட்டவணை}%
     \def\seename{பார்க்க}%
     %\def\alsoname{}%
     %\def\alsoseename{}%
}
\def\datetamil{%
   \def\today{\number\year\space\ifcase\month\or
     ஜனவரி\or
     பிப்ரவரி\or
     மார்ச்\or
    ஏப்ரல்\or
     மே\or
     ஜூன்\or
     ஜூலை\or
    ஆகஸ்ட்\or
     செப்டம்பர்\or
     அக்டோபர்\or
     நவம்பர்\or
     டிசம்பர்\fi
     \space\number\day}%
}

%    \end{macrocode}
% \iffalse
%</gloss-tamil.ldf>
%<*gloss-telugu.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-telugu.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-telugu.ldf}[polyglossia: module for Telugu]

% Translations provided by Anmol Sharma <unmole.in@gmail.com>

\PolyglossiaSetup{telugu}{
  bcp47=te,
  bcp47-language=te,
  bcp47-script=Telu,
  script=Telugu,
  scripttag=telu,
  langtag=TEL,
  hyphennames={telugu},
  hyphenmins={2,2}, %FIXME
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{telugu}{te}

\def\captionstelugu{%
   \def\refname{ఆధారాలు}%
   \def\abstractname{సారాంశం}%
   \def\bibname{గ్రంథాల జాబితా}%
   \def\prefacename{ముందుమాట}%
   \def\chaptername{అధ్యాయము}%
   \def\appendixname{అదనంగా}%
   \def\contentsname{విషయాలు}%
   \def\listfigurename{ఆకృతుల జాబితా}%
   \def\listtablename{పట్టికల జాబితా}%
   \def\indexname{విషయ సూచిక}%
   \def\figurename{ఆకృతి}%
   \def\tablename{పట్టిక}%
   %\def\thepart{}%
   \def\partname{భాగం}%
   \def\pagename{పేజి}%
   \def\seename{చూడండి}%
   \def\alsoname{కూడా చూడండి}%
   \def\enclname{ఎంక్లోజర్*}%
   \def\ccname{సిసి}%
   \def\headtoname{కి}%
   \def\proofname{రుజువు}%
   \def\glossaryname{నిఘంటువు}%
}

\def\datetelugu{%
   \def\telugu@month{%
      \ifcase\month\or
         జనవరి\or
         ఫిబ్రవరి\or
         మార్చ్\or
         ఏప్రిల్\or
         మే\or
         జూన్\or
         జూలై\or
         ఆగస్ట్\or
         సెప్టెంబర్\or
         అక్తోబెర్\or
         నవంబర్\or
         డిసంబర్\fi}%
   \def\today{\telugu@month\space\number\day,\space\number\year}%
}

%    \end{macrocode}
% \iffalse
%</gloss-telugu.ldf>
%<*gloss-thai.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-thai.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-thai.ldf}[polyglossia: module for Thai]
%% This is partly based on thai-latex for Babel:
%%%% Copyright (C) 1999 - 2006
%%%%           by Surapant Meknavin,
%%%%              Theppitak Karoonboonyanan (thep at linux.thai.net),
%%%%              Chanop Silpa-Anan (chanop at debian.org),
%%%%              Poonlap Veerathanabutr (poonlap at linux.thai.net)
%%%%              Thai Linux Working Group
%%%%              http://linux.thai.net/
%%%%
\PolyglossiaSetup{thai}{
  bcp47=th,
  bcp47-language=th,
  bcp47-script=Thai,
  script=Thai,
  scripttag=thai,
  langtag=THA,
  hyphennames={nohyphenation},
  fontsetup=true,
  localnumeral=thainumerals
  %TODO localalph={xxx@alph,xxx@Alph}
  %TODO localdigits=thainumber
}

% BCP-47 compliant aliases
\setlanguagealias*{thai}{th}

\newif\if@thai@numerals
\def\tmp@thai{thai}
\define@key{thai}{numerals}[arabic]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@thai
	  \@thai@numeralstrue%
          \SetLanguageKeys{thai}{bcp47-extension-u=nu-thai}%
	\else
	  \@thai@numeralsfalse%
          \SetLanguageKeys{thai}{bcp47-extension-u=nu-latn}%
	\fi
}

% Register default options
\xpg@initialize@gloss@options{thai}{numerals=arabic}

\def\captionsthai{%
   \def\refname{หนังสืออ้างอิง}%
   \def\abstractname{บทคัดย่อ}%
   \def\bibname{บรรณานุกรม}%
   \def\prefacename{คำนำ}%
   \def\chaptername{บทที่}%
   \def\appendixname{ภาคผนวก}%
   \def\contentsname{สารบัญ}%
   \def\listfigurename{สารบัญรูป}%
   \def\listtablename{สารบัญตาราง}%
   \def\indexname{ดรรชนี}%
   \def\figurename{รูปที่}%
   \def\tablename{ตารางที่}%
   %\def\thepart{}%
   \def\partname{ภาค}%
   \def\pagename{หน้า}%
   \def\seename{ดู}%
   \def\alsoname{ดูเพิ่มเติม}%
   \def\enclname{สิ่งที่แนบมาด้วย}%
   \def\ccname{สำเนาถึง}%
   \def\headtoname{เรียน}%
   \def\proofname{พิสูจน์}%
   %\def\glossaryname{}%
}
\def\datethai{%   
   \def\thai@month{%
     \ifcase\month\or
       มกราคม\or กุมภาพันธ์\or มีนาคม\or เมษายน%
      \or พฤษภาคม\or มิถุนายน\or กรกฎาคม\or สิงหาคม%
      \or กันยายน\or ตุลาคม\or พฤศจิกายน\or ธันวาคม\fi}%
   \newcount\thai@year%
   \thai@year=\year%
   \advance\thai@year by 543%
   \def\today{\thainumber\day \space \thai@month\space พ.ศ.~\thainumber\thai@year}%
}

%NB: thai-latex had "plus 0.6pt", but .4em appears to give better results
% FIXME to avoid name clashes, rename \wbr to \wordbreak or \thaiworkbreak ?
\def\wbr{\hskip0pt plus .4em\relax} %%OR \char"200B = ZWSP ? Does not work
%\catcode"200b=\active
%\def^^200b{\hskip 0pt plus .4em}

\def\thaidigits#1{\expandafter\@thai@digits #1@}
\def\@thai@digits#1{%
  \ifx @#1% then terminate
  \else
    \ifx0#1๐\else\ifx1#1๑\else\ifx2#1๒\else\ifx3#1๓\else\ifx4#1๔\else\ifx5#1๕\else\ifx6#1๖\else\ifx7#1๗\else\ifx8#1๘\else\ifx9#1๙\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@thai@digits
  \fi
}

\newcommand{\thainumerals}[2]{\thainumber{#2}}

\def\thainumber#1{%
  \if@thai@numerals
    \thaidigits{\number#1}%
    %%{\protect\addfontfeature{Mapping=thaidigits}\protect\number#1}
  \else
    \number#1%
    %%{\protect\reset@font\number#1}
  \fi}

\def\@thaialph#1{%
  \ifcase#1\or ก\or ข\or ค\or ง\or จ\or ฉ\or ช\or ซ\or ฌ\or ญ\or ฎ\or
   ฏ\or ฐ\or ฑ\or ฒ\or ณ\or ด\or ต\or ถ\or ท\or ธ\or น\or บ\or ป\or ผ\or
   ฝ\or พ\or ฟ\or ภ\or ม\or ย\or ร\or ล\or ว\or ศ\or ษ\or ส\or ห\or ฬ\or อ\or
   ฮ\else\xpg@ill@value{#1}{@thaialph}\fi}
\def\thaiAlph#1{\expandafter\@thaiAlph\csname c@#1\endcsname}
\def\@thaiAlph#1{%
  \ifcase#1\or ก\or ข\or ฃ\or ค\or ฅ\or ฆ\or ง\or จ\or ฉ\or ช\or ซ\or
   ฌ\or ญ\or ฎ\or ฏ\or ฐ\or ฑ\or ฒ\or ณ\or ด\or ต\or ถ\or ท\or ธ\or น\or
    บ\or ป\or ผ\or ฝ\or พ\or ฟ\or ภ\or ม\or ย\or ร\or ฤ\or ล\or ฦ\or ว\or
     ศ\or ษ\or ส\or ห\or ฬ\or อ\or ฮ\else\xpg@ill@value{#1}{@thaialph}\fi}
     
\def\thai@numbers{%
   \if@thai@numerals
     \let\@alph\@thaialph%
     \let\@Alph\@thaiAlph%
   \fi
}
\def\nothai@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

\def\thai@globalnumbers{%
   \let\orig@arabic\@arabic%
   \let\@arabic\thainumber%
   \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
}
\def\nothai@globalnumbers{%
   \let\@arabic\orig@arabic%
}

\def\blockextras@thai{%
%%TODO \XeTeXlinebreaklocales "th"% uses ICU to find line breaks on the basis of a dictionary lookup-- make this optional? (in case a user might prefer a preprocessor
   \let\orig@baselinestrech\baselinestretch%
   \renewcommand{\baselinestretch}{1.2}%
}
\def\noblockextras@thai{%
%%TODO \XeTeXlinebreaklocales "en"%
   \let\baselinestrech\orig@baselinestretch%
}

%    \end{macrocode}
% \iffalse
%</gloss-thai.ldf>
%<*gloss-tibetan.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-tibetan.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-tibetan.ldf}[polyglossia: module for Tibetan]
%% Copyright 2013 Elie Roux
%% Under the CC0 license <http://creativecommons.org/publicdomain/zero/1.0/>
%%
%% A good font to make tests is \newfontfamily\tibetanfont{Tibetan Machine Uni}
%%

\PolyglossiaSetup{tibetan}{
  bcp47=bo,
  bcp47-language=bo,
  bcp47-script=Tibt,
  script=Tibetan,
  scripttag=tibt,
  langtag=TIB,
  hyphennames={nohyphenation},
  fontsetup=true,
  localnumeral=tibetannumerals
  %TODO localalph={xxx@alph,xxx@Alph}
}

% BCP-47 compliant aliases
\setlanguagealias*{tibetan}{bo}

\newif\if@tibetan@numerals
\def\tmp@tibetan{tibetan}
\define@key{tibetan}{numerals}[tibetan]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@tibetan
	   \@tibetan@numeralstrue%
           \SetLanguageKeys{tibetan}{bcp47-extension-u=nu-tibt}%
	\else
	  \@tibetan@numeralsfalse%
           \SetLanguageKeys{tibetan}{bcp47-extension-u=nu-latn}%
	\fi%
}

\ifluatex
  \newluatexattribute\xpg@tibteol %
  \directlua{polyglossia.load_tibt_eol()}%
\fi

\def\tibetan@eol{%
  \ifluatex%
    \xpg@tibteol=1\relax%
    \directlua{polyglossia.activate_tibt_eol()}%
  \else%
    \XeTeXlinebreaklocale "bo"%
    \XeTeXlinebreakskip=0pt plus 0.1em% doesn't do much, but doesn't harm I guess...
  \fi%
}

\def\notibetan@eol{%
  \ifluatex%
    \xpg@tibteol=0\relax%
    %\directlua{polyglossia.activate_tibt_eol()}%
  \else%
    \XeTeXlinebreaklocale "en"% en? really?
    \XeTeXlinebreakskip=0pt plus 0pt%
  \fi%
}

% Register default options
\xpg@initialize@gloss@options{tibetan}{numerals=tibetan}

% some are known, but very few
% a few come from "Standardizing Tibetan Terms of Information Technology"
% from the China Tibetology Research Center
\def\captionstibetan{%
   %\def\refname{}%
   \def\abstractname{གནད་བསྡུས།}%
   \def\bibname{དཔེ་ཆའི་ཐོ་གཞུང་།}% or dpe deb kyi re'u mig?
   \def\prefacename{དཔེ་དེབ་ཀྱི་གླེང་བརྗོད།}% or gleng brjod 'god pa or ngo sprod?
   \def\chaptername{ལེའུ་}%
   \def\appendixname{ཞར་བྱུང་།}%
   \def\contentsname{དཀར་ཆག།}%
   %\def\listfigurename{}%
   %\def\listtablename{}%
   \def\indexname{གསུལ་བྱང་།}%
   \def\figurename{པར་རིས་}% or dpe ris?
   \def\tablename{རེའུ་མིག་}%
   %\def\thepart{}%
   \def\partname{ཆ་ཤས་}%
   \def\pagename{ཤོག་}%
   %\def\seename{}%
   %\def\alsoname{}%
   %\def\enclname{}%
   \def\ccname{འདྲ་བཤུས་ལེན་མཁན་}%
   %\def\headtoname{}%
   \def\proofname{བདེན་དཔང་།}% not sure about this one...
   \def\glossaryname{མིང་ཚིག་རེའུ་མིག།}%
}

\def\datetibetan{%   
   \def\tibetan@month{%
     \ifcase\month\or
       ཟླ་དང་པོ\or ཟླ་གཉིས་པ\or ཟླ་གསུམ་པ%
      \or ཟླ་བཞི་པ\or ཟླ་ལྔ་པ\or ཟླ་དྲུག་པ\or ཟླ་བདུན་པ%
      \or ཟླ་བརྒྱད་པ\or ཟླ་དགུ་པ\or ཟླ་བཆུ་པ\or ཟླ་བཆུ་གཅིག་པ\or ཟླ་བཆུ་གཉིས་པ\fi}%      
   \def\tibetan@daynum{%
     \ifcase\day\or དང་པོ\or གཉིས་པ\or གསུམ་པ \or བཞི་པ\or ལྔ་པ\or དྲུག་པ\or བདུན་པ\or བརྒྱད་པ\or དགུ་པ\or བཆུ་པ%
 \or བཆུ་གཅིག་པ\or བཆུ་གཉིས་པ\or བཆུ་གསུམ་པ\or བཆུ་བཞི་པ\or བཆུ་ལྔ་པ\or བཆུ་དྲུག་པ\or བཆུ་བདུན་པ\or བཆུ་བརྒྱད་པ\or བཆུ་དགུ་པ\or ཉི་ཤུ་པ%
 
 \or ཉི་ཤུ་རྩ་གཅིག་པ\or ཉི་ཤུ་རྩ་གཉིས་པ\or ཉི་ཤུ་རྩ་གསུམ་པ\or ཉི་ཤུ་རྩ་བཞི་པ\or ཉི་ཤུ་རྩ་ལྔ་པ\or ཉི་ཤུ་རྩ་དྲུག་པ\or ཉི་ཤུ་རྩ་བདུན་པ\or ཉི་ཤུ་རྩ་བརྒྱད་པ\or ཉི་ཤུ་རྩ་དགུ་པ\or སུམ་ཆུ་པ%
 \or སུམ་ཆུ་སོ་གཅིག་པ\fi}%      
   % As we use gregorian calendar, it's better to stick with spyi lo
   %\newcount\tibetan@year%
   %\tibetan@year=\year%
   %\advance\tibetan@year by 127% this is bod rgyal lo, the most common, but there are others...
   % I'm not sure the / character is in most tibetan fonts
   %\def\today{\tibetannumber\day /\tibetannumber\day /\tibetannumber\year}%
   \def\today{\tibetannumber\day །\tibetannumber\month །\tibetannumber\year}%
   % this is more litterate, but longer
   %\def\today{སྤྱི་ལོ་\tibetannumber\year ་སྤྱི་\tibetan@month{}་ད་རེས་\tibetan@daynum{}།}%  
}

\def\tibetandigits#1{\expandafter\@tibetan@digits #1@}

\def\@tibetan@digits#1{%
  \ifx @#1% then terminate
  \else
    \ifx0#1༠\else\ifx1#1༡\else\ifx2#1༢\else\ifx3#1༣\else\ifx4#1༤\else\ifx5#1༥\else\ifx6#1༦\else\ifx7#1༧\else\ifx8#1༨\else\ifx9#1༩\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@tibetan@digits
  \fi
}

\def\tibetannumber#1{%
  \if@tibetan@numerals
    \tibetandigits{\number#1}%
    %%{\protect\addfontfeature{Mapping=tibetandigits}\protect\number#1}
  \else
    \number#1%
    %%{\protect\reset@font\number#1}
  \fi}

\def\@tibetanalph#1{%
    \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or
           ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or
           བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or
           འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ
    \else%
        \xpg@ill@value{#1}{@tibetanalph}%
    \fi%
}
 
\def\tibetanAlph#1{%
    \expandafter\@tibetanAlph\csname c@#1\endcsname%
}

\def\@tibetanAlph#1{%
    \ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or
          ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or བ\or མ\or ཙ\or
           ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or
            ས\or ཧ\or ཨ%
    \else%
       \xpg@ill@value{#1}{@tibetanalph}%
    \fi%
}

\newcommand{\tibetanumerals}[2]{\tibetannumber{#2}}

\def\tibetan@numbers{%
   \if@tibetan@numerals
     \let\@alph\@tibetanalph%
     \let\@Alph\@tibetanAlph%
   \fi
}

\def\notibetan@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

% Store original definition
\let\xpg@orig@arabic\@arabic

\def\tibetan@globalnumbers{%
   \let\@arabic\tibetannumber%
   \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
}

\def\notibetan@globalnumbers{%
   \let\@arabic\xpg@orig@arabic%
}

\def\noextras@tibetan{%
   \notibetan@eol%
   \ifcsname xpg@orig@baselinestretch\endcsname%
       \renewcommand{\baselinestretch}{\xpg@orig@baselinestretch}%
   \fi%
}

\def\inlineextras@tibetan{%
   \xdef\xpg@orig@baselinestretch{%
       \ifcsname baselinestretch\endcsname
           \baselinestretch
        \else
           1%
        \fi%
   }%
   \renewcommand{\baselinestretch}{1.2}%
   \tibetan@eol%
}

\def\blockextras@tibetan{%
   \xdef\xpg@orig@baselinestretch{%
        \ifcsname baselinestretch\endcsname
            \baselinestretch
        \else
           1%
        \fi%
   }%
   \renewcommand{\baselinestretch}{1.2}%
   \tibetan@eol%
}

%    \end{macrocode}
% \iffalse
%</gloss-tibetan.ldf>
%<*gloss-turkish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-turkish.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-turkish.ldf}[polyglossia: module for Turkish]
\RequirePackage{hijrical}
\PolyglossiaSetup{turkish}{
  bcp47=tr,
  bcp47-language=tr,
  bcp47-script=Latn,
  hyphennames={turkish},
  hyphenmins={2,2},
  langtag=TRK,
  frenchspacing=true,
  fontsetup=true
  }

% TODO Add \ifluatex branch everywhere
\ifxetex
\newXeTeXintercharclass\turkish@punctthin % ! :
\newXeTeXintercharclass\turkish@punctthick % =
\fi

\def\turkish@punctthinspace{{\ifdim\lastskip>\z@\unskip\penalty\@M\thinspace\fi}}
\def\turkish@punctthickspace{{\unskip\nobreakspace}}

\def\turkish@punctuation{%
   \ifxetex
   \XeTeXinterchartokenstate=1%
   \XeTeXcharclass `\! \turkish@punctthin
   \XeTeXcharclass `\: \turkish@punctthin
   \XeTeXcharclass `\= \turkish@punctthick
   \XeTeXinterchartoks \z@ \turkish@punctthin = \turkish@punctthinspace
   \XeTeXinterchartoks \z@ \turkish@punctthick = \turkish@punctthickspace
   \fi
}

% BCP-47 compliant aliases
\setlanguagealias*{turkish}{tr}

\def\noturkish@punctuation{%
   \ifxetex
   \XeTeXcharclass `\! \z@
   \XeTeXcharclass `\: \z@
   \XeTeXcharclass `\= \z@
   \XeTeXinterchartokenstate=0%
   \fi
}

\def\turkish@casing{%
  \lccode`\I=`\ı
  \uccode`\i=`\İ
}

\def\noturkish@casing{%
  \lccode`\I=`\i
  \uccode`\i=`\I
}

\def\captionsturkish{%
  \def\prefacename{Önsöz}%
  \def\refname{Kaynaklar}%
  \def\abstractname{Özet}%
  \def\bibname{Kaynakça}%
  \def\chaptername{Bölüm}%
  \def\appendixname{Ek}%
  \def\contentsname{İçindekiler}%
  \def\listfigurename{Şekil Listesi}%
  \def\listtablename{Tablo Listesi}%
  \def\indexname{Dizin}%
  \def\figurename{Şekil}%
  \def\tablename{Tablo}%
  \def\partname{Kısım}%
  \def\enclname{İlişik}%
  \def\ccname{Diğer Alıcılar}%
  \def\headtoname{Alıcı}%
  \def\pagename{Sayfa}%
  \def\subjectname{İlgili}%
  \def\seename{bkz.}%
  \def\alsoname{ayrıca bkz.}%
  \def\proofname{Kanıt}%
  \def\glossaryname{Lügatçe}%
   }
\def\dateturkish{%
   \def\today{\number\day~\ifcase\month\or
    Ocak\or Şubat\or Mart\or Nisan\or Mayıs\or Haziran\or
    Temmuz\or Ağustos\or Eylül\or Ekim\or Kasım\or
    Aralık\fi
    \space\number\year}%
}
\def\hijrimonthturkish#1{\ifcase#1%
\or Muharrem\or Safer\or Rebiülevvel\or Rebiülahir\or Cemaziyelevvel\or Cemaziyelahir\or Recep\or Şaban\or Ramazan\or Şevval\or Zilkade\or Zilhicce\fi}
%%\Hijritoday is now locale-aware and will format the date with this macro:
\DefineFormatHijriDate{turkish}{%
\number\value{Hijriday}\space\hijrimonthturkish{\value{Hijrimonth}}\space\number\value{Hijriyear}}

\def\noextras@turkish{%
   \noturkish@punctuation%
   \noturkish@casing%
}

\def\blockextras@turkish{%
   \turkish@punctuation%
   \turkish@casing%
}

\def\inlineextras@turkish{%
   \turkish@punctuation%
   \turkish@casing%
}

%    \end{macrocode}
% \iffalse
%</gloss-turkish.ldf>
%<*gloss-turkmen.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-turkmen.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-turkmen.ldf}[polyglossia: module for Turkmen]
%% Translations provided by Nazar Annagurban <nazartm at gmail dot com>
\PolyglossiaSetup{turkmen}{
  bcp47=tk,
  bcp47-language=tk,
  bcp47-script=Latn,
  hyphennames={turkmen},
  hyphenmins={2,2},
  langtag=TKM,
  frenchspacing=false,
  fontsetup=true
}

% BCP-47 compliant aliases
\setlanguagealias*{turkmen}{tk}

\def\captionsturkmen{%
  \def\prefacename{Sözbaşy}%
  \def\refname{Çeşmeler}%
  \def\abstractname{Gysgaça manysy}%
  \def\bibname{Çeşmeler}%
  \def\chaptername{Bap}%
  \def\appendixname{Goşmaça}%
  \def\contentsname{Mazmuny}%
  \def\listfigurename{Suratlaryň sanawy}%
  \def\listtablename{Tablisalaryň sanawy}%
  \def\indexname{Indeks}%
  \def\figurename{Surat}%
  \def\tablename{Tablisa}%
  \def\partname{Bölüm}%
  \def\enclname{Goşmaça}%
  \def\ccname{Iberilenler}%
  \def\headtoname{Kime}%
  \def\pagename{Sahypa}%
  \def\subjectname{Tema}%
  \def\seename{ser.}%
  \def\alsoname{şuňa-da ser.}%
  \def\proofname{Delil}%
  \def\glossaryname{Sözlük}%
}
\def\dateturkmen{%
   \def\today{\number\day~\ifcase\month\or
    Ýanwar\or Fewral\or Mart\or Aprel\or Maý\or Iýun\or
    Iýul\or Awgust\or Sentýabr\or Oktýabr\or Noýabr\or
    Dekabr\fi
    \space\number\year}%
}
%    \end{macrocode}
% \iffalse
%</gloss-turkmen.ldf>
%<*gloss-ug.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ug.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ug.ldf}[polyglossia: module for ug (Uyghur)]
% BCP 47 tag for Uyghur

\xpg@load@master@language{uyghur}

%    \end{macrocode}
% \iffalse
%</gloss-ug.ldf>
%<*gloss-ukrainian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ukrainian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-ukrainian.ldf}[polyglossia: module for Ukrainian]
% Strings taken from Babel
% and revised by Roman Kyrylych

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{ukrainian}{%
  bcp47=uk,
  bcp47-language=uk,
  bcp47-script=Cyrl,
  script=Cyrillic,
  scripttag=cyrl,
  langtag=UKR,
  hyphennames={ukrainian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
  localnumeral=ukrainiannumerals,
  Localnumeral=Ukrainiannumerals
}

% BCP-47 compliant aliases
\setlanguagealias*{ukrainian}{uk}

\newif\ifcyrillic@numerals
\newif\ifcyrillic@asbuk@numerals
\define@choicekey*+{ukrainian}{numerals}[\xpg@val\xpg@nr]{arabic,cyrillic,cyrillic-trad,cyrillic-alph}[arabic]{%
   \ifcase\xpg@nr\relax
      % arabic:
      \cyrillic@numeralsfalse%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{ukrainian}{bcp47-extension-u=nu-latn}%
   \or
      % cyrillic:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{ukrainian}{bcp47-extension-u=nu-cyrl}%
   \or
      % cyrillic-trad:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralsfalse%
      \SetLanguageKeys{ukrainian}{bcp47-extension-u=nu-cyrl}%
   \or
      % cyrillic-alph:
      \cyrillic@numeralstrue%
      \cyrillic@asbuk@numeralstrue%
      \SetLanguageKeys{ukrainian}{bcp47-extension-u=nu-cyrl}%
   \fi
   \xpg@info{Option: Ukrainian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Ukrainian numerals value `#1'}}


% Define some math functions
\define@boolkey{ukrainian}[ukrainian@]{mathfunctions}[true]{}

% Register default options
\xpg@initialize@gloss@options{ukrainian}{numerals=arabic,mathfunctions=true}

\define@boolkey{ukrainian}[ukrainian@]{babelshorthands}[true]{}

\ifsystem@babelshorthands
  \setkeys{ukrainian}{babelshorthands=true}
\else
  \setkeys{ukrainian}{babelshorthands=false}
\fi

\ifcsundef{initiate@active@char}{%
  \input{babelsh.def}%
  \initiate@active@char{"}%
  \shorthandoff{"}%
}{}

\def\ukrainian@shorthands{%
  \xpg@activate@shorthands%
  \def\language@group{ukrainian}%
%  \declare@shorthand{ukrainian}{"`}{„}%
%  \declare@shorthand{ukrainian}{"'}{“}%
%  \declare@shorthand{ukrainian}{"<}{«}%
%  \declare@shorthand{ukrainian}{">}{»}%
  \declare@shorthand{ukrainian}{""}{\hskip\z@skip}%
  \declare@shorthand{ukrainian}{"~}{\textormath{\leavevmode\hbox{-}}{-}}%
  \declare@shorthand{ukrainian}{"=}{\nobreak-\hskip\z@skip}%
  \declare@shorthand{ukrainian}{"|}{\textormath{\nobreak\discretionary{-}{}{\kern.03em}\allowhyphens}{}}%
  \declare@shorthand{ukrainian}{"-}{%
  \def\ukrainian@sh@tmp{%
    \if\ukrainian@sh@next-\expandafter\ukrainian@sh@emdash
    \else\expandafter\ukrainian@sh@hyphen\fi
  }%
  \futurelet\ukrainian@sh@next\ukrainian@sh@tmp}%
  \def\ukrainian@sh@hyphen{%
  \nobreak\-\bbl@allowhyphens}%
  \def\ukrainian@sh@emdash##1##2{\cdash-##1##2}%
  \def\cdash##1##2##3{%
    \def\tempx@{##3}%
    \def\tempa@{-}\def\tempb@{~}\def\tempc@{*}%
    \ifx\tempx@\tempa@\@Acdash\else
    \ifx\tempx@\tempb@\@Bcdash\else
    \ifx\tempx@\tempc@\@Ccdash\else
    \errmessage{Wrong usage of cdash}\fi\fi\fi%
  }%
  \def\@Acdash{\ifdim\lastskip>\z@\unskip\nobreak\hskip.2em\fi
  \cyrdash\hskip.2em\ignorespaces}%
  \def\@Bcdash{\leavevmode\ifdim\lastskip>\z@\unskip\fi
  \nobreak\cyrdash\penalty\exhyphenpenalty\hskip\z@skip\ignorespaces}%
  \def\@Ccdash{\leavevmode
  \nobreak\cyrdash\nobreak\hskip.35em\ignorespaces}%
  \ifx\cyrdash\undefined
    \def\cyrdash{\hbox to.8em{\textendash\hss\textendash}}%
  \fi
  \declare@shorthand{ukrainian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

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

\def\captionsukrainian{%
   \def\refname{Література}%
   \def\abstractname{Анотація}%
   \def\bibname{Бібліоґрафія}%
   \def\prefacename{Вступ}%
   \def\chaptername{Розділ}%
   \def\appendixname{Додаток}%
   \def\contentsname{Зміст}%
   \def\listfigurename{Перелік ілюстрацій}%
   \def\listtablename{Перелік таблиць}%
   \def\indexname{Покажчик}%
   \def\authorname{Іменний покажчик}% babel has "Їменний покажчик"
   \def\figurename{Рис.}%
   \def\tablename{Табл.}%
   %\def\thepart{}%
   \def\partname{Частина}%
   \def\pagename{с.}%
   \def\seename{див.}%
   \def\alsoname{див.\ також}%
   \def\enclname{вкладка}%
   \def\ccname{копія}%
   \def\headtoname{До}%
   \def\proofname{Доведення}%
   \def\glossaryname{Словник термінів}%
}

\def\dateukrainian{%
   \def\today{\number\day~\ifcase\month\or
    січня\or
    лютого\or
    березня\or
    квітня\or
    травня\or
    червня\or
    липня\or
    серпня\or
    вересня\or
    жовтня\or
    листопада\or
    грудня\fi%
    \space\number\year~р.}%
}

% The following is based on some ideas from ruscor.sty
\def\ukrainian@capsformat{%
  \def\@seccntformat##1{\csname pre##1\endcsname%
  \csname the##1\endcsname%
  \csname post##1\endcsname}%
  \def\@aftersepkern{\hspace{0.5em}}%
  \def\postchapter{.\@aftersepkern}%
  \def\postsection{.\@aftersepkern}%
  \def\postsubsection{.\@aftersepkern}%
  \def\postsubsubsection{.\@aftersepkern}%
  \def\postparagraph{.\@aftersepkern}%
  \def\postsubparagraph{.\@aftersepkern}%
  \def\prechapter{}%
  \def\presection{}%
  \def\presubsection{}%
  \def\presubsubsection{}%
  \def\preparagraph{}%
  \def\presubparagraph{}%
}

\newcommand{\ukrainiannumerals}[2]{\ukrainiannumber{#2}}
\newcommand{\Ukrainiannumerals}[2]{\Ukrainiannumber{#2}}

\def\ukrainiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \ukrainian@asbuk@alph{#1}%
    \else
      \cyr@alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\def\Ukrainiannumber#1{%
  \ifcyrillic@numerals
    \ifcyrillic@asbuk@numerals
      \ukrainian@asbuk@Alph{#1}%
    \else
      \cyr@Alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

\let\ukrainiannumeral=\ukrainiannumber
\let\Ukrainiannumeral=\Ukrainiannumber

\def\Asbuk#1{\expandafter\ukrainian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\ukrainian@asbuk@alph\csname c@#1\endcsname}

\def\AsbukTrad#1{\expandafter\cyr@Alph\csname c@#1\endcsname}
\def\asbukTrad#1{\expandafter\cyr@alph\csname c@#1\endcsname}

% This is a poor man's cyrillic alphanumeric. It just uses the alphabet and
% thus ends at 30.
\def\ukrainian@asbuk@Alph#1{\ifcase#1\or
   А\or Б\or В\or Г\or Д\or Е\or Ж\or
   З\or И\or К\or Л\or М\or Н\or О\or
   П\or Р\or С\or Т\or У\or Ф\or Х\or
   Ц\or Ч\or Ш\or Щ\or Э\or Ю\or Я%
   \else\xpg@ill@value{#1}{ukrainian@asbuk@Alph}\fi%
}

\def\ukrainian@asbuk@alph#1{\ifcase#1\or
   а\or б\or в\or г\or д\or е\or ж\or
   з\or и\or к\or л\or м\or н\or о\or
   п\or р\or с\or т\or у\or ф\or х\or
   ц\or ч\or ш\or щ\or э\or ю\or я%
   \else\xpg@ill@value{#1}{ukrainian@asbuk@alph}\fi%
}

\def\ukrainian@numbers{%
  \ifcyrillic@numerals
     \def\ukrainian@alph##1{\expandafter\ukrainiannumeral\expandafter{\the##1}}%
     \def\ukrainian@Alph##1{\expandafter\Ukrainiannumeral\expandafter{\the##1}}%
     \let\@Alph\ukrainian@Alph%
     \let\@alph\ukrainian@alph%
  \fi
}

\def\noukrainian@numbers{%
   \let\@Alph\latin@Alph%
   \let\@alph\latin@alph%
}

\def\noextras@ukrainian{%
  \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
  \ifcyrillic@numerals\noukrainian@numbers\fi
  \ifukrainian@babelshorthands\noukrainian@shorthands\fi%
}

\def\blockextras@ukrainian{%
  \ukrainian@capsformat%
  \ifcyrillic@numerals\ukrainian@numbers\else\noukrainian@numbers\fi%
  \ifukrainian@babelshorthands\ukrainian@shorthands\else\noukrainian@shorthands\fi%
}

\def\inlineextras@ukrainian{%
  \ifukrainian@babelshorthands\ukrainian@shorthands\else\noukrainian@shorthands\fi%
}

%%% stuff from Babel
\AtBeginDocument{%
\ifukrainian@mathfunctions%
  \def\sh{\mathop{\operator@font sh}\nolimits}
  \def\ch{\mathop{\operator@font ch}\nolimits}
  \def\tg{\mathop{\operator@font tg}\nolimits}
  \def\arctg{\mathop{\operator@font arctg}\nolimits}
  \def\arcctg{\mathop{\operator@font arcctg}\nolimits}
  \def\ctg{\mathop{\operator@font ctg}\nolimits}
  \def\cth{\mathop{\operator@font cth}\nolimits}
  \def\cosec{\mathop{\operator@font cosec}\nolimits}
  \def\Prob{\mathop{\kern\z@\mathsf{P}}\nolimits}
  \def\Variance{\mathop{\kern\z@\mathsf{D}}\nolimits}
  \def\nsd{\mathop{\mathrm{н.с.д.}}\nolimits}
  \def\nsk{\mathop{\mathrm{н.с.к.}}\nolimits}
  \def\NSD{\mathop{\mathrm{НСД}}\nolimits}
  \def\NSK{\mathop{\mathrm{НСК}}\nolimits}
  \def\nod{\mathop{\mathrm{н.о.д.}}\nolimits}
  \def\nok{\mathop{\mathrm{н.о.к.}}\nolimits}
  \def\NOD{\mathop{\mathrm{НОД}}\nolimits}
  \def\NOK{\mathop{\mathrm{НОК}}\nolimits}
  \def\Proj{\mathop{\mathrm{пр}}\nolimits}
\fi
}

%    \end{macrocode}
% \iffalse
%</gloss-ukrainian.ldf>
%<*gloss-uppersorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-uppersorbian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-uppersorbian.ldf}[polyglossia: module for Upper Sorbian]

% We provide this as a babel alias

\xpg@load@master@language{sorbian}

%    \end{macrocode}
% \iffalse
%</gloss-uppersorbian.ldf>
%<*gloss-urdu.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-urdu.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
%%% Adapted from a file contributed by Kamal Abdali
\ProvidesFile{gloss-urdu.ldf}[polyglossia: module for Urdu]

\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{hijrical}

\PolyglossiaSetup{urdu}{
  bcp47=ur,
  bcp47-language=ur,
  bcp47-script=Arab,
  script=Arabic,
  direction=RL,
  scripttag=arab,
  langtag=URD,
  hyphennames={urdu,nohyphenation},
  fontsetup=true,
  localnumeral=urdunumerals
  %TODO localalph={abjad,abjad}
}

% BCP-47 compliant aliases
\setlanguagealias*{urdu}{ur}

\newif\if@western@numerals
\define@choicekey*+{urdu}{numerals}[\xpg@val\xpg@nr]{eastern,western}[eastern]{%
   \ifcase\xpg@nr\relax
      % eastern:
      \@western@numeralsfalse%
      \SetLanguageKeys{urdu}{bcp47-extension-u=nu-arab}%
   \or
      % western:
      \@western@numeralstrue%
      \SetLanguageKeys{urdu}{bcp47-extension-u=nu-latn}%
   \fi
   \xpg@info{Option: Urdu, numerals=\xpg@val}%
}{\xpg@warning{Unknown Urdu numerals option `#1'}}

\newif\ifurdu@customsep\urdu@customsepfalse
\def\xpg@sepmark{}
\define@key{urdu}{sectionsep}[.]{%
   \urdu@customseptrue%
   \gdef\xpg@sepmark{#1}%
}

%this is needed for \abjad in arabicnumbers.sty
\define@boolkey{urdu}[urdu@]{abjadjimnotail}[true]{%
  \ifurdu@abjadjimnotail
    \abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi%
}

\newif\if@hijrical
\define@choicekey*+{urdu}{calendar}[\xpg@val\xpg@nr]{gregorian,hijri}[gregorian]{%
   \ifcase\xpg@nr\relax
      % gregorian:
      \@hijricalfalse
   \or
      % hijri:
      \@hijricaltrue
   \fi
   \xpg@info{Option: Urdu, calendar=\xpg@val}%
}{\xpg@warning{Unknown Urdu calendar option `#1'}}

\define@key{urdu}{hijricorrection}[0]{%
  \gdef\urdu@hijri@correction{#1}}%

% This should set the defaults
\setkeys{urdu}{calendar,numerals,hijricorrection}

\def\urdugregmonth#1{\ifcase#1%
  \or جنوری\or فروری\or مارچ\or اپریل\or مئی\or جون\or جولائی\or اگست\or  ستمبر\or اکتوبر\or نومبر\or دسمبر\fi}

\def\urduhijrimonth#1{\ifcase#1%
 \or محرّم\or صفر\or ربیع الاوّل\or ربیع الثّانی\or جمادی الاوّل\or جمادی الثّانی\or رجب\or شعبان\or  رمضان\or شوّال\or ذیقعدہ\or ذی الحجّہ\fi}

%\Hijritoday is now locale-aware and will format the date with this macro:
\DefineFormatHijriDate{urdu}{\@ensure@RTL{%
  \urdunumber{\value{Hijriday}}؍\space\urduhijrimonth{\value{Hijrimonth}}\space\urdunumber{\value{Hijriyear}}}}

\def\captionsurdu{%
  \def\refname{\@ensure@RTL{حوالہ جات}}%
  \def\abstractname{\@ensure@RTL{ملخّص}}%
  \def\bibname{\@ensure@RTL{کتابیات}}%
  \def\prefacename{\@ensure@RTL{دیباچہ}}%
  \def\chaptername{\@ensure@RTL{باب}}%
  \def\appendixname{\@ensure@RTL{ضمیمہ}}%
  \def\contentsname{\@ensure@RTL{فہرست عنوانات}}%
  \def\listfigurename{\@ensure@RTL{فہرست اشکال}}%
  \def\listtablename{\@ensure@RTL{فہرست جداول}}%
  \def\indexname{\@ensure@RTL{اشاریہ}}%
  \def\figurename{\@ensure@RTL{شكل}}%
  \def\tablename{\@ensure@RTL{جدول}}%
  %\def\thepart{}%
  \def\partname{\@ensure@RTL{حصّہ}}%
  \def\pagename{\@ensure@RTL{صفحہ}}%
  \def\seename{\@ensure@RTL{ملاحظہ ہو}}%
  \def\alsoname{\@ensure@RTL{ایضاً}}%
  \def\enclname{\@ensure@RTL{منسلک}}%
  \def\ccname{\@ensure@RTL{نقل}}%
  \def\headtoname{\@ensure@RTL{بملاحظہ}}%
  \def\proofname{\@ensure@RTL{ثبوت}}%
  \def\glossaryname{\@ensure@RTL{لغت}}%
  \def\sectionname{\@ensure@RTL{فصل}}%
}

\def\dateurdu{%
  \def\today{%
    \if@hijrical
     \Hijritoday[\urdu@hijri@correction]%
    \else
      \@ensure@RTL{\urdunumber\day؍\space\urdugregmonth{\month}%
         \space\urdunumber\year}%
    \fi}%
}

\def\urdunumber#1{%
  \if@western@numerals
    \number#1%
  \else
    %%FIXME use farsidigits instead???
    \@ensure@LTR{\protect\arabicdigits{\number#1}}%
  \fi}

\def\urdu@numbers{%
  \let\@alph\abjad%
  \let\@Alph\abjad%
}

\def\nourdu@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

\newcommand{\urdunumerals}[2]{\urdunumber{#2}}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\urdu@globalnumbers{%
  \let\@arabic\urdunumber%
  % For some reason \thefootnote needs to be set separately:
  \renewcommand\thefootnote{\localnumeral*{footnote}}%
}

\def\nourdu@globalnumbers{
  \let\@arabic\xpg@save@arabic%
}

\def\urdu@xetex@capsformat{%
  \let\xpg@save@sepmark\@SepMark%
  \SepMark{\xpg@sepmark}
}

\def\nourdu@xetex@capsformat{%
   \ifcsdef{xpg@save@sepmark}{%
     \SepMark{\xpg@save@sepmark}
   }{}%
}

\def\urdu@luatex@capsformat{%
  %
  % change chapter and part headings
  \ifurdu@customsep
     \ifcsdef{chapter}{%
        \let\xpg@save@thesection\thesection%
        \renewcommand*\thesection{\thechapter\xpg@sepmark\@arabic\c@section}
        \let\xpg@save@theequation\theequation%
        \renewcommand*\theequation{%
	    \ifnum \c@chapter>\z@ \thechapter\xpg@sepmark\fi\@arabic\c@equation}
        \let\xpg@save@thefigure\thefigure%
	\renewcommand*\thefigure{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@figure}
        \let\xpg@save@thetable\thetable%
	\renewcommand*\thetable{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@table}
     }{}
     \let\xpg@save@thesubsection\thesubsection%
     \renewcommand\thesubsection
	{\thesection\xpg@sepmark\@arabic\c@subsection}
     \let\xpg@save@thesubsubsection\thesubsubsection%
     \renewcommand\thesubsubsection{\thesubsection\xpg@sepmark\@arabic\c@subsubsection}
     \let\xpg@save@theparagraph\theparagraph%
     \renewcommand\theparagraph
         {\thesubsubsection\xpg@sepmark\@arabic\c@paragraph}
     \let\xpg@save@thesubparagraph\thesubparagraph%
     \renewcommand\thesubparagraph{\theparagraph\xpg@sepmark\@arabic\c@subparagraph}
  \fi% (end \ifurdu@customsep)
}

\def\nourdu@luatex@capsformat{%
   \ifcsdef{xpg@save@thesection}{%
        \let\thesection\xpg@save@thesection%
   }{}%
   \ifcsdef{xpg@save@theequation}{%
        \let\theequation\xpg@save@theequation%
   }{}%
   \ifcsdef{xpg@save@thefigure}{%
        \let\thefigure\xpg@save@thefigure%
   }{}%
   \ifcsdef{xpg@save@thetable}{%
        \let\thetable\xpg@save@thetable%
   }{}%
   \ifcsdef{xpg@save@thesubsection}{%
        \let\thesubsection\xpg@save@thesubsection%
   \ifcsdef{xpg@save@thesubsubsection}{%
        \let\thesubsubsection\xpg@save@thesubsubsection%
   }{}%
   }{}%
   \ifcsdef{xpg@save@theparagraph}{%
        \let\theparagraph\xpg@save@theparagraph%
   }{}%
   \ifcsdef{xpg@save@thesubparagraph}{%
        \let\thesubparagraph\xpg@save@thesubparagraph%
   }{}%
}

\def\blockextras@urdu{%
   \ifurdu@customsep
      \ifxetex
        \urdu@xetex@capsformat
      \else
        \urdu@luatex@capsformat
      \fi   
   \fi
}
%
\def\noextras@urdu{%
    \ifurdu@customsep
      \ifxetex
        \nourdu@xetex@capsformat
      \else
        \nourdu@luatex@capsformat
      \fi   
   \fi
}

%    \end{macrocode}
% \iffalse
%</gloss-urdu.ldf>
%<*gloss-usorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-usorbian.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-usorbian.ldf}[polyglossia: module for Upper Sorbian]

% We only provide this gloss for babel compatibility. Since usorbian is 
% a sorbian variety, we use 'sorbian' with variant 'upper' now.

\xpg@load@master@language{sorbian}

%    \end{macrocode}
% \iffalse
%</gloss-usorbian.ldf>
%<*gloss-uyghur.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-uyghur.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-uyghur.ldf}[polyglossia: module for Uyghur]
%% Translations provided by Osman Tursun (Github Account: neouyghur)

\RequireBidi
\PolyglossiaSetup{uyghur}{
  bcp47=ug,
  bcp47-language=ug,
  bcp47-script=Arab,
  script=Arabic,
  direction=RL,
  scripttag=arab,
  langtag=UYG,
  hyphennames={nohyphenation},
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{uyghur}{ug}

\newif\if@uyghur@swapcaptions
\newif\if@uyghur@swapheadings
\newif\if@uyghur@swapheaders
\define@choicekey*+{uyghur}{swapstrings}[\xpg@val\xpg@nr]{all,captions,headings,headers,hheaders,none}[all]{%
   \ifcase\xpg@nr\relax
      % all:
      \@uyghur@swapcaptionstrue%
      \@uyghur@swapheadingstrue%
      \@uyghur@swapheaderstrue%
   \or
      % captions:
      \@uyghur@swapcaptionstrue%
      \@uyghur@swapheadingsfalse%
      \@uyghur@swapheadersfalse%
   \or
      % headings:
      \@uyghur@swapcaptionsfalse%
      \@uyghur@swapheadingstrue%
      \@uyghur@swapheadersfalse%
   \or
      % headers:
      \@uyghur@swapcaptionsfalse%
      \@uyghur@swapheadingsfalse%
      \@uyghur@swapheaderstrue%
   \or
      % hheaders:
      \@uyghur@swapcaptionsfalse%
      \@uyghur@swapheadingstrue%
      \@uyghur@swapheaderstrue%
   \or
      % none:
      \@uyghur@swapcaptionsfalse%
      \@uyghur@swapheadingsfalse%
      \@uyghur@swapheadersfalse%
   \fi
   \xpg@info{Option: Uyghur, swapstrings=\xpg@val}%
}{\xpg@warning{Unknown Uyghur swapstrings value `#1'}}

\newif\if@uyghur@ordchapter
\newif\if@uyghur@romchapter
\define@choicekey*+{uyghur}{chapterformat}[\xpg@val\xpg@nr]{ordinal,roman,arabic}[ordinal]{%
   \ifcase\xpg@nr\relax
      % ordinal:
      \@uyghur@ordchaptertrue%
      \@uyghur@romchapterfalse%
   \or
      % roman:
      \@uyghur@ordchapterfalse%
      \@uyghur@romchaptertrue%
   \or
      % arabic:
      \@uyghur@ordchapterfalse%
      \@uyghur@romchapterfalse%
   \fi
   \xpg@info{Option: Uyghur, chapterformat=\xpg@val}%
}{\xpg@warning{Unknown Uyghur chapterformat value `#1'}}

% Register default options
\xpg@initialize@gloss@options{uyghur}{swapstrings=all,chapterformat=ordinal}


\def\captionsuyghur{%
  \def\refname{\@ensure@RTL{پايدىلانمىلار}}%
  \def\abstractname{\@ensure@RTL{قىسقىچە مەزمۇنى}}%
  \def\bibname{\@ensure@RTL{پايدىلانمىلار}}%
  \def\prefacename{\@ensure@RTL{كىرىش سۆز}}%
  \def\chaptername{\@ensure@RTL{باب}}%
  \def\appendixname{\@ensure@RTL{قوشۇمچە}}%
  \def\contentsname{\@ensure@RTL{مۇندەرىجە}}%
  \def\listfigurename{\@ensure@RTL{رەسىملەر}}%
  \def\listtablename{\@ensure@RTL{جەدۋەللەر}}%
  \def\indexname{\@ensure@RTL{ئىندېكىس}}%
  \def\figurename{\@ensure@RTL{رەسىم}}%
  \def\tablename{\@ensure@RTL{جەدۋەل}}%
  %\def\thepart{}%
  \def\partname{\@ensure@RTL{قىسىم}}%
  \def\pagename{\@ensure@RTL{بەت}}%
  \def\seename{\@ensure@RTL{قاراڭ}}%
  \def\alsoname{\@ensure@RTL{ئايرىم قاراڭ}}%
  \def\enclname{\@ensure@RTL{قوشۇمچە ھۆججەت}}%
  \def\ccname{\@ensure@RTL{باشقا تاپشۇرۇۋالغۇچى}}%
  \def\headtoname{\@ensure@RTL{تاپشۇرۇۋالغۇچى}}%
  \def\proofname{\@ensure@RTL{ئىسپات}}%
  \def\glossaryname{\@ensure@RTL{لۇغەت}}%
  %\def\sectionname{\@ensure@RTL{}}%
  \def\subjectname{\@ensure@RTL{تېما}}%
}

% Save original capsformats
\let\xpg@save@fnum@table\fnum@table
\let\xpg@save@fnum@figure\fnum@figure

\def\uyghur@capsformat{%
  %
  % Change captions
  \if@uyghur@swapcaptions
     % change ‫‪'x.x‬‬ ‫ﺭﻩﺳﯩﻢ‬' to 'ﺭﻩﺳﯩﻢ-x.x‬‬'
     \def\fnum@figure{\thefigure-\figurename}
     %
     % same for table
     \def\fnum@table{\thetable-\tablename}
  \fi
  %
  % change chapter and part headings
  \if@uyghur@swapheadings
     % With titlesec
     \ifcsdef{titleformat}{%
       \ifcsdef{H@old@part}{% Hyperref
            \let\xpg@save@part@format\H@old@part%
            \patchcmd{\H@old@part}%
                      {\partname\nobreakspace\thepart}%
                      {\the@uyghur@part\nobreakspace\partname}%
                      {}%
                      {\xpg@warning{Failed to patch part for Uyghur}}%
       }{% not hyperref
         \ifcsdef{@part}{%
            \let\xpg@save@part@format\@part%
            \patchcmd{\@part}%
                      {\partname\nobreakspace\thepart}%
                      {\the@uyghur@part\nobreakspace\partname}%
                      {}%
                      {\xpg@warning{Failed to patch part for Uyghur}}%
         }{}%
       }
       \ifcsdef{chapter}{%
          \titleformat\chapter[display]%
             {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}
             {\the@uyghur@chapter\space\@chapapp}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}
       }{}%
     }{% (not \ifdefined\titleformat)
       % With KOMA
       \ifcsdef{sectionformat}{%
          \ifcsdef{partformat}{%
            \let\xpg@save@part@format\partformat%
            \renewcommand{\partformat}{\the@uyghur@part~\partname}%
          }{}%
          \ifcsdef{chapterformat}{%
            \let\xpg@save@chap@format\chapterformat%
            \renewcommand{\chapterformat}{\mbox{\the@uyghur@chapter%
                                          \IfUsePrefixLine{\nobreakspace\chapapp}{\enskip}}}%
          }{}%
       }{%  (not \ifdefined\sectionformat)
         % With memoir
         \ifcsdef{@memptsize}{%
           \ifcsdef{@makechapterhead}{%
              \let\xpg@save@chap@format\@makechapterhead%
              \patchcmd{\@makechapterhead}{\printchaptername \chapternamenum \printchapternum}%
                       {\chapnumfont\the@uyghur@chapter\chapternamenum\printchaptername}%
                       {}%
                       {\xpg@warning{Failed to patch chapter for Uyghur}}%
           }{}%
           \ifcsdef{H@old@part}{% Hyperref
                \let\xpg@save@part@format\H@old@part%
                \patchcmd{\H@old@part}{\printpartname \partnamenum \printpartnum}%
                                 {\chapnumfont\the@uyghur@part\partnamenum\printpartname}%
                                 {}%
                                 {\xpg@warning{Failed to patch part for Uyghur}}%
           }{% not hyperref
             \ifcsdef{@part}{%
                \let\xpg@save@part@format\@part%
                \patchcmd{\@part}{\printpartname \partnamenum \printpartnum}%
                                 {\chapnumfont\the@uyghur@part\partnamenum\printpartname}%
                                 {}%
                                 {\xpg@warning{Failed to patch part for Uyghur}}%
             }{}%
           }%
         }{%  (not \ifdefined\@memptsize)
           % With standard classes
            \ifcsdef{@makechapterhead}{%
              \let\xpg@save@chap@format\@makechapterhead%
              \patchcmd{\@makechapterhead}%
                       {\@chapapp\space \thechapter}%
                       {\the@uyghur@chapter\space \@chapapp}%
                       {}%
                       {\xpg@warning{Failed to patch chapter for Uyghur}}%
            }{}%
            \ifcsdef{H@old@part}{% Hyperref
              \let\xpg@save@part@format\H@old@part%
              \patchcmd{\H@old@part}%
                       {\partname\nobreakspace\thepart}%
                       {\the@uyghur@part\nobreakspace\partname}%
                       {}%
                       {\xpg@warning{Failed to patch part for Uyghur}}%            
            }{% not hyperref
              \ifcsdef{@part}{%
                \let\xpg@save@part@format\@part%
                \patchcmd{\@part}%
                         {\partname\nobreakspace\thepart}%
                         {\the@uyghur@part\nobreakspace\partname}%
                         {}%
                         {\ifcsdef{part}{\xpg@warning{Failed to patch part for Uyghur}}{}}%
              }{}%  (end \ifdefined\@part)
            }% (end not hyperref)
          }% (end \ifdefined\@memptsize)
        }% (end \ifdefined\sectionformat)
     }% (end \ifdefined\titleformat)
  \fi% (end \if@uyghur@swapheadings)
  %
  % Change running headers
  \if@uyghur@swapheaders
    \ifcsdef{chapterformat}{%
      % With KOMA
      \let\xpg@save@chaptermark@format\chaptermarkformat%
      \renewcommand*\chaptermarkformat{%
         \the@uyghur@chapter\ \IfChapterUsesPrefixLine{\chapapp\enskip}{}}
    }{% (not \ifdefined\chapterformat)
      \ifcsdef{@memptsize}{%
        % With memoir
        \let\xpg@save@chaptermark@format\chaptermark%
        \renewcommand*\chaptermark[1]{%
          \markboth{\memUChead{%
            \ifnum \c@secnumdepth >\m@ne
              \ifbool{@mainmatter}{%
                \the@uyghur@chapter\ \@chapapp\ %
              }{}%
            \fi
            ##1}}{}}%
      }{% (not \ifdefined\@memptsize)
        % With standard classes
        \ifcsdef{chaptermark}{%
          \ifpatchable{\chaptermark}%
               {\@chapapp\ \thechapter.}%
               {\let\xpg@save@chaptermark@format\chaptermark%
                \patchcmd{\chaptermark}%
                    {\@chapapp\ \thechapter.}%
                    {\the@uyghur@chapter\ \@chapapp}%
                    {}%
                    {\xpg@warning{Failed to patch chaptermark for Uyghur}}}%
               {}%
        }{}% (end \ifdefined\sectionmark)
                \ifcsdef{sectionmark}{%
          \ifpatchable{\sectionmark}%
               {\thesection.}%
               {\let\xpg@save@sectionmark@format\sectionmark%
                \patchcmd{\sectionmark}%
                    {\thesection.}%
                    {\thesection}%
                    {}%
                    {\xpg@warning{Failed to patch sectionmark for Uyghur}}}%
               {}%
        }{}% (end \ifdefined\chaptermark)
      }% (end \ifdefined\@memptsize)
    }% (end \ifdefined\chapterformat)
  \fi% (end \if@uyghur@swapheaders)
}

\def\nouyghur@capsformat{%
   %
   % Reset changes of \uyghur@capsformat
   \let\fnum@table\xpg@save@fnum@table%
   \let\fnum@figure\xpg@save@fnum@figure%
   %
   % Reset chapter and part heading
   \ifcsdef{titleformat}{%
      % With titlesec
     \ifcsdef{xpg@save@part@format}{%
        \ifcsdef{H@old@part}{%
            \let\H@old@part\xpg@save@part@format%
        }{%
            \let\@part\xpg@save@part@format%
        }%
     }{}%
     \ifcsdef{chapter}{%
        \titleformat\chapter[display]%
          {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}
          {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}
     }{}%
   }{% (not \ifdefined\titleformat)
     \ifcsdef{sectionformat}{%
        % With KOMA
        \ifcsdef{xpg@save@part@format}{%
           \let\partformat\xpg@save@part@format
        }{}%
        \ifcsdef{xpg@save@chap@format}{%
           \let\chapterformat\xpg@save@chap@format
        }{}%
     }{%
        % With memoir and standard classes
        \ifcsdef{xpg@save@part@format}{%
           \ifcsdef{H@old@part}{%
               \let\H@old@part\xpg@save@part@format%
           }{%
               \let\@part\xpg@save@part@format%
           }%
        }{}%
        \ifcsdef{xpg@save@chap@format}{%
          \let\@makechapterhead\xpg@save@chap@format
        }{}%
     }% (end \ifdefined\sectionformat)
   }% (end \ifdefined\titleformat)
  %
  % Reset headers
  \ifcsdef{chaptermarkformat}{%
     % With KOMA
     \ifcsdef{xpg@save@chaptermark@format}{%
       \let\chaptermarkformat\xpg@save@chaptermark@format%
     }{}%
  }{%
     \ifcsdef{chaptermark}{%
       % With memoir and standard classes
       \ifcsdef{xpg@save@chaptermark@format}{%
         \let\chaptermark\xpg@save@chaptermark@format%
       }{}%
     }{}% (end \ifdefined\chaptermark)
     \ifcsdef{sectionmark}{%
       \ifcsdef{xpg@save@sectionmark@format}{%
         \let\sectionmark\xpg@save@sectionmark@format%
       }{}%
     }{}% (end \ifdefined\sectionmark)
  }% (end \ifdefined\chapterformat)
}

\def\blockextras@uyghur{%
   \uyghur@capsformat%
}

\def\noextras@uyghur{%
   \nouyghur@capsformat%
}

\ifxetex
  \let\xpg@orig@DigitsDotDashInterCharToks\DigitsDotDashInterCharToks%
\fi

\def\uyghur@ltr@numbers{%
    \ifxetex
       % Bidi inserts an RTL mark (0x200f) between number and number separator (- .),
       % forcing numbers to RTL. This is wrong for Uyghur, where numbers are left to right.
       % So we defunc the respective command.
       \renewcommand*{\DigitsDotDashInterCharToks}{}%
    \fi%
}

\def\nouyghur@ltr@numbers{%
    \ifxetex
      % Restore bidi's \DigitsDotDashInterCharToks
      \let\DigitsDotDashInterCharToks\xpg@orig@DigitsDotDashInterCharToks%
    \fi%
}

\let\the@uyghur@part\thepart
\let\the@uyghur@chapter\thechapter

\def\uyghur@chapterformat{%
   \ifcsdef{part}{%
      \if@uyghur@ordchapter%
        \renewcommand{\the@uyghur@part}{\uyghurord{part}}%
      \fi%
      \if@uyghur@romchapter%
        \renewcommand{\the@uyghur@part}{\Roman{part}}%
      \fi%
   }{}%
   \ifcsdef{chapter}{%
      \if@uyghur@ordchapter%
        \renewcommand{\the@uyghur@chapter}{\uyghurord{chapter}}%
      \fi%
      \if@uyghur@romchapter%
        \renewcommand{\the@uyghur@chapter}{\Roman{chapter}}%
      \fi%
   }{}%
}

\def\uyghur@numbers{%
   % Prevent bidi from setting the numbers RTL
   \uyghur@ltr@numbers%
   % Format chapter and part
   \uyghur@chapterformat%
}

\def\nouyghur@numbers{%
  % Restore previous bidi numbers definition
  \nouyghur@ltr@numbers
}

\def\uyghur@globalnumbers{%
   % Prevent bidi from setting the numbers RTL
   \uyghur@ltr@numbers%
   % Format chapter and part
   \uyghur@chapterformat%
}

\def\uyghurmonth#1{\ifcase#1%
  \or يانۋار\or فېۋرال\or مارت\or ئاپرېل\or ماي\or ئىيۇن
  \or ئىيۇل\or ئاۋغۇست\or سېنتەبىر\or ئۆكتەبىر\or نويابىر\or دېكابىر\fi}

\def\dateuyghur{%
   \def\today{\number\year-يىلى\space\number\day-\uyghurmonth{\month}}%
}

\def\uyghurord#1{\expandafter\uyghurordinal\csname c@#1\endcsname}

% Ordinals 1--100
\def\uyghurordinal#1{\ifcase#1%
\or بىرىنچى\or ئىككىنچى\or ئۈچىنچى\or تۆتىنچى\or بەشىنچى\or ئالتىنچى\or يەتتىنچى\or سەككىزىنچى
\or توققۇزىنچى\or ئونىنچى\or ئون بىرىنچى\or ئون ئىككىنچى\or ئون ئۈچىنچى\or ئون تۆتىنچى\or ئون بەشىنچى
\or ئون ئالتىنچى\or ئون يەتتىنچى\or ئون سەككىزىنچى\or ئون توققۇزىنچى\or يىگىرمىنچى\or يىگىرمە بىرىنچى
\or يىگىرمە ئىككىنچى\or يىگىرمە ئۈچىنچى\or يىگىرمە تۆتىنچى\or يىگىرمە بەشىنچى\or يىگىرمە ئالتىنچى
\or يىگىرمە يەتتىنچى\or يىگىرمە سەككىزىنچى\or يىگىرمە توققۇزىنچى\or ئوتتۇزىنچى\or ئوتتۇز بىرىنچى
\or ئوتتۇز ئىككىنچى\or ئوتتۇز ئۈچىنچى\or ئوتتۇز تۆتىنچى\or ئوتتۇز بەشىنچى\or ئوتتۇز ئالتىنچى\or ئوتتۇز يەتتىنچى
\or ئوتتۇز سەككىزىنچى\or ئوتتۇز توققۇزىنچى\or قىرىقىنچى\or قىرىق بىرىنچى\or قىرىق ئىككىنچى\or قىرىق ئۈچىنچى
\or قىرىق تۆتىنچى\or قىرىق بەشىنچى\or قىرىق ئالتىنچى\or قىرىق يەتتىنچى\or قىرىق سەككىزىنچى\or قىرىق توققۇزىنچى
\or ئەللىكىنچى\or ئەللىك بىرىنچى\or ئەللىك ئىككىنچى\or ئەللىك ئۈچىنچى\or ئەللىك تۆتىنچى\or ئەللىك بەشىنچى
\or ئەللىك ئالتىنچى\or ئەللىك يەتتىنچى\or ئەللىك سەككىزىنچى\or ئەللىك توققۇزىنچى\or ئاتمىشىنچى\or ئاتمىش بىرىنچى
\or ئاتمىش ئىككىنچى\or ئاتمىش ئۈچىنچى\or ئاتمىش تۆتىنچى\or ئاتمىش بەشىنچى\or ئاتمىش ئالتىنچى\or ئاتمىش يەتتىنچى
\or ئاتمىش سەككىزىنچى\or ئاتمىش توققۇزىنچى\or يەتمىشىنچى\or يەتمىش بىرىنچى\or يەتمىش ئىككىنچى\or يەتمىش ئۈچىنچى
\or يەتمىش تۆتىنچى\or يەتمىش بەشىنچى\or يەتمىش ئالتىنچى\or يەتمىش يەتتىنچى\or يەتمىش سەككىزىنچى\or يەتمىش توققۇزىنچى
\or سەكسىنىنچى\or سەكسەن بىرىنچى\or سەكسەن ئىككىنچى\or سەكسەن ئۈچىنچى\or سەكسەن تۆتىنچى\or سەكسەن بەشىنچى
\or سەكسەن ئالتىنچى\or سەكسەن يەتتىنچى\or سەكسەن سەككىزىنچى\or سەكسەن توققۇزىنچى\or توقسىنىنچى\or توقسان بىرىنچى
\or توقسان ئىككىنچى\or توقسان ئۈچىنچى\or توقسان تۆتىنچى\or توقسان بەشىنچى\or توقسان ئالتىنچى\or توقسان يەتتىنچى
\or توقسان سەككىزىنچى\or توقسان توققۇزىنچى\or يۈزىنچى\fi}

%    \end{macrocode}
% \iffalse
%</gloss-uyghur.ldf>
%<*gloss-vietnamese.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-vietnamese.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-vietnamese.ldf}[polyglossia: module for Vietnamese]
%% Strings contributed by Daniel Owens < dhowens . pmbx . net >

\PolyglossiaSetup{vietnamese}{
  bcp47=vi,
  bcp47-language=vi,
  bcp47-script=Latn,
  hyphennames={nohyphenation},
  hyphenmins={2,2},
  langtag=VIT,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{vietnamese}{vi}

\def\captionsvietnamese{%
  \def\refname{Tài liệu}%
  \def\abstractname{Tóm tắt nội dung}%
  \def\bibname{Tài liệu tham khảo}%
  \def\prefacename{Lời nói đầu}%
  \def\chaptername{Chương}%
  \def\appendixname{Phụ lục}%
  \def\contentsname{Mục lục}%
  \def\listfigurename{Danh sách hình vẽ}%
  \def\listtablename{Danh sách bảng}%
  \def\indexname{Chỉ mục}%
  \def\figurename{Hình}%
  \def\tablename{Bảng}%
  \def\partname{Phần}%
  \def\pagename{Trang}%
  \def\seename{Xem}%
  \def\alsoname{Xem thêm}%
  \def\enclname{Kèm theo}%
  \def\ccname{Cùng gửi}%
  \def\headtoname{Gửi}%
  \def\proofname{Chứng minh}%
  \def\glossaryname{Từ điển chú giải}%
  }

\def\datevietnamese{%
  \def\today{%
    Ngày \number\day\space
    tháng \number\month\space
    năm \number\year}%
  }

%    \end{macrocode}
% \iffalse
%</gloss-vietnamese.ldf>
%<*gloss-welsh.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-welsh.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-welsh.ldf}[polyglossia: module for Welsh]

\PolyglossiaSetup{welsh}{
  bcp47=cy,
  bcp47-language=cy,
  bcp47-script=Latn,
  hyphennames={welsh},
  hyphenmins={2,3},
  langtag=WEL,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{welsh}{cy}

\providebool{welsh@formaldate}

\define@choicekey*+{welsh}{date}[\xpg@val\xpg@nr]{long,short}[short]{%
   \ifcase\xpg@nr\relax
      % long:
      \welsh@formaldatetrue
   \or
      % accented:
      \welsh@formaldatefalse
   \fi
   \xpg@info{Option: Welsh, date=\xpg@val}%
}{\xpg@warning{Unknown date value `#1'}}

% Register default options
\xpg@initialize@gloss@options{welsh}{date=short}

\def\captionswelsh{%
  \def\refname{Cyfeiriadau}%
  \def\abstractname{Crynodeb}%
  \def\bibname{Llyfryddiaeth}%
  \def\prefacename{Rhagair}%
  \def\chaptername{Pennod}%
  \def\appendixname{Atodiad}%
  \def\contentsname{Cynnwys}%
  \def\listfigurename{Rhestr Ddarluniau}%
  \def\listtablename{Rhestr Dablau}%
  \def\indexname{Mynegai}%
  \def\figurename{Darlun}%
  \def\tablename{Taflen}%
  %\def\thepart{}%
  \def\partname{Rhan}%
  \def\pagename{tudalen}%
  \def\seename{gweler}%
  \def\alsoname{gweler hefyd}%
  \def\enclname{amgaeëdig}%
  \def\ccname{copïau}%
  \def\headtoname{At}% ‘at’ on letters meaning ‘to (a person)’;
                     % ‘to (a place)’ is ‘i’ in Welsh
  \def\proofname{Prawf}%
  \def\glossaryname{Rhestr termau}%
  }

\newif\ifwelsh@first
\def\welsh@article#1{\welsh@firsttrue y\expandafter\welsh@article@do#1}
\def\welsh@article@do#1{\ifwelsh@first\welsh@isvowel#1\ifwelsh@vowel r\space\welsh@vowelfalse\else\space\fi#1\welsh@firstfalse\fi}
\newif\ifwelsh@vowel
\def\welsh@isvowel#1{\show#1\ifx#1a\welsh@voweltrue\else\ifx#1u\welsh@voweltrue\else\ifx#1w\welsh@voweltrue\fi\fi\fi}% FIXME Add the other vowels, just for good measure

\def\welsh@ordinal@long#1{%
  \ifcase#1\or cyntaf\or ail\or trydydd\or pedwerydd\or
  pumed\or chweched\or seithfed\or wythfed\or nawfed\or degfed\or unfed ar ddeg\or deuddegfed\or trydydd ar ddeg\or pedwerydd ar ddeg\or pymthegfed\or unfed ar bymtheg\or ail ar bymtheg\or deunawfed\or pedwerydd ar bymtheg\or ugeinfed\else\expandafter\welsh@ordinalplusxx@long#1\fi}

\def\welsh@ordinalplusxx@long#1{%
  \let\dday=#1\advance\dday by -20\relax\welsh@ordinal@long\dday\space ar hugain%
}

\def\datewelsh{%   
  \def\today{\ifwelsh@formaldate\formaltoday\else\standardtoday\fi}
  \def\standardtoday{%
    \ifcase\day\or 1af\or 2ail\or 3ydd\or 4ydd\or 5ed\or 6ed%
    \or 7fed\or 8fed\or 9fed\or 10fed\or 11eg\or 12fed\or 13eg\or
    14eg\or 15fed\or 16eg\or 17eg\or 18fed\or 19eg\or
    20fed\else\number\day ain\fi\space\ifcase\month\or
    Ionawr\or Chwefror\or Mawrth\or Ebrill\or
    Mai\or Mehefin\or Gorffennaf\or Awst\or
    Medi\or Hydref\or Tachwedd\or Rhagfyr\fi%
    \space\number\year}%
  \def\formaltoday{%
    \expandafter\welsh@article\welsh@ordinal@long\day\space o\space\ifcase\month\or
    Ionawr\or Chwefror\or Fawrth\or Ebrill\or Fai\or Fehefin\or Orffenaf\or Awst\or
    Fedi\or Hydref\or Dachwedd\or Ragfyr\fi%
    \space\number\year}%
}

%    \end{macrocode}
% \iffalse
%</gloss-welsh.ldf>
%<*gloss-zh-CN.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-zh-CN.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-zh-CN.ldf}[polyglossia: module for zh-CN (Chinese)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{chinese}

%    \end{macrocode}
% \iffalse
%</gloss-zh-CN.ldf>
%<*gloss-zh-TW.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-zh-TW.ldf}
%    \begin{macrocode}
% Language definition file (part of polyglossia v1.64 -- 2023/07/21)
%
\ProvidesFile{gloss-zh-TW.ldf}[polyglossia: module for zh-TW (Chinese)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{chinese}

%    \end{macrocode}
% \iffalse
%</gloss-zh-TW.ldf>
%<*arabicdigits.map>
% \fi
% \clearpage
% 
% \subsection{arabicdigits.map}
%    \begin{macrocode}
; FC ... 
LHSName	"Digits"
RHSName	"ArabicDigits"

pass(Unicode)
U+0030 <> U+0660 ;
U+0031 <> U+0661 ;
U+0032 <> U+0662 ;
U+0033 <> U+0663 ;
U+0034 <> U+0664 ;
U+0035 <> U+0665 ;
U+0036 <> U+0666 ;
U+0037 <> U+0667 ;
U+0038 <> U+0668 ;
U+0039 <> U+0669 ;

%    \end{macrocode}
% \iffalse
%</arabicdigits.map>
%<*bengalidigits.map>
% \fi
% \clearpage
% 
% \subsection{bengalidigits.map}
%    \begin{macrocode}
; FC ... 
LHSName	"Digits"
RHSName	"BengaliDigits"

pass(Unicode)
U+0030 <> U+09E6 ;
U+0031 <> U+09E7 ;
U+0032 <> U+09E8 ;
U+0033 <> U+09E9 ;
U+0034 <> U+09EA ;
U+0035 <> U+09EB ;
U+0036 <> U+09EC ;
U+0037 <> U+09ED ;
U+0038 <> U+09EE ;
U+0039 <> U+09EF ;

%    \end{macrocode}
% \iffalse
%</bengalidigits.map>
%<*devanagaridigits.map>
% \fi
% \clearpage
% 
% \subsection{devanagaridigits.map}
%    \begin{macrocode}
; FC ... 
LHSName	"Digits"
RHSName	"DevanagariDigits"

pass(Unicode)
U+0030 <> U+0966 ;
U+0031 <> U+0967 ;
U+0032 <> U+0968 ;
U+0033 <> U+0969 ;
U+0034 <> U+096A ;
U+0035 <> U+096B ;
U+0036 <> U+096C ;
U+0037 <> U+096D ;
U+0038 <> U+096E ;
U+0039 <> U+096F ;

%    \end{macrocode}
% \iffalse
%</devanagaridigits.map>
%<*farsidigits.map>
% \fi
% \clearpage
% 
% \subsection{farsidigits.map}
%    \begin{macrocode}
; FC ... 
LHSName	"Digits"
RHSName	"FarsiDigits"

pass(Unicode)
U+0030 <> U+06F0 ;
U+0031 <> U+06F1 ;
U+0032 <> U+06F2 ;
U+0033 <> U+06F3 ;
U+0034 <> U+06F4 ;
U+0035 <> U+06F5 ;
U+0036 <> U+06F6 ;
U+0037 <> U+06F7 ;
U+0038 <> U+06F8 ;
U+0039 <> U+06F9 ;

%    \end{macrocode}
% \iffalse
%</farsidigits.map>
%<*gurmukhidigits.map>
% \fi
% \clearpage
% 
% \subsection{gurmukhidigits.map}
%    \begin{macrocode}
; FC ... 
LHSName	"Digits"
RHSName	"GurmukhiDigits"

pass(Unicode)
U+0030 <> U+0A66 ;
U+0031 <> U+0A67 ;
U+0032 <> U+0A68 ;
U+0033 <> U+0A69 ;
U+0034 <> U+0A6A ;
U+0035 <> U+0A6B ;
U+0036 <> U+0A6C ;
U+0037 <> U+0A6D ;
U+0038 <> U+0A6E ;
U+0039 <> U+0A6F ;

%    \end{macrocode}
% \iffalse
%</gurmukhidigits.map>
%<*thaidigits.map>
% \fi
% \clearpage
% 
% \subsection{thaidigits.map}
%    \begin{macrocode}
; FC ... 
LHSName	"Digits"
RHSName	"ThaiDigits"

pass(Unicode)
U+0030 <> U+0E50 ;
U+0031 <> U+0E51 ;
U+0032 <> U+0E52 ;
U+0033 <> U+0E53 ;
U+0034 <> U+0E54 ;
U+0035 <> U+0E55 ;
U+0036 <> U+0E56 ;
U+0037 <> U+0E57 ;
U+0038 <> U+0E58 ;
U+0039 <> U+0E59 ;

%    \end{macrocode}
% \iffalse
%</thaidigits.map>
%<*polyglossia-french.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-french.lua}
%    \begin{macrocode}
--
-- polyglossia-punct.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia-punct')

local function set_left_space(lang, char, kern, rubber)
    polyglossia.add_left_spaced_character(lang, char, kern, "space", rubber)
end

local function set_right_space(lang, char, kern, rubber)
    polyglossia.add_right_spaced_character(lang, char, kern, "space", rubber)
end

local function activate_french_punct(thincolonspace, autospaceguillemets)
    -- We need different language tags here to make switching of options possible
    -- within a paragraph.
    local lang = "french"
    if thincolonspace then
        lang = lang.."-thincolon"
    end
    if autospaceguillemets then
        lang = lang.."-autospace"
    end

    polyglossia.activate_punct(lang)
    polyglossia.clear_spaced_characters(lang)

    if thincolonspace then
        set_left_space(lang, ':', 0.5)
    else
        set_left_space(lang, ':', 1, true) -- stretchable and shrinkable space
    end

    set_left_space(lang, '!', 0.5)
    set_left_space(lang, '?', 0.5)
    set_left_space(lang, ';', 0.5)
    set_left_space(lang, '‼', 0.5)
    set_left_space(lang, '⁇', 0.5)
    set_left_space(lang, '⁈', 0.5)
    set_left_space(lang, '⁉', 0.5)
    set_left_space(lang, '‽', 0.5) -- U+203D (interrobang)

    if autospaceguillemets then
        set_left_space(lang, '»', 0.5)
        set_left_space(lang, '›', 0.5)
        set_right_space(lang, '«', 0.5)
        set_right_space(lang, '‹', 0.5)
    end
end

local function deactivate_french_punct()
    polyglossia.deactivate_punct()
end

polyglossia.activate_french_punct   = activate_french_punct
polyglossia.deactivate_french_punct = deactivate_french_punct
%    \end{macrocode}
% \iffalse
%</polyglossia-french.lua>
%<*polyglossia-korean.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-korean.lua}
%    \begin{macrocode}
--
-- polyglossia-korean.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

local glyph_id = node.id"glyph"
local hbox_id  = node.id"hlist"
local vbox_id  = node.id"vlist"
local glue_id  = node.id"glue"
local penalty_id = node.id"penalty"
local disc_id  = node.id"disc"

--
-- attr_korean: variant = plain (0), classic (1), modern (2)
--
local attr_korean = luatexbase.attributes["xpg@attr@korean"]
local attr_josa   = luatexbase.attributes["xpg@attr@autojosa"]

--
-- characters after which linebreak is not allowed
--
local nobr_after = {
    [0x28] = 1, -- ( LEFT PARENTHESIS
    [0x3C] = 1, -- < LESS-THAN SIGN
    [0x5B] = 1, -- [ LEFT SQUARE BRACKET
    [0x60] = 1, -- ` GRAVE ACCENT
    [0x7B] = 1, -- { LEFT CURLY BRACKET
    [0xAB] = 1, -- « LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
    [0x2018] = 1, -- ‘ LEFT SINGLE QUOTATION MARK
    [0x201C] = 1, -- “ LEFT DOUBLE QUOTATION MARK
    [0x2329] = 1, -- 〈 LEFT-POINTING ANGLE BRACKET
    [0x3008] = 1, -- 〈 LEFT ANGLE BRACKET
    [0x300A] = 1, -- 《 LEFT DOUBLE ANGLE BRACKET
    [0x300C] = 1, -- 「 LEFT CORNER BRACKET
    [0x300E] = 1, -- 『 LEFT WHITE CORNER BRACKET
    [0x3010] = 1, -- 【 LEFT BLACK LENTICULAR BRACKET
    [0x3014] = 1, -- 〔 LEFT TORTOISE SHELL BRACKET
    [0x3016] = 1, -- 〖 LEFT WHITE LENTICULAR BRACKET
    [0x3018] = 1, -- 〘 LEFT WHITE TORTOISE SHELL BRACKET
    [0x301A] = 1, -- 〚 LEFT WHITE SQUARE BRACKET
    [0x301D] = 1, -- 〝 REVERSED DOUBLE PRIME QUOTATION MARK
    [0xFE17] = 1, -- ︗ PRESENTATION FORM FOR VERTICAL LEFT WHITE LENTICULAR BRACKET
    [0xFE35] = 1, -- ︵ PRESENTATION FORM FOR VERTICAL LEFT PARENTHESIS
    [0xFE37] = 1, -- ︷ PRESENTATION FORM FOR VERTICAL LEFT CURLY BRACKET
    [0xFE39] = 1, -- ︹ PRESENTATION FORM FOR VERTICAL LEFT TORTOISE SHELL BRACKET
    [0xFE3B] = 1, -- ︻ PRESENTATION FORM FOR VERTICAL LEFT BLACK LENTICULAR BRACKET
    [0xFE3D] = 1, -- ︽ PRESENTATION FORM FOR VERTICAL LEFT DOUBLE ANGLE BRACKET
    [0xFE3F] = 1, -- ︿ PRESENTATION FORM FOR VERTICAL LEFT ANGLE BRACKET
    [0xFE41] = 1, -- ﹁ PRESENTATION FORM FOR VERTICAL LEFT CORNER BRACKET
    [0xFE43] = 1, -- ﹃ PRESENTATION FORM FOR VERTICAL LEFT WHITE CORNER BRACKET
    [0xFE47] = 1, -- ﹇ PRESENTATION FORM FOR VERTICAL LEFT SQUARE BRACKET
    [0xFE59] = 1, -- ﹙ SMALL LEFT PARENTHESIS
    [0xFE5B] = 1, -- ﹛ SMALL LEFT CURLY BRACKET
    [0xFE5D] = 1, -- ﹝ SMALL LEFT TORTOISE SHELL BRACKET
    [0xFF08] = 1, -- （ FULLWIDTH LEFT PARENTHESIS
    [0xFF3B] = 1, -- ［ FULLWIDTH LEFT SQUARE BRACKET
    [0xFF5B] = 1, -- ｛ FULLWIDTH LEFT CURLY BRACKET
    [0xFF5F] = 1, -- ｟ FULLWIDTH LEFT WHITE PARENTHESIS
    [0xFF62] = 1, -- ｢ HALFWIDTH LEFT CORNER BRACKET
}

--
-- characters before which linebreak is not allowed
--   (currently, not much differences among the followings)
--   1: normal chars
--   2: hangul jamo vowels and trailing consonants
--   3: kana small letters
--   0: dashes (supress visible spacing)
--
local nobr_before = setmetatable({
    [0x21] = 1, -- ! EXCLAMATION MARK
    [0x22] = 1, -- " QUOTATION MARK
    [0x27] = 1, -- ' APOSTROPHE
    [0x29] = 1, -- ) RIGHT PARENTHESIS
    [0x2C] = 1, -- , COMMA
    [0x2D] = 0, -- - HYPHEN-MINUS
    [0x2E] = 1, -- . FULL STOP
    [0x2F] = 0, -- / SOLIDUS
    [0x3A] = 0, -- : COLON
    [0x3B] = 1, -- ; SEMICOLON
    [0x3E] = 1, -- > GREATER-THAN SIGN
    [0x3F] = 1, -- ? QUESTION MARK
    [0x5C] = 0, -- \ REVERSE SOLIDUS
    [0x5D] = 1, -- ] RIGHT SQUARE BRACKET
    [0x7D] = 1, -- } RIGHT CURLY BRACKET
    [0x7E] = 0, -- ~ TILDE
    [0xB7] = 1, -- · MIDDLE DOT
    [0xBB] = 1, -- » RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
    [0x2013] = 0, -- – EN DASH
    [0x2014] = 0, -- — EM DASH
    [0x2015] = 1, -- ― HORIZONTAL BAR
    [0x2019] = 1, -- ’ RIGHT SINGLE QUOTATION MARK
    [0x201D] = 1, -- ” RIGHT DOUBLE QUOTATION MARK
    [0x2025] = 1, -- ‥ TWO DOT LEADER
    [0x2026] = 1, -- … HORIZONTAL ELLIPSIS
    [0x232A] = 1, -- 〉 RIGHT-POINTING ANGLE BRACKET
    [0x3001] = 1, -- 、 IDEOGRAPHIC COMMA
    [0x3002] = 1, -- 。 IDEOGRAPHIC FULL STOP
    [0x3005] = 1, -- 々 IDEOGRAPHIC ITERATION MARK
    [0x3009] = 1, -- 〉 RIGHT ANGLE BRACKET
    [0x300B] = 1, -- 》 RIGHT DOUBLE ANGLE BRACKET
    [0x300D] = 1, -- 」 RIGHT CORNER BRACKET
    [0x300F] = 1, -- 』 RIGHT WHITE CORNER BRACKET
    [0x3011] = 1, -- 】 RIGHT BLACK LENTICULAR BRACKET
    [0x3015] = 1, -- 〕 RIGHT TORTOISE SHELL BRACKET
    [0x3017] = 1, -- 〗 RIGHT WHITE LENTICULAR BRACKET
    [0x3019] = 1, -- 〙 RIGHT WHITE TORTOISE SHELL BRACKET
    [0x301B] = 1, -- 〛 RIGHT WHITE SQUARE BRACKET
    [0x301C] = 1, -- 〜 WAVE DASH
    [0x301E] = 1, -- 〞 DOUBLE PRIME QUOTATION MARK
    [0x301F] = 1, -- 〟 LOW DOUBLE PRIME QUOTATION MARK
    [0x3035] = 1, -- 〵 VERTICAL KANA REPEAT MARK LOWER HALF
    [0x303B] = 1, -- 〻 VERTICAL IDEOGRAPHIC ITERATION MARK
    [0x303C] = 1, -- 〼 MASU MARK
    [0x3041] = 3, -- ぁ HIRAGANA LETTER SMALL A
    [0x3043] = 3, -- ぃ HIRAGANA LETTER SMALL I
    [0x3045] = 3, -- ぅ HIRAGANA LETTER SMALL U
    [0x3047] = 3, -- ぇ HIRAGANA LETTER SMALL E
    [0x3049] = 3, -- ぉ HIRAGANA LETTER SMALL O
    [0x3063] = 3, -- っ HIRAGANA LETTER SMALL TU
    [0x3083] = 3, -- ゃ HIRAGANA LETTER SMALL YA
    [0x3085] = 3, -- ゅ HIRAGANA LETTER SMALL YU
    [0x3087] = 3, -- ょ HIRAGANA LETTER SMALL YO
    [0x308E] = 3, -- ゎ HIRAGANA LETTER SMALL WA
    [0x3095] = 3, -- ゕ HIRAGANA LETTER SMALL KA
    [0x3096] = 3, -- ゖ HIRAGANA LETTER SMALL KE
    [0x3099] = 1, --  COMBINING KATAKANA-HIRAGANA VOICED SOUND MARK
    [0x309A] = 1, --  COMBINING KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
    [0x309B] = 1, -- ゛ KATAKANA-HIRAGANA VOICED SOUND MARK
    [0x309C] = 1, -- ゜ KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
    [0x309D] = 1, -- ゝ HIRAGANA ITERATION MARK
    [0x309E] = 1, -- ゞ HIRAGANA VOICED ITERATION MARK
    [0x30A0] = 1, -- ゠ KATAKANA-HIRAGANA DOUBLE HYPHEN
    [0x30A1] = 3, -- ァ KATAKANA LETTER SMALL A
    [0x30A3] = 3, -- ィ KATAKANA LETTER SMALL I
    [0x30A5] = 3, -- ゥ KATAKANA LETTER SMALL U
    [0x30A7] = 3, -- ェ KATAKANA LETTER SMALL E
    [0x30A9] = 3, -- ォ KATAKANA LETTER SMALL O
    [0x30C3] = 3, -- ッ KATAKANA LETTER SMALL TU
    [0x30E3] = 3, -- ャ KATAKANA LETTER SMALL YA
    [0x30E5] = 3, -- ュ KATAKANA LETTER SMALL YU
    [0x30E7] = 3, -- ョ KATAKANA LETTER SMALL YO
    [0x30EE] = 3, -- ヮ KATAKANA LETTER SMALL WA
    [0x30F5] = 3, -- ヵ KATAKANA LETTER SMALL KA
    [0x30F6] = 3, -- ヶ KATAKANA LETTER SMALL KE
    [0x30FB] = 1, -- ・ KATAKANA MIDDLE DOT
    [0x30FC] = 1, -- ー KATAKANA-HIRAGANA PROLONGED SOUND MARK
    [0x30FD] = 1, -- ヽ KATAKANA ITERATION MARK
    [0x30FE] = 1, -- ヾ KATAKANA VOICED ITERATION MARK
    [0xFE30] = 1, -- ︰ PRESENTATION FORM FOR VERTICAL TWO DOT LEADER
    [0xFE31] = 1, -- ︱ PRESENTATION FORM FOR VERTICAL EM DASH
    [0xFE32] = 1, -- ︲ PRESENTATION FORM FOR VERTICAL EN DASH
    [0xFE36] = 1, -- ︶ PRESENTATION FORM FOR VERTICAL RIGHT PARENTHESIS
    [0xFE38] = 1, -- ︸ PRESENTATION FORM FOR VERTICAL RIGHT CURLY BRACKET
    [0xFE3A] = 1, -- ︺ PRESENTATION FORM FOR VERTICAL RIGHT TORTOISE SHELL BRACKET
    [0xFE3C] = 1, -- ︼ PRESENTATION FORM FOR VERTICAL RIGHT BLACK LENTICULAR BRACKET
    [0xFE3E] = 1, -- ︾ PRESENTATION FORM FOR VERTICAL RIGHT DOUBLE ANGLE BRACKET
    [0xFE40] = 1, -- ﹀ PRESENTATION FORM FOR VERTICAL RIGHT ANGLE BRACKET
    [0xFE42] = 1, -- ﹂ PRESENTATION FORM FOR VERTICAL RIGHT CORNER BRACKET
    [0xFE44] = 1, -- ﹄ PRESENTATION FORM FOR VERTICAL RIGHT WHITE CORNER BRACKET
    [0xFE48] = 1, -- ﹈ PRESENTATION FORM FOR VERTICAL RIGHT SQUARE BRACKET
    [0xFE5A] = 1, -- ﹚ SMALL RIGHT PARENTHESIS
    [0xFE5C] = 1, -- ﹜ SMALL RIGHT CURLY BRACKET
    [0xFE5E] = 1, -- ﹞ SMALL RIGHT TORTOISE SHELL BRACKET
    [0xFF01] = 1, -- ！ FULLWIDTH EXCLAMATION MARK
    [0xFF09] = 1, -- ） FULLWIDTH RIGHT PARENTHESIS
    [0xFF0C] = 1, -- ， FULLWIDTH COMMA
    [0xFF0E] = 1, -- ． FULLWIDTH FULL STOP
    [0xFF1A] = 1, -- ： FULLWIDTH COLON
    [0xFF1B] = 1, -- ； FULLWIDTH SEMICOLON
    [0xFF1F] = 1, -- ？ FULLWIDTH QUESTION MARK
    [0xFF3D] = 1, -- ］ FULLWIDTH RIGHT SQUARE BRACKET
    [0xFF5D] = 1, -- ｝ FULLWIDTH RIGHT CURLY BRACKET
    [0xFF60] = 1, -- ｠ FULLWIDTH RIGHT WHITE PARENTHESIS
    [0xFF61] = 1, -- ｡ HALFWIDTH IDEOGRAPHIC FULL STOP
    [0xFF63] = 1, -- ｣ HALFWIDTH RIGHT CORNER BRACKET
    [0xFF64] = 1, -- ､ HALFWIDTH IDEOGRAPHIC COMMA
    [0xFF65] = 1, -- ･ HALFWIDTH KATAKANA MIDDLE DOT
    [0xFF9E] = 1, -- ﾞ HALFWIDTH KATAKANA VOICED SOUND MARK
    [0xFF9F] = 1, -- ﾟ HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK
}, { __index = function(_,c)
        if c >= 0x1160  and c <= 0x11FF  then return 2 end
        if c >= 0xD7B0  and c <= 0xD7FF  then return 2 end
        if c >= 0x302A  and c <= 0x302F  then return 1 end
        if c >= 0x31F0  and c <= 0x31FF  then return 3 end
        if c >= 0xFF67  and c <= 0xFF70  then return 3 end
        if c >= 0xFE00  and c <= 0xFE0F  then return 1 end
        if c >= 0xFE10  and c <= 0xFE19 and not (c == 0xFE17) then return 1 end
        if c >= 0xFE50  and c <= 0xFE58  then return 1 end
        if c >= 0xE0100 and c <= 0xE01EF then return 1 end
    end
})

--
-- whether 'c' is a cjk character
--
local function is_cjk (c)
    return c >= 0xAC00  and c <= 0xD7FF
    or     c >= 0x1100  and c <= 0x11FF
    or     c >= 0xA960  and c <= 0xA97F
    or     c >= 0x2E80  and c <= 0x9FFF
    or     c >= 0xF900  and c <= 0xFAFF
    or     c >= 0xFE10  and c <= 0xFE1F
    or     c >= 0xFE30  and c <= 0xFE6F
    or     c >= 0xFF00  and c <= 0xFFEF
    or     c >= 0x1F100 and c <= 0x1F2FF
    or     c >= 0x20000 and c <= 0x2FA1F
    or     nobr_after[c]  and c > 0x2014
    or     nobr_before[c] and c > 0x2014
end

--
-- classify cjk characters
--   1: openings
--   2: closings
--   3: centered chars
--   4: full stops
--   5: ellipses
--   6: exclamation and question marks
--   0: all others
--
local charclass = setmetatable({
    [0x2018] = 1, [0x201C] = 1, [0x2329] = 1, [0x3008] = 1,
    [0x300A] = 1, [0x300C] = 1, [0x300E] = 1, [0x3010] = 1,
    [0x3014] = 1, [0x3016] = 1, [0x3018] = 1, [0x301A] = 1,
    [0x301D] = 1, [0xFE17] = 1, [0xFE35] = 1, [0xFE37] = 1,
    [0xFE39] = 1, [0xFE3B] = 1, [0xFE3D] = 1, [0xFE3F] = 1,
    [0xFE41] = 1, [0xFE43] = 1, [0xFE47] = 1, [0xFF08] = 1,
    [0xFF3B] = 1, [0xFF5B] = 1, [0xFF5F] = 1, [0xFF62] = 1,
    [0x2019] = 2, [0x201D] = 2, [0x232A] = 2, [0x3001] = 2,
    [0x3009] = 2, [0x300B] = 2, [0x300D] = 2, [0x300F] = 2,
    [0x3011] = 2, [0x3015] = 2, [0x3017] = 2, [0x3019] = 2,
    [0x301B] = 2, [0x301E] = 2, [0x301F] = 2, [0xFE10] = 2,
    [0xFE11] = 2, [0xFE18] = 2, [0xFE36] = 2, [0xFE38] = 2,
    [0xFE3A] = 2, [0xFE3C] = 2, [0xFE3E] = 2, [0xFE40] = 2,
    [0xFE42] = 2, [0xFE44] = 2, [0xFE48] = 2, [0xFF09] = 2,
    [0xFF0C] = 2, [0xFF3D] = 2, [0xFF5D] = 2, [0xFF60] = 2,
    [0xFF63] = 2, [0xFF64] = 2, [0x00B7] = 3, [0x30FB] = 3,
    [0xFF1A] = 3, [0xFF1B] = 3, [0xFF65] = 3, [0x3002] = 4,
    [0xFE12] = 4, [0xFF0E] = 4, [0xFF61] = 4, [0x2015] = 5,
    [0x2025] = 5, [0x2026] = 5, [0xFE19] = 5, [0xFE30] = 5,
    [0xFE31] = 5, [0xFE15] = 6, [0xFE16] = 6, [0xFF01] = 6,
    [0xFF1F] = 6,
}, { __index = function() return 0 end })

--
-- table for spacing between char classes
--   1 stands for 0.5*fontsize when variant=classic
--
local intercharclass = { [0] =
    { [0] = nil,    {1,1},  nil,    {.5,.5} },
    { [0] = nil,    nil,    nil,    {.5,.5} },
    { [0] = {1,1},  {1,1},  nil,    {.5,.5}, nil,    {1,1},  {1,1} },
    { [0] = {.5,.5},{.5,.5},{.5,.5},{1,.5},  {.5,.5},{.5,.5},{.5,.5} },
    { [0] = {1,0},  {1,0},  nil,    {1.5,.5},nil,    {1,0},  {1,0} },
    { [0] = nil,    {1,1},  nil,    {.5,.5} },
    { [0] = {1,1},  {1,1},  nil,    {.5,.5} },
}

--
-- get a new penalty node
--
local function get_new_penalty (p)
    local penalty = node.new("penalty")
    penalty.penalty = p
    return penalty
end

--
-- get a new glue node
--
local function get_new_glue (...)
    local glue = node.new("glue")
    node.setglue(glue, ...)
    return glue
end

--
-- return 0.5*fontsize of given fontid
--   space: true if variant=modern; then 0.5*interword_space
--
local function get_font_size (fid, space)
    local size = font.getparameters(fid)
    if space then
        size = size and size.space or 196608
    else
        size = size and size.quad  or 655360
    end
    return size/2
end

--
-- charclass 1 thru 4 will be packed in \hbox to 0.5em{\hss? curr \hss?}
--   when variant=classic/modern
--
local function glyph_to_box (head, curr, class)
    local g, h = curr
    local size = get_font_size(g.font)
    head, curr = node.remove(head, curr)
    g.next, g.prev = nil, nil
    local hss = get_new_glue(0, 65536, 65536, 2, 2)
    if class == 1 then
        h, hss.next, g.prev = hss, g, hss
    elseif class == 2 or class == 4 then
        h, g.next, hss.prev = g, hss, g
    else
        local hss2 = node.copy(hss)
        h, hss.next, g.prev, g.next, hss2.prev = hss, g, hss, hss2, g
    end
    h = nodes.simple_font_handler(h)
    local box = node.hpack(h, size, "exactly")
    if curr then
        head, curr = node.insert_before(head, curr, box)
    else
        head, curr = node.insert_after(head, node.tail(head), box)
    end
    return head, curr
end

--
-- insert spacing defined as charclass[a][b] between a and b
--   f:    fontid
--   var:  variant = plain, classic, modern
--   cc:   charclass of current char
--   nc:   charclass of next char
--   nobr: linebreak is not allowed
--
local function insert_cjk_penalty_glue (head, curr, f, var, cc, nc, nobr)
    if nobr or cc == 1 or nc > 1 then
        local penalty = get_new_penalty(10000)
        head, curr = node.insert_after(head, curr, penalty)
    end
    local factor = get_font_size(f, var == 2)
    local t = intercharclass[cc][nc]
    local glue = get_new_glue(t[1]*factor, nil, t[2]*factor)
    head, curr = node.insert_after(head, curr, glue)
    return head, curr
end

--
-- insert inter-character spacing in other normal cases
--   f:   fontid
--   var: variant = plain, classic, modern
--   x:   true between cjk and non-cjk (a little more spacing)
--
local function insert_penalty_glue (head, curr, f, var, x)
    if var ~= 1 then
        local penalty = get_new_penalty(50)
        head, curr = node.insert_after(head, curr, penalty)
    end
    local size, glue = get_font_size(f, x and var == 2)
    if x then
        glue = get_new_glue(size/2, size/4, size/8)
    else
        glue = get_new_glue(0, size/10, size/50)
    end
    head, curr = node.insert_after(head, curr, glue)
    return head, curr
end

--
-- main process for linebreak and inter-character spacing
--   lb: true if pre_linebreak_filter
--
local function korean_break (head, lb)
    local curr = head
    while curr do
        if curr.id == glyph_id then
            local var = node.has_attribute(curr, attr_korean)
            if var then
                local c, f = curr.char or 0, curr.font or 0
                local cc, cjkc = charclass[c], is_cjk(c)

                -- compress cjk punctuations when charclass is 1 thru 4
                if var > 0 and cc > 0 and cc < 5 then
                    head, curr = glyph_to_box(head, curr, cc)
                end

                local next = curr.next
                if next and next.id == glyph_id then
                    local n = next.char or 0
                    local nc = charclass[n]
                    local nobr = nobr_before[n] or nobr_after[c]

                    -- insert spacing as of intercharclass
                    if var > 0 and intercharclass[cc][nc] then
                        head, curr = insert_cjk_penalty_glue(head, curr, f, var, cc, nc, nobr)

                    -- or insert spacing when linebreak is allowed
                    elseif not nobr then
                        local cjkn = is_cjk(n)

                        -- if curr or next is cjk char
                        if cjkc or cjkn then

                            -- if between cjk and non-cjk
                            if var > 0 and not (cjkc and cjkn) and nobr_before[c] ~= 0 then
                                head, curr = insert_penalty_glue(head, curr, f, var, true)

                            -- or under pre_linebreak_filter
                            elseif lb then
                                head, curr = insert_penalty_glue(head, curr, f, var)
                            end
                        end
                    end
                end
            end
        end
        curr = curr.next
    end
    return head
end

--
-- process for reordering hangul tone marks (U+302E, U+302F)
--   some hangul fonts (eg. Noto CJK) are so designed that hangul tone marks
--   should be moved to the first position of a syllable.
--   Currently, this functionality is not provided by luaotfload.
--
local function reorder_tm (head)
    local curr, tone = node.slide(head)
    while curr do
        if curr.id == glyph_id and node.has_attribute(curr, attr_korean) then
            local f = font.getfont(curr.font) or font.fonts[curr.font]
            if f and f.hb then -- harfbuzz do the right thing
                tone = nil
            else
                local c, wd = curr.char or 0, curr.width or 0
                if (c == 0x302E or c == 0x302F) and wd > 0 then
                    tone = curr
                elseif tone and not nobr_before[c] then
                    head = node.remove(head, tone)
                    tone.next, tone.prev = nil, nil
                    head, curr = node.insert_before(head, curr, tone)
                    tone = nil
                end
            end
        end
        curr = curr.prev
    end
    return head
end

--
-- automatic josa selection
--
local josa_table = {
    --          consonant ㄹ, vowel,  other consonants
    [0xAC00] = {0xC774,       0xAC00, 0xC774}, -- 가 => 이, 가, 이
    [0xC740] = {0xC740,       0xB294, 0xC740}, -- 은 => 은, 는, 은
    [0xC744] = {0xC744,       0xB97C, 0xC744}, -- 을 => 을, 를, 을
    [0xC640] = {0xACFC,       0xC640, 0xACFC}, -- 와 => 과, 와, 과
    [0xC73C] = {nil,          nil,    0xC73C}, -- 으(로) =>   ,  , 으
    [0xC774] = {0xC774,       nil,    0xC774}, -- 이(라) => 이,  , 이
}

--
-- helper function for number-like characters
--
local function josa_char_num (t, c)
    c = c % 10 + 0x30
    return t[c] or 2
end

--
-- decide josa selection
--
local josa_code = setmetatable({
    [0x30] = 3, [0x31] = 1, [0x33] = 3, [0x36] = 3, [0x37] = 1,
    [0x38] = 1, [0x4C] = 1, [0x4D] = 3, [0x4E] = 3, [0x6C] = 1,
    [0x6D] = 3, [0x6E] = 3, [0xFB02] = 1, [0xFB04] = 1,
},{ __index = function(t,c)
        if c >= 0xAC00 and c <= 0xD7A3 then
            c = (c - 0xAC00) % 28 + 0x11A7
        end
        if c >= 0x11A8 and c <= 0x11FF then
            if c == 0x11AF then return 1 end
            return 3
        end
        if c >= 0xD7CB and c <= 0xD7FB then return 3 end
        if c >= 0x2170 and c <= 0x217F then c = c - 0x10 end
        if c >= 0x2160 and c <= 0x216F then
            if c >= 0x216C then return 3 end
            return josa_char_num(t, c - 0x215F)
        end
        if c >= 0x2460 and c <= 0x2473 then return josa_char_num(t, c - 0x245F) end
        if c >= 0x2474 and c <= 0x2487 then return josa_char_num(t, c - 0x2473) end
        if c >= 0x2488 and c <= 0x249B then return josa_char_num(t, c - 0x2487) end
        if c >= 0x249C and c <= 0x24B5 then return t[c - 0x249C + 0x61] or 2 end
        if c >= 0x24B6 and c <= 0x24CF then return t[c - 0x24B6 + 0x61] or 2 end
        if c >= 0x24D0 and c <= 0x24E9 then return t[c - 0x24D0 + 0x61] or 2 end
        if c >= 0x3131 and c <= 0x318E then
            if c == 0x3139 then return 1 end
            if c >= 0x314F and c <= 0x3163 or c >= 0x3187 then return 2 end
            return 3
        end
        if c >= 0x3260 and c <= 0x327E then c = c - 0x60 end
        if c >= 0x3200 and c <= 0x321E then
            if c == 0x3203 then return 1 end
            if c >= 0x320E then return 2 end
            return 3
        end
        if c >= 0xFF10 and c <= 0xFF19 then return josa_char_num(t, c - 0xFF10) end
        if c >= 0xFF21 and c <= 0xFF3A then return t[c - 0xFF21 + 0x61] or 2 end
        if c >= 0xFF41 and c <= 0xFF5A then return t[c - 0xFF41 + 0x61] or 2 end
        return 2
    end
})

--
-- obtain char that comes just before the josa
--
local function get_prev_char (p)
    while p do
        if p.id == glyph_id then
            local pc = p.char or 0
            if not nobr_after[pc] then
                if not nobr_before[pc] or nobr_before[pc] >= 2 then
                    return pc
                end
            end
        elseif p.id == hbox_id or p.id == vbox_id then
            local pc = get_prev_char(node.slide(p.head))
            if pc then return pc end
        end
        p = p.prev
    end
end

--
-- main process of josa selection
--
local function auto_josa (head)
    local curr, tofree = head, {}
    while curr do
        if curr.id == glyph_id then
            local josa = node.has_attribute(curr, attr_josa)
            if josa then
                local cc = curr.char or 0
                if josa == 0 then
                    josa = josa_code[get_prev_char(curr.prev) or 0x30]
                end
                if cc == 0xC774 then
                    local n = curr.next
                    if n and n.char and n.char >= 0xAC00 and n.char <= 0xD7A3 then
                    else
                        cc = 0xAC00
                    end
                end
                local new = josa_table[cc]
                if new then
                    cc = new[josa]
                    if cc then
                        curr.char = cc
                    else
                        head = node.remove(head, curr)
                        table.insert(tofree, curr)
                    end
                end
                node.unset_attribute(curr, attr_josa)
            end
        end
        curr = curr.next
    end
    for _,v in ipairs(tofree) do node.free(v) end
    return head
end

--
-- now register to luatex callbacks
--   As char value of glyphs can be changed by opentype GSUB process,
--   we have to occupy the first position among callback functions.
--
local prepend_to_callback
if luatexbase.base_add_to_callback then
    prepend_to_callback = function(name, func, desc)
        luatexbase.add_to_callback(name, func, desc, 1)
    end
else
    prepend_to_callback = function(name, func, desc)
        local t = { {func, desc} }
        for _,v in ipairs(luatexbase.callback_descriptions(name)) do
            table.insert(t, {luatexbase.remove_from_callback(name, v)})
        end
        for _,v in ipairs(t) do
            luatexbase.add_to_callback(name, v[1], v[2])
        end
    end
end

prepend_to_callback ("pre_linebreak_filter",
    function(head)
        head = auto_josa(head)
        head = korean_break(head, true)
        head = reorder_tm(head)
        return head
    end,
    "polyglossia.lang_korean")

prepend_to_callback ("hpack_filter",
    function(head)
        head = auto_josa(head)
        head = korean_break(head)
        head = reorder_tm(head)
        return head
    end,
    "polyglossia.lang_korean")

-- vim:ft=lua:tw=0:sw=4:ts=4:expandtab
%    \end{macrocode}
% \iffalse
%</polyglossia-korean.lua>
%<*polyglossia-latin.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-latin.lua}
%    \begin{macrocode}
--
-- polyglossia-latin.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia-punct')

-- For ecclesiastic Latin (and sometimes for Italian) a very small space is
-- used for the punctuation. The ecclesiastic package uses a space of
-- 0.3\fontdimen2, where \fontdimen2 is a interword space, which is typically
-- between 1/4 and 1/3 of a quad. We choose a half of a \thinspace here.
local hairspace = 0.08333 -- 1/12

local function space_left(char)
    polyglossia.add_left_spaced_character('latin', char, hairspace, 'quad')
end

local function space_right(char)
    polyglossia.add_right_spaced_character('latin', char, hairspace, 'quad')
end

polyglossia.clear_spaced_characters('latin')
space_left('!')
space_left('?')
space_left('‼')
space_left('⁇')
space_left('⁈')
space_left('⁉')
space_left('‽') -- U+203D (interrobang)
space_left(':')
space_left(';')
space_left('»')
space_left('›')
space_right('«')
space_right('‹')

local function activate_latin_punct()
    polyglossia.activate_punct('latin')
end

local function deactivate_latin_punct()
    polyglossia.deactivate_punct()
end

polyglossia.activate_latin_punct   = activate_latin_punct
polyglossia.deactivate_latin_punct = deactivate_latin_punct
%    \end{macrocode}
% \iffalse
%</polyglossia-latin.lua>
%<*polyglossia-punct.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-punct.lua}
%    \begin{macrocode}
--
-- polyglossia-punct.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia') -- just in case...

local add_to_callback      = luatexbase.add_to_callback
local remove_from_callback = luatexbase.remove_from_callback
local priority_in_callback = luatexbase.priority_in_callback
local new_attribute        = luatexbase.new_attribute

local node = node

local insert_node_before = node.insert_before
local insert_node_after  = node.insert_after
local remove_node        = node.remove
local has_attribute      = node.has_attribute
local node_copy          = node.copy
local new_node           = node.new
local end_of_math        = node.end_of_math
local getnext            = node.getnext
local getprev            = node.getprev

-- node types according to node.types()
local glue_code    = node.id"glue"
local glyph_code   = node.id"glyph"
local penalty_code = node.id"penalty"
local kern_code    = node.id"kern"
local math_code    = node.id"math"

-- we need some node subtypes
local userkern = 1
local userskip = 0
local removable_skip = {
    [0]  = true, -- userskip
    [13] = true, -- spaceskip
    [14] = true, -- xspaceskip
}

-- we make a new node, so that we can copy it later on
local kern_node = new_node(kern_code)
kern_node.subtype = userkern -- this kern can be removed later on

local function get_kern_node(dim)
    local n = node_copy(kern_node)
    n.kern = dim
    return n
end

local glue_node = new_node(glue_code)
glue_node.subtype = userskip

local function get_glue_node(dim, stretch, shrink)
    local n   = node_copy(glue_node)
    n.width   = dim
    n.stretch = stretch
    n.shrink  = shrink
    return n
end

local penalty_node   = new_node(penalty_code)
penalty_node.penalty = 10000

local function get_penalty_node()
    return node_copy(penalty_node)
end

-- all possible space characters according to section 6.2 of the Unicode Standard
-- https://www.unicode.org/versions/Unicode12.0.0/ch06.pdf
local space_chars = {
    [0x20] = true, -- space
    [0xA0] = true, -- no-break space
    [0x1680] = true, -- ogham space mark
    [0x2000] = true, -- en quad
    [0x2001] = true, -- em quad
    [0x2002] = true, -- en space
    [0x2003] = true, -- em space
    [0x2004] = true, -- three-per-em-space
    [0x2005] = true, -- four-per-em space
    [0x2006] = true, -- six-per-em space
    [0x2007] = true, -- figure space
    [0x2008] = true, -- punctuation space
    [0x2009] = true, -- thin space
    [0x200A] = true, -- hair space
    [0x202F] = true, -- narrow no-break space
    [0x205F] = true, -- medium mathematical space
    [0x3000] = true -- ideographic space
}

-- all left bracket characters, referenced by their Unicode slot
local left_bracket_chars = {
    [0x28] = true, -- left parenthesis
    [0x5B] = true, -- left square bracket
    [0x7B] = true, -- left curly bracket
    [0x27E8] = true -- mathematical left angle bracket
}

-- all right bracket characters, referenced by their Unicode slot
local right_bracket_chars = {
    [0x29] = true,  -- right parenthesis
    [0x5D] = true,  -- right square bracket
    [0x7D] = true,  -- right curly bracket
    [0x27E9] = true -- mathematical right angle bracket
}

-- question and exclamation marks, referenced by their Unicode slot
local question_exclamation_chars = {
    [0x21] = true,   -- exclamation mark !
    [0x3F] = true,   -- question mark ?
    [0x203C] = true, -- double exclamation mark ‼
    [0x203D] = true, -- interrobang ‽
    [0x2047] = true, -- double question mark ⁇
    [0x2048] = true, -- question exclamation mark ⁈
    [0x2049] = true  -- exclamation question mark ⁉
}

-- from nodes-tst.lua, adapted
local function somespace(n)
    if n then
        local id, subtype = n.id, n.subtype
        if id == glue_code then
            -- it is dangerous to remove all the type of glue
            return removable_skip[subtype]
        elseif id == kern_code then
            -- remove only user's kern
            return subtype == userkern
        elseif id == glyph_code then
            return space_chars[n.char]
        end
    end
end

local function someleftbracket(n)
    if n then
        local id = n.id
        if id == glyph_code then
            return left_bracket_chars[n.char]
        end
    end
end

local function somerightbracket(n)
    if n then
        local id = n.id
        if id == glyph_code then
            return right_bracket_chars[n.char]
        end
    end
end

local function question_exclamation_sequence(n1, n2)
    if n1 and n2 then
        local id1 = n1.id
        local id2 = n2.id
        if id1 == glyph_code and id2 == glyph_code then
            return question_exclamation_chars[n1.char] and question_exclamation_chars[n2.char]
        end
    end
end

-- idem
local function somepenalty(n, value)
    if n then
        local id = n.id
        if id == penalty_code then
            if value then
                return n.penalty == value
            else
                return true
            end
        end
    end
end

local punct_attr = new_attribute("polyglossia_punct")

local lang_id      = {}
local lang_counter = 0
local left_space   = {}
local right_space  = {}

local function ensure_lang_id(lang)
    if not lang_id[lang] then
        lang_counter = lang_counter + 1
        lang_id[lang] = lang_counter
    end
    return lang_id[lang]
end

local function clear_spaced_characters(lang)
    local id = ensure_lang_id(lang)
    left_space[id]  = {}
    right_space[id] = {}
end

local function illegal_unit(unit)
    if unit then
        texio.write_nl('Illegal spacing unit "'..unit..'".')
    else
        texio.write_nl('Spacing unit is a nil value.')
    end
end

local function add_left_spaced_character(lang, char, kern, unit, rubber)
-- The parameter kern is a number meant as a fraction of the unit.
-- The unit can be "quad" (1em) or "space" (interword space).
-- The parameter rubber is a Boolean value indicating if the inserted space is
-- stretchable and shrinkable (only relevant if the unit is "space").
    local id = ensure_lang_id(lang)
    if unit == "quad" or unit == "space" then
        left_space[id][char] = {}
        left_space[id][char]["kern"] = kern
        left_space[id][char]["unit"] = unit
        left_space[id][char]["rubber"] = rubber
    else
        illegal_unit(unit)
    end
end

local function add_right_spaced_character(lang, char, kern, unit, rubber)
    local id = ensure_lang_id(lang)
    if unit == "quad" or unit == "space" then
        right_space[id][char] = {}
        right_space[id][char]["kern"] = kern
        right_space[id][char]["unit"] = unit
        right_space[id][char]["rubber"] = rubber
    else
        illegal_unit(unit)
    end
end

-- from typo-spa.lua, adapted
local function process(head)
    local current = head
    while current do
        local id = current.id
        if id == glyph_code then
            local attr = has_attribute(current, punct_attr)
            if attr then
                local char, leftspace, rightspace
                if current.char <= 0x10FFFF then -- greater values may cause problems with utf8.char
                    char = utf8.char(current.char)
                    leftspace  = left_space[attr][char]
                    rightspace = right_space[attr][char]
                end
                if leftspace or rightspace then
                    local fontparameters = fonts.hashes.parameters[current.font]
                    local unit, stretch, shrink, spacing_node
                    if leftspace and fontparameters then
                        local prev = getprev(current)
                        local space_exception = false
                        if prev then
                            -- do not add space after left (opening) bracket and between question/exclamation marks
                            space_exception = someleftbracket(prev) or question_exclamation_sequence(prev, current)
                            -- TODO: there is a question here: do we override a preceding space or not?...
                            while somespace(prev) do
                                head = remove_node(head, prev)
                                prev = getprev(current)
                            end
                            if somepenalty(prev, 10000) then
                                head = remove_node(head, prev)
                            end
                        end
                        if leftspace.unit == "quad" then
                            unit = fontparameters.quad
                            spacing_node = get_kern_node(leftspace.kern*unit)
                        elseif leftspace.unit == "space" then
                            unit = fontparameters.space
                            if leftspace.rubber then
                                stretch = leftspace.kern*fontparameters.space_stretch
                                shrink  = leftspace.kern*fontparameters.space_shrink
                                spacing_node = get_glue_node(leftspace.kern*unit, stretch, shrink)
                                head = insert_node_before(head, current, get_penalty_node())
                            else
                                spacing_node = get_kern_node(leftspace.kern*unit)
                            end
                        end
                        if not space_exception then
                            head = insert_node_before(head, current, spacing_node)
                        end
                    end
                    if rightspace and fontparameters then
                        local next = getnext(current)
                        local space_exception = false
                        if next then
                            -- do not add space before right (closing) bracket
                            space_exception = somerightbracket(next)
                            local nextnext = getnext(next)
                            if somepenalty(next, 10000) and somespace(nextnext) then
                                head, next = remove_node(head, next)
                            end
                            while somespace(next) do
                                head, next = remove_node(head, next)
                            end
                        end
                        if rightspace.unit == "quad" then
                            unit = fontparameters.quad
                            spacing_node = get_kern_node(rightspace.kern*unit)
                        elseif rightspace.unit == "space" then
                            unit = fontparameters.space
                            if rightspace.rubber then
                                stretch = rightspace.kern*fontparameters.space_stretch
                                shrink  = rightspace.kern*fontparameters.space_shrink
                                spacing_node = get_glue_node(rightspace.kern*unit, stretch, shrink)
                                if not space_exception then
                                    head, current = insert_node_after(head, current, get_penalty_node())
                                end
                            else
                                spacing_node = get_kern_node(rightspace.kern*unit)
                            end
                        end
                        if not space_exception then
                            head, current = insert_node_after(head, current, spacing_node)
                        end
                    end
                end
            end
        elseif id == math_code then
            -- warning: this is a feature of luatex > 0.76
            current = end_of_math(current) -- weird, can return nil .. no math end?
        end
        current = getnext(current) -- no error even if current is nil
    end
    return head
end

local function activate(lang)
    local id = ensure_lang_id(lang)
    -- We set the punctuation attribute to a language id here. This is
    -- important to be able to intermix languages with different spacings
    -- in one paragraph.
    tex.setattribute(punct_attr, id)
    for _, callback_name in ipairs{ "pre_linebreak_filter", "hpack_filter" } do
        if not priority_in_callback(callback_name, "polyglossia-punct.process") then
            add_to_callback(callback_name, process, "polyglossia-punct.process", 1)
        end
    end
end

local function deactivate()
    tex.setattribute(punct_attr, -0x7FFFFFFF) -- this value means "unset"
    -- Though it would make compilation slightly faster, it is not possible to
    -- safely uncomment the following lines. Imagine the following case: you
    -- start a paragraph by some spaced punctuation text, then, in the same
    -- paragraph, you change the language to something else, and thus call the
    -- following lines. This means that, at the end of the paragraph, the
    -- function won't be in the callback, so the beginning of the paragraph
    -- won't be processed by it.
    -- if priority_in_callback(callback_name, "polyglossia-punct.process") then
    --     remove_from_callback(callback_name, "polyglossia-punct.process")
    -- end
end

polyglossia.activate_punct             = activate
polyglossia.deactivate_punct           = deactivate
polyglossia.add_left_spaced_character  = add_left_spaced_character
polyglossia.add_right_spaced_character = add_right_spaced_character
polyglossia.clear_spaced_characters    = clear_spaced_characters
%    \end{macrocode}
% \iffalse
%</polyglossia-punct.lua>
%<*polyglossia-sanskrit.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-sanskrit.lua}
%    \begin{macrocode}
--
-- polyglossia-sanskrit.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia-punct')

-- How do we now, in Lua, what a \thinspace is? In the LaTeX source (latex.ltx)
-- it is defined as:
-- \def\thinspace{\leavevmode@ifvmode\kern .16667em }
-- I see no way of seeing if it has been overriden or not. So we stick to this
-- value.
local thinspace = 0.16667 -- 1/6

local function space_left(char)
    polyglossia.add_left_spaced_character('sanskrit', char, thinspace, 'quad')
end

polyglossia.clear_spaced_characters('sanskrit')
space_left('!')
space_left('?')
space_left('‼')
space_left('⁇')
space_left('⁈')
space_left('⁉')
space_left('‽') -- U+203D (interrobang)
space_left(':')
space_left(';')
space_left('।') -- danda, U+0964
space_left('॥') -- double danda, U+0965

local function activate_sanskrit_punct()
    polyglossia.activate_punct('sanskrit')
end

local function deactivate_sanskrit_punct()
    polyglossia.deactivate_punct()
end

polyglossia.activate_sanskrit_punct   = activate_sanskrit_punct
polyglossia.deactivate_sanskrit_punct = deactivate_sanskrit_punct
%    \end{macrocode}
% \iffalse
%</polyglossia-sanskrit.lua>
%<*polyglossia-tibt.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia-tibt.lua}
%    \begin{macrocode}
--
-- polyglossia-tibt.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

require('polyglossia') -- just in case...

local add_to_callback = luatexbase.add_to_callback
local remove_from_callback = luatexbase.remove_from_callback
local priority_in_callback = luatexbase.priority_in_callback

local next, type = next, type

local nodes, fonts, node = nodes, fonts, node

local nodecodes          = nodes.nodecodes --- <= preloaded node.types()

local insert_node_before = node.insert_before
local insert_node_after  = node.insert_after
local remove_node        = nodes.remove
local copy_node          = node.copy
local has_attribute      = node.has_attribute

local end_of_math        = node.end_of_math
if not end_of_math then -- luatex < .76
  local traverse_nodes = node.traverse_id
  local math_code      = nodecodes.math
  local end_of_math = function (n)
    for n in traverse_nodes(math_code, n.next) do
      return n
    end
  end
end

-- node types as of April 2013
local glyph_code         = nodecodes.glyph
local penalty_code       = nodecodes.penalty
local kern_code          = nodecodes.kern

-- we make a new node, so that we can copy it later on
local penalty_node  = node.new(penalty_code)
penalty_node.penalty = 50 -- corresponds to the penalty LaTeX sets at explicit hyphens

local function get_penalty_node()
  return copy_node(penalty_node)
end

local xpgtibtattr = luatexbase.attributes['xpg@tibteol']

local tsheg = unicode.utf8.byte('་')

-- from typo-spa.lua
local function process(head)
    local start = head
    -- head is always begin of par (whatsit), so we have at least two prev nodes
    -- penalty followed by glue
    while start do
        local id = start.id
        if id == glyph_code then 
            local attr = has_attribute(start, xpgtibtattr)
            if attr and attr > 0 then
                if start.char == tsheg then
                    if start.next then
                        insert_node_after(head,start,get_penalty_node())
                    end
                end
            end
        elseif id == math_code then
            -- warning: this is a feature of luatex > 0.76
            start = end_of_math(start) -- weird, can return nil .. no math end?
        end
        if start then
            start = start.next
        end
    end
    return head
end

local callback_name = "pre_linebreak_filter"

local function activate()
  if not priority_in_callback (callback_name, "polyglossia-tibt.process") then
    add_to_callback(callback_name, process, "polyglossia-tibt.process", 1)
  end
end

local function desactivate()
  if priority_in_callback (callback_name, "polyglossia-tibt.process") then
    remove_from_callback(callback_name, "polyglossia-tibt.process")
  end
end

polyglossia.activate_tibt_eol    = activate
polyglossia.desactivate_tibt_eol = desactivate
%    \end{macrocode}
% \iffalse
%</polyglossia-tibt.lua>
%<*polyglossia.lua>
% \fi
% \clearpage
% 
% \subsection{polyglossia.lua}
%    \begin{macrocode}
--
-- polyglossia.lua
-- part of polyglossia v1.64 -- 2023/07/21
--

local module_name = "polyglossia"
local polyglossia_module = {
    name          = module_name,
    version       = 1.3,
    date          = "2013/05/11",
    description   = "Polyglossia",
    author        = "Elie Roux",
    copyright     = "Elie Roux",
    license       = "CC0"
}

luatexbase.provides_module(polyglossia_module)

local log_info = function(message, ...)
    luatexbase.module_info(module_name, message:format(...))
end
local log_warn = function(message, ...)
    luatexbase.module_warning(module_name, message:format(...))
end

polyglossia = polyglossia or {}
local polyglossia = polyglossia

local function select_language(lang, id)
    polyglossia.current_language = lang
end

local function set_default_language(lang, id)
    polyglossia.default_language = lang
end

local byte = utf8.codepoint -- use standard module of lua 5.3

local check_char

if luaotfload and luaotfload.aux and luaotfload.aux.font_has_glyph then
    local font_has_glyph = luaotfload.aux.font_has_glyph
    function check_char(chr)
        local codepoint = tonumber(chr) or byte(chr)
        if font_has_glyph(font.current(), codepoint) then
            tex.sprint('1')
        else
            tex.sprint('0')
        end
    end
else
    function check_char(chr) -- always in current font
        local fontid    = font.current()
        local fontdata  = font.getfont(fontid) or font.fonts[fontid]
        local chardata  = fontdata.characters
        local codepoint = tonumber(chr) or byte(chr)
        if chardata and chardata[codepoint] then
            tex.sprint('1')
        else
            tex.sprint('0')
        end
    end
end

local function load_tibt_eol()
    require('polyglossia-tibt')
end

-- predefined l@nohyphenation or LuaTeX's maximum value for \language
local nohyphid = luatexbase.registernumber'l@nohyphenation' or 16383

-- key `nohyphenation` is for .sty file when possibly undefined l@nohyphenation
local newloader_loaded_languages = { nohyphenation = nohyphid }

local newloader_available_languages = require'language.dat.lua'
-- Suggestion by Dohyun Kim on #129
local t = { }
for k, v in pairs(newloader_available_languages) do
    t[k] = v
    for _, vv in pairs(v.synonyms) do
        t[vv] = v
    end
end
newloader_available_languages = t

-- LaTeX's language register is \count19
local lang_register = 19

-- New hyphenation pattern loader: use language.dat.lua directly and the language identifiers
local function newloader(langentry)
    local loaded_language = newloader_loaded_languages[langentry]
    if loaded_language then
        local langid = lang.id(loaded_language)
        log_info('Language %s already loaded; id is %i', langentry, langid)
        return langid
    else
        local langdata = newloader_available_languages[langentry]
        if langdata then

            local special = langdata.special
            if special then
                -- language0 (USenglish) is already included in the format
                if special == 'language0' then
                    return 0

                -- disabled language should not be used for utf-8 text
                elseif special:find'^disabled:' then
                    log_warn('Hyphenation of language %s %s', langentry, special)
                    return nohyphid
                end
            end

            -- language info will be written into the .log file
            local s = { "Language data for " .. langentry }
            for k, v in pairs(langdata) do
                if type(v) == 'table' then -- for 'synonyms'
                    s[#s+1] = k .. "\t" .. table.concat(v,',')
                else
                    s[#s+1] = k .. "\t" .. tostring(v)
                end
            end
            log_info(table.concat(s,"\n"))

            --
            -- LaTeX's \newlanguage increases language register (count19),
            -- whereas LuaTeX's lang.new() increases its own language id.
            -- So when a user has declared, say, \newlanguage\lang@xyz, then
            -- these two numbers do not match each other. If we do not consider
            -- this possible situation, our newloader() function will
            -- unfortunately overwrite the language \lang@xyz.
            --
            -- Threfore here we will compare LaTeX's \newlanguage number with
            -- LuaTeX's lang.new() id and select the bigger one for our new
            -- language object. Also we will update LaTeX's language register
            -- by this new id, so that another possible \newlanguage should not
            -- overwrite our language object.
            --
            -- get next \newlanguage allocation number
            local langcnt = tex.count[lang_register] + 1
            -- get new lang object
            local langobject = lang.new()
            local langid = lang.id(langobject)
            -- get bigger one between \newlanguage and new lang obj id
            local newlangid = math.max(langcnt, langid)
            -- set language register for possible \newlanguage
            tex.setcount('global', lang_register, newlangid)
            -- get new lang object if needeed
            if langid ~= newlangid then
                langobject = lang.new(newlangid)
            end

            -- load hyphenation patterns and exceptions
            for _,v in ipairs{ 'patterns', 'hyphenation' } do
                local data = langdata[v]
                if data and data ~= '' then
                    -- cope with comma separated list, such as serbian
                    for _,vv in ipairs(data:explode',+') do
                        local filepath = kpse.find_file(vv)
                        if filepath then
                            local fh = io.open(filepath)
                            lang[v](langobject, fh:read'a')
                            fh:close()
                        else
                            log_warn('Hyphenation file %s not found', vv)
                        end
                    end
                end
            end

            newloader_loaded_languages[langentry] = langobject

            log_info('Language %s was not yet loaded; created with id %i',
                     langentry, newlangid)
            return newlangid
        else
            log_warn('Language %s not found in language.dat.lua', langentry)
            return nohyphid
        end
    end
end

polyglossia.select_language = select_language
polyglossia.set_default_language = set_default_language
polyglossia.check_char = check_char
polyglossia.load_tibt_eol = load_tibt_eol
polyglossia.newloader = newloader
polyglossia.newloader_loaded_languages = newloader_loaded_languages
-- global variables:
-- polyglossia.default_language
-- polyglossia.current_language
%    \end{macrocode}
% \iffalse
%</polyglossia.lua>
% \fi
% \clearpage
% \PrintChanges
% \Finale
% 
% \iffalse
%<*examples.tex>
\documentclass[a4paper]{article}
\usepackage[no-math]{fontspec}
\usepackage{xltxtra,url}
\let\XeTeX\undefined
\let\XeLaTeX\undefined
\usepackage{polyglossia}
\usepackage{trace}
\setdefaultlanguage{french}
\setotherlanguage[variant=british,ordinalmonthday=false]{english}
\setotherlanguage[variant=poly]{greek}
\setotherlanguage[numerals=thai]{thai}
\setotherlanguage[locale=mashriq]{arabic}
\setotherlanguage[spelling=new,latesthyphen=true,babelshorthands=true]{german}
\setotherlanguages{latin,russian,turkish,polish,latvian,sanskrit,ukrainian,farsi,syriac,divehi,hebrew,amharic,nko}
\setotherlanguage[calendar=gregorian,numerals=western]{urdu}
\setmainfont{Linux Libertine O}
\defaultfontfeatures{Scale=MatchLowercase}
\setmonofont{Inconsolata}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}
\newfontfamily\syriacfont[Script=Syriac]{Serto Jerusalem}
\newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}
\newfontfamily\sanskritfont[Script=Devanagari]{Sanskrit 2003}
\newfontfamily\thaifont[Script=Thai]{Norasi}
\newfontfamily\thaanafont[Script=Thaana,WordSpace=2]{FreeSerif}
\newfontfamily\ethiopicfont[Script=Ethiopic]{Abyssinica SIL}
\newfontfamily\nkofont[Renderer=Graphite]{Conakry}
\parskip 1.33\baselineskip
%\newcommand\showhyphmin{\fbox{\the\lefthyphenmin\ \the\righthyphenmin}}
\begin{document}
\hyphenation{Bru-xel-les}
\noindent
\textbf{Le français}\footnote{ From \url{http://fr.wikipedia.org/wiki/Français}} est une langue romane parlée en France, dont elle est originaire (la «langue d'oïl»), ainsi qu'en Afrique francophone, au Canada (principalement au Québec, au Nouveau-Brunswick et en Ontario), en Belgique (en Région wallonne et à Bruxelles), en Suisse, au Liban, en Haïti et dans d'autres régions du monde, soit au total dans 51 pays du monde ayant pour la plupart fait partie des anciens empires coloniaux français et belge. \\
(\today)

\begin{english}
\textbf{English}\footnote{From \url{http://en.wikipedia.org/wiki/English_language}} is a West Germanic language originating in England, and the first language for most people in Australia, Canada, the Commonwealth Caribbean, Ireland, New Zealand, the United Kingdom and the United States of America (also commonly known as the Anglosphere). It is used extensively as a second language and as an official language throughout the world, especially in Commonwealth countries and in many international organisations. \\
(\today)
\end{english}

\begin{german}
\textbf{Die deutsche Sprache}\footnote{ From \url{http://de.wikipedia.org/wiki/Deutsche_Sprache}} (auch das Deutsche) gehört zum westlichen Zweig der germanischen Sprachen und ist eine der meistgesprochenen europäischen Sprachen weltweit, und gilt so als Weltsprache.\\
(\today)
\end{german}

\begin{russian}
\textbf{Русский язык} — один из восточнославянских языков, один из крупнейших языков мира, в том числе самый распространённый из славянских языков и самый распространённый язык Европы, как географически, так и по числу носителей языка как родного (хотя значительная, и географически бо́льшая, часть русского языкового ареала находится в Азии).	\\
(\today)
\end{russian}

\begin{latin}
\textbf{Lingua Latina} est lingua Indoeuropaea. Nomen ductum est de terra in paeninsula Italica quam Latine loquentes incolebant, Vetus Latium appellata sitaque inter flumen Tiberis, Volscam terram, mare Tyrrhenicum, montes Apenninos. 
Quamquam sermone nativo fungi desinit, cumque nostris diebus perpauci Latine loqui possint, lingua mortua appellari solet, multas tamen peperit linguas quae linguae romanicae vocantur, sicut Hispanicam, Francogallicam, Italicam, Lusitanam, Dacoromanicam, Gallaicam, ne omnes afferam. \\
(\today) 
\end{latin}

\begin{greek}
\textbf{Η ελληνική γλώσσα} είναι μία από τις ινδοευρωπαϊκές γλώσσες, για την
οποία έχουμε γραπτά κείμενα από τον 15ο αιώνα π.Χ. μέχρι σήμερα. Αποτελεί το
μοναδικό μέλος ενός κλάδου της ινδοευρωπαϊκής οικογένειας γλωσσών. Ανήκει
επίσης στον βαλκανικό γλωσσικό δεσμό.\\	
(\today) 
\end{greek}


\begin{hebrew}[numerals=hebrew]
\textbf{עברית} היא שפה ממשפחת השפות השמיות, הידועה כשפתו של העם היהודי, ואשר ניב מודרני שלה משמש כשפה הרשמית והעיקרית של מדינת ישראל. \\
(\today\ = \hebrewtoday)
\end{hebrew}

\begin{syriac}[numerals=abjad]
ܠܫܢܐ ܐܪܡܝܐ ܐܘ ܐܪܡܝܬ ܗܘ ܠܫܢ̈ܐ ܥܡ ܬܫܥܝܬܐ ܕ\textrm{3000} ܫܢ̈ܝܐ܂ ܗܘܐ ܠܫܢܐ ܕܡܠܟܘ̈ܬܐ ܘܬܘܕ̈ܝܬܐ܂ ܥܡ ܠܫܢܐ ܥܒܪܝܐ܄ ܗܘܐ ܠܫܢܐ ܕܣܦܪ̈ܐ ܕܕܢܝܐܝܠ ܘܥܙܪܐ ܘܗܘ ܠܫܢܐ ܚܕܢܝܐ ܕܬܠܡܘܕ܂ ܐܪܡܝܐ ܗܘܐ ܠܫܢܐ ܕܝܫܘܥ܂ ܐܕܝܘܡ܄ ܐܪܡܝܐ ܗܘ ܠܫܢܐ ܕܟܠܕ̈ܝܐ܄ ܐܬܘܪ̈ܝܐ܄ ܡܪ̈ܘܢܝܐ܄ ܘܣܘܪ̈ܝܝܐ܀ \\
(\today)
\end{syriac}

\begin{turkish}
\textbf{Türkiye Türkçesi}, Ural-Altay Dilleri içerisinde Türk dil ailesinin Oğuz Grubu'na mensup lehçedir. Anadolu, Kıbrıs, Balkanlar ve Orta Avrupa'da geniş yayılım alanı bulmuş olup, Türkiye Cumhuriyeti, Kuzey Kıbrıs Türk Cumhuriyeti, Güney Kıbrıs Rum Kesimi, Makedonya ve Kosova'nın resmî dilidir. \\
(\today = \Hijritoday)
\end{turkish}

\begin{polish}
\textbf{Język polski (polszczyzna)} należy wraz z językiem czeskim, słowackim, pomorskim (kaszubskim), dolnołużyckim, górnołużyckim oraz wymarłym połabskim do grupy języków zachodniosłowiańskich, stanowiących część rodziny języków indoeuropejskich. Ocenia się, że język polski jest językiem ojczystym około 44 milionów ludzi na świecie (w literaturze naukowej można spotkać szacunki od 40 do 48 milionów), mieszkańców Polski oraz Polaków zamieszkałych za granicą (Polonia).\\
(\today)
\end{polish}

\begin{latvian} 
\textbf{Latviešu valoda} ir dzimtā valoda apmēram 1,5 miljoniem cilvēku, galvenokārt Latvijā, kurā tā ir vienīgā valsts valoda. Lielākās latviešu valodas pratēju kopienas ārzemēs ir Austrālijā, ASV, Zviedrijā, Lielbritānijā, Vācijā, Brazīlijā, Krievijā. Latviešu valoda pieder indoeiropiešu valodu saimes baltu valodu grupai.\\
(\today)
\end{latvian}

\begin{ukrainian}
\textbf{Українська мова} — східнослов'янська мова, входить до однієї підгрупи з білоруською та російською. Подібно до цих мов українську записують кирилицею. Історично білоруська та українська мови походять з давньоруської (давньоукраїнської) — розмовної мови Київської Русі.\\
(\today)
\end{ukrainian}

\begin{sanskrit}
{\Large ससकत} पृथिव्यां प्राचीना समृद्घा वैज्ञानिकी च भाषा मन्यते । विश्ववाङ्‌मयेषु संस्कृतं श्रेष्ठरत्नम् इति न केवलं भारते अपि तु समग्रविश्वे एतद्विषये निर्णयाधिकारिभि: जनै: स्वीकृतम् । महर्षि पाणिनिना विरचिता अष्टाध्यायी इति संस्कृतव्याकरणम्‌ अधुनापि भारते विदेशेषु च भाषाविज्ञानिनां प्रेरणास्‍थानं वर्तते . संस्कृतशब्दा: एव उत्तरं दक्षिणं च भारतं संयोजयन्ति ।
\end{sanskrit}

\begin{Arabic}[]
«اعلم أنّ فنّ التاريخ فنّ عزيز المذهب، جمّ الفوائد، شريف الغاية؛ إذ هو يوقفنا على أحوال الماضين من الأمم في أخلاقهم، و الأنبياء في سيرهم، و الملوك في دولهم و سياستهم؛ حتّى تتمّ فائدة الإقتداء في ذلك لمن يرومه في أحوال الدين و الدنيا.» (ابن خلدون، المقدّمة)\\
(\today\ = \Hijritoday[0])
\end{Arabic}

\begin{farsi}
فارسی یا پارسی، (که دری، فارسی دری، و پارسی دری نیز نامیده می‌شود) زبانی است که
در کشورهای ایران، افغانستان، تاجیکستان و ازبکستان به آن سخن می‌رانند. \\
(\Jalalitoday = \Hijritoday)
\end{farsi}

\pagebreak
\begin{urdu}
اُردو ایک ہندآریائی زبان ہے جس کا تعلّق ہند یوروپی لسانی خاندان کی ہندایرانی شاخ سے ہے۔ بارہویں صدی میں ہندوستان کی مقامی زبانوں اور فارسی، عربی، اور تُرکی زبانوں کے اختلاط سے اردو وجود میں آئی۔ اردو پاکستان کی قومی زبان ہے، اور ہندوستان کی 23 سرکاری زبانوں میں سے ایک ہے۔ جنوبی ایشیا کے باہر خلیجِ فارس کے ممالک، سعودی عرب، برطانیہ، امریکہ، کنیڈا، جرمنی، ناروے، اور آسٹریلیا میں بھی جنوبی ایشیائی مہاجرین کی بڑی تعداد اردو بولتی ہے۔ \\

(\today\ مطابق \Hijritoday[0])
\end{urdu}

\begin{thai}
เป็น\wbr แผนงานเพื่อ\wbr สนับสนุน\wbr การ\wbr ร่วมกัน\wbr สร้าง, การ\wbr ร่วมกันใช้, และ\wbr การ%
ร่วมกัน\wbr พัฒนา\wbr ทรัพยากร\wbr ทาง\wbr ภาษา\wbr ของ\wbr ภาษา\wbr ไทย, บน\wbr เครือข่าย World Wide Web. แผนงานนี้\wbr มี%
จุด\wbr ประสงค์หลั\wbr กอยู่\wbr สอง\wbr ประการคือ เพื่อแก้ปัญหา\wbr กำ\wbr แพง\wbr ทาง\wbr ภาษา, และรักษา%
ไว้เพื่อ\wbr ความค\wbr งอยู่\wbr ของ\wbr ภาษา\wbr และ\wbr วัฒนธรรม\wbr ไทย. \\
(\today)
\end{thai}

\begin{divehi}\small\sloppy
ދިވެހިބަހަކީ ދިވެހިރާއްޖޭގެ ރަސްމީ ބަހެވެ. މި ބަހުން ވާހަކަ ދައްކައި އުޅެނީ ދިވެހިރާއްޖޭގެ އަހުލުވެރިންގެ އިތުރުން ހިންދުސްތާނުގެ މަލިކު ގެ
އަހުލުވެރިންނެވެ. އެބައިމީހުން މި ބަހަށް ކިޔަނީ މަހަލް ބަހެވެ. ބަހާބެހޭ މާހިރުން ދިވެހިބަސް ހިމަނުއްވައިފައިވަނީ އިންޑޯ އާރިޔަން ބަސްތަކުގެ
ތެރޭގަ އެވެ. 
\end{divehi}

%\fontspec[Script=Georgian]{DejaVu Serif}
%ქართული ენა არის საქართველოს სახელმწიფო ენა (აფხაზეთის ავტონომიურ რესპ\-უბლიკაში მის პარალელურად სახელმწიფო ენად აღიარებულია აგრეთვე აფხაზური ენა). ქართულ ენაზე 7 მილიონზე მეტი ადამიანი ლაპარაკობს.
%

\begin{amharic}
\textbf{አማርኛ} የኢትዮጵያ መደበኛ ቋንቋ ነው። ከሴማዊ ቋንቋዎች እንደ ዕብራይስጥ ወይም ዓረብኛ አንዱ ነው። እንዲያውም 27 ሚሊዮን ያህል ተናጋሪዎች እያሉት፣ አማርኛ ከአረብኛ ቀጥሎ ትልቁ ሴማዊ ቋንቋ ነው። የሚጻፈውም በግዕዝ ፊደል ነው። አማርኛ ክዓረብኛና ከዕብራይስጥ ያለው መሰረታዊ ልዩነት አንደላቲን ከግራ ወደ ቀኝ መጻፉ ነው። \\
(\today)
\end{amharic}

\begin{nko}
ߒߞߏ ߦߋ߫ ߛߓߍߟߌߞߊ߲ߞߋ ߟߋ߬ ߘߌ߫ ߝߘߊ߬ߝߌ߲߬ߠߊ߫ ߕߟߋ߬ߓߋ ߘߐ߫ ߡߊ߲߬ߘߋ߲߬ ߡߌߙߌ߲ߘߌ ߞߊ߲ ߞߊߡߊ߬߸ ߊ߬ ߣߴߊ߬ ߡߟߋߞߎߦߊߞߊ߲ ߕߐ߮ ߟߋ߬. ߞߊ߬ߕߎ߲߯ ߸ ߊ߬ ߞߘߐ ߟߋ߬ ߡߊ߲߬ߘߋ߲߫ ߝߘߏ߬ߓߊ߬ߞߊ߲ ߓߏߟߏ߲ ߓߍ߯ ߘߐ߫ ߞߏ߫: ߒ ߞߊ߲߫ ߠߋ߬ ߞߏ߫. ߝߣߊ߫߸ ߊ߬ ߦߋ߫ ߟߊߓߊ߯ߙߟߊ߫ ߟߊ߫ ߖߡߊ߬ߣߊ ߢߌ߲߬ ߠߎ߫ ߟߋ߬ ߘߐ߫ ߓߊߞߍ߭: ߖߌ߬ߣߍ߫، ߜߋ߲ߞߐ߰ߖߌ߬ߘߊ، ߊ߬ ߣߌ߫ ߡߊߟߌ߫.
\\
(\today)
\end{nko}

\end{document}
%</examples.tex>
%<*example-arabic.tex>
% !TeX TS-program = xelatex
\documentclass[a4paper]{book}%
\usepackage[no-math]{fontspec}
\usepackage{xltxtra,url,amsmath}
\setmainfont{Linux Libertine O}
\defaultfontfeatures{Scale=MatchLowercase}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}
\newfontfamily\arabicfonttt[Script=Arabic,Scale=.75]{DejaVu Sans Mono}
\newfontfamily\farsifont[Script=Arabic,Scale=1.1,WordSpace=2]{IranNastaliq}
\let\XeTeX\undefined
\let\XeLaTeX\undefined
\usepackage[quiet,nolocalmarks]{polyglossia}
\setdefaultlanguage[calendar=gregorian,hijricorrection=1,locale=mashriq]{arabic}
\setotherlanguage[variant=british]{english}
\setotherlanguage{farsi}
\parindent 0pt
\title{اختبار دعم اللغة العربية}
\author{فرانسوا شاريت}
\begin{document}
\pagenumbering{alph}
\maketitle
\tableofcontents
\chapter{تجربة}
\pagenumbering{arabic}
\section{لغات مختلفة}

\textbf{العربية}\footnote{%
من «\LR{\textenglish{\url{http://ar.wikipedia.org/wiki/}}\RL{\ttfamily لغة عربية}}»} 
أكبر لغات المجموعة السامية من حيث عدد المتحدثين، وإحدى أكثر اللغات انتشارا في
العالم، يتحدثها أكثر من ٤٢٢ مليون نسمة، ويتوزع متحدثوها في المنطقة المعروفة
باسم الوطن العربي، بالإضافة إلى العديد من المناطق الأخرى المجاورة كالأحواز وتركيا
وتشاد ومالي والسنغال. وللغة العربية أهمية قصوى لدى أتباع الديانة الإسلامية، فهي
لغة مصدري التشريع الأساسيين في الإسلام: القرآن، والأحاديث النبوية المروية عن النبي
محمد، ولا تتم الصلاة في الإسلام (وعبادات أخرى) إلا بإتقان بعض من كلمات هذه اللغة.
والعربية هي أيضًا لغة طقسية رئيسية لدى عدد من الكنائس المسيحية في العالم العربي،
كما كتبت بها الكثير من أهم الأعمال الدينية والفكرية اليهودية في العصور الوسطى.
وإثر انتشار الإسلام، وتأسيسه دولا، ارتفعت مكانة اللغة العربية، وأصبحت لغة السياسة
والعلم والأدب لقرون طويلة في الأراضي التي حكمها المسلمون، وأثرت العربية، تأثيرا
مباشرا أو غير مباشر على كثير من اللغات الأخرى في العالم الإسلامي، كالتركية
والفارسية والأردية مثلا.

\textlang{farsi}{\bfseries فارسی}\footnote{%
از «\LR{\textenglish{\url{http://fa.wikipedia.org/wiki/}}\RL{\ttfamily فارسي}}»}
\begin{farsi}
یا پارسی، (که دری، فارسی دری، و پارسی دری نیز نامیده می‌شود) زبانی است که
در کشورهای ایران، افغانستان، تاجیکستان و ازبکستان به آن سخن می‌رانند.
(برخی زبان فارسی در تاجیکستان و ازبکستان و چین را فارسی تاجیکی نام
می‌گذارند).  
\end{farsi}

\newpage
\begin{english}
\textbf{English}\footnote{%
	From \url{http://en.wikipedia.org/wiki/English_language}} 
is a West Germanic language originating in England, and the first language for
most people in Australia, Canada, the Commonwealth Caribbean, Ireland, New
Zealand, the United Kingdom and the United States of America (also commonly
known as the Anglosphere). It is used extensively as a second language and as
an official language throughout the world, especially in Commonwealth countries
and in many international organisations.

\textarabic{١ ٢ ٣}

\end{english}
\clearpage

\section{أعمال تأريخية \textenglish{(Calendar operations)}}

%\textenglish{\today} = \LTR{\today} = 
\setfootnoteLR
\today\ = \Hijritoday%\footnote{ 
%	محسوب بـ \textenglish{\textsf{hijrical.sty}}}
\LTRfootnote{ What is this?}
\setfootnoteRL

%\newpage
\subsection{فلان}
\textenglish{This is English: a b c}\marginpar{انكليزي} %FIXME! cf farsitex?

\subsubsection{فلان فلان}
\begin{enumerate}
	\item مثال
	\item مثال
		\begin{enumerate}
			\item مثال
			\item مثال
		\end{enumerate}

	\item مثال	
\end{enumerate}

\begin{table}[h]
	\centering
	\begin{tabular}{cc}
		ا & ب  \\
		ج & د  
	\end{tabular}
	\caption{هذا المثال}
\end{table}

\[
x^\text{مال مال}
\]

\begin{equation}
	x^2 + y^2 = z^2
	\label{test}
\end{equation}
\end{document}
%</example-arabic.tex>
%<*example-thai.tex>
\documentclass[a4paper]{article}
\usepackage[no-math]{fontspec}
\usepackage{xltxtra,url}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=thai]{thai}
\setotherlanguage{english}
\setmainfont{Norasi}
\begin{document}
\begin{center}
	\abstractname
\end{center}
\begin{english}
Some English to begin with.\footnote{ %
	Blabla}
\end{english}
%%% NOTE: The wordbreak (\wbr) commands were inserted by the preprocessor cttex 
%%% (available from http://linux.thai.net/pub/thailinux/cvs/software/cttex/ 
%%% or from http://packages.debian.org/cttex) 
%%% using the command :
%%% $ cttex-utf8 <infile.tex> <outfile.tex>
%%% where cttex-utf8 is the following simple shell script:
%%% #!/bin/bash 
%%% cat $1 | iconv -f UTF-8 -t TIS-620 | cttex -w | sed 's/<WBR>/\\wbr /g' | iconv -f TIS-620 -t UTF8 > $2
%%% (this should also work on MacOSX; windows users need to tweak it into a batch file I guess)

เป็น\wbr แผนงานเพื่อ\wbr สนับสนุน\wbr การ\wbr ร่วมกัน\wbr สร้าง, การ\wbr ร่วมกันใช้, และ\wbr การ%
ร่วมกัน\wbr พัฒนา\wbr ทรัพยากร\wbr ทาง\wbr ภาษา\wbr ของ\wbr ภาษา\wbr ไทย, บน\wbr เครือข่าย World Wide Web. แผนงานนี้\wbr มี%
จุด\wbr ประสงค์หลั\wbr กอยู่\wbr สอง\wbr ประการคือ เพื่อแก้ปัญหา\wbr กำ\wbr แพง\wbr ทาง\wbr ภาษา, และรักษา%
ไว้เพื่อ\wbr ความค\wbr งอยู่\wbr ของ\wbr ภาษา\wbr และ\wbr วัฒนธรรม\wbr ไทย.

เรา\wbr ตระหนัก\wbr ดีถึง\wbr ความ\wbr สำคัญ\wbr ของ\wbr ภาษา ซึ่ง\wbr นอกจาก\wbr จะ\wbr เป็นสื่อ\wbr ระหว่าง\wbr คนกับ\wbr คน\wbr แล้ว ยัง\wbr เป็น%
รูปแทน\wbr ความคิด และ\wbr เป็น\wbr เครื่องมือ\wbr ใน\wbr การใช้\wbr ความคิด\wbr ด้วย. เครือข่าย\wbr คอมพิวเตอร์%
ใน\wbr ปัจจุบัน\wbr ทำให้ข้อมูล\wbr ข่าวสาร\wbr แพร่หลาย\wbr ไป\wbr อย่าง\wbr รวดเร็ว. เครื่องมือที่ใช้\wbr ใน\wbr การแส\wbr ดง\wbr ผล%
และ\wbr การเต\wbr รี\wbr ยมข้อมูล\wbr ข่าวสาร\wbr นั้น จึง\wbr เป็นสิ่ง\wbr จำ\wbr เป็น. ด้วย\wbr เทคโนโลยีที่\wbr ก้าวหน้า\wbr ไป%
อย่าง\wbr รวดเร็ว, การที่\wbr เพียง\wbr จะ\wbr สามารถแส\wbr ดง\wbr ผลได้หรือ\wbr ป้อนข้อมูลได้\wbr เท่านั้น ไม่\wbr เป็นที่%
เพียงพออีก\wbr แล้ว. การแส\wbr ดง\wbr ผลที่\wbr สวย\wbr งาม\wbr ถูก\wbr ต้อง\wbr ตาม\wbr แบบแผน หรือ\wbr การเต\wbr รี\wbr ยมข้อมูลได้\wbr อย่าง%
ถูก\wbr ต้อง และ\wbr รวดเร็วจึง\wbr เป็นสิ่งที่\wbr จำ\wbr เป็นที่\wbr จะ\wbr ต้อง\wbr พัฒนาให้\wbr ทันตาม\wbr การ\wbr เปลี่ยนแปลง\wbr ของ%
เทคโนโลยี.\footnote{ %
	Second footnote}

\today

\begin{english}
This is today: \today
\end{english}

\begin{enumerate}
	\item A
	\item B	
	\begin{enumerate}
		\item a
		\item b	
		\item c	
	\end{enumerate}
	\item C	
\end{enumerate}
\end{document}
%</example-thai.tex>
% \fi
% 
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by TeX:}
% \typeout{*}
% \typeout{* \space\space all *.sty, *.lua, *.def, *.lde and *.ldf files}
% \typeout{*}
% \typeout{* You also need to compile the *.map files with teckit_compile}
% \typeout{* and place the resulting *.tec files under}
% \typeout{* .../fonts/misc/xetex/fontmapping}
% \typeout{*}
% \typeout{*************************************************************}
\endinput
