%\iffalse
% polyglossia.dtx generated using mkpolyglossiadtx.pl
% (derived from makedtx.pl version 0.94b (c) Nicola Talbot)
% 
% To extract the files, use xetex polyglossia.dtx or luatex polyglossia.dtx
% 
%<*internal>
\iffalse
%</internal>
%<*README>

   ¦----------------------------------------------¦
   ¦                                              ¦
   ¦       THE POLYGLOSSIA PACKAGE v1.48          ¦
   ¦                                              ¦
   ¦     Modern multilingual typesetting          ¦
   ¦        with XeLaTeX and LuaLaTeX             ¦
   ¦                                              ¦
   ¦----------------------------------------------¦

This package provides an alternative to Babel for users of XeLaTeX and LuaLaTeX
(with a few languages incompletely supported for the latter). This version
includes support for over 70 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).

LICENSE

Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2020 Arthur Reutenauer,
Copyright (c) 2019-2020 Bastien Roucariès, 2019-2020 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 me
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-2020 Arthur Reutenauer
  (C) 2013 Elie Roux
  License information appended


\endpreamble
\postamble

 Copyright (C) 2020 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{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-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.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-latex.ldf}{\from{polyglossia.dtx}{gloss-latex.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-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-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-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-vietnamese.ldf}{\from{polyglossia.dtx}{gloss-vietnamese.ldf}}}
\generate{\file{gloss-welsh.ldf}{\from{polyglossia.dtx}{gloss-welsh.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{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{../README}{\from{polyglossia.dtx}{../README}}}
\generate{\file{Changelog}{\from{polyglossia.dtx}{Changelog}}}
\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}}}
\endgroup
%</internal>
%
%<*driver>
% !TeX spellcheck = en_US
% !TeX TS-program = xelatex
\documentclass[11pt]{ltxdoc}
\usepackage{color}
\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{metalogo}
\let\XeTeX\undefined
\let\XeLaTeX\undefined
\usepackage[babelshorthands]{polyglossia}
\usepackage{farsical}
\setmainlanguage[variant=british,ordinalmonthday=false]{english}
\setotherlanguages{arabic,armenian,hebrew,syriac,greek,russian,serbian,catalan,georgian}
\usepackage[protrusion]{microtype}
\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⟩}}
\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%
}

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

%% fontspec declarations:
\setmainfont{Linux Libertine O}[Numbers=OldStyle]
\setsansfont{Linux Biolinum O}
\setmonofont[Scale=MatchLowercase]{DejaVu Sans Mono}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}
\newfontfamily\armenianfont[Script=Armenian]{DejaVu Sans}
\newfontfamily\syriacfont[Script=Syriac]{Serto Jerusalem}
\newfontfamily\hebrewfont[Script=Hebrew]{Ezra SIL}
\newfontfamily\georgianfont{DejaVu Serif}

\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{\textcolor{lightblue}{\Huge\fontspec[LetterSpace=40]{GFS Ambrosia} Πολυγλωσσια}
% \\[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\\
% \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 (with some exceptions) \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, 2019-11-01
% ^^A Edited by hand -- JS, 2019-11-01
% \begin{tabular}{lllll}
% \toprule
% \TX{afrikaans}  & danish         & \TX{hungarian} & \TX{marathi}    & \TX{slovenian} \\
% albanian        & divehi         & icelandic      & \TX{mongolian}  & \TX{sorbian}   \\
% amharic         & \TX{dutch}     & interlingua    & nko             & \TX{spanish}   \\
% \TX{arabic}     & \TX{english}   & \TX{italian}   & \TX{norwegian}  & swedish        \\
% \TX{armenian}   & \TX{esperanto} & japanese       & occitan         & \TX{syriac}    \\
% asturian        & estonian       & kannada        & \TX{persian}    & tamil          \\
% basque          & \TX{finnish}   & khmer          & piedmontese     & telugu         \\
% \TX{belarusian} & \TX{french}    & \TX{korean}    & polish          & \TX{thai}      \\
% \TX{bengali}    & friulian       & \TX{kurdish}   & \TX{portuguese} & \TX{tibetan}   \\
% bosnian         & \TX{gaelic}    & \TX{lao}       & romanian        & turkish        \\
% breton          & galician       & \TX{latin}     & romansh         & turkmen        \\
% bulgarian       & \TX{georgian}  & latvian        & \TX{russian}    & \TX{ukrainian} \\
% \TX{catalan}    & \TX{german}    & lithuanian     & \TX{sami}       & urdu           \\
% coptic          & \TX{greek}     & macedonian     & \TX{sanskrit}   & vietnamese     \\
% \TX{croatian}   & \TX{hebrew}    & \TX{malay}     & \TX{serbian}    & \TX{welsh}     \\
% \TX{czech}      & \TX{hindi}     & malayalam      & \TX{slovak}     &                \\
% \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.
% 
% 
% \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
% acadien            & 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\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.classic}).}
%                    & latin      & variant=classic                     \\
% farsi              & persian    &                                     \\
% ecclesiasticlatin\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.ecclesiastic}).}
%                    & 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\footnote{In \pkg{babel} currently only selectable via dot modifier (\emph{latin.medieval}).}
%                    & 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]{lll}
% 	\caption{\label{tab:BCP47-polyglossia}BCP47-polyglossia language name matching}\\
% 	\toprule
% 	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\\
% 	\midrule
% 	\endfirsthead
% 	\caption[]{BCP47-polyglossia language name matching (\emph{continued})}\\
% 	\toprule
% 	\textbf{BCP-47 tag} & \textbf{Polyglossia name} & \textbf{Polyglossia options}\\
% 	\midrule
% 	\endhead
% 	aeb              & arabic      & locale=tunisia                                     \\
% 	af               & afrikaans   &                                                    \\
% 	afb              & arabic      & locale=default                                     \\
% 	am               & amharic     &                                                    \\
% 	apd              & arabic      & locale=default                                     \\
% 	ar               & arabic      &                                                    \\
% 	ar-IQ            & arabic      & locale=mashriq                                     \\
% 	ar-JO            & arabic      & locale=mashriq                                     \\
% 	ar-LB            & arabic      & locale=mashriq                                     \\
% 	ar-MR            & arabic      & locale=mauritania                                  \\
% 	ar-PS            & arabic      & locale=mashriq                                     \\
% 	ar-SY            & arabic      & locale=mashriq                                     \\
% 	ar-YE            & arabic      & locale=default                                     \\
% 	arq              & arabic      & locale=algeria                                     \\
% 	ary              & arabic      & locale=morocco                                     \\
% 	arz              & arabic      & locale=default                                     \\
% 	ast              & asturian    &                                                    \\
% 	ayl              & arabic      & locale=libya                                       \\
% 	be               & belarusian  &                                                    \\
% 	be-tarask        & belarusian  & spelling=classic                                   \\
% 	bg               & bulgarian   &                                                    \\
% 	bn               & bengali     &                                                    \\
% 	bo               & tibetan     &                                                    \\
% 	br               & breton      &                                                    \\
% 	bs               & bosnian     &                                                    \\
% 	ca               & catalan     &                                                    \\
% 	ckb              & kurdish     & variant=sorani [\emph{default}]                    \\
% 	ckb-Arab         & kurdish     & variant=sorani, script=Arabic [\emph{default}]     \\
% 	ckb-Latn         & kurdish     & variant=sorani, script=Latin                       \\
% 	cop              & coptic      &                                                    \\
% 	cy               & welsh       &                                                    \\
% 	cz               & czech       &                                                    \\
% 	da               & danish      &                                                    \\
% 	de               & german      &                                                    \\
% 	de-AT            & german      & variant=austrian, spelling=new                     \\
% 	de-AT-1901       & german      & variant=austrian, spelling=old                     \\
% 	de-AT-1996       & german      & variant=austrian, spelling=new                     \\
% 	de-CH            & german      & variant=swiss, spelling=new                        \\
% 	de-CH-1901       & german      & variant=swiss, spelling=old                        \\
% 	de-CH-1996       & german      & variant=swiss, spelling=new                        \\
% 	de-DE            & german      & variant=german, spelling=new                       \\
% 	de-DE-1901       & german      & variant=german, spelling=old                       \\
% 	de-DE-1996       & german      & variant=german, spelling=new  [\emph{default}]     \\
% 	de-Latf          & german      & script=blackletter                                 \\
% 	de-Latf-AT       & german      & variant=austrian, spelling=new, script=blackletter \\
% 	de-Latf-AT-1901  & german      & variant=austrian, spelling=old, script=blackletter \\
% 	de-Latf-AT-1996  & german      & variant=austrian, spelling=new, script=blackletter \\
% 	de-Latf-CH       & german      & variant=swiss, spelling=new, script=blackletter    \\
% 	de-Latf-CH-1901  & german      & variant=swiss, spelling=old, script=blackletter    \\
% 	de-Latf-CH-1996  & german      & variant=swiss, spelling=new, script=blackletter    \\
% 	de-Latf-DE       & german      & variant=german, spelling=new, script=blackletter   \\
% 	de-Latf-DE-1901  & german      & variant=german, spelling=old, script=blackletter   \\
% 	de-Latf-DE-1996  & german      & variant=german, spelling=new, script=blackletter   \\
% 	dsb              & sorbian     & variant=lower                                      \\
% 	dv               & divehi      &                                                    \\
% 	el               & greek       &                                                    \\
% 	el-monoton       & greek       & variant=monotonic  [\emph{default}]                \\
% 	el-polyton       & greek       & varant=polytonic                                   \\
% 	en               & english     &                                                    \\
% 	en-AU            & english     & variant=australian                                 \\
% 	en-CA            & english     & variant=canadian                                   \\
% 	en-GB            & english     & variant=british                                    \\
% 	en-NZ            & english     & variant=newzealand                                 \\
% 	en-US            & english     & variant=us [\emph{default}]                        \\
% 	eo               & esperanto   &                                                    \\
% 	es               & spanish     &                                                    \\
% 	es-ES            & spanish     & variant=spanish [\emph{default}]                   \\
% 	es-MX            & spanish     & variant=mexican                                    \\
% 	et               & estonian    &                                                    \\
% 	eu               & basque      &                                                    \\
% 	fa               & persian     &                                                    \\
% 	fi               & finnish     &                                                    \\
% 	fr               & french      &                                                    \\
% 	fr-CA            & french      & variant=canadian                                   \\
% 	fr-CH            & french      & variant=swiss                                      \\
% 	fr-FR            & french      & variant=french [\emph{default}]                    \\
% 	fur              & friulian    &                                                    \\
% 	ga               & gaelic      & variant=irish [\emph{default}]                     \\
% 	gd               & gaelic      & variant=scottish                                   \\
% 	gl               & galician    &                                                    \\
% 	grc              & greek       & variant=ancient                                    \\
% 	he               & hebrew      &                                                    \\
% 	hi               & hindi       &                                                    \\
% 	hr               & croatian    &                                                    \\
% 	hsb              & sorbian     & variant=upper [\emph{default}]                     \\
% 	hu               & hungarian   &                                                    \\
% 	hy               & armenian    &                                                    \\
% 	ia               & interlingua &                                                    \\
% 	id               & malay       & variant=indonesian                                 \\
% 	is               & icelandic   &                                                    \\
% 	it               & italian     &                                                    \\
% 	ja               & japanese    &                                                    \\
% 	ka               & georgian    &                                                    \\
% 	km               & khmer       &                                                    \\
% 	kmr              & kurdish     & variant=kurmanji                                   \\
% 	kmr-Arab         & kurdish     & variant=kurmanji, script=Arabic                    \\
% 	kmr-Latn         & kurdish     & variant=kurmanji, script=Latin                     \\
% 	kn               & kannada     &                                                    \\
% 	ko               & korean      &                                                    \\
% 	ku               & kurdish     &                                                    \\
% 	ku-Arab          & kurdish     & script=Arabic                                      \\
% 	ku-Latn          & kurdish     & script=Latin                                       \\
% 	la               & latin       &                                                    \\
% 	la-x-classic     & latin       & variant=classic                                    \\
% 	la-x-ecclesia    & latin       & variant=ecclesiastic                               \\
% 	la-x-medieval    & latin       & variant=medieval                                   \\
% 	lo               & lao         &                                                    \\
% 	lt               & lithuanian  &                                                    \\
% 	lv               & latvian     &                                                    \\
% 	mk               & macedonian  &                                                    \\
% 	ml               & malayalam   &                                                    \\
% 	mn               & mongolian   &                                                    \\
% 	mr               & marathi     &                                                    \\
% 	nb               & norwegian   & variant=bokmal                                     \\
% 	nko              & nko         &                                                    \\
% 	nl               & dutch       &                                                    \\
% 	nn               & norwegian   & variant=nynorsk [\emph{default}]                   \\
% 	oc               & occitan     &                                                    \\
% 	pl               & polish      &                                                    \\
% 	pms              & piedmontese &                                                    \\
% 	pt               & portuguese  &                                                    \\
% 	pt-BR            & portuguese  & variant=brazilian                                  \\
% 	pt-PT            & portuguese  & variant=portuguese [\emph{default}]                \\
% 	rm               & romansh     &                                                    \\
% 	ro               & romanian    &                                                    \\
% 	ru               & russian     &                                                    \\
% 	ru-luna1918      & russian     & spelling=modern [\emph{default}]                   \\
% 	ru-petr1708      & russian     & spelling=old                                       \\
% 	sa               & sanskrit    &                                                    \\
% 	sa-Beng          & sanskrit    & script=Bengali                                     \\
% 	sa-Deva          & sanskrit    & script=Devanagari [\emph{default}]                 \\
% 	sa-Gujr          & sanskrit    & script=Gujarati                                    \\
% 	sa-Knda          & sanskrit    & script=Kannada                                     \\
% 	sa-Mlym          & sanskrit    & script=Malayalam                                   \\
% 	sa-Telu          & sanskrit    & script=Telugu                                      \\
% 	se               & sami        &                                                    \\
% 	sk               & slovak      &                                                    \\
% 	sl               & slovenian   &                                                    \\
% 	sq               & albanian    &                                                    \\
% 	sr               & serbian     &                                                    \\
% 	sr-Cyrl          & serbian     & script=Cyrillic                                    \\
% 	sr-Latn          & serbian     & script=Latin [\emph{default}]                      \\
% 	sv               & swedish     &                                                    \\
% 	syr              & syriac      &                                                    \\
% 	ta               & tamil       &                                                    \\
% 	te               & telugu      &                                                    \\
% 	th               & thai        &                                                    \\
% 	tk               & turkmen     &                                                    \\
% 	tr               & turkish     &                                                    \\
% 	uk               & ukrainian   &                                                    \\
% 	ur               & urdu        &                                                    \\
% 	vi               & vietnamese  &                                                    \\
% 	zsm              & malay       & variant=malaysian [\emph{default}]                 \\
% 	\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. Currently
% 		shorthands are implemented 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 \xpgoption{quiet} turns off most info messages and some of the warnings issued
% 		by \LaTeX, \pkg{fontspec} and \pkg{polyglossia}.
% \end{itemize}
% 
% \pagebreak
% \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*\}}
% \end{itemize}
% ^^A
% \cmd\selectlanguage\marg{lang} and the ¦otherlanguage¦ environment are identical to the
% 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.
% 
% 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 also accessible.
% 
% \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):
% 	completely 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
% \displaycmd{\setlanguagealias\oarg{options}\marg{language}\marg{alias}}{\setlanguagealias}\new{1.46}
% 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{Verbatim}
% \hyphenation{%
%   po-ly-glos-sia
%   LaTeX
% }
% \end{Verbatim}
% ^^A
% These exceptions, however, apply to all languages. In addition to this, \pkg{polyglossia} provides
% the command\new{1.45}
% \displaycmd{\xpghyphenation\oarg{options}\marg{lang}\marg{exceptions}}{\xpghyphenation}
% which can be used to define exceptions that only apply to a specific language or language variant,
% respectively.
% 
% \subsection{Hyphenation disabling}
% 
% In some very specific contexts (such as music score creation), \TeX{} hyphenation
% is something to avoid 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 \xpgchoicekey{locale}{\xpgpresetvalue{default}\footnote{ %
% 			For Egypt, Sudan, Yemen and the Gulf states.},
% 		\xpgvalue{mashriq}\footnote{ %
% 			For Iraq, Syria, Jordan, Lebanon and Palestine.},
% 		\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 overriden by the following option).
% 	\item \xpgchoicekey{numerals}{\xpgpresetvalue{mashriq} or \xpgvalue{maghrib}}
% 		The latter is the default when \xpgvalue{locale=algeria}, \xpgvalue{tunisia}, or \xpgvalue{morocco}.
% 	\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 and \Cmd\abjadmaghribi (see section \ref{abjad})
%   \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}}
% \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[\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[¦"---¦] Cyrillic emdash in plain text.
% 		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
% 		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
% 		\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}
%     \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}
% ^^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 ¦\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{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 (ligatures):
% 	\begin{shorthands}
% 		\item[¦"dz¦] Generates the ligature \charifavailable{01C6}{dž}\ if the font provides it. If not, the
% 		             two characters are output separately. Also available for ¦"Dz¦ (\charifavailable{01C5}{Dž})
% 		             and ¦"DZ¦ (\charifavailable{01C4}{DŽ}).
% 		\item[¦"lj¦] Generates the ligature \charifavailable{01C9}{lj}\ if the font provides it. If not, the
% 		             two characters are output separately. Also available for ¦"Lj¦ (\charifavailable{01C8}{Lj})
% 		             and ¦"LJ¦ (\charifavailable{01C7}{LJ}).
% 		\item[¦"nj¦] Generates the ligature \charifavailable{01CC}{nj}\ if the font provides it. If not, the
% 		             two characters are output separately. 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]{disableligatures}
% 		If this is \xpgvalue{true}, all Croatian ligatures (for digraphs such as
% 		\charifavailable{01C6}{dž}) will be replaced by single characters. This can
% 		be useful if the ligatures on your font are broken (if the font does not
% 		have them, they are automatically replaced).
% \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 \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[¦"-¦] 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}
% \end{itemize}
% 
% \subsection{french}\label{french}
% \paragraph*{Options:}
% 	\begin{itemize}
% 		\item \xpgchoicekey{variant}{\xpgpresetvalue{french} or \xpgvalue{canadian} (=~\xpgvalue{acadian})\new{1.45}, \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 \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[\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[¦"---¦] Cyrillic emdash in plain text.
% 			\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
% 			\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
% 			\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}
% 	\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.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 left double quotes („)
% 		\item[¦"'¦] for German right double quotes (“)
% 		\item[¦"<¦] for French left double quotes («)
% 		\item[¦">¦] for French right double quotes (»).
% 		\end{shorthands}
% 	\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 (ſ)
% 		where appropriate).
% 	\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{attic}
% 	\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.
% 	\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}
% \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 \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{\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), 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), also available for A͞u, E͞u,
% 					and O͞e.
% 				\item[¦=AE¦] for A͞E (AE diphthong with macron), 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}{\xpgpresetvalue{indonesian} or \xpgvalue{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[\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[¦"---¦] Cyrillic emdash in plain text.
% 		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
% 		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
% 		\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}
% 	\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 \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{portuguese}\label{portuguese}
% \paragraph*{Options:}
% \begin{itemize}
% 	\item \xpgchoicekey[1.45]{variant}{\xpgvalue{brazilian} or \xpgpresetvalue{portuguese}}
% \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[\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[¦"---¦] Cyrillic emdash in plain text.
% 		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
% 		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
% ^^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.46]{indentfirst}
% 		By default, all paragraphs are indented in Russian, also those after a
% 		chapter or section heading. If this option is false, the latter paragraphs
% 		are not indented, as normal in \LaTeX.
% 	\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}
% 
% \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}, or \xpgvalue{Latin}}
% 		The value is passed to \pkg{fontspec} in cases where the respective
% 		\cmd{\⟨script⟩font} is not 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{script}{\xpgpresetvalue{Cyrillic} or \xpgvalue{Latin}}
% 	\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.
% \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
% 		            (only needed with ¦splithyphens=false¦).
%         \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}, alpha-numeric counters will use a localized version including characters with caron
% 	      (a, b, c, č, d, \ldots).
% 	\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}}
% 	\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[\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[¦"---¦] Cyrillic emdash in plain text.
% 		\item[¦"--~¦] Cyrillic emdash in compound names (surnames).
% 		\item[¦"--*¦] Cyrillic emdash for denoting direct speech.
% ^^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}
% 	\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}
% 
% \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.
% 
% \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\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\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 generate variants of Hebrew alphanumeric numerals.
% 			The commands behave exactly as they do in \pkg{babel}: \cmd\hebrewnumeral\ outputs the numbers without any decoration,
% 			\cmd\Hebrewnumeral\ adds \textit{gereshayim} before the last letter, \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\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.
% 
% \condbreak{5\baselineskip}
% \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)}
% 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 \displaycmd{\charifavailable\marg{char code}\marg{substitution}}{\charifavailable}\new{1.47} 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}
% 
% The following is specifically relevant to package authors who need information about the languages in use.
% In order to get such information, \pkg{polyglossia} provides the following macros:
% 
% \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
% \displaycmd{\iflanguageidloaded\marg{type}\marg{id}\marg{true}\marg{false}}{\iflanguageidloaded}\new{1.47}
% 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
% \displaycmd{\iflanguageoption\marg{lang}\marg{opt. key}\marg{opt. value}\marg{true}\marg{false}}{\iflanguageoption}\new{1.47}
% 
% \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}, \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{José Mancera}, \TA{Yevgen Pogribnyi}, \TA{Will Robertson}, \TA{Maïeul Rouquette},
% \TA{Elie Roux}, \TA{Hugo Roy},  \TA{Guy Rutenberg}, \TA{Philipp Stephani}, \TA{Niranjan Tambe}, \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
%<*gloss-acadien.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-acadien.ldf}
%    \begin{macrocode}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-afrikaans.ldf}[polyglossia: module for afrikaans]

\PolyglossiaSetup{afrikaans}{
  bcp47=af,
  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{%
  \bbl@activate{"}%
  \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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\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{%
  \noafrikaans@shorthands%
}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-afrikaans.ldf>
%<*gloss-albanian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-albanian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-albanian.ldf}[polyglossia: module for albanian]

\PolyglossiaSetup{albanian}{
  bcp47=sq,
  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ërmbajta}%
   \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}
\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}
\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}
\ProvidesFile{gloss-amharic.ldf}[polyglossia: module for amharic]
\PolyglossiaSetup{amharic}{
  bcp47=am,
  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}
\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}
\ProvidesFile{gloss-ar-IQ.ldf}[polyglossia: module for ar-IQ (arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar-IQ.ldf>
%<*gloss-ar-JO.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-JO.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-ar-JO.ldf}[polyglossia: module for ar-JO (arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar-JO.ldf>
%<*gloss-ar-LB.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-LB.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-ar-LB.ldf}[polyglossia: module for ar-LB (arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar-LB.ldf>
%<*gloss-ar-MR.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-MR.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-ar-MR.ldf}[polyglossia: module for ar-MR (arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar-MR.ldf>
%<*gloss-ar-PS.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-PS.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-ar-PS.ldf}[polyglossia: module for ar-PS (arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar-PS.ldf>
%<*gloss-ar-SY.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-SY.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-ar-SY.ldf}[polyglossia: module for ar-SY (arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar-SY.ldf>
%<*gloss-ar-YE.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar-YE.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-ar-YE.ldf}[polyglossia: module for ar-YE (arabic)]

% We provide this as a bcp47-compliant alias

\xpg@load@master@language{arabic}

%    \end{macrocode}
% \iffalse
%</gloss-ar-YE.ldf>
%<*gloss-ar.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ar.ldf}
%    \begin{macrocode}
\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}
\ProvidesFile{gloss-arabic.ldf}[polyglossia: module for arabic]
\ifluatex
  \xpg@warning{Arabic is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{hijrical}

\PolyglossiaSetup{arabic}{
  bcp47=ar,
  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}

\newif\ifeastern@numerals
\def\tmp@mashriq{mashriq}
\def\tmp@maghrib{maghrib}
\define@key{arabic}{numerals}[mashriq]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@mashriq%
    \eastern@numeralstrue%
  \else
    \ifx\@tmpa\tmp@maghrib\eastern@numeralsfalse\fi%
  \fi}

%this is needed for \abjad in arabicnumbers.sty
\def\tmp@true{true}
\define@key{arabic}{abjadjimnotail}[true]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@true\abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi}

\def\tmp@morocco{morocco}
\def\tmp@algeria{algeria}
\define@key{arabic}{locale}[default]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@morocco%
    \eastern@numeralsfalse%
    \SetLanguageKeys{arabic}{bcp47=ary}%
  \else
    \ifx\@tmpa\tmp@algeria%
      \eastern@numeralsfalse%
      \SetLanguageKeys{arabic}{bcp47=arq}%
    \fi%
  \fi%
  \gdef\@@arabic@month{\@arabic@month{#1}}}

\newif\if@hijrical
\def\tmp@hijri{hijri}
\def\tmp@islamic{islamic}
\define@key{arabic}{calendar}[gregorian]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@hijri\@hijricaltrue%
  \else
    \ifx\@tmpa\tmp@islamic\@hijricaltrue%
    \else\@hijricalfalse%
    \fi
  \fi}

\define@key{arabic}{hijricorrection}[0]{%
  \gdef\@hijri@correction{#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[\@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}}


\newcommand{\arabicnumerals}[2]{\arabicnumber{#2}}

\def\arabicnumber#1{%
  \ifeastern@numerals
    \@ensure@dir{\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\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{%
   \let\@alph\abjad%
   \let\@Alph\abjad%
}

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

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@arabic{%
   \def\MakeUppercase##1{##1}%
   % TODO disable \@Roman and \@roman ?
}

\def\noextras@arabic{%
   % restore original \MakeUppercase definition
   \let\MakeUppercase\xpg@save@MakeUppercase
}

%    \end{macrocode}
% \iffalse
%</gloss-arabic.ldf>
%<*gloss-armenian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-armenian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-armenian.ldf}[polyglossia: module for armenian]

\PolyglossiaSetup{armenian}{
  bcp47=hy,
  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}{\@armenian@numeralstrue}%
}

% 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}
\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}
\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}
\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}
\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}
% 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,
  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}
\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}
\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}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-basque.ldf}[polyglossia: module for basque]
\PolyglossiaSetup{basque}{
  bcp47=eu,
  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}
\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}
\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}
\ProvidesFile{gloss-belarusian.ldf}[polyglossia: module for belarusian]

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{belarusian}{
  bcp47=be,
  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}%
   \or
      % classic:
      \def\belarusian@spelling{tarask}%
      \SetLanguageKeys{belarusian}{bcp47=be-tarask}%
   \or
      % tarask:
      \def\belarusian@spelling{tarask}%
      \SetLanguageKeys{belarusian}{bcp47=be-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{%
  \bbl@activate{"}%
  \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{--\hss--}}%
  \fi
  \declare@shorthand{belarusian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

\def\nobelarusian@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

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

\newcommand{\belarusiannumerals}[2]{\belarusiannumber{#2}}
\newcommand{\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%
   \nobelarusian@shorthands%
}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-belarusian.ldf>
%<*gloss-bengali.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bengali.ldf}
%    \begin{macrocode}
% Translations provided by সাজেদুর রহিম জোয়ারদার <toshazed@gmail.com>
% TODO implement Bengali calendar

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

\ifluatex
  \xpg@warning{Bengali is not supported with LuaTeX.\MessageBreak
               I will proceed with the compilation, but\MessageBreak
               the output is not guaranteed to be correct\MessageBreak
               and may look very wrong.}
\fi

\RequirePackage{devanagaridigits}
\RequirePackage{bengalidigits}

\PolyglossiaSetup{bengali}{
  bcp47=bn,
  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}
\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}
\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}
\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}
\ProvidesFile{gloss-bosnian.ldf}[polyglossia: module for bosnian]

\PolyglossiaSetup{bosnian}{
  bcp47=bs,
  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}
\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}
\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}
\ProvidesFile{gloss-breton.ldf}[polyglossia: module for breton]
\PolyglossiaSetup{breton}{
  bcp47=br,
  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}
\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}
\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}
\ProvidesFile{gloss-bulgarian.ldf}[polyglossia: module for bulgarian]
\PolyglossiaSetup{bulgarian}{
  bcp47=bg,
  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}
\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}
\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}
\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}
\ProvidesFile{gloss-catalan.ldf}[polyglossia: module for catalan]
\PolyglossiaSetup{catalan}{
  bcp47=ca,
  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}\setbox1\hbox{l\/}%
    \xpg@if@char@available{00B7}%
          {\setbox2\hbox{\char"00B7}}%
          {\setbox2\hbox{.}}%
    \advance\raiselldim by \the\fontdimen5\the\font
    \advance\raiselldim by -\ht2%
    \leftllkern=-.25\wd0%
    \advance\leftllkern by \wd1%
    \advance\leftllkern by -\wd0%
    \rightllkern=-.25\wd0%
    \advance\rightllkern by -\wd1%
    \advance\rightllkern by \wd0%
    \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}\setbox1\hbox{L\/}%
    \xpg@if@char@available{00B7}%
          {\setbox2\hbox{\char"00B7}}%
          {\setbox2\hbox{.}}%
    \advance\raiselldim by .5\ht0%
    \advance\raiselldim by -.5\ht2%
    \leftllkern=-.125\wd0%
    \advance\leftllkern by \wd1%
    \advance\leftllkern by -\wd0%
    \rightllkern=-\wd0%
    \divide\rightllkern by 6%
    \advance\rightllkern by -\wd1%
    \advance\rightllkern by \wd0%
    \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{%
  \bbl@activate{"}%
  \def\language@group{catalan}%
  \declare@shorthand{catalan}{"l}{\lgem{}}
  \declare@shorthand{catalan}{"L}{\Lgem{}}
}

\def\nocatalan@shorthands{%
    \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\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{%
   \nocatalan@shorthands%
}

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

\def\inlineextras@catalan{%
   \ifcatalan@babelshorthands\catalan@shorthands\fi%
}
%    \end{macrocode}
% \iffalse
%</gloss-catalan.ldf>
%<*gloss-ckb-Arab.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ckb-Arab.ldf}
%    \begin{macrocode}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-coptic.ldf}[polyglossia: module for coptic]
\PolyglossiaSetup{coptic}{
  bcp47=cop,
  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}
\ProvidesFile{gloss-croatian.ldf}[polyglossia: module for croatian]
\PolyglossiaSetup{croatian}{
  bcp47=hr,
  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}

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

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

% Register default options
\xpg@initialize@gloss@options{croatian}{babelshorthands=false,disableligatures=false}

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

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

\def\croatian@shorthands{%
  \bbl@activate{"}%
  \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@lig{D}}%
  \declare@shorthand{croatian}{"d}{\xpg@hr@lig{d}}%
  \declare@shorthand{croatian}{"L}{\xpg@hr@lig{L}}%
  \declare@shorthand{croatian}{"l}{\xpg@hr@lig{l}}%
  \declare@shorthand{croatian}{"N}{\xpg@hr@lig{N}}%
  \declare@shorthand{croatian}{"n}{\xpg@hr@lig{n}}%
}

\def\nocroatian@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\newcommand*\hr@charifavailable[2]{%
   \ifcroatian@disableligatures
     \bgroup#2\egroup%
   \else
     \charifavailable{#1}{#2}%
   \fi%
}

% Provide croatian ligatures if available in current font
\def\xpg@hr@lig#1#2{%
 \bgroup%
  % 1. DŽ, Dž and dž
  \ifx#1D%
    \ifx#2Z\relax%
       \hr@charifavailable{01C4}{DŽ}%
    \else%
       \ifx#2z\relax
          \hr@charifavailable{01C5}{Dž}%
       \else
           D#2%
       \fi%
    \fi%
  \fi%
  \ifx#1d%
    \ifx#2z\relax
       \hr@charifavailable{01C6}{dž}%
    \else
       d#2%
    \fi%
  \fi%
  % 2. LJ, Lj and lj
  \ifx#1L%
    \ifx#2J\relax%
       \hr@charifavailable{01C7}{LJ}%
    \else%
       \ifx#2j\relax
          \hr@charifavailable{01C8}{Lj}%
       \else
           L#2%
       \fi%
    \fi%
  \fi%
  \ifx#1l%
    \ifx#2j\relax
       \hr@charifavailable{01C9}{lj}%
    \else
       l#2%
    \fi%
  \fi%
  % 2. NJ, Nj and nj
  \ifx#1N%
    \ifx#2J\relax%
       \hr@charifavailable{01CA}{NJ}%
    \else%
       \ifx#2j\relax
          \hr@charifavailable{01CB}{Nj}%
       \else
           N#2%
       \fi%
    \fi%
  \fi%
  \ifx#1n%
    \ifx#2j\relax
       \hr@charifavailable{01CC}{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\hr@charifavailable{01C9}{lj}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čnja\or veljače\or ožujka\or travnja\or svibnja\or
    lipnja\or srpnja\or kolovoza\or rujna\or listopada\or studenoga\or
    prosinca\fi \space \number\year.}%
}

\def\noextras@croatian{%
  \nocroatian@shorthands%
}

\def\blockextras@croatian{%
  \ifcroatian@babelshorthands\croatian@shorthands\fi%
}

\def\inlineextras@croatian{%
  \ifcroatian@babelshorthands\croatian@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-croatian.ldf>
%<*gloss-cy.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-cy.ldf}
%    \begin{macrocode}
\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}
\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}
\ProvidesFile{gloss-czech.ldf}[polyglossia: module for czech]

\PolyglossiaSetup{czech}{
  bcp47=cz,
  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\cs@@splithyphen#1{%
  \ifnum\hyphenchar \font>0%
    \kern\z@\discretionary{-}{\char\hyphenchar\the\font}{#1}%
    \nobreak\hskip\z@%
  \else%
    #1%
  \fi%
}

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

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

\def\noczech@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\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 = {\cs@@splithyphen}% "-" -> "\cs@@splithyphen-"
      % necessary if used together with vlna:
      \XeTeXinterchartoks \czech@nonsyllabicpreposition \czech@hyphen = {\cs@@splithyphen}% "-" -> "\cs@@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
\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}
        \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\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{%
  \noczech@shorthands%
  \noczech@hyphens%
  \noczech@vlna%
  \ifxetex\XeTeXinterchartokenstate=0\fi%
}

\def\blockextras@czech{%
  \ifczech@babelshorthands\czech@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\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}
\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}
\ProvidesFile{gloss-danish.ldf}[polyglossia: module for danish]
\PolyglossiaSetup{danish}{
  bcp47=da,
  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}
\ProvidesFile{gloss-de-AT-1901.ldf}[polyglossia: module for de-AT-1901 (german)]

% 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}
\ProvidesFile{gloss-de-AT-1996.ldf}[polyglossia: module for de-AT-1996 (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}
\ProvidesFile{gloss-de-AT.ldf}[polyglossia: module for de-AT (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}
\ProvidesFile{gloss-de-CH-1901.ldf}[polyglossia: module for de-CH-1901 (german)]

% 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}
\ProvidesFile{gloss-de-CH-1996.ldf}[polyglossia: module for de-CH-1996 (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}
\ProvidesFile{gloss-de-CH.ldf}[polyglossia: module for de-CH (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}
\ProvidesFile{gloss-de-DE-1901.ldf}[polyglossia: module for de-DE-1901 (german)]

% 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}
\ProvidesFile{gloss-de-DE-1996.ldf}[polyglossia: module for de-DE-1996 (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}
\ProvidesFile{gloss-de-DE.ldf}[polyglossia: module for de-DE (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}
\ProvidesFile{gloss-de-AT-1901-Latf.ldf}[polyglossia: module for de-AT-1901-Latf (german)]

% 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}
\ProvidesFile{gloss-de-AT-1996-Latf.ldf}[polyglossia: module for de-AT-1996-Latf (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}
\ProvidesFile{gloss-de-AT-Latf.ldf}[polyglossia: module for de-AT-Latf (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}
\ProvidesFile{gloss-de-CH-1901-Latf.ldf}[polyglossia: module for de-CH-1901-Latf (german)]

% 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}
\ProvidesFile{gloss-de-CH-1996-Latf.ldf}[polyglossia: module for de-CH-1996-Latf (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}
\ProvidesFile{gloss-de-CH-Latf.ldf}[polyglossia: module for de-CH-Latf (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}
\ProvidesFile{gloss-de-DE-1901-Latf.ldf}[polyglossia: module for de-DE-1901-Latf (german)]

% 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}
\ProvidesFile{gloss-de-DE-1996-Latf.ldf}[polyglossia: module for de-DE-1996-Latf (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}
\ProvidesFile{gloss-de-DE-Latf.ldf}[polyglossia: module for de-DE-Latf (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}
\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}
\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}
\ProvidesFile{gloss-divehi.ldf}[polyglossia: module for divehi]
\ifluatex
  \xpg@warning{Divehi is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\RequireBidi
\PolyglossiaSetup{divehi}{
  bcp47=dv,
  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{<++>}}

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@divehi{%
   \def\MakeUppercase##1{##1}%
}

\def\noextras@divehi{%
   % restore original \MakeUppercase definition
   \let\MakeUppercase\xpg@save@MakeUppercase%
}

%    \end{macrocode}
% \iffalse
%</gloss-divehi.ldf>
%<*gloss-dsb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-dsb.ldf}
%    \begin{macrocode}
\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}
\ProvidesFile{gloss-dutch.ldf}[polyglossia: module for dutch]
\PolyglossiaSetup{dutch}{
  bcp47=nl,
  hyphennames={dutch},
  hyphenmins={2,2},
  langtag=NLD,
  frenchspacing=true,
  fontsetup=true,
}

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

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

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

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

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

\def\dutch@shorthands{%
  \bbl@activate{"}%
  \def\language@group{dutch}%
  \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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
  \def\-{\discretionary{-}{}{}}% << original def in latex.ltx
}

\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{%
  \nodutch@shorthands%
}

\def\blockextras@dutch{%
  \ifdutch@babelshorthands\dutch@shorthands\fi%
}

\def\inlineextras@dutch{%
  \ifdutch@babelshorthands\dutch@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-dutch.ldf>
%<*gloss-dv.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-dv.ldf}
%    \begin{macrocode}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-en-AU.ldf}[polyglossia: module for en-AU (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}
\ProvidesFile{gloss-en-CA.ldf}[polyglossia: module for en-CA (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}
\ProvidesFile{gloss-en-GB.ldf}[polyglossia: module for en-GB (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}
\ProvidesFile{gloss-en-NZ.ldf}[polyglossia: module for en-NZ (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}
\ProvidesFile{gloss-en-US.ldf}[polyglossia: module for en-US (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}
\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}
\ProvidesFile{gloss-english.ldf}[polyglossia: module for english]

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

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

% 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}%
      \xpg@info{Option: English, variant=british}%
   \or
      % british:
      \british@hyphentrue
      \british@dateformattrue
      \english@ordinalmonthdaytrue
      \SetLanguageKeys{english}{babelname=british,bcp47=en-GB}%
      \xpg@info{Option: english variant=british}%
   \or
      % us:
      \british@hyphenfalse
      \british@dateformatfalse
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
      \xpg@info{Option: English, variant=american}%
   \or
      % american:
      \british@hyphenfalse
      \british@dateformatfalse
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=american,bcp47=en-US}%
      \xpg@info{Option: English, variant=american}%
   \or
      % usmax:
      \british@hyphenfalse
      \british@dateformatfalse
      \english@ordinalmonthdayfalse
      \SetLanguageKeys{english}{babelname=american,bcp47=en-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}%
      \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}%
      \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}%
      \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}
\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}
\ProvidesFile{gloss-es-ES.ldf}[polyglossia: module for es-ES (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}
\ProvidesFile{gloss-es-MX.ldf}[polyglossia: module for es-MX (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}
\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}
\ProvidesFile{gloss-esperanto.ldf}[polyglossia: module for esperanto]
\PolyglossiaSetup{esperanto}{
  bcp47=eo,
  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}
\ProvidesFile{gloss-estonian.ldf}[polyglossia: module for estonian]
\PolyglossiaSetup{estonian}{
  bcp47=et,
  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}
\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}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-finnish.ldf}[polyglossia: module for finnish]
\PolyglossiaSetup{finnish}{
  bcp47=fi,
  hyphennames={finnish},
  hyphenmins={2,2},
  langtag=FIN,
  frenchspacing=true,
  fontsetup=true,
}

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

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

% Register default options
\xpg@initialize@gloss@options{finnish}{babelshorthands=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{%
  \bbl@activate{"}%
  \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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\def\captionsfinnish{%
   \def\refname{Viitteet}%
   \def\abstractname{Tiivistelmä}%
   \def\bibname{Kirjallisuutta}%
   \def\prefacename{Esipuhe}%
   \def\chaptername{Luku}%
   \def\appendixname{Liite}%
   \def\contentsname{Sisältö}%
   \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\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{%
  \nofinnish@shorthands%
}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-finnish.ldf>
%<*gloss-fr-CA.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-fr-CA.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-fr-CA.ldf}[polyglossia: module for fr-CA (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}
\ProvidesFile{gloss-fr-CH.ldf}[polyglossia: module for fr-CH (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}
\ProvidesFile{gloss-fr-FR.ldf}[polyglossia: module for fr-FR (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}
\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}
\ProvidesFile{gloss-french.ldf}[polyglossia: module for french]

\PolyglossiaSetup{french}{%
  bcp47=fr-FR,
  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=canadian]{french}{fr-CA}
\setlanguagealias*[variant=swiss]{french}{fr-CH}

% Babel aliases
\setlanguagealias[variant=acadian]{french}{acadien}
\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}%
      \french@thincolonspacefalse
   \or
      % canadian:
      \def\french@variant{canadien}%
      \SetLanguageKeys{french}{babelname=canadien,bcp47=fr-CA}%
      \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=canadien,bcp47=fr-CA}%
      \xpg@ifdefined{acadian}{}%
      {\xpg@warning{No hyphenation patterns were loaded for "French (Canada)"\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}%
      \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]{%
  \AfterPreamble{%
    \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
  }%
}

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

\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]{%
  \AfterPreamble{%
    \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
  }%
}

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

\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.}}%
   \def\@Fpt{\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\space}%
   \def\thepart{\@Fpt partie}%
   \def\partname{}%
   \def\pagename{page}%
   \def\seename{\emph{voir}}%
   \def\alsoname{\emph{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\noextras@french{%
   \nofrench@punctuation%
   \nofrench@fontsetup%
}

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

\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}
\ProvidesFile{gloss-friulan.ldf}[polyglossia: module for friulan]

% 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}
\ProvidesFile{gloss-friulian.ldf}[polyglossia: module for friulian]

\PolyglossiaSetup{friulian}{%
  bcp47=fur,
  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}
\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}
\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}
\ProvidesFile{gloss-gaelic.ldf}[polyglossia: module for gaelic]

\PolyglossiaSetup{gaelic}{
  bcp47=ga,
  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}%
      \xpg@fontsetup@latin{gaelic}%
   \or
      % scottish:
      \gdef\gaelic@variant{scottish}%
      \SetLanguageKeys{gaelic}{language=Gaelic,langtag=GAE,babelname=scottish,bcp47=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}
\ProvidesFile{gloss-galician.ldf}[polyglossia: module for galician]
\PolyglossiaSetup{galician}{
  bcp47=gl,
  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}
\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}
\ProvidesFile{gloss-georgian.ldf}[polyglossia: module for georgian]

\PolyglossiaSetup{georgian}{
  bcp47=ka,
  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}%
      {\georgian@numeralsfalse}%
}

\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{%
  \bbl@activate{"}%
  \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{--\hss--}}%
  \fi
  \declare@shorthand{georgian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

\def\nogeorgian@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\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%
   \nogeorgian@shorthands%
}

\def\blockextras@georgian{%
   \ifgeorgian@numerals\georgian@numbers\fi%
   \ifgeorgian@babelshorthands\georgian@shorthands\fi%
}

\def\inlineextras@georgian{%
   \ifgeorgian@babelshorthands\georgian@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-georgian.ldf>
%<*gloss-german.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-german.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-german.ldf}[polyglossia: module for german]

\PolyglossiaSetup{german}{
  bcp47=de-DE,
  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}%
         \else
           \SetLanguageKeys{german}{babelname=swissgerman,bcp47=de-CH-1901}%
         \fi
     \else
     \if@austrian@locale
         \if@german@blackletter
            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-Latf-AT-1901}%
         \else
            \SetLanguageKeys{german}{babelname=austrian,bcp47=de-AT-1901}%
         \fi
     \else
         \if@german@blackletter
            \SetLanguageKeys{german}{babelname=german,bcp47=de-Latf-DE-1901}%
         \else
            \SetLanguageKeys{german}{babelname=german,bcp47=de-DE-1901}%
         \fi
     \fi\fi
  \else
     \if@swiss@locale
         \if@german@blackletter
           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-Latf-CH}%
         \else
           \SetLanguageKeys{german}{babelname=nswissgerman,bcp47=de-CH}%
         \fi
     \else
     \if@austrian@locale
         \if@german@blackletter
           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-Latf-AT}%
         \else
           \SetLanguageKeys{german}{babelname=naustrian,bcp47=de-AT}%
         \fi
     \else
         \if@german@blackletter
           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-Latf-DE}%
         \else
           \SetLanguageKeys{german}{babelname=ngerman,bcp47=de-DE}%
         \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'}}

% Option defunc'ed, as bot 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,latesthyphen=false,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{%
  \bbl@activate{"}%
  \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}{\textormath{\bbl@discff}{f}}%
  \def\bbl@discff{\penalty\@M
    \afterassignment\bbl@insertff \let\bbl@nextff= }%
  \def\bbl@insertff{%
    \if f\bbl@nextff
      \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
    {\relax\discretionary{ff-}{f}{ff}\allowhyphens}{f\bbl@nextff}}%
  \let\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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\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{%
  \nogerman@shorthands%
}

\def\blockextras@german{%
  \ifgerman@babelshorthands\german@shorthands\fi
}

\def\inlineextras@german{%
  \ifgerman@babelshorthands\german@shorthands\fi
}

%    \end{macrocode}
% \iffalse
%</gloss-german.ldf>
%<*gloss-germanb.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-germanb.ldf}
%    \begin{macrocode}
\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}
\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}
\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}
\ProvidesFile{gloss-greek.ldf}[polyglossia: module for greek]

\PolyglossiaSetup{greek}{
  bcp47=el-monoton,
  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\tmp@mono{mono}
\def\tmp@monotonic{monotonic}
\def\tmp@poly{poly}
\def\tmp@polytonic{polytonic}
\def\tmp@ancient{ancient}
\def\tmp@ancientgreek{ancientgreek}

\def\greek@variant{monogreek}

\define@key{greek}{variant}[monotonic]{%
  \def\@tmpa{#1}%
  \xpg@ifdefined{greek}{}{%
      \xpg@nopatterns{greek}%
      \adddialect\l@greek\l@nohyphenation
  }
  \ifx\@tmpa\tmp@poly\def\@tmpa{polytonic}\fi
  \ifx\@tmpa\tmp@ancientgreek\def\@tmpa{ancient}\fi
  \ifx\@tmpa\tmp@polytonic%
    \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}%
    \xpg@info{Option: Polytonic Greek}%
  \else
    \ifx\@tmpa\tmp@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}%
      \xpg@info{Option: Ancient Greek}%
    \else %monotonic
      \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}%
      \xpg@info{Option: Monotonic Greek}%
    \fi
  \fi}

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


\newif\if@greek@numerals
\define@key{greek}{numerals}[greek]{%
  \ifstrequal{#1}{arabic}{\@greek@numeralsfalse}{\@greek@numeralstrue}%
}

\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

\newcommand{\greeknumerals}[2]{\greeknumber{#2}}
\newcommand{\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 \MakeUppercase{Ϛ}\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}
\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}
\ProvidesFile{gloss-hebrew.ldf}[polyglossia: module for hebrew]
\ifluatex
  \xpg@warning{Hebrew is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\RequireBidi
\RequirePackage{hebrewcal}

\PolyglossiaSetup{hebrew}{
  bcp47=he,
  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}

\newif\if@calendar@hebrew
\def\tmp@hebrew{hebrew}
\define@key{hebrew}{calendar}[gregorian]{%
	\message{Setting \string\if@calendar@hebrew}
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@hebrew%
    \@calendar@hebrewtrue%
	\else%
    \@calendar@hebrewfalse%
	\fi}

\newif\if@xpg@hebrew@marcheshvan
\@xpg@hebrew@marcheshvanfalse

\define@boolkey{hebrew}[@xpg@hebrew@]{marcheshvan}[true]{}

% hebrewcal.sty also defines the boolean key fullyear (default=false)

\newif\if@hebrew@numerals
\def\tmp@hebrew{hebrew}
\define@key{hebrew}{numerals}[arabic]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@hebrew%
	  \@hebrew@numeralstrue%
	\else%
    \@hebrew@numeralsfalse%
	\fi}

\setkeys{hebrew}{numerals}

% Register default options
\xpg@initialize@gloss@options{hebrew}{numerals=arabic,calendar=gregorian,marcheshvan=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
}

% Bidi inserts an RTL mark (0x200f) before any number, forcing numbers to
% RTL. Hebrew uses LTR numbers, though. So we insert an LTR mark to revert
% the directionality
\ifxetex
  \newcommand\xpg@hebrew@DigitsDotDashInterCharToks{\ifbool{@nonlatin}{\char"200E }{}}
\fi

\def\hebrew@ltr@numbers{%
    \ifxetex
      \XeTeXinterchartoks \bidi@sepmark@charclass  \bidi@digits@charclass = {\xpg@hebrew@DigitsDotDashInterCharToks}%
    \fi%
}

\def\nohebrew@ltr@numbers{%
    \ifxetex
      % This is bidi's original intervention
      \XeTeXinterchartoks \bidi@sepmark@charclass  \bidi@digits@charclass = {\DigitsDotDashInterCharToks}%
    \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%
}

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@hebrew{%
   \def\MakeUppercase##1{##1}%
}

\def\noextras@hebrew{%
   % restore original \MakeUppercase definition
   \let\MakeUppercase\xpg@save@MakeUppercase%
}

%    \end{macrocode}
% \iffalse
%</gloss-hebrew.ldf>
%<*gloss-hi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hi.ldf}
%    \begin{macrocode}
\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}
% 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,
  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}%
}

\def\tmp@western{Western}
\newif\ifhindi@devanagari@numerals
\hindi@devanagari@numeralstrue

\define@key{hindi}{numerals}[Devanagari]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@western
    \hindi@devanagari@numeralsfalse
  \fi%
}

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

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@hindi{%
  \def\MakeUppercase##1{##1}%
}

\def\noextras@hindi{%
   % restore original \MakeUppercase definition
   \let\MakeUppercase\xpg@save@MakeUppercase%
}

%    \end{macrocode}
% \iffalse
%</gloss-hindi.ldf>
%<*gloss-hr.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hr.ldf}
%    \begin{macrocode}
\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}
\ProvidesFile{gloss-hsb.ldf}[polyglossia: module for hsb (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}
\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}
\ProvidesFile{gloss-hungarian.ldf}[polyglossia: module for hungarian]

\PolyglossiaSetup{hungarian}{
  bcp47=hu,
  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'}}

% Register default options
\xpg@initialize@gloss@options{hungarian}{swapstrings=all}

\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{@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{@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{@part}{%
              \let\xpg@save@part@format\@part%
              \patchcmd{\@part}%
                       {\partname\nobreakspace\thepart}%
                       {\thepart.\nobreakspace\partname}%
                       {}%
                       {\xpg@warning{Failed to patch part for Hungarian}}%
            }{}%  (end \ifdefined\@part)
          }% (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\enskip}{}}
    }{% (not \ifdefined\chapterformat)
      \ifcsdef{@memptsize}{%
        % With memoir
        \let\xpg@save@chaptermark@format\chaptermark%
        \renewcommand*\chaptermark[1]{%
          \markboth{\memUChead{%
            \ifnum \c@secnumdepth >\m@ne
              \if@mainmatter
                \thechapter.\ \@chapapp\ %
              \fi
            \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}%
                    {}%
                    {\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}{%
        \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}{%
           \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\blockextras@hungarian{%
   \hungarian@capsformat%
}

\def\noextras@hungarian{%
   \nohungarian@capsformat%
   \let\ontoday\@undefined%
}

%    \end{macrocode}
% \iffalse
%</gloss-hungarian.ldf>
%<*gloss-hy.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hy.ldf}
%    \begin{macrocode}
\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}
\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}
\ProvidesFile{gloss-icelandic.ldf}[polyglossia: module for icelandic]
\PolyglossiaSetup{icelandic}{
  bcp47=is,
  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}
\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}
\ProvidesFile{gloss-interlingua.ldf}[polyglossia: module for interlingua]
\PolyglossiaSetup{interlingua}{
  bcp47=ia,
  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}
\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}
\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}
\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
\ProvidesFile{gloss-italian.ldf}[polyglossia: module for italian]
\PolyglossiaSetup{italian}{
  bcp47=it,
  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{%
  \bbl@activate{"}%
  \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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}
%%% 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@
   \noitalian@shorthands
   \xpgit@savedvalues
}

\def\blockextras@italian{%
   \lccode\string"2019=\string"2019
   \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000
   \finalhyphendemerits=50000000
   \ifitalian@babelshorthands\italian@shorthands\fi
}

\def\inlineextras@italian{%
   \lccode\string"2019=\string"2019
   \ifitalian@babelshorthands\italian@shorthands\fi
}
%%% CHANGES END %%%
%    \end{macrocode}
% \iffalse
%</gloss-italian.ldf>
%<*gloss-ja.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ja.ldf}
%    \begin{macrocode}
\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}
\ProvidesFile{gloss-japanese.ldf}[polyglossia: module for japanese]

\PolyglossiaSetup{japanese}{
	bcp47=ja,
	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}
\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
%% 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]
\ifluatex
  \xpg@warning{Kannada is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\PolyglossiaSetup{kannada}{
  bcp47=kn,
  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}
\ProvidesFile{gloss-khmer.ldf}[polyglossia: module for Khmer]
\PolyglossiaSetup{khmer}{
  bcp47=km,
	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%
	\else\@khmer@numeralsfalse\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}
\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}
\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}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-korean.ldf}[polyglossia: module for Korean]

\PolyglossiaSetup{korean}{
  bcp47=ko,
    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
    \ifdefined\titleformat
      \ifdefined\@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}}%
      \fi
      \ifdefined\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}%
      \fi
    \else % (not \ifdefined\titleformat)
      % With KOMA
      \ifdefined\sectionformat
        \ifdefined\partformat
          \let\xpg@save@part@format\partformat
          \renewcommand*{\partformat}{\koreanTHEname~\thepart~\partname}%
        \fi
        \ifdefined\chapterformat
          \let\xpg@save@chap@format\chapterformat
          \renewcommand*{\chapterformat}{\mbox{%
            \IfChapterUsesPrefixLine
            {%
              \ifx\@chapapp\korean@appendix@chapapp
                \chapappifchapterprefix\nobreakspace \thechapter\autodot
              \else
                \koreanTHEname\nobreakspace \thechapter\nobreakspace \chapappifchapterprefix{}%
              \fi
            }%
            {\thechapter\autodot\enskip}%
          }}%
        \fi
      \else % (not \ifdefined\sectionformat)
        % With memoir
        \ifdefined\@memptsize
          \ifdefined\@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
          \fi
          \ifdefined\@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
          \fi
        \else % (not \ifdefined\@memptsize)
          % With standard classes
          \ifdefined\@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}}%
          \fi
          \ifdefined\@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}}%
          \fi % (end \ifdefined\@part)
        \fi % (end \ifdefined\@memptsize)
      \fi % (end \ifdefined\sectionformat)
    \fi % (end \ifdefined\titleformat)
  \fi % (end \if@korean@swapheadings)
  %
  % Change running headers
  \if@korean@swapheaders
    \ifdefined\chapterformat
      % With KOMA
      \let\xpg@save@chaptermark@format\chaptermarkformat
      \renewcommand*\chaptermarkformat{%
        \IfChapterUsesPrefixLine
        {%
          \ifx\@chapapp\korean@appendix@chapapp
            \chapappifchapterprefix\ \thechapter\autodot
          \else
            \koreanTHEname\ \thechapter\ \chapappifchapterprefix{}%
          \fi
        }%
        {\thechapter\autodot}%
        \enskip
      }%
    \else % (not \ifdefined\chapterformat)
      \ifdefined\@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
                 }%
                 {}%
                 {}%
      \else % (not \ifdefined\@memptsize)
        % With standard classes
        \ifdefined\chaptermark
          \let\xpg@save@chaptermark@format\chaptermark
          \patchcmd{\chaptermark}%
                   {\@chapapp\ \thechapter}%
                   {%
                     \ifx\@chapapp\korean@appendix@chapapp
                       \appendixname\ \thechapter
                     \else
                       \koreanTHEname\ \thechapter\ \@chapapp
                     \fi
                   }%
                   {}%
                   {}%
        \fi % (end \ifdefined\chaptermark)
      \fi % (end \ifdefined\@memptsize)
    \fi % (end \ifdefined\chapterformat)
  \fi % (end \if@korean@swapheaders)
}

\def\nokorean@headingsformat{%
  % Reset chapter and part heading
  \ifdefined\titleformat
    % With titlesec
    \ifdefined\xpg@save@part@format
      \let\@part\xpg@save@part@format
    \fi
    \ifdefined\chapter
      \titleformat\chapter[display]%
        {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6}%
        {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit}%
    \fi
  \else % (not \ifdefined\titleformat)
    \ifdefined\sectionformat
      % With KOMA
      \ifdefined\xpg@save@part@format
        \let\partformat\xpg@save@part@format
      \fi
      \ifdefined\xpg@save@chap@format
        \let\chapterformat\xpg@save@chap@format
      \fi
    \else
      % With memoir and standard classes
      \ifdefined\xpg@save@part@format
        \let\@part\xpg@save@part@format
      \fi
      \ifdefined\xpg@save@chap@format
        \let\@makechapterhead\xpg@save@chap@format
      \fi
    \fi % (end \ifdefined\sectionformat)
  \fi % (end \ifdefined\titleformat)
  %
  % Reset headers
  \ifdefined\chaptermarkformat
    % With KOMA
    \ifdefined\xpg@save@chaptermark@format
      \let\chaptermarkformat\xpg@save@chaptermark@format
    \fi
  \else
    \ifdefined\chaptermark
      % With memoir and standard classes
      \ifdefined\xpg@save@chaptermark@format
        \let\chaptermark\xpg@save@chaptermark@format
      \fi
    \fi % (end \ifdefined\chaptermark)
  \fi % (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}
\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}
\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}
\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}
% Created on September 1, 2019
% Sina Ahmadi (https://sinaahmadi.github.io/)
\ProvidesFile{gloss-kurdish.ldf}[polyglossia: module for Kurdish]

\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{farsical}
\RequirePackage{hijrical}

\PolyglossiaSetup{kurdish}{
  bcp47=ckb,
  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}%
     \else
         \SetLanguageKeys{kurdish}{script=Latin,direction=LR,scripttag=latn,babelname=kurdish,bcp47=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}%
            \def\kurdish@script{arabic}%
        \else
            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=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}%
            \xpg@fontsetup@latin{kurdish}%
            \def\kurdish@script{latin}
        \else
            \SetLanguageKeys{kurdish}{script=Arabic,direction=RL,scripttag=arab,babelname=kurdish,bcp47=ckb-Arab}%
            \xpg@fontsetup@nonlatin{kurdish}%
        \fi
     \fi
  \fi
}

\def\tmp@western{western}
\define@key{kurdish}{numerals}[eastern]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@western\@western@numeralstrue\@force@western@numeralstrue\else%
    \@western@numeralsfalse%
  \fi%
}

%this is needed for \abjad in arabicnumbers.sty
\def\tmp@true{true}
\define@key{kurdish}{abjadjimnotail}[true]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@true\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êwerrok}%
  \def\listfigurename{Lîstî Wênekan}%
  \def\listtablename{Lîstî Xiştekan}%
  \def\indexname{Pêrrist}%
  \def\figurename{Wêney}%
  \def\tablename{Xiştey}%
  \def\partname{Beşî}%
  \def\enclname{Hawpêç}%
  \def\ccname{Rûnûs}%
  \def\headtoname{Bo}%
  \def\pagename{Laperre}%
  \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{Pirtuken bijartî}%
  \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{le vêya ji 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\datekurdish@kurmanji@arabic{%
   \datekurdish@sorani@arabic% FIXME: correct?
}

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

\newcommand{\kurdishnumerals}[2]{\kurdishnumber{#2}}

\def\kurdishnumber#1{%
  \if@western@numerals
    \number#1%
  \else
    \xpg@if@char@available{06F0}%
          {\farsidigits{\number#1}}%
          {\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}}%
}

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@kurdish{%
   \def\MakeUppercase##1{##1}%
}

\def\noextras@kurdish{%
   \let\MakeUppercase\xpg@save@MakeUppercase%
}

%    \end{macrocode}
% \iffalse
%</gloss-kurdish.ldf>
%<*gloss-kurmanji.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-kurmanji.ldf}
%    \begin{macrocode}
\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}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-lao.ldf}[polyglossia: module for Lao]
\ifluatex
  \xpg@warning{Lao is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\PolyglossiaSetup{lao}{
  bcp47=lo,
  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-latex.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latex.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-latex.ldf}[polyglossia: module for default language]

\PolyglossiaSetup{latex}{
  hyphennames={english},
  hyphenmins={2,3},
  langtag=ENG,
  fontsetup=true,
}

\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.ldf>
%<*gloss-latin.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latin.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-latin.ldf}[polyglossia: module for Latin v.2.3 2020-03-08]

\ExplSyntaxOn

\PolyglossiaSetup {latin}
  {
    bcp47 = la,
    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_digraphs_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_digraphs_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 }
    \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_digraphs_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 }
    \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_digraphs_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_digraphs_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 }
    \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_digraphs_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:
  {
    \str_set:Nx \l_tmpa_str
      {
        \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
      {
        \tl_mixed_case:n { \l_tmpa_str }
      }
      {
        \str_use:N \l_tmpa_str
      }
  }

\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 the unicode-math package
% (in case Latin is used as a secondary language, see #394). We have to
% turn it of if Latin is not the main language.

\protected@write \@auxout { } { \shorthandoff {=} } % for the aux file

\AtBeginDocument
  {
    \str_if_eq:VnTF \xpg@main@language {latin}
      {
        \iflatin@prosodicshorthands
        \else
          \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 {'}
      }
  }

\cs_new:Npn \polyglossia_latin_shorthands:
  {
    \def \language@group {latin}
    \bbl@activate {"}
    \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 {'}
    \bbl@activate {'}
    \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 '=' shorthand is normally turned off to avoid problems with key=value
    % interfaces. We turn it 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
          }
      }
    \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_digraph_shorthand:Nnn E { Æ }
                {
                  \polyglossia_latin_digraph_shorthand:Nnn e { Æ }
                    {
                      \polyglossia_latin_allow_hyphens: A
                    }
                }
            }
        {a} { \polyglossia_latin_digraph_shorthand:Nnn e { æ }
                {
                  \polyglossia_latin_allow_hyphens: a
                }
            }
        {O} { \polyglossia_latin_digraph_shorthand:Nnn E { Œ }
                {
                  \polyglossia_latin_digraph_shorthand:Nnn e { Œ }
                    {
                      \polyglossia_latin_allow_hyphens: O
                    }
                }
            }
        {o} { \polyglossia_latin_digraph_shorthand:Nnn e { œ }
                {
                  \polyglossia_latin_allow_hyphens: o
                }
            }
        {|} { \polyglossia_latin_allow_hyphens: }
        {<} { « }
        {>} { » }
      }
      {
        \token_if_letter:NTF #1 { \polyglossia_latin_allow_hyphens: #1 }
          {
            \token_if_eq_meaning:NNTF #1 \AE { \polyglossia_latin_allow_hyphens: #1 }
              {
                \token_if_eq_meaning:NNTF #1 \ae { \polyglossia_latin_allow_hyphens: #1 }
                  {
                    \token_if_eq_meaning:NNTF #1 \OE { \polyglossia_latin_allow_hyphens: #1 }
                      {
                        \token_if_eq_meaning:NNTF #1 \oe { \polyglossia_latin_allow_hyphens: #1 }
                          {
                            \token_to_str:N "
                            #1
                          }
                      }
                  }
              }
          }
      }
  }

\cs_new:Npn \polyglossia_latin_put_acute:N #1
  {
    \str_case:nnF {#1}
      {
        {A} { \polyglossia_latin_digraph_shorthand:Nnn E { Ǽ }
                {
                  \polyglossia_latin_digraph_shorthand:Nnn e { Ǽ } { Á }
                }
            }
        {a} { \polyglossia_latin_digraph_shorthand:Nnn e { ǽ } { á } }
        {E} { É }
        {e} { é }
        {I} { Í }
        {i} { í }
        {O} { \polyglossia_latin_digraph_shorthand:Nnn E { \'Œ }
                {
                  \polyglossia_latin_digraph_shorthand:Nnn e { \'Œ } { Ó }
                }
            }
        {o} { \polyglossia_latin_digraph_shorthand:Nnn e { \'œ } { ó } }
        {U} { Ú }
        {u} { ú }
        {V} { \' V } % V may be a vowel, but lowercase v is never used as a vowel.
        {Y} { Ý }
        {y} { ý }
        {Æ} { Ǽ }
        {æ} { ǽ }
        {Œ} { \'Œ }
        {œ} { \'œ }
      }
      {
        \token_if_eq_meaning:NNTF #1 \AE { Ǽ }
          {
            \token_if_eq_meaning:NNTF #1 \ae { ǽ }
              {
                \token_if_eq_meaning:NNTF #1 \OE { \'Œ }
                  {
                    \token_if_eq_meaning:NNTF #1 \oe { \'œ }
                      {
                        \token_to_str:N '
                        #1
                      }
                  }
              }
          }
      }
  }

\cs_new:Npn \polyglossia_latin_put_macron:N #1
  {
    \str_case:nnF {#1}
      {
        {A} { \polyglossia_latin_diphthong_macron:NNn AE
                {
                  \polyglossia_latin_diphthong_macron:NNn Ae
                    {
                      \polyglossia_latin_diphthong_macron:NNn AU
                        {
                          \polyglossia_latin_diphthong_macron:NNn Au { Ā }
                        }
                    }
                }
            }
        {a} { \polyglossia_latin_diphthong_macron:NNn 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_diphthong_macron:NNn OE
                {
                  \polyglossia_latin_diphthong_macron:NNn Oe { Ō }
                }
            }
        {o} { \polyglossia_latin_diphthong_macron:NNn oe { ō } }
        {U} { Ū }
        {u} { ū }
        {V} { \= V } % V may be a vowel, but lowercase v is never used as a vowel.
        {Y} { Ȳ }
        {y} { ȳ }
      }
      {
        \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_digraph_shorthand:Nnn #1#2#3
% #1: second letter of digraph (E or e)
% #2: digraph character
% #3: non-digraph code
  {
    \bool_if:NTF \l_polyglossia_latin_use_digraphs_bool
      {
        \peek_meaning_remove:NTF #1 {#2} {#3}
      }
      {
        #3
      }
  }

\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 \char "35E \relax } {#3} % U+35E: combining double macron
  }

\cs_new:Npn \polyglossia_latin_no_shorthands:
  {
    \bbl@deactivate {"}
    \bbl@deactivate {'}
    \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 {=}
  }


%%%%% 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
    \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:
    \fi
    \iflatin@prosodicshorthands
      \polyglossia_latin_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-2020
%%
%%   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}
\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}
\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}
\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}
\ProvidesFile{gloss-latvian.ldf}[polyglossia: module for latvian]
\PolyglossiaSetup{latvian}{
  bcp47=lv,
  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}
% Translated by Paulius Sladkevičius <komsas@gmail.com>

\ProvidesFile{gloss-lithuanian.ldf}[polyglossia: module for lithuanian]
\PolyglossiaSetup{lithuanian}{
  bcp47=lt,
  hyphennames={lithuanian},
  hyphenmins={2,2},
  langtag=LTH,
  indentfirst=true, % TODO Dokumentų rengimo taisyklių, patvirtintų Lietuvos vyriausiojo archyvaro 2011 m. liepos 4 d. įsakymu Nr. V-117, 29.1 punktą
  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}% TODO letter case
   \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ė}% TODO any special reason for \protect in babel?
   \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}% TODO some other variants are considered in babel?
   \def\proofname{Įrodymas}%
   \def\glossaryname{Terminų žodynas}% TODO some other variants are considered in babel?
}

\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}
\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}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-macedonian.ldf}[polyglossia: module for macedonian]
\PolyglossiaSetup{macedonian}{
  bcp47=mk,
  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}
\ProvidesFile{gloss-magyar.ldf}[polyglossia: module for 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}
\ProvidesFile{gloss-malay.ldf}[polyglossia: module for malay]

\RequirePackage{hijrical}

\PolyglossiaSetup{malay}{%
  bcp47=id,
  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}%
      \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}%
      \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 Pebruari\or Maret\or April\or Mei\or Juni\or
    Juli\or Agustus\or September\or Oktober\or Nopember\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}
﻿\ProvidesFile{gloss-malayalam.ldf}[polyglossia: module for malayalam]
\ifluatex
  \xpg@warning{Malayalam is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
% Translations provided by Kevin & Siji, 01-11-2009

\PolyglossiaSetup{malayalam}{
  bcp47=ml,
  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}
% 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]
\ifluatex
  \xpg@warning{Marathi is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\RequirePackage{devanagaridigits}

\PolyglossiaSetup{marathi}{
  bcp47=mr,
  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%
   \or
      % Devanagari:
      \marathi@devanagari@numeralstrue%
   \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 अः\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 ळ\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 शंभर\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
}

\def\blockextras@marathi{%
  \let\xpg@orig@baselinestretch\baselinestrech%
  \renewcommand{\baselinestretch}{1.2}%
  \renewcommand{\labelitemii}{$\rightarrow$}%
}

\let\xpg@orig@labelitemii\labelitemii

\def\noextras@marathi{%
  \let\baselinestrech\xpg@orig@baselinestretch%
  \let\labelitemii\xpg@orig@labelitemii%
}

%    \end{macrocode}
% \iffalse
%</gloss-marathi.ldf>
%<*gloss-mk.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-mk.ldf}
%    \begin{macrocode}
\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}
\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}
\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}
\ProvidesFile{gloss-mongolian.ldf}[polyglossia: module for mongolian]

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{mongolian}{
  bcp47=mn,
  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{%
  \bbl@activate{"}%
  \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{--\hss--}}%
  \fi
  \declare@shorthand{mongolian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

\def\nomongolian@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

% 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%
   \nomongolian@shorthands%
}

\def\blockextras@mongolian{%
   \ifcyrillic@numerals\mongolian@numbers\fi%
   \ifmongolian@babelshorthands\mongolian@shorthands\fi%
}

\def\inlineextras@mongolian{%
   \ifmongolian@babelshorthands\mongolian@shorthands\fi%
}

%    \end{macrocode}
% \iffalse
%</gloss-mongolian.ldf>
%<*gloss-mr.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-mr.ldf}
%    \begin{macrocode}
\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}
\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}
\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}
\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}
\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}
\ProvidesFile{gloss-nko.ldf}[Polyglossia: module for N’Ko v0.1 2013/05/19]
\PolyglossiaSetup{nko}{%
  bcp47=nko,
  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}
\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}
\ProvidesFile{gloss-norwegian.ldf}[polyglossia: module for norwegian]
\PolyglossiaSetup{norwegian}{
  bcp47=nn,
  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}%
      \xpg@fontsetup@latin{norwegian}%
   \or
      % bokmal:
      \def\norwegian@variant{norsk}%
      \SetLanguageKeys{norwegian}{langtag=NOR,babelname=norsk,bcp47=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}
\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}
\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}
%%
%% 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}[2016/02/04 v0.3 polyglossia:
     module for Occitan]
\PolyglossiaSetup{occitan}{
  bcp47=oc,
  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{%
  \bbl@activate{"}%
  \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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}
\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@
   \nooccitan@shorthands
   \xpgoc@savedvalues
}
\def\blockextras@occitan{%
   \lccode\string"2019=\string"2019
   \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000
   \finalhyphendemerits=50000000
   \ifoccitan@babelshorthands\occitan@shorthands\fi
}

\def\inlineextras@occitan{%
   \lccode\string"2019=\string"2019
   \ifoccitan@babelshorthands\occitan@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-persian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-persian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-persian.ldf}[polyglossia: module for persian]
\ifluatex
  \xpg@warning{Persian is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{farsical}
\RequirePackage{hijrical}
\PolyglossiaSetup{persian}{
  bcp47=fa,
  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
\def\tmp@western{western}
\define@key{persian}{numerals}[eastern]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@western\@western@numeralstrue\else%
    \@western@numeralsfalse%
  \fi}

%this is needed for \abjad in arabicnumbers.sty
\def\tmp@true{true}
\define@key{persian}{abjadjimnotail}[true]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@true\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}%
          {\farsidigits{\number#1}}%
          {\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%
}

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@persian{%
   \def\MakeUppercase##1{##1}%
}

\def\noextras@persian{%
   % restore original \MakeUppercase definition
   \let\MakeUppercase\xpg@save@MakeUppercase
}
%    \end{macrocode}
% \iffalse
%</gloss-persian.ldf>
%<*gloss-piedmontese.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-piedmontese.ldf}
%    \begin{macrocode}
% !TEX encoding = UTF-8 Unicode
\ProvidesFile{gloss-piedmontese.ldf}[2013/02/12 v1.0 polyglossia: module for piedmontese]
\makeatletter
\PolyglossiaSetup{piedmontese}{
  bcp47=pms,
  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{%
  \bbl@activate{"}%
  \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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}
\@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@
   \nopiedmontese@shorthands
   \xpgpms@savedvalues
}

\def\blockextras@piedmontese{%
   \lccode\string"2019=\string"2019
   \clubpenalty=3000 \@clubpenalty=3000 \widowpenalty=3000
   \finalhyphendemerits=50000000
   \ifpiedmontese@babelshorthands\piedmontese@shorthands\fi
}

\def\inlineextras@piedmontese{%
   \lccode\string"2019=\string"2019
   \ifpiedmontese@babelshorthands\piedmontese@shorthands\fi
}
%%% CHANGES END %%%
%    \end{macrocode}
% \iffalse
%</gloss-piedmontese.ldf>
%<*gloss-polish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-polish.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-polish.ldf}[polyglossia: module for polish]
\PolyglossiaSetup{polish}{
  bcp47=pl,
  hyphennames={polish},
  hyphenmins={2,2},
  langtag=PLK,
  frenchspacing=true,
  fontsetup=true,
}

% BCP-47 compliant aliases
\setlanguagealias*{polish}{pl}

\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{Glossary}% <-- Needs translation
  }

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

%    \end{macrocode}
% \iffalse
%</gloss-polish.ldf>
%<*gloss-polutonikogreek.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-polutonikogreek.ldf}
%    \begin{macrocode}
\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}
\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}
\ProvidesFile{gloss-portuguese.ldf}[polyglossia: module for portuguese]

\PolyglossiaSetup{portuguese}{
  bcp47=pt-PT,
  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}

\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}%
   \or
      % brazilian:
      \def\portuguese@variant{brazil}%
      \SetLanguageKeys{portuguese}{babelname=brazil,bcp47=pt-BR}%
      \xpg@ifdefined{brazil}{}%
	    {\xpg@warning{No hyphenation patterns were loaded for "Portuguese (Brazil)"\MessageBreak
	      I will use the standard patterns for Portuguese instead}%
	    \adddialect\l@brazil\l@portuges\relax}%
   \fi
   \xpg@info{Option: portuguese, variant=\xpg@val}%
}{\xpg@warning{Unknown portuguese variant `#1'}}


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


\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%
}
     
%    \end{macrocode}
% \iffalse
%</gloss-portuguese.ldf>
%<*gloss-romanian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-romanian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-romanian.ldf}[polyglossia: module for romanian]

\PolyglossiaSetup{romanian}{
  bcp47=ro,
  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}
\ProvidesFile{gloss-romansh.ldf}[polyglossia: module for romansh]
\makeatletter
\PolyglossiaSetup{romansh}{%
  bcp47=rm,
  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}
\ProvidesFile{gloss-russian.ldf}[polyglossia: module for russian]

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{russian}{
  bcp47=ru,
  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}}%
    {\@russian@moderntrue\SetLanguageKeys{russian}{bcp47=ru}}%
}

\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%
   \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: 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]{}


% Register default options
\xpg@initialize@gloss@options{russian}{babelshorthands=false,spelling=modern,numerals=arabic,indentfirst=false}


\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{%
  \bbl@activate{"}%
  \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{--\hss--}}%
  \fi
  \declare@shorthand{russian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

\def\norussian@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}


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

% The following is based on some ideas from ruscor.sty
\def\russian@capsformat{%
   \ifdef{\KOMAScript}{%
      \ifdef{\chapterformat}{%
        \renewcommand{\chapterformat}{\prechapter\thechapter\postchapter}}{}%
      \ifdef{\sectionformat}{%
        \renewcommand{\sectionformat}{\presection\thesection\postsection}}{}%
      \ifdef{\subsectionformat}{%
        \renewcommand{\subsectionformat}{\presubsection\thesubsection\postsubsection}}{}%
      \ifdef{\subsubsectionformat}{%
        \renewcommand{\subsubsectionformat}{\presubsubsection\thesubsubsection\postsubsubsection}}{}%
      \ifdef{\paragraphformat}{%
        \renewcommand{\paragraphformat}{\preparagraph\theparagraph\postparagraph}}{}%
      \ifdef{\subparagraphformat}{%
        \renewcommand{\subparagraphformat}{\presubparagraph\thesubparagraph\postsubparagraph}}{}%
   }{%
      \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{\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{%
   \ifdef{\KOMAScript}{%
      \ifdef{\chapterformat}{%
        \renewcommand{\chapterformat}{\thechapter\autodot\enskip}}{}%
      \ifdef{\sectionformat}{%
        \renewcommand{\sectionformat}{\thesection\autodot\enskip}}{}%
      \ifdef{\subsectionformat}{%
        \renewcommand{\subsectionformat}{\thesubsection\autodot\enskip}}{}%
      \ifdef{\subsubsectionformat}{%
        \renewcommand{\subsubsectionformat}{\thesubsubsection\autodot\enskip}}{}%
      \ifdef{\paragraphformat}{%
        \renewcommand{\paragraphformat}{\theparagraph\autodot\enskip}}{}%
      \ifdef{\subparagraphformat}{%
        \renewcommand{\subparagraphformat}{\thesubparagraph\autodot\enskip}}{}%
   }{%
      \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
   }%
   \ifcyrillic@numerals\norussian@numbers\fi%
   \norussian@shorthands%
}

\def\blockextras@russian{%
   \russian@capsformat%
   \ifcyrillic@numerals\russian@numbers\fi%
   \ifrussian@babelshorthands\russian@shorthands\fi%
}

\def\inlineextras@russian{%
   \ifrussian@babelshorthands\russian@shorthands\fi%
}

%%% These lines taken from russianb.ldf, part of babel package.
% make it optional?
\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}{№}

%    \end{macrocode}
% \iffalse
%</gloss-russian.ldf>
%<*gloss-sami.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-sami.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-sami.ldf}[polyglossia: module for sami]

\PolyglossiaSetup{sami}{
  bcp47=se,
  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}
\ProvidesFile{gloss-samin.ldf}[polyglossia: module for samin]

% 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}
\ProvidesFile{gloss-sanskrit.ldf}[polyglossia: module for sanskrit]
\ifluatex
  \xpg@warning{Sanskrit is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi

\RequirePackage{devanagaridigits}

\PolyglossiaSetup{sanskrit}{
  bcp47=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}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Gujarati{%
  \SetLanguageKeys{sanskrit}{scripttag=gujr,script=Gujarati,bcp47=sa-Gujr}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Malayalam{%
  \SetLanguageKeys{sanskrit}{scripttag=mlym,script=Malayalam,bcp47=sa-Mlym}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Bengali{%
  \SetLanguageKeys{sanskrit}{scripttag=beng,script=Bengali,bcp47=sa-Beng}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Kannada{%
  \SetLanguageKeys{sanskrit}{scripttag=knda,script=Kannada,bcp47=sa-Knda}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Telugu{%
  \SetLanguageKeys{sanskrit}{scripttag=telu,script=Telugu,bcp47=sa-Relu}
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Latin{%
  \SetLanguageKeys{sanskrit}{scripttag=latn,script=Latin,bcp47=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%
   \or
      % Western:
      \sanskrit@devanagari@numeralsfalse%
   \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}


\newcommand{\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}
\ProvidesFile{gloss-scottish.ldf}[polyglossia: module for scottish]

% 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}
\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,
  langtag=SRB,
  hyphennames={serbian},
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=false,
  localnumeral=serbiannumerals,
  Localnumeral=Serbiannumerals
  %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}

\newif\if@serbian@cyr
\define@choicekey*+{serbian}{Script}[\xpg@val\xpg@nr]{cyrillic,latin}[cyrillic]{%
   \ifcase\xpg@nr\relax
      % cyrillic:
      \@serbian@cyrtrue
      \SetLanguageKeys{serbian}{scripttag=cyrl,script=Cyrillic,babelname=serbianc,bcp47=sr-Cyrl}
      \xpg@fontsetup@nonlatin{serbian}%
   \or
      % latin:
      \@serbian@cyrfalse
      \SetLanguageKeys{serbian}{scripttag=latn,script=Latin,bcp47=sr-Latn}
      \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
   \xpg@info{Option: Serbian, script=\xpg@val}%
}{\xpg@warning{Unknown Serbian script `#1'}}

\define@key{serbian}{script}[Cyrillic]{\setkeys{serbian}{Script=#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%
   \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: Serbian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Serbian numerals value `#1'}}

\setkeys{serbian}{Script,numerals}

% Register default options
\xpg@initialize@gloss@options{serbian}{script=Cyrillic,numerals=arabic}

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

\def\dateserbian@lat{%
   \def\today{\number\day .~\ifcase\month\or
    januar\or februar\or mart\or april\or maj\or
    jun\or jul\or avgust\or septembar\or oktobar\or novembar\or
    decembar\fi \space \number\year.}%
}

\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{Речник непознатих речи}%
}

\def\dateserbian@cyr{%
   \def\today{\number\day .~\ifcase\month\or
    јануар\or фебруар\or март\or април\or мај\or
    јун\or јул\or август\or септембар\or октобар\or новембар\or
    децембар\fi \space \number\year.}%
}


\newcommand{\serbiannumerals}[2]{\serbiannumber{#2}}
\newcommand{\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
}

\def\blockextras@serbian{%
   \ifcyrillic@numerals\serbian@numbers\fi
}
 
\def\noextras@serbian{%
   \ifcyrillic@numerals\noserbian@numbers\fi
}

\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 Я%
   \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 я%
   \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}
\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}
\ProvidesFile{gloss-slovak.ldf}[polyglossia: module for slovak]

\PolyglossiaSetup{slovak}{
  bcp47=sk,
  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{"}%
}{}

\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{%
  \bbl@activate{"}%
  \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{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\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
\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}
        \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\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{%
  \noslovak@shorthands%
  \noslovak@hyphens%
  \noslovak@vlna%
  \ifxetex\XeTeXinterchartokenstate=0\fi%
}

\def\blockextras@slovak{%
  \ifslovak@babelshorthands\slovak@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\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}
\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}
\ProvidesFile{gloss-slovenian.ldf}[polyglossia: module for slovenian]

\PolyglossiaSetup{slovenian}{
  bcp47=sl,
  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}
\ProvidesFile{gloss-sorbian.ldf}[polyglossia: module for sorbian]

\PolyglossiaSetup{sorbian}{
  bcp47=hsb,
  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}%
      \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}%
      \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}
\ProvidesFile{gloss-spanish.ldf}[polyglossia: module for spanish]

\PolyglossiaSetup{spanish}{
  bcp47=es-ES,
  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}%
   \or
      % mexican:
      \@spanish@mexicotrue%
      \SetLanguageKeys{spanish}{babelname=spanishmx,bcp47=es-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%
}

\newcommand*\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}
\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}
\ProvidesFile{gloss-swedish.ldf}[polyglossia: module for swedish]

\PolyglossiaSetup{swedish}{
  bcp47=sv,
  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}
\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}
\ProvidesFile{gloss-syriac.ldf}[polyglossia: module for syriac]
\ifluatex
  \xpg@warning{Syriac is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\RequireBidi
\RequirePackage{arabicnumbers}

\PolyglossiaSetup{syriac}{
  bcp47=syr,
  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
\def\tmp@eastern{eastern}
\def\tmp@abjad{abjad}
\define@key{syriac}{numerals}[western]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@abjad
	  \let\syriacnumber\abjadsyriac
	\else
	  \ifx\@tmpa\tmp@eastern
      \@eastern@numeralstrue
	  \else
      \@eastern@numeralsfalse
 	  \fi
  \fi}

% 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}%
          {\protect\arabicdigits{\number#1}}%
          {\arabicdigits{\number#1}
           \ifcsdef{arabicfont}%
	     {\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%
}

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@syriac{%
   \def\MakeUppercase##1{##1}%
}

\def\noextras@syriac{%
   % restore original \MakeUppercase definition
   \let\MakeUppercase\xpg@save@MakeUppercase%
}

%    \end{macrocode}
% \iffalse
%</gloss-syriac.ldf>
%<*gloss-tamil.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-tamil.ldf}
%    \begin{macrocode}
﻿\ProvidesFile{gloss-tamil.ldf}[polyglossia: module for tamil]
\ifluatex
  \xpg@warning{Tamil is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
% Translations provided by Kevin & Siji, 01-11-2009

\PolyglossiaSetup{tamil}{
  bcp47=ta,
  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}
\ProvidesFile{gloss-telugu.ldf}[polyglossia: module for telugu]
\ifluatex
  \xpg@warning{Telugu is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
% Translations provided by Anmol Sharma <unmole.in@gmail.com>

\PolyglossiaSetup{telugu}{
  bcp47=te,
  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}
\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/
%%%%
\ifluatex
  \xpg@warning{Thai is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\PolyglossiaSetup{thai}{
  bcp47=th,
  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\else
	  \@thai@numeralsfalse\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}
\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,
  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\else
	  \@tibetan@numeralsfalse\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%
}

\def\tibetan@globalnumbers{%
   \let\xpg@orig@arabic\@arabic%
   \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}
\ProvidesFile{gloss-turkish.ldf}[polyglossia: module for turkish]
\RequirePackage{hijrical}
\PolyglossiaSetup{turkish}{
  bcp47=tr,
  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}
\ProvidesFile{gloss-turkmen.ldf}[polyglossia: module for turkmen]
%% Translations provided by Nazar Annagurban <nazartm at gmail dot com>
\PolyglossiaSetup{turkmen}{
  bcp47=tk,
  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-ukrainian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-ukrainian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-ukrainian.ldf}[polyglossia: module for ukrainian]
% Strings taken from Babel
% and revised by Roman Kyrylych

\RequirePackage{xpg-cyrillicnumbers}

\PolyglossiaSetup{ukrainian}{%
  bcp47=uk,
  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%
   \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: Ukrainian, numerals=\xpg@val}%
}{\xpg@warning{Unknown Ukrainian numerals value `#1'}}


% Register default options
\xpg@initialize@gloss@options{ukrainian}{numerals=arabic}

\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{%
  \bbl@activate{"}%
  \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{--\hss--}}
  \fi
  \declare@shorthand{ukrainian}{",}{\nobreak\hskip.2em\ignorespaces}%
}

\def\noukrainian@shorthands{%
  \@ifundefined{initiate@active@char}{}{\bbl@deactivate{"}}%
}

\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
      \serbian@asbuk@alph{#1}%
    \else
      \cyr@alph{#1}%
    \fi
  \else
    \number#1%
  \fi%
}

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

\let\ukrainiannumeral=\ukrainiannumber
\let\Ukrainiannumeral=\Ukrainiannumber

\def\Asbuk#1{\expandafter\ukranian@asbuk@Alph\csname c@#1\endcsname}
\def\asbuk#1{\expandafter\ukranian@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\ukranian@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}{ukranian@asbuk@Alph}\fi%
}

\def\ukranian@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}{ukranian@asbuk@alph}\fi%
}

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

\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
  \noukrainian@shorthands%
}

\def\blockextras@ukrainian{%
  \ukrainian@capsformat%
  \ifcyrillic@numerals\ukrainian@numbers\fi
  \ifukrainian@babelshorthands\ukrainian@shorthands\fi
}

\def\inlineextras@ukrainian{%
  \ifukrainian@babelshorthands\ukrainian@shorthands\fi%
}

%%% stuff from Babel
% make it optional?
\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}

%    \end{macrocode}
% \iffalse
%</gloss-ukrainian.ldf>
%<*gloss-uppersorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-uppersorbian.ldf}
%    \begin{macrocode}
\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}
%%% Adapted from a file contributed by Kamal Abdali
\ProvidesFile{gloss-urdu.ldf}[polyglossia: module for Urdu]
\ifluatex
  \xpg@warning{Urdu is not supported with LuaTeX.\MessageBreak
I will proceed with the compilation, but\MessageBreak
the output is not guaranteed to be correct\MessageBreak
and may look very wrong.}
\fi
\RequireBidi
\RequirePackage{arabicnumbers}
\RequirePackage{hijrical}

\PolyglossiaSetup{urdu}{
  bcp47=ur,
  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
\def\tmp@western{western}
\define@key{urdu}{numerals}[eastern]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@western\@western@numeralstrue%
	  \else\@western@numeralsfalse%
	\fi}

%% TODO USE boolkey instead !!!
%this is needed for \abjad in arabicnumbers.sty
\def\tmp@true{true}
\define@key{urdu}{abjadjimnotail}[true]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@true\abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi}

\newif\if@hijrical
\def\tmp@hijri{hijri}
\define@key{urdu}{calendar}[gregorian]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@hijri\@hijricaltrue%
    \else\@hijricalfalse%
  \fi}

\define@key{urdu}{hijricorrection}[0]{%
  \gdef\@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[\@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???
    \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%
}

% Save original \MakeUppercase definition
\let\xpg@save@MakeUppercase\MakeUppercase

\def\blockextras@urdu{%
  \def\MakeUppercase##1{##1}%
}

\def\noextras@urdu{%
   % restore original \MakeUppercase definition
   \let\MakeUppercase\xpg@save@MakeUppercase%
}

%    \end{macrocode}
% \iffalse
%</gloss-urdu.ldf>
%<*gloss-usorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-usorbian.ldf}
%    \begin{macrocode}
\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-vietnamese.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-vietnamese.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-vietnamese.ldf}[polyglossia: module for vietnamese]
%% Strings contributed by Daniel Owens < dhowens . pmbx . net >

\PolyglossiaSetup{vietnamese}{
  bcp47=vi,
  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}
\ProvidesFile{gloss-welsh.ldf}[polyglossia: module for welsh]

\PolyglossiaSetup{welsh}{
  bcp47=cy,
  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>
%<*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>
%<*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}
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
--

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}
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}
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 = utf8.char(current.char) -- requires Lua 5.3
                local leftspace  = left_space[attr][char]
                local rightspace = right_space[attr][char]
                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
                            local prevprev = getprev(prev)
                            -- do not add space after left (opening) bracket and between question/exclamation marks
                            space_exception = someleftbracket(prev) or question_exclamation_sequence(prev, current)
                            if somespace(prev) then
                            -- TODO: there is a question here: do we override a preceding space or not?...
                                if somepenalty(prevprev, 10000) then
                                    head = remove_node(head, prevprev)
                                end
                                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 = remove_node(head, next)
                                head = remove_node(head, nextnext)
                            elseif somespace(next) then
                                head = 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}
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}
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}

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
%<*../README>

   ¦----------------------------------------------¦
   ¦                                              ¦
   ¦       THE POLYGLOSSIA PACKAGE v1.48          ¦
   ¦                                              ¦
   ¦     Modern multilingual typesetting          ¦
   ¦        with XeLaTeX and LuaLaTeX             ¦
   ¦                                              ¦
   ¦----------------------------------------------¦

This package provides an alternative to Babel for users of XeLaTeX and LuaLaTeX
(with a few languages incompletely supported for the latter). This version
includes support for over 70 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).

LICENSE

Copyright (c) 2008-2010 François Charette, 2013 Élie Roux, 2011-2020 Arthur Reutenauer,
Copyright (c) 2019-2020 Bastien Roucariès, 2019-2020 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 me
to track the issues and follow progress.
%</../README>
%<*Changelog>
1.48 (25-03-2020)

No new features

Bug fixes:
  * Fix use of Hebrew with LuaLaTeX (#389).
  * Do not overwrite footnote redefinitions of other packages
    with Latin and French (#391)
  * Fix Serbian cyrillic numerals code (#392).
  * Fix [no]localmarks option, whose logic was swapped (part of #395).
  * Protect localmarks function against uppercased language names (part of #395).
  * Fix buggy redefinition of \@markright with option localmarks (#396).
  * Fix incompatibility between Latin and unicode-math (#394).
  * Make (undocumented) \defineshorthand command (imported from babel) work.
  * Fix usage of localmarks option without value.
  * Emergency fixes for bugs caused by updates in Babel’s switch.def (#399 and #400).

Interface and defaults changes:
  * Use private macros in keyval choice keys (#390).

1.47 (29-01-2020)

New features:
  * IETF BCP-47 compliant language tags can now be used for loading and switching
    languages alternatively to language names (#226).
  * New commands \languageid{<type>} and \mainlanguageid{<type>}.
  * New test \iflanguageidloaded.
  * New list \xpg@bcp@loaded.
  * New environment {lang}{<lang>} (equivalent to {<lang>},  but also available with
    \setlanguagealias* which does not define dedicated alias environments).
  * New gloss option totalhyphenmin (corresponds to LuaTeX's \hyphenationmin) (#111).
  * New test \iflanguageoption{<lang>}{<key>}{<val>} (#364).
  * Restore simple alphabetic numbering for \asbuk and \Asbuk in Belarusian, Mongolian,
    Russian, Serbian, and Ukrainian (#377).
  * New command \AsbukTrad and \asbukTrad for Belarusian, Mongolian, Russian, Serbian,
    and Ukrainian which uses traditional alphanumerical numbering.
  * New numerals option "cyrillic-trad" and "cyrillic-alph" to differentiate simple
    alphabetic and traditional alpnanumerical Cyrillic numbering.
  * \selectbackgroundlanguage and \resetdefaultlanguage now also support language
    aliases.
  * New macro \charifavailable{<char code>}{<substitution>}.
  * Add French language variant "swiss".
  * Implement babelshorthands for Croatian.
  * Implement \localnumeral for Japanese.

Bug fixes:
  * Fix font family issue in headers (#355).
  * Fix whitespace issues in \text<lang> (#356).
  * Fix option-less \babelname in multi-variant languages (#357).
  * Fix some spacing inconsistencies with French, Latin, and Sanskrit (#358).
  * Fix issues with babelshorthands and graphics package (#368).
  * Fix some captions and improve numbering in Marathi (#370).
  * Fix Hungarian swapstrings feature (#373).
  * Fix lua punctuation code problem (#374).
  * Fix Bengali changecounternumbering option (#381).
  * Fix whitespace issue in Japanese (#387).
  * Fix \text<lang> command with multiple paragraphs.
  * Actually implement documented german spelling variant '1996' (= 'new').
  * Fix Slovenian localalph option.
  * Fix Czech and Slovak splithyphens with typewriter fonts.
  * farsical.sty: fix spacing issue with some month names.
  * Fix directionalty of numbers in Hebrew with XeTeX.
  * Improve interoperatability with biblatex (some language variants did not work yet).

Interface and defaults changes:
  * 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 (#363).
    Concerned are the following options:
    - babelshorthands in language belarusian, mongolian, ukrainian, and russian
      ('babelshorthands' now equals 'babelshorthand=true', no longer 'babelshorthands=false')
    - localalph in language slovenian ('localalph' now equals 'localalph=true')
    - latesthyphen in language german ('latesthyphen' now equals 'latesthyphen=true')
    - fullyear in package hebrewcal ('fullyear' now equals 'fullyear=true')
  * The command \setlanguagealias* (introduced in v1.46) does no longer define
    dedicated alias environments.
  * The babelnames for latin variants have been corrected to classiclatin, ecclesiasticlatin
    and medievallatin. This is how the hyphenation patterns and babel \extras are named, even
    though the variants can currently be selected in babel only via appended "dot modifier".
  * In accordance with the respective l3kernel change, \str_lower_case:n  has been renamed to
    \str_lowercase:n where used in polyglossia.sty. Thus polyglossia 1.47 requires l3kernel
    2020-01-12 at least.

1.46 (15-11-2019)

New features:
  * Add option "indentfirst" to Russian (#78).
  * Add options to set and customize French-style itemize item labels to French (#89).
  * Polyglossia now understands all babel language names in \setdefaultlanguage,
    \setotherlanguage and the language switching commands (#112, #132).
  * Add optional localized math operators to Spanish (#123).
  * Swap section headings in Hungarian (#344). New option "swapstrings" provides control
    over this.
  * Introduce macro \setlanguagealias and \setlanguagealias*.
  * Introduce language switching command \textlang{lang}{...} (equivalent to \text<lang>,
    but also available with \setlanguagealias* which does not define \text<alias>).
  * Add support for Afrikaans.
  * Add support for Belarusian.
  * Add support for Bosnian.
  * Add support for Georgian.
  * Add Spanish variant "mexican".
  * Add babelshorthands as well as options "splithyphens" and "vlna" to Slovak.
  * Add Latin language variant "ecclesiastic".
  * Add Latin language options "capitalizemonth", "ecclesiasticfootnotes", "hyphenation",
    "prosodicshorthands", and "usej".
  * Add Latin shorthands for "«", "»", "æ", "Æ", "œ", and "Œ".
  * Add French language option "thincolonspace".

Bug fixes:
  * Fix problems with fragile font settings (#24).
  * Fix clash of French punctuation spacing with the soul package (#52).
  * Re-enable the possibility to pass a macro as main argumente to \setmainlanguage and
    \setotherlanguage (#331).
  * Fix detection of default \languagevariant (#332).
  * Fix LaTeX error with undefined hyphenation pattern (#346).
  * Fix some babel shorthand issues by updating the shorthand code from recent babel.
  * Fix some problems with French and Latin auto-spacing (#345, #352).
  * Fix an expl3 declaration (#348).

Interface and defaults changes:
  * Per TeXLive request, the sub-package cyrillicnumbers.sty has been renamed to
    xpg-cyrillicnumbers.sty.
  * In Russian, all paragraphs are now indented by default, as common in Russian typography.
    The behavior can be opted out by indentfirst=false.
  * In Czech, splithyphens and lvna are enabled by default. Also, the option does now work
    as well with LuaTeX.
  * Changed option name "fraktur" to "blackletter" in German (the former is still available
    as an alias).
  * In French, high punctuation characters and guillemets are spaced by half an interword
    space now instead of a \thinspace (cf. #345).

1.45 (27-10-2019)

New features:
  * Introduce a framework for external packages to access language variants. This fixes,
    among other things, long-standing problems in the interaction of biblatex and polyglossia.
  * Add new macros \languagevariant, \mainlanguagevariant, \babelname and \mainbabelname
    for package authors to access language information.
  * Add new test \iflanguageloaded{<language>}{<true>}{<false>}, where <language>
    can be a \polyglossia or babel language name.
  * Add new macros \localnumeral, \localnumeral*, \Localnumeral and
    \Localnumeral* that convert Arabic digitals to the local number scheme.
  * Add new macro \pghyphenation to add language-specific hyphenation exceptions (#18).
  * Add support form (Khalkha & Cyrillic) Mongolian in line with babel-mongolian (#23).
  * Add option splithyphens and vlna to Czech (XeTeX only; for LuaTeX, use the package
    luavlna to get these features) (#32).
  * Add support for Kurdish, both Kurmanji and Sorani (#277).
  * Implement proper Cyrillic (alphanumeric) numbering (#285).
  * Add new language friulian.
    This deprecates friulan (which is still supported for backwards compatibility).
  * Add new language malay with variants indonesian and malaysian.
    This deprecates bahasai and bahasam (which are still supported for
    backwards compatibility).
  * Add new language gaelic with variants irish and scottish.
    This deprecates irish and scottish as own polyglossia languages (which
    are still supported for backwards compatibility).
  * Add new language hungarian.
    This deprecates magyar (which is still supported for backwards compatibility).
  * Add new language sorbian with variants lower and upper.
    This deprecates lsorbian and usorbian (which are still supported for
    backwards compatibility).
  * Add new language portuguese with variants portuguese and brazilian.
    This deprecates brazil and portuges (which are still supported for
    backwards compatibility).
  * Add new language norwegian with variants nynorsk and bokmal.
    This deprecates nynorsk and norsk (which are still supported for
    backwards compatibility).
  * Add new language persian.
    This deprecates farsi (which is still supported for backwards compatibility).
  * Add new language sami. Currently only Northern Sami is supported.
    This deprecates samin (which is still supported for backwards compatibility).
  * gloss-serbian: add numerals=cyrillic option. Add \asbuk and \Asbuk (#285).
  * Implement basic support for (French) canadien and (English) canadian (#22)
  * Improve support for Armenian (#79): Add captions, Eastern month names
    (accessible via variant=eastern) and Armenian alphabetic numbering
    (via numerals=armenian and \armenicnumeral).
  * Add french option autospacing and commands \AutoSpacing, \NoAutoSpacing
    This allows to switch off autospacing globally or locally (#113)
  * Fixup \normalfont (#203)
  * Fix directionality issues in mixed RTL/LTR paragraphs (#204)
  * Implement babelshorthands for Finnish (#212) and Czech.
  * Implement access to current language via Lua (#243).
  * Introduce french option option autospacetypewriter
    alias OriginalTypewriter
  * Support \aemph with lualatex
  * Rename automaticspacesaroundguillemets to autospaceguillemets 
    The old option is kept for backwards compatibility.

Bug fixes:
  * Fix equation number in arabic and farsi (#7).
  * Simplify and document Hebrew marcheshvan option (#16).
  * Fix hyphenation of Greek with LuaTeX (#55).
  * Fix N'ko date format (#63).
  * Disable the extras of a language when a nested language starts (#66, #169).
  * Properly implement bengali numbers (#69, #184).
  * Fix conflicts with other packages caused by premature shorthand activation
    in preamble (#81, #200).
  * Fix kerning in math with French (#92).
  * Fix expansion issue in Hebrew (#93).
  * Fix numbering expansion issue in Greek (#110).
  * Postpone \disablehyphenation in preamble until after setting of
    document language (#125).
  * Postpone the assignment of defaultfamily to BeginDocument,
    thus do not overwrite \familydefault redefinitions in the preamble (#127).
  * Reset number settings when switching language (#133).
  * hebrew: Properly store \MakeUppercase for later restoration (#152).
  * Fix whitespace issue in \datewelsh (#158).
  * When switching language, set the language/script specific font families (#164).
  * Correct some Bengali captions (#165).
  * Fix documentation of Serbian (#168).
  * Reset ucl codes in latin only if the respective variant is used (#172).
  * Fix \disablehyphenation with LuaTeX (#187).
  * Fix typos in Hindi captions (#202).
  * Pass language options to the aux files (#205).
  * Rewrite and fix English variant handling (#208).
  * Define magyar caption formats in \blockextras and undef them in \noextras (#209).
  * Ensure proper direction with arabic digits in Arabic and Farsi (#213).
  * Fix \linespread with Korean (#218).
  * Define russian caption before key allocation (#219).
  * Register current language in polyglossia lua module after selection (#234).
  * Fix babel language switching commands (#239).
    \foreignlanguage and the starred otherlanguage* environment are not
    supposed to change dates.
  * Fix French spacing leaking beyond French (#270).
  * Redefine fontfamilies for French only if language is loaded (#270).
  * gloss-russian: 
    - check whether command exist before redefining (#280).
    - Fix some whitespace issues.
  * Fix and simplify frenchfootnote definition (#294).
  * Fix footnote numbering in Farsi.
  * Fix latin footnotes in Arabic documents.
  * Set the correct main direction with luabidi.
  * Fix autospaceguillemets option in French.
  * Fix grouping in gloss-danish.ldf.
  * Properly store \MakeUppercase and \@arabic for later restoration.

Documentation:
  * Add documentation about footnotes in RTL context
  * Document tibetan numerals option (#109)
  * Improve frenchfootnote documentation.
  * Mention Japanese support in the docs.

1.44 (04-04-2019)
  * Correction to Russian language file, by Maksim Zholudev (commit d2f383e)
  * Added Macedonian language file, by Stefan Zlatinov (commit cd379e1)

05-03-2019
  * Correction to Hindi language file, by Zdenĕk Wagner

1.42.5 (13-04-2017)
  * Many changes to the French language file, by Maïeul Rouquette

1.42.4 (February, March 2016)
  * Remedial actions for the Babel changes

09-02-2016
  * Fixed side effect of pull request #122 (see commit d2a34ff)
  * Added automatic Josa selection, variant, and captions options to Korean, by Dohyun Kim (pull request #128)

08-02-2016
  * Updated gloss-occitan from CTAN

18-01-2016
  * Fixed issue #124 (minor typo in polyglossia-frpt.lua)

03-12-2015
  * Merged pull request #117 for more French guillemet spacing
  * Merged pull request #121 to add \bbl@loaded; fixes issue #120
  * Merged pull request #122 that build on #121

08-11-2015
  * Merged pull request #116 for French (spacing around guillemets)

22-10-2015
  * Fixed issue #115 (spurious spaces in Arabic)

19-08-2015
  * Fixed issue #107 for Marathi (labels and month names)

1.42.0 (06-08-2015)
  * Add Bengali digits package, and option to reset all numbering functions

05-08-2015
  * Add “long” option for Welsh date
  * Add local alphabet in Slovenian, for enumerations and such

04-08-2015
  * Fix long-standing bug with Welsh: date should use ordinals

03-08-2015
  * Fix for Latin with LuaTeX: all variants had same problems as Classic

02-08-2015
  * Fixed error with British variant of English and LuaTeX (issue #86)

1.41.0 (16-07-2015)
  * Added support for Khmer, by Say Ol (private email)

1.40.1 (14-07-2015)
  * Bugfix for Korean, by Kim Dohyun (pull request #103)

1.40.0 (07-07-2015)
  * gloss-korean.ldf contributed by Kim Dohyun (pull request #102)

1.33.7 (04-07-2015)
  * Release to CTAN, no code change

03-07-2015
  * Fixed extraneous space in code for Swiss German (pull request #101)
  * Fixed a typo in Ukrainian alphabet, for \Asbuk (pull request #99)

24-06-2015
  * Fix for Classic Latin: load patterns for LuaTeX

23-05-2015
  * Made \rmfamily, \sffamily and \ttfamily robust again

11-05-2015
  * Merged fix for Hebrew date format, by Guy Rutenberg (pull request #94)
  * Merged fix for spurious space, by Caleb McKennan (pull request #91)
  * Merged pull request #84 by Élie Roux for Tibetan

10-05-2015
  * Added support for Swiss German (pull request #75)
  * Added commands \Asbuk and \asbuk for Ukrainian (pull request #76), similar to Russian
  * Documented changes to Latin from last year.

09-05-2015
  * Be friendlier to right-to-left languages with LuaTeX

04-06-2014
  * Enhanced Latin support by Claudio Beccari

1.33.5 (21-05-2014)
  * Option to disable hyphenation entirely, by Élie Roux
  * Fix spurious spaces in gloss-russian.ldf, by Oleg Domanov
  * Support for the Austrian variant of German, by Jürgen Spitzmüller
  * Changes to the Croatian translations, by Ivan Kokan
  * Correction to the Lithuanian translations, by Ignas Anikevičius

1.33.4 (27-06-2013)
  * Emergency release for a bug introduced in babelsh.def

1.33.3 (28-05-2013)
  * Changed formatting of some error messages (emergency fixes for TeX Live 2013)

1.33.2 (26-05-2013)
  * Added \disablehyphenation and \enablehyphenation, contributed by
    Élie Roux.
  * Fixed bug related to package inclusion.  Polyglossia would break if
    we loaded breqn.sty, and then called \setmainlanguage{english}, this
    is no longer the case.
  * Removed spurious space introduced by \captionswedish.

1.33.1 (23-05-2013)
  * Editorial changes to the documentation
  * Hunted and documented bugs

1.33.0 (20-05-2013)
  * Added support for N’Ko.
  * Bugfixes for LuaTeX
  * More work in progress on Bidi in LuaTeX.

1.32.0 (15-05-2013)
  Transitional version to support right-to-left languages with LuaTeX.

1.31 (10-05-2013) / 1.3 (11-05-2013)
  * Several bugfixes.
  * Sync with Babel 3.9.
  * 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 Élie Roux for his help.
  * Added support for Tibetan, contributed by Élie Roux (end of lines are experimental).

1.30MM (06-08-2012)
  * Added support for LuaTeX.  Many languages don’t work yet.  Please be
    patient.

1.2.0e (28-04-2012)
  * Fixed a number of outstanding and not very interesting bugs.
  * Added gloss files for Romansh and Friulan, contributed by Claudio
    Beccari.

1.2.0d (12-01-2012)
  * Removed \makeatletter and \makeother from gloss files entirely.

1.2.0cc (12-10-2011) [First update by Arthur Reutenauer]
  * Update to gloss-italian.ldf by Claudio Beccari, incorporating changes
    by Enrico Gregorio.
  * 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 :-)
  * Conclude polyglossia.sty with \ExplSyntaxOff to match the initial
    \ExplSyntaxOn.
  * Added gloss file for Kannada, contributed by Aravinda VK and others.
  * Corrections to the gloss-dutch.ldf thanks to Wouter Bolsterlee.
  * Several patches by Enrico Gregorio, fixing long-standing bugs.
    From the git log:
    - Deleted setup for right-to-left writing direction, see http://tug.org/pipermail/xetex/2011-April/020319.html
    - Changed three appearances of \newcommand to \newrobustcmd, as the commands needs to be protected. Bug reported by "kamensky".
    - Corrected \datepolish as suggested by Piotr Kempa
    - Changed \lccode" into \lccode\string", because it might come into action at wrong times when " is active
    - 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 Vadim Rodionov on the XeTeX mailing list.
    - Deleted \bgroup and \egroup tokens from the definition of otherlanguage*; they serve no purpose (we are already inside an environment) and conflict with csquotes. Noticed by P. Lehman.
    - Changed the calls of \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.
    - Added "\csuse{date#2}" to the definition of "otherlanguage*"


1.2.0b (03-10-2011) [Update by Philipp Stephani]
  * Load xkeyval package explicitly since newer versions
    of fontspec don't load it any more

1.2.0a (27-07-2010) [Last update by François Charette]
  * Initialize \fontfamily acc to value of \familydefault
    (Fixes a bug when using polyglossia with beamer)
  * Remove spurious space in def of \dateenglish
  * Add missing English variant "american"
  * Serbian: fix date format and captions (Latin+Cyrillic)
  * Fix \atticnumeral in gloss-greek
  * Small improvements and fixes in documentation


1.2.0 (15-07-2010)
  * Adapted for fontspec 2.0 (will not work with earlier versions!)
  * New implementation of a \PolyglossiaSetup interface
    that simplifies writing gloss-*.ldf files
  * Many internal enhancements and refactoring
    (including a patch by Dirk Ulrich)
  * Improved automatic font setup when \<lang>font is not defined
  * New environment otherlanguage* (env. equivalent of \foreignlanguage
    (Enrico Gregorio)
  * Bugfix to prevent bogus expansion of \{rm,sf,tt}family even in aux files
    (Enrico Gregorio)
  * New gloss files for Armenian, Bengali, Occitan, Bengali, Lao,
    Malayalam, Marathi, Tamil, Telugu, and Turkmen.
  * New auxiliary packages 'devanagaridigits' and 'bengalidigits'
  * hijrical no longer loads bidi and checks for incompatible l3calc
  * Add Babel shorthands for Russian (based on a patch by Vladimir Lomov)
  * Fix \fnum@{table,figure} for Lithuanian
  * Various improvements in gloss-russian (provided by Vladimir Lomov and
    others)
  * Corrected captions for Bahasai, Lithuanian, Russian, Croatian
  * Add option indentfirst=true for Spanish, Croation and other languages
    (NB: indentfirst was previously named frenchindent)
  * New option 'script' for German: Setting script=fraktur modifies the
    captions for typesetting in Fraktur.
  * New command \aemph for Arabic, Farsi, Urdu, etc. to mark emphasis through
    overlining.
  * Package option 'nolocalmarks' is now true by default: to activate it the
    option 'localmarks' must be passed instead.
  * Loading languages à la Babel as package options is no longer possible (this
    feature was deprecated since v1.1.0).

1.1.1 (23-03-2010)
  * 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 Babel.
  * Bugfix for font switching mechanism within Latin script
    (pending a complete re-implementation in v1.2):
    the font shape and series are no longer reset when switching language.
  * New macros for non-Western decimal digits
    (instead of fontmappings)
  * New gloss files for Asturian, Lithuanian and Urdu
  * hijrical.sty is now locale-aware: \hijritoday is
    formatted differently in Arabic, Farsi, Urdu, Turkish
    and Bahasa Indonesia.
---NB: the above five items were not part of v1.1.1-rc1 which was made available on github---
  * Enable babelshorthands for Dutch
  * Add missing macro \allowhyphens
  * Add global option babelshorthands
  * Support Catalan geminated l
  * Bugfix when declaring more than one pkg option
  * Protect \reset@font
  * Add missing requirement makecmds
  * Bugfix for smallcaps in captions
  * Typo for ccname in Hebrew
  * Add option numerals to gloss-russian
  * Provide newXeTeXintercharclass when undefined
  * Bugfix for Russian alph
  * Remove superfluous level of {} in def of markright
  * Bugfix for \datecatalan
  * Change hyphenmins for Sanskrit

1.1.0b
   * Modify hyphenmins for Sanskrit (Yves Codet)
   * Bugfixes for Serbian and Bulgarian (Enrico Gregorio)
1.1.0a
   * Bugfix for interchar tokens
1.1.0
   * Use \newXeTeXintercharclass (thanks to Enrico Gregorio)
   * Fixed implementation of shorthands for German (Babel code in file babelsh.def)
   * Arabic (Khaled Hosny):
     - Fix abjad form for 3 and 5 and add option abjadjimnotail
     - bugfix for \arabicnumber
     - make Gregorian calender the default
     - fixed typos in the sample text
   * Turkish (S. Ö. Yıldız):
     - fix white-space before : and !
     - also check if the font specified TRK for language
     - added missing Turkish translation of "Glossary"
   * Suppress nopattern warning for non-hyphenated scripts
   * Changed U+0163 to U+021B for Romanian (Elie Roux)
   * Stylistic fixes and use macro \xpg@option for package options (E. Gregorio)
   * Fix monthnames in Dutch (A. Ledda)
   * Add Brazilian translation for "glossary"
   * Remove spurious space generated by gloss-spanish
   * Fix ldf file for brazilian
   * Various improvements in the code communicated by E. Gregorio:
     - remove superfluous \protect\language
     - change default language from 0 to \l@nohyphenation=255
     - localize lccode handling of apostrophe in French; add it to Italian
   * Fix frenchspacing for vietnamese
   * Other minor bugfixes

1.0.2
   This is mostly a bug fixes release.
   * Captions corrected in Hebrew, Russian and Spanish
   * Removed all \text<lang> wrappers within caption definitions
   * Improved compatibility with Babel
   * New option "babelshorthands" for German
   * New option "Script" for Sanskrit

1.0.1
   * Improved documentation (added sections on font setup and numeration mappings)
   * Improvements and bugfixes for English and German
   * Bugfix in gloss-syriac.ldf (spurious space after \textsyriac{...})
   * Extended the scope of \syriacabjad
   * Added gloss-amharic.ldf (ported from ethiop.ldf in the package ethiop)

1.0
   * Initial release on CTAN
%</Changelog>
%<*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>
\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\space all *.sty, *.lua, *.def 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
