%\iffalse
% polyglossia.dtx generated using mkpolyglossiadtx.pl
% (derived from makedtx.pl version 0.94b (c) Nicola Talbot)
% 
% Created on 2012/4/29 23:15
%<*internal>
\iffalse
%</internal>
%<*README>

   ¦----------------------------------------------¦
   ¦                                              ¦
   ¦       THE POLYGLOSSIA PACKAGE v1.2.1         ¦
   ¦                                              ¦
   ¦ Modern multilingual typesetting with XeLaTeX ¦
   ¦                                              ¦
   ¦----------------------------------------------¦

This package for provides a complete Babel replacement for users of XeLaTeX.
This version includes support for 68 different languages.

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 package bidi, available separately).

Several features of Babel that do not make sense in the XeTeX world (like font
encodings, shorthands, etc) are not supported. For German however, several
shorthands do make sense and can be activated with the language option babelshorthands=true.

Polyglossia is distributed in the traditional way with *.dtx and *.ins files,
and also comes with a TDS-conformant ready-to-unpack zip file.

To install from source (i.e. using polyglossia.dtx), run
	xelatex polyglossia.dtx
which will generate all files and produce the pdf documentation all at once.
Alternatively if you have the file polyglossia.ins run
	xetex polyglossia.ins
and follow the instructions displayed.


BUGS

Users are encouraged to report bugs on the github tracker:
http://github.com/reutenauer/polyglossia/issues


CHANGES

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


  ------------------------------
   Arthur Reutenauer, April 2012
     <arthur 'dot' reutenauer 'at' normalesup 'dot' org>

   Original author:
   François Charette
     <firmicus ατ gmx δοτ net>
  ------------------------------
%</README>
%<*internal>
\fi
%</internal>
%
%<*internal>
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble
  ____________________________

  The polyglossia package         
  (C) 2008–2010 François Charette    
  (C) 2012 Arthur Reutenauer
  License information appended


\endpreamble
\postamble

 Copyright (C) 2012 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
\askforoverwritefalse
\generate{\file{polyglossia.sty}{\from{polyglossia.dtx}{polyglossia.sty}}}
\generate{\file{farsical.sty}{\from{polyglossia.dtx}{farsical.sty}}}
\generate{\file{hebrewcal.sty}{\from{polyglossia.dtx}{hebrewcal.sty}}}
\generate{\file{hijrical.sty}{\from{polyglossia.dtx}{hijrical.sty}}}
\generate{\file{babel-hebrewalph.def}{\from{polyglossia.dtx}{babel-hebrewalph.def}}}
\generate{\file{babelsh.def}{\from{polyglossia.dtx}{babelsh.def}}}
\generate{\file{cal-util.def}{\from{polyglossia.dtx}{cal-util.def}}}
\generate{\file{xgreek-fixes.def}{\from{polyglossia.dtx}{xgreek-fixes.def}}}
\generate{\file{gloss-albanian.ldf}{\from{polyglossia.dtx}{gloss-albanian.ldf}}}
\generate{\file{gloss-amharic.ldf}{\from{polyglossia.dtx}{gloss-amharic.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-asturian.ldf}{\from{polyglossia.dtx}{gloss-asturian.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-bengali.ldf}{\from{polyglossia.dtx}{gloss-bengali.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-bulgarian.ldf}{\from{polyglossia.dtx}{gloss-bulgarian.ldf}}}
\generate{\file{gloss-catalan.ldf}{\from{polyglossia.dtx}{gloss-catalan.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-czech.ldf}{\from{polyglossia.dtx}{gloss-czech.ldf}}}
\generate{\file{gloss-danish.ldf}{\from{polyglossia.dtx}{gloss-danish.ldf}}}
\generate{\file{gloss-divehi.ldf}{\from{polyglossia.dtx}{gloss-divehi.ldf}}}
\generate{\file{gloss-dutch.ldf}{\from{polyglossia.dtx}{gloss-dutch.ldf}}}
\generate{\file{gloss-english.ldf}{\from{polyglossia.dtx}{gloss-english.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-farsi.ldf}{\from{polyglossia.dtx}{gloss-farsi.ldf}}}
\generate{\file{gloss-finnish.ldf}{\from{polyglossia.dtx}{gloss-finnish.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-galician.ldf}{\from{polyglossia.dtx}{gloss-galician.ldf}}}
\generate{\file{gloss-german.ldf}{\from{polyglossia.dtx}{gloss-german.ldf}}}
\generate{\file{gloss-greek.ldf}{\from{polyglossia.dtx}{gloss-greek.ldf}}}
\generate{\file{gloss-hebrew.ldf}{\from{polyglossia.dtx}{gloss-hebrew.ldf}}}
\generate{\file{gloss-hindi.ldf}{\from{polyglossia.dtx}{gloss-hindi.ldf}}}
\generate{\file{gloss-icelandic.ldf}{\from{polyglossia.dtx}{gloss-icelandic.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-italian.ldf}{\from{polyglossia.dtx}{gloss-italian.ldf}}}
\generate{\file{gloss-kannada.ldf}{\from{polyglossia.dtx}{gloss-kannada.ldf}}}
\generate{\file{gloss-lao.ldf}{\from{polyglossia.dtx}{gloss-lao.ldf}}}
\generate{\file{gloss-latin.ldf}{\from{polyglossia.dtx}{gloss-latin.ldf}}}
\generate{\file{gloss-latvian.ldf}{\from{polyglossia.dtx}{gloss-latvian.ldf}}}
\generate{\file{gloss-lithuanian.ldf}{\from{polyglossia.dtx}{gloss-lithuanian.ldf}}}
\generate{\file{gloss-lsorbian.ldf}{\from{polyglossia.dtx}{gloss-lsorbian.ldf}}}
\generate{\file{gloss-magyar.ldf}{\from{polyglossia.dtx}{gloss-magyar.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-norsk.ldf}{\from{polyglossia.dtx}{gloss-norsk.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-polish.ldf}{\from{polyglossia.dtx}{gloss-polish.ldf}}}
\generate{\file{gloss-portuges.ldf}{\from{polyglossia.dtx}{gloss-portuges.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-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-slovak.ldf}{\from{polyglossia.dtx}{gloss-slovak.ldf}}}
\generate{\file{gloss-slovenian.ldf}{\from{polyglossia.dtx}{gloss-slovenian.ldf}}}
\generate{\file{gloss-spanish.ldf}{\from{polyglossia.dtx}{gloss-spanish.ldf}}}
\generate{\file{gloss-swedish.ldf}{\from{polyglossia.dtx}{gloss-swedish.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-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-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}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{polyglossia.ins}{\from{polyglossia.dtx}{batchfile}}}
\nopreamble\nopostamble
\generate{\file{README}{\from{polyglossia.dtx}{README}}}
\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>
\documentclass[11pt]{ltxdoc}
\usepackage[dvipdfm]{color}
\usepackage{xltxtra}
\usepackage{xspace,fancyvrb}
\usepackage[neverdecrease]{paralist}
\definecolor{myblue}{rgb}{0.02,0.04,0.48}
\definecolor{lightblue}{rgb}{0.61,.8,.8}
\definecolor{myred}{rgb}{0.65,0.04,0.07}
\definecolor{darkgray}{gray}{0.3}
\definecolor{lightgray}{gray}{0.6}
\definecolor{mygreen}{rgb}{0,.43,0}
\usepackage[
    bookmarks=true,
    colorlinks=true,
    linkcolor=myblue,
    urlcolor=myblue,
    citecolor=myblue,
    hyperindex=false,
    hyperfootnotes=false,
    pdftitle={Polyglossia: A Babel replacement for XeLaTeX},
    pdfauthor={F Charette <firmicus · gmx · net>},
    pdfkeywords={xetex, xelatex, multilingual, babel, hyphenation}
    ]{hyperref}
\usepackage[babelshorthands]{polyglossia}
%\usepackage{farsical} <<< needs to be disabled otherwise we have too many counters!
\setmainlanguage[variant=british,ordinalmonthday=false]{english}
\setotherlanguages{arabic,hebrew,syriac,greek,russian,catalan}
\newcommand*\Cmd[1]{\cmd{#1}\DescribeMacro{#1}\xspace}
\newcommand*\pkg[1]{\textsf{\color{myblue}#1}}
\newcommand*\file[1]{\texttt{\color{myblue}#1}}
\newcommand*\TR[1]{\textcolor{myred}{#1}}
\newcommand*\TX[1]{\hyperref[#1]{\textcolor{myred}{#1}}}
\newcommand*\TB[1]{\textcolor{myblue}{\bf #1}}
\newcommand*\link[1]{\href{#1}{#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}}

%% Sidenotes  << copied from fontspec.dtx
\newcommand\warn[2]{%
  \edef\thisversion{#1}%
  \ifhmode\unskip~\fi{\ifx\thisversion\fileversion\color{red}\fi
  $\leftarrow$}%
  \marginpar{\raggedleft
    \small%
    \ifx\thisversion\fileversion\color{red}\fi
    \notefont #1:~#2}}

\newcommand\new[1]{%
  \edef\thisversion{#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
    \notefont #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}}

%% Sidenote font
\newfontfamily\notefont[Scale=MatchLowercase]{Lucida Sans Unicode}
%%%

%% fontspec declarations:
\setromanfont[Mapping=tex-text]{Linux Libertine O}
\defaultfontfeatures{Scale=MatchLowercase}
\setmonofont{DejaVu Sans Mono}
\setsansfont{Lucida Sans Unicode}
\newfontfamily\arabicfont[Script=Arabic]{Scheherazade}
\newfontfamily\farsifont[Script=Arabic]{Farsi Simple Bold}
\newfontfamily\syriacfont[Script=Syriac]{Serto Jerusalem}
\newfontfamily\hebrewfont[Script=Hebrew]{SBL Hebrew}

\newcommand\Babel{\pkg{Babel}\xspace}

\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
% 
% \GetFileInfo{polyglossia.sty}
% 
% \title{\textcolor{lightblue}{\huge
% \fontspec{GFS Ambrosia}
% Π$\;\,$ο$\;\,$λ$\;\,$υ$\;\,$γ$\;\,$λ$\;\,$ω$\;\,$σ$\;\,$σ$\;\,$ι$\;\,$α}\\[16pt]
% \color{myblue}Polyglossia: A Babel Replacement for \XeLaTeX}
% \author{\scshape\color{myblue}François Charette\\\color{myblue}Current maintainer: \scshape Arthur Reutenauer}
% \date{\filedate \qquad \fileversion\\
% \footnotesize (\textsc{pdf} file generated on \today)}
% 
% \maketitle
% \tableofcontents
% 
% 
% \DeleteShortVerb{\|}
% \MakeShortVerb{\¦}
% 
% ^^A\begin{abstract}
% ^^ABlablabla
% ^^A\end{abstract}
% 
% 
% \section{Introduction}
% 
% Polyglossia is a package for facilitating multilingual typesetting with \XeLaTeX.
% Basically, it can be used as a replacement of \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{ %
%         For the Arabic script this is now done by the bundled package \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}
% 
% Several features of \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 \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 Philipp Lehmann. Being designed
% specifically for \XeLaTeX, it obviously also relies on \pkg{fontspec} by Will
% Robertson. For languages written from right to left, it needs the package \pkg{bidi}
% by Vafa Khalighi (\textarabic{وفا خليقي}). Polyglossia also bundles three packages for calendaric
% computations (\pkg{hebrewcal}, \pkg{hijrical}, and \pkg{farsical}).
% 
% \section{Loading language definition files}
% 
% \subsection{The recommended way}
% You can determine the default language by means of the command:
% 	\displaycmd{\setdefaultlanguage[⟨options⟩]\{lang\}}{\setdefaultlanguage}
% (or equivalently \Cmd\setmainlanguage).
% Secondary languages can be loaded with
% 	\displaycmd{\setotherlanguage[⟨options⟩]\{lang\}}{\setotherlanguage}.
% These commands have the advantage of being explicit and of allowing you to set
% language-specific options.\footnote{ %
% 	More on language-specific options below.}
% It is also possible to load a series of secondary languages at once using
% 	\displaycmd{\setotherlanguages\{lang1,lang2,lang3,…\}}{\setotherlanguages}.
% Language-specific options can be set or changed at any time by means of
% 	\displaycmd{\setkeys\{⟨lang⟩\}\{opt1=value1,opt2=value2,…\}}{\setkeys}.
% 
% 
% \subsection{The “Babel way”}
% \new{v1.2.0}
% {\color{red}\bfseries Warning}: \pkg{polyglossia} no longer supports loading
% language definition files as package options!
% ^^AAs with \Babel, \pkg{polyglossia} also allows you to load language definition files
% ^^Aas package options. In most cases, option \texttt{⟨lang⟩} will load the file
% ^^A\file{gloss-⟨lang⟩.ldf}. Note however that the \textit{first} language listed in \\
% ^^A\centerline{\cmd{\usepackage[lang1,lang2,…]{polyglossia}}}
% ^^Awill be the default language for the document, which
% ^^Ais the opposite convention of \Babel.
% ^^ANote also that this method may not work in some cases, and should be
% ^^Aconsidered deprecated.
% 
% \subsection{Supported languages}
% 
% Table~\ref{tab:lang} lists all languages currently supported.
% Those in red have specific options and/or commands
% that are explained in section \ref{specific} below.
% 
% \begin{table}[h]\centering
% \label{tab:lang}
% ^^Aalbanian
% ^^Aamharic
% ^^A\TX{arabic}
% ^^Aarmenian
% ^^Aasturian
% ^^Abahasai
% ^^Abahasam
% ^^Abasque
% ^^A\TX{bengali}
% ^^Abrazil[ian]
% ^^Abreton
% ^^Abulgarian
% ^^A\TX{catalan}
% ^^Acoptic
% ^^Acroatian
% ^^Aczech
% ^^Adanish
% ^^Adivehi
% ^^A\TX{dutch}
% ^^A\TX{english}
% ^^A\TX{esperanto}
% ^^Aestonian
% ^^A\TX{farsi}
% ^^Afinnish
% ^^Afrench
% ^^Agalician
% ^^A\TX{german}
% ^^A\TX{greek}
% ^^A\TX{hebrew}
% ^^A\TX{hindi}
% ^^Aicelandic
% ^^Ainterlingua
% ^^Airish
% ^^Aitalian
% ^^A\TX{lao}
% ^^Alatin
% ^^Alatvian
% ^^Alithuanian
% ^^A\TX{lsorbian}
% ^^A\TX{magyar}
% ^^Amalayalam
% ^^Amarathi
% ^^Anorsk
% ^^Anynorsk
% ^^Aoccitan
% ^^Apolish
% ^^Aportuges
% ^^Aromanian
% ^^A\TX{russian}
% ^^Asamin
% ^^A\TX{sanskrit}
% ^^Ascottish
% ^^A\TX{serbian}
% ^^Aslovak
% ^^Aslovenian
% ^^Aspanish
% ^^Aswedish
% ^^A\TX{syriac}
% ^^Atamil
% ^^Atelugu
% ^^A\TX{thai}
% ^^Aturkish
% ^^Aturkmen
% ^^Aukrainian
% ^^Aurdu
% ^^A\TX{usorbian}
% ^^Avietnamese
% ^^Awelsh
% ^^A private note: the following table was automatically generated with "maketabular.pl 5 < above_input"
% \begin{tabular}{lllll}
% \hline
% albanian     & croatian       & \TX{hebrew}   & norsk        & swedish       \\
% amharic      & czech          & \TX{hindi}    & nynorsk      & \TX{syriac}   \\
% \TX{arabic}  & danish         & icelandic     & occitan      & tamil         \\
% armenian     & divehi         & interlingua   & polish       & telugu        \\
% asturian     & \TX{dutch}     & irish         & portuges     & \TX{thai}     \\
% bahasai      & \TX{english}   & \TX{italian}  & romanian     & turkish       \\
% bahasam      & \TX{esperanto} & \TX{lao}      & \TX{russian} & turkmen       \\
% basque       & estonian       & latin         & samin        & ukrainian     \\
% \TX{bengali} & \TX{farsi}     & latvian       & \TX{sanskrit}& urdu          \\
% brazil[ian]  & finnish        & lithuanian    & scottish     & \TX{usorbian} \\
% breton       & french         & \TX{lsorbian} & \TX{serbian} & vietnamese    \\
% bulgarian    & galician       & \TX{magyar}   & slovak       & welsh         \\
% \TX{catalan} & \TX{german}    & malayalam     & slovenian    &               \\
% coptic       & \TX{greek}     & marathi       & spanish      &               \\
% \hline
% \end{tabular}
% \caption{Languages currently supported in \pkg{polyglossia}}
% \end{table}
% 
% \textit{NB:} The support for Amharic\new{v1.0.1} should be considered an experimental attempt to
% port the package \pkg{ethiop}.\footnote{ Feedback is welcome.}
% Version 1.1.1\new{v1.1.1} addded 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{v1.2.0} adds support for Armenian, Occitan, Bengali,
% Lao, Malayalam, Marathi, Tamil, Telugu, and Turkmen.\footnote{ %
%   See acknowledgements at the end for due credit to the various contributors.}
% 
% 
% 
% Polyglossia can also be loaded with the option
% ‘babelshorthands’\new{v1.1.1}, which globally activates \Babel
% shorthands whenever available. Currently shorthands are implemented for
% Catalan, Dutch, German, Italian, and Russian: see these respective
% languages for details.
% 
% Another option (turned off by default) is ‘localmarks’, which
% redefines the internal \LaTeX\ macros \cmd\markboth\ and \cmd\markright.
% \new{v1.2.0}Note that this was formerly turned on by default, but ẃe
% now realize that it causes more problems than otherwise. For backwards-compatibility
% the opposite option ‘nolocalmarks’ is still available.
% 
% There is also the option ‘quiet’ which turns off most info messages and some of the warnings
% issued by \LaTeX, \pkg{fontspec} and \pkg{polyglossia}.
% 
% \section{Language-switching commands}
% 
% Whenever a language definition file \file{gloss-⟨lang⟩.ldf} is loaded,
% the command \cmd{\text⟨lang⟩[⟨options⟩]\{…\}} \DescribeMacro{\text⟨lang⟩}
% becomes available for short insertions of text in that language.
% For example ¦\textrussian{\today}¦ yields \textrussian{\today}
% Longer passages are better put between the environment ¦⟨lang⟩¦
% (again with the possibility of setting language options locally.
% \DescribeEnv{⟨lang⟩}
% For instance the following allows us to quote the beginning
% of Homer’s \textit{Iliad}:
% 
% \begin{Verbatim}[formatcom=\color{myblue}]
% \begin{greek}[variant=ancient]
% μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος οὐλομένην, ἣ μυρί' Ἀχαιοῖς ἄλγε'
% ἔθηκε, πολλὰς δ' ἰφθίμους ψυχὰς Ἄϊδι προί̈αψεν ἡρώων, αὐτοὺς δὲ ἑλώρια
% τεῦχε κύνεσσιν οἰωνοῖσί τε πᾶσι, Διὸς δ' ἐτελείετο βουλή, ἐξ οὗ δὴ τὰ
% πρῶτα διαστήτην ἐρίσαντε Ἀτρεί̈δης τε ἄναξ ἀνδρῶν καὶ δῖος Ἀχιλλεύς.
% \end{greek}
% \end{Verbatim}
% 
% \begin{greek}[variant=ancient]
% μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος οὐλομένην, ἣ μυρί' Ἀχαιοῖς ἄλγε' ἔθηκε,
% πολλὰς δ' ἰφθίμους ψυχὰς Ἄϊδι προί̈αψεν ἡρώων, αὐτοὺς δὲ ἑλώρια τεῦχε κύνεσσιν
% οἰωνοῖσί τε πᾶσι, Διὸς δ' ἐτελείετο βουλή, ἐξ οὗ δὴ τὰ πρῶτα διαστήτην ἐρίσαντε
% Ἀτρεί̈δης τε ἄναξ ἀνδρῶν καὶ δῖος Ἀχιλλεύς.
% \end{greek}
% \bigskip
% 
% 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\DescribeEnv{Arabic}.
% This is the beginning of Ibn Khaldūn’s \textit{Muqaddima}:
% 
% ^^A TODO: convince XeTeX to typeset right-to-left, even in verbatim.
% ^^A The individual words are set correctly, but the whole paragraph is
% ^^A left-to-right!
% \begin{Verbatim}[formatcom={\color{myblue}\addfontfeature{Script=Arabic}}]
% \begin{Arabic}
% اعلم أنّ فنّ التاريخ فنّ عزيز المذهب، جمّ الفوائد، شريف الغاية؛ إذ هو
% يوقفنا على أحوال الماضين من الأمم في أخلاقهم، والأنبياء في سيرهم، والملوك
% في دولهم وسياستهم؛ حتّى تتمّ فائدة الإقتداء في ذلك لمن يرومه في أحوال
% الدين والدنيا.
% \end{Arabic}
% \end{Verbatim}
% 
% \begin{Arabic}
% اعلم أنّ فنّ التاريخ فنّ عزيز المذهب، جمّ الفوائد، شريف الغاية؛ إذ هو يوقفنا على
% أحوال الماضين من الأمم في أخلاقهم، والأنبياء في سيرهم، والملوك في دولهم
% وسياستهم؛ حتّى تتمّ فائدة الإقتداء في ذلك لمن يرومه في أحوال الدين والدنيا.
% \end{Arabic}
% 
% \subsection{Other commands}
% The following commands are probably of lesser interest to the end user, but
% ought to be mentioned here.
% \begin{itemize}
% \item \Cmd\selectbackgroundlanguage: this selects the global font setup and
% 	the numbering definitions for the default language.
% 
% \item \Cmd\resetdefaultlanguage\ (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 call the font defined with \cmd\setromanfont\ etc.
% 	Likewise it is possible to use \Cmd\rmfamilylatin, \Cmd\sffamilylatin,
% 	and \Cmd\ttfamilylatin.
% 
% \item Some macros defined in \Babel’s \file{hyphen.cfg} (and thus usually
% 	compiled into the xelatex format) are redefined, but keep a similar
% 	behaviour, namely \Cmd\selectlanguage, \Cmd\foreignlanguage,
% 	and the environment ¦otherlanguage¦\DescribeEnv{otherlanguage}.
% \end{itemize}
% ^^A
% Since the \XeLaTeX\ format incorporates \Babel’s \file{hyphen.cfg},
% the low-level commands for hyphenation and language switching
% defined there are also accessible.
% ^^A\footnote{ %
% ^^A	The file \file{hyphen\_cfg} (available on the
% ^^A	\href{http://scripts.sil.org/svn-view/xetex/TRUNK/texmf/tex/xelatex/polyglossia/hyphen\_cfg}{\XeTeX\ subversion repository})
% ^^A	is meant to eventually replace \Babel’s \file{hyphen.cfg}. If you want
% ^^A	to experiment with it, rename it into \file{hyphen.cfg}, copy it to
% ^^A	\texttt{…/tex/xelatex/polyglossia/} and rebuild the xelatex format.}
% 
% 
% \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
% ¦\⟨script⟩font¦\ or ¦\⟨language⟩font¦.
% For instance, if the default roman font defined by \cmd\setromanfont\
% does not support Greek, then one can define the font used to display Greek with:\\
% \centerline{ \cmd\newfontfamily\cmd{\greekfont[Script=Greek,⟨…⟩]\{⟨font⟩\}}. }
% Note that polyglossia will use the font thus defined as is.
% for instance if ¦\arabicfont¦ is explicitly defined, then one should take care of
% including the option ¦Script=Arabic¦ in that definition.
% See the \pkg{fontspec} documentation for more information.
% If a specific sans or monospace font is needed for a particular script or language,
% it can be defined by means of \new{v1.2.0}
% ¦\⟨script⟩fontsf¦\ or ¦\⟨language⟩fontsf¦ and ¦\⟨script⟩fonttt¦\ or ¦\⟨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{Language-specific options and commands}\label{specific}
% 
% This section gives a list of all languages for which options and end-user commands are defined.
% The default value of each option is given in italic.
% 
% ^^A\subsection{amharic}\label{amharic}
% 
% \subsection{arabic}\label{arabic}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{calendar} = \textit{gregorian} or islamic (= hijri)
% 	\item \TB{locale} = \textit{default},\footnote{ %
% 			For Egypt, Sudan, Yemen and the Gulf states.}
% 		mashriq,\footnote{ %
% 			For Iraq, Syria, Jordan, Lebanon and Palestine.}
% 		libya, algeria, tunisia, morocco, or 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 \TB{numerals} = \textit{mashriq} or maghrib
% 		(the latter is the default when locale = algeria, tunisia or morocco)
%   \item \TB{abjadjimnotail} = \textit{false} or true. \new{v1.0.3}
%     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}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\abjad and \Cmd\abjadmaghribi (see section \ref{abjad})
%   \item \Cmd\aemph to emphasize Arabic text with ¦\overline¦:\new{v1.2.0}
%     ¦\textarabic{مثال: \aemph{اب}}¦ yields \textarabic{مثال: \aemph{اب}}.
%     This command is also available for Farsi, Urdu, etc.
% 	\end{itemize}
% 
% \subsection{bengali}\label{bengali}\new{v1.2.0}
% \textbf{Options}:
% 	\begin{itemize}
%     \item \TB{numerals} = Western or \textit{Devanagari}
% 	\end{itemize}
% 
% \subsection{catalan}\label{catalan}
% \textbf{Options:}
% \begin{itemize}
%   \item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
%     Activates the shorthands \texttt{"l} and \texttt{"L} to type geminated l’s.
% \end{itemize}
% \textbf{Commands}:
% \begin{itemize}
%   \item \Cmd{\l.l} and \Cmd{\L.L} behave as in \Babel to type a geminated l, as in \textit{co\l.laborar}. \new{v1.1.1}
%     In polyglossia the same can also be achieved with \Cmd{\l·l} and \Cmd{\L·L}.\footnote{ %
%         NB: · is the glyph U+00B7 MIDDLE DOT.}
% \end{itemize}
% 
% \subsection{dutch}\label{dutch}
% \textbf{Options:}
% \begin{itemize}
%   \item \TB{babelshorthands} = \textit{false} or true. \new{v1.1.1}
% 		if this is turned on, all shorthands defined in \Babel
% 		for fine-tuning the hyphenation of Dutch words are activated.
% 		\begin{itemize}
% 		\item ¦"-¦ for an explicit hyphen sign, allowing hyphenation in the rest of the word
% 		\item ¦"~¦ for a compound word mark without a breakpoint
% 		\item ¦"|¦ disables the ligature at this position
% 		\item ¦""¦ is like ¦"-¦, but produces no hyphen sign
% 			(for compound words with a hyphen, e.g., ¦foo-""bar¦)
% 		\item ¦"/¦ to enable hyphenation in two words written together but separated by a slash.
%     \item In addition, the macro \Cmd\- is redefined to allow hyphens in the rest of the word.
% 		\end{itemize}
% \end{itemize}
% 
% \subsection{english}\label{english}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{variant} = \textit{american} (= us), usmax (same as ‘american’ but with additional hyphenation patterns), british (= uk), australian or newzealand
% 	\item \TB{ordinalmonthday} = true/\textit{false} (true by default only when variant = british)
% 	\end{itemize}
% 
% \subsection{esperanto}\label{esperanto}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\hodiau\ and \Cmd\hodiaun are special forms of \cmd\today\ (see the \Babel documentation)
% 	\end{itemize}
% 
% \subsection{farsi}\label{farsi}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{numerals} = western or \textit{eastern}
% 	\item \TB{locale} (not yet implemented)
% 	\item \TB{calendar} (not yet implemented)
% 	\end{itemize}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\abjad (see section \ref{abjad})
%   \item \Cmd\aemph (see section \ref{arabic}).
% 	\end{itemize}
% 
% ^^A\subsection{french}\label{french}
% ^^A\textbf{Options}:
% ^^A	\begin{itemize}
% ^^A    \item \TB{espacedeuxpoints} = thick or half \new{v1.2.x} ???
% ^^A  \footnote{ %
% ^^A    Can be customized by redefining \french@colonspace }
% ^^A	\end{itemize}
% ^^A
% 
% \subsection{german}\label{german}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{spelling} = \textit{new} (= 1996) or old (= 1901):
% 		indicates whether hyphenation patterns for traditional (1901) or reformed
% 		(1996) orthography should be used. The latter is the default.
% 	\item \TB{latesthyphen} = \textit{false} or true: if this option is set to true,
% 		the latest (experimental) hyphenation patterns ‘(n)german-x-latest’
% 		will be loaded instead of ‘german’ or ‘ngerman’. NB: This is based on
% 		the file \texttt{language.dat} that comes with \TeX Live 2008 and later.
% 	\item\TB{babelshorthands} = \textit{false} or true: \new{v1.0.3}
% 		if this is turned on, all shorthands defined in \Babel
% 		for fine-tuning the hyphenation of German words are activated.
% 		\begin{itemize}
% 		\item  ¦"ck¦ for ¦ck¦ to be hyphenated as ¦k-k¦
% 		\item  ¦"ff¦ for ¦ff¦ to be hyphenated as ¦ff-f¦; this is also available for the letters l, m, n, p, r and t
% 		\item ¦"|¦ disables the ligature at this position
% 		\item ¦"-¦ for an explicit hyphen sign, allowing hyphenation in the rest of the word
% 		\item ¦""¦ is like ¦"-¦, but produces no hyphen sign
% 			(for compound words with a hyphen, e.g., ¦foo-""bar¦)
% 		\item ¦"~¦ for a compound word mark without a breakpoint
% 		\item ¦"=¦ for a compound word mark with a breakpoint,
% 			allowing hyphenation in the composing words.
% 		\end{itemize}
% 
% 		There are also four shorthands for quotation signs:
% 		\begin{itemize}
% 		\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{itemize}
%   \item\TB{script} = \textit{latin} or fraktur.\new{v1.2.0}
%     Setting script=fraktur modifies the captions for typesetting German in Fraktur.
% 	\end{itemize}
% 
% \subsection{greek}\label{greek}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{variant} = \textit{monotonic} (= mono), polytonic (= poly), or ancient
% 	\item \TB{numerals} = \textit{greek} or arabic
% 	\item \TB{attic} = \textit{false}/true
% 	\end{itemize}
% \textbf{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}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{numerals} = hebrew or \textit{arabic}
% 	\item \TB{calendar} = hebrew or \textit{gregorian}
% 	\end{itemize}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\hebrewnumeral\ (= \Cmd\hebrewalph) (see section \ref{abjad}).
%   \item \Cmd\aemph (see section \ref{arabic}).
% 	\end{itemize}
% 
% \subsection{hindi}\label{hindi}\new{v1.2.0}
% \textbf{Options}:
% 	\begin{itemize}
%     \item \TB{numerals} = Western or \textit{Devanagari}
% 	\end{itemize}
% 
% \subsection{italian}\label{italian}
% \textbf{Option:}
% \begin{itemize}
%   \item \TB{babelshorthands} = \textit{false} or true. \new{v1.2.0cc}% TODO: check version
% 	Activates the ¦"¦ character as a switch to perform etymological
% 	hyphenation when followed by a letter, or other tasks when followed by
% 	certain analphabetic characters; in particular ¦""¦ is used to enter
% 	double raised open quotes (the Italian keyboard misses the backtick),
% 	and ¦"<¦  and ¦">¦ to insert open and closed guillemets without any
% 	spacing after the open or before the closed sign. ¦"/¦ is made
% 	equivalent to \slash allowing a linebreak after the slash without any
% 	hyphen sign; ¦"-¦ produces  a short rule/hyphen and a discretional line
% 	break alowing line breaks in the second compound word fragment.
% \end{itemize}
% 
% \subsection{lao}\label{lao}\new{v1.2.0}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{numerals} = lao or \textit{arabic}
% 	\end{itemize}
% 
% \subsection{lsorbian and usorbian}\label{lsorbian}\label{usorbian}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\oldtoday : see the \Babel documentation.
% 	\end{itemize}
% 
% \subsection{magyar}\label{magyar}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\ontoday\ (= \Cmd\ondatemagyar): special forms of \cmd\today\
% 		(see the \Babel documentation).
% 	\end{itemize}
% 
% 
% \subsection{russian}\label{russian}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{babelshorthands} = \textit{false} or true. % TODO check and document!
% 	\item \TB{spelling} = \textit{modern} or old (for captions and date only, not for hyphenation)
% 	\end{itemize}
% 
% \subsection{sanskrit}\label{sanskrit}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{Script} (default = Devanagari). \new{v1.0.2}
% 	The value is passed to \pkg{fontspec} in cases where ¦\sanskritfont¦ or
% 	¦\devanagarifont¦ are not defined. This can be useful if you typeset
% 	Sanskrit texts in scripts other than Devanagari.
% ^^ATODO \item Numerals <<<<
% 	\end{itemize}
% 
% \subsection{serbian}\label{serbian}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{script} = \textit{cyrillic} or latin
% 	\end{itemize}
% 
% \subsection{syriac}\label{syriac}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{numerals} = \textit{western} (i.e., 1234567890), eastern
% 		(for which the Oriental Arabic numerals are used: \textarabic{١٢٣٤٥٦٧٨٩٠}),
% 		or abjad. \new{v1.0.1}.
% 	\end{itemize}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\abjadsyriac (see section \ref{abjad})
%   \item \Cmd\aemph (see section \ref{arabic}).
% 	\end{itemize}
% 
% \subsection{thai}\label{thai}
% \textbf{Options}:
% 	\begin{itemize}
% 	\item \TB{numerals} = thai or \textit{arabic}
% 	\end{itemize}
% 
% To insert the 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.
% 
% \section{Modifying or extending captions and date formats}
% 
% To redefine internal macros, you can use the command ¦\gappto¦ from the package
% \pkg{etoolbox}. For compatibility with \Babel the command ¦\addto¦ is also available
% with the same effect. For instance, to change the ¦\chaptername¦ for language ¦lingua¦,
% you can do this:
% \begin{verbatim}
% \gappto\captionslingua{\renewcommand{\chaptername}{Caput}}
% \end{verbatim}
% 
% \section{Non-Western decimal digits}
% 
% Several scripts have their own versions of the decimal digits commonly called
% ‘Arabic numerals’.  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.
% 
% In previous versions this conversion was achieved my means of TECKit fontmappings.
% If needed they can be activated with the fontspec option
% ¦Mapping=arabicdigits¦ (or ¦farsidigits¦ or ¦thaidigits¦).
% For instance if \cmd\arabicfont\ is defined with the option ¦Mapping=arabicdigits¦,
% then by typing ¦\textarabic{2010}¦ one will obtain \textarabic{٢٠١٠}.
% 
% With version v1.1.1\new{v1.1.1} the same conversion is achieved directly by
% simple \TeX\ macros. This prevents some problems that occur when the value of a
% counter has to be written and read from auxiliary files.\footnote{ %
%   For instance the package \pkg{lastpage} did not work with \pkg{polyglossia} in situations
%   where the display of counters was redefined to include a font-switching command.}
% These macros (currently \Cmd\arabicdigits, \Cmd\farsidigits\ and \Cmd\thaidigits\ are provided)
% are also available to the users. For instance in an Arabic environment
% ¦\arabicdigits{9182/738543-X}¦ yields
% \textarabic{\arabicdigits{9182/738543-X}}.
% 
% \section{Alphabetic numbering in Greek, Arabic, Hebrew, Syriac and Farsi}\label{abjad}
% 
% In certain languages, numbers can be represented
% by a special alphanumerical notation.\footnote{ %
% 	See, e.g., \url{http://en.wikipedia.org/wiki/Greek_numerals},
% 	\url{http://en.wikipedia.org/wiki/Abjad_numerals},
% 	and \url{http://en.wikipedia.org/wiki/Hebrew_numerals}.}
% ^^A \url{http://en.wikipedia.org/wiki/Syriac_alphabet}
% 
% The Greek numerals are obtained with \Cmd\greeknumeral (or \Cmd\Greeknumeral\ in uppercase).
% Example: ¦\greeknumeral{1863}¦ yields \textgreek{\greeknumeral{1863}}.
% 
% The Arabic \textit{abjad} numbers can be generated with the command \Cmd\abjad.
% Example: ¦\abjad{1863}¦ yields {\arabicfont\abjad{1863}}.
% In the Maghrib the conventions are somewhat different, and the maghribi forms
% of the \textit{abjad} numerals are obtained with the \Cmd\abjadmaghribi\ command.
% Example: ¦\abjadmaghribi{1863}¦ yields {\arabicfont\abjadmaghribi{1863}}.
% 
% The code for Hebrew numerals, which was incorrect in previous versions, was
% ported from the implementation in \Babel with v1.1.1\new{v1.1.1}, and the
% user interface is identical to the one in \Babel.
% The commands \Cmd\hebrewnumeral, \Cmd\Hebrewnumeral and \Cmd\Hebrewnumeralfinal\ behave exactly
% as they do in \Babel: the second command prints the number with \textit{gereshayim} before
% the last letter, and the latter uses in addition the final forms of Hebrew letters.
% Examples:
% ¦\hebrewnumeral{1750}¦ yields {\hebrewfont\hebrewnumeral{1750}}.
% ¦\Hebrewnumeral{1750}¦ yields {\hebrewfont\Hebrewnumeral{1750}}.
% ¦\Hebrewnumeralfinal{1750}¦ yields {\hebrewfont\Hebrewnumeralfinal{1750}}.
% 
% 
% Support is also provided for Syriac abjad numerals, which can be generated
% with \Cmd\abjadsyriac.\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 {\syriacfont\abjadsyriac{463}}.
% 
% 
% \section{Calendars}
% 
% \subsection{Hebrew calendar (hebrewcal.sty)}
% The package \file{hebrewcal.sty} is almost a verbatim copy of \file{hebcal.sty}
% that comes with \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\{⟨year⟩\}\{⟨month⟩\}\{⟨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{v1.1.1}: its output will differ depending on the
% currently active language. Presently \pkg{polyglossia}’s language definition files
% for Arabic, Farsi, Urdu, Turkish, Bahasa Indonesia and Bahasa Melayu
% provide a localized version of ¦\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\{<lang>\}\{<code>\}}{\DefineHijriDateFormat}.
% 
% The command ¦\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 ¦\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 I 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.
% ^^AExample: today is \Jalalitoday.
% 
% 
% ^^A\section{Varia}
% 
% 
% \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: Johannes
% Braams and the numerous contributors to the \Babel{} package (in particular
% Boris Lavva and others for its Hebrew support), Alexej Kryukov (\pkg{antomega}), Will
% Robertson (\pkg{fontspec}), Apostolos Syropoulos (\pkg{xgreek}), Youssef Jabri
% (\pkg{arabi}), and Vafa Khalighi (\pkg{xepersian} and \pkg{bidi}).
% The work of Mojca Miklavec and 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: Yves Codet
% (Sanskrit), Zdenek Wagner (Hindi), Mikhal Oren (Hebrew), Sergey Astanin (Russian),
% Khaled Hosny (Arabic), Sertaç Ö. Yıldız (Turkish), Kamal Abdali (Urdu),
% and several other members of the \XeTeX\ user community, notably Enrico Gregorio, who
% has sent me many useful suggestions and corrections and contributed the ¦\newXeTeXintercharclass¦
% mechanism in xelatex.ini which is now used by polyglossia.
% More recently, 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 Brian Wilson.
% I also thank Alan Munn for kindly proof-reading the penultimate version of this documentation.
% And of course my gratitude also goes to Jonathan Kew, the formidable author of \XeTeX!
% 
% 
% 
% \StopEventually{}
% \section{Implementation}
% \iffalse
%<*polyglossia.sty>
% \fi
% \clearpage
% 
% \subsection{polyglossia.sty}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{polyglossia}[2012/04/29 v1.2.1
  Babel replacement for XeLaTeX]
\RequirePackage{etoolbox}
\RequirePackage{makecmds}
\RequirePackage{xkeyval}[2008/08/13]
\RequirePackage{fontspec}[2010/06/08]% v2.0
% fontspec now uses LaTeX3 packages such as expl3, so we need this:
\ExplSyntaxOn

\ifcsundef{newXeTeXintercharclass}{%
  \xpg@error{Your~ xelatex~ format~ appears~ to~ be~ outdated!^^J
~~~~Please~ update~ your~ system~ and~ recreate~ it~ with~ fmtutil.}
  }{}

%% This is for compatibility with Babel-aware package:
\cslet{ver@babel.sty}{\@empty} % this "fakes" babel
\def\languageshorthands#1{\relax} %this is for scrlttr2 class
\AtEndPreamble{\let\bbl@set@language\xpg@set@language} %for biblatex
\AtEndPreamble{\let\bbl@main@language\xpg@main@language} %for biblatex

%% for \docvslist (etoolbox)
\providecommand*{\do}[1]{}%

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

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

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

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

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

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

%% use macro if defined, else warn that it is not
\def\csuse@warn#1{%
   \ifcsundef{#1}{\xpg@warning{ \expandafter\string\csname #1\endcsname\space is~ not~ defined}}%
   {\csname #1\endcsname}}

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

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

%% == Utility macros ==
%%   They are needed because \MakeUppercase and \MakeLowercase are protected,
%%   but we need to change case while defining csnames when setting up fonts for
%%   non-Latin scripts. For instance with "Script=Arabic" we need to lowercase
%%   "Arabic" to create \arabicfont.
\def\xpg@uppercasefirst#1{\expandafter\xpg@@uppercasefirst #1}
\def\xpg@@uppercasefirst#1{%
       \if a#1A\else
       \if b#1B\else
       \if c#1C\else
       \if d#1D\else
       \if e#1E\else
       \if f#1F\else
       \if g#1G\else
       \if h#1H\else
       \if i#1I\else
       \if j#1J\else
       \if k#1K\else
       \if l#1L\else
       \if m#1M\else
       \if n#1N\else
       \if o#1O\else
       \if p#1P\else
       \if q#1Q\else
       \if r#1R\else
       \if s#1S\else
       \if t#1T\else
       \if u#1U\else
       \if v#1V\else
       \if w#1W\else
       \if x#1X\else
       \if y#1Y\else
       \if z#1Z\else
       \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}

\def\xpg@lowercasefirst#1{\expandafter\xpg@@lowercasefirst #1}
\def\xpg@@lowercasefirst#1{%
       \if A#1a\else
       \if B#1b\else
       \if C#1c\else
       \if D#1d\else
       \if E#1e\else
       \if F#1f\else
       \if G#1g\else
       \if H#1h\else
       \if I#1i\else
       \if J#1j\else
       \if K#1k\else
       \if L#1l\else
       \if M#1m\else
       \if N#1n\else
       \if O#1o\else
       \if P#1p\else
       \if Q#1q\else
       \if R#1r\else
       \if S#1s\else
       \if T#1t\else
       \if U#1u\else
       \if V#1v\else
       \if W#1w\else
       \if X#1x\else
       \if Y#1y\else
       \if Z#1z\else
       \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
}

%% NEW EXPERIMENTAL SETUP INTERFACE FOR GLOSS FILES
%% options currently available:
%% language : the name of the language (as understood by fontspec)
%% hyphennames : the different hyphenation patterns to try (comma separated list)
%%%   TODO: if pattern is prefixed by !, then it should be loaded as a fallback, with \xpg@nopatterns@fallback - i.e. with a warning: e.g. sanskrit for hindi, or catalan for asturian.
%% script : the name of the script (as understood by fontspec) – default is Latin
%% direction : the direction of the script: LR or RL
%% scripttag : the OpenType tag for the script
%% langtag : the OpenType tag for the language
%% hyphenmins : the hyphenmins for this language (comma-sep list of two integers)
%% frenchspacing : boolean
%% indentfirst : boolean
%% fontsetup : boolean
%% TODO: nouppercase : boolean (for scripts like Arabic, Devanagari, etc which have no concept of uppercase/lowercase)
%% TODO: localalph = {<alph_csname>,<Alph_csname>}
%% TODO: localnumber = <csname>
%%       or even better localdigits = {0123456789} for fully automatic setup

\newcommand*\PolyglossiaSetup[2]{%
  %define booleans etoolbox style and set defaults
  %% TODO ? \providetoggle{#1@setup@done}%
  \providetoggle{#1@RL}%
  \providetoggle{#1@latin}\toggletrue{#1@latin}%
  \providetoggle{#1@scriptlangequal}% whether lang and script names are same: e.g. Hebrew, Arabic
  \providebool{#1@fontsetup}%
  \providebool{#1@indentfirst}%
  \providebool{#1@frenchspacing}%
  % we initialize these so that we can use \gappto below
  \csgdef{init@extras@#1}{}%
  \csgdef{init@noextras@#1}{}% we don't use this yet: remove?
  \csgdef{xpg@langname@#1}{\xpg@uppercasefirst{#1}}%
  %needed for docvslist with hyphennames key:
  \renewcommand*{\do}[1]{%
    \ifcsdef{l@#1}{}{%
      \ifstrequal{#1}{##1}{}%
      {\ifcsdef{l@##1}%
        {\csletcs{l@#1}{l@##1}\listbreak}%
        {}%
      }%
    }%
  }%
  %define all keys:
  \xpg@define@keys{#1}%
  \setkeys[xpg@setup]{#1}{#2}%
  % here we do the fontsetup:
  \ifbool{#1@fontsetup}%
    {\xpg@fontsetup@auto{#1}}%
    {\xpg@info{Skipping~ automatic~ font~ setup~ for~ language~ #1}}%
  %% TODO? \toggletrue{#1@setup@done}%
  % reinit \do
  \renewcommand*{\do}[1]{\setotherlanguage{##1}}%
}

\def\xpg@first#1,#2{#1}
\def\xpg@second#1,#2{#2}

\def\xpg@define@keys#1{%
  \define@key[xpg@setup]{#1}{script}{%
    \ifstrequal{##1}{Latin}%
      {\toggletrue{#1@latin}}%
      {\togglefalse{#1@latin}}%
    \csgdef{xpg@scriptname@#1}{##1}%
    \csgdef{xpg@scriptname@#1@lc}{\xpg@lowercasefirst{##1}}}%
  \define@key[xpg@setup]{#1}{scripttag}{%
    \csgdef{xpg@scripttag@#1}{##1}}%
  \define@key[xpg@setup]{#1}{language}{%
    \csgdef{xpg@langname@#1}{##1}}%
  \define@key[xpg@setup]{#1}{langtag}{%
    \csgdef{xpg@langtag@#1}{##1}}%
  \define@key[xpg@setup]{#1}{hyphennames}[{#1}]{%
    \docsvlist{##1}%
    % if l@#1 does not yet exist,
    % we assign it to nohyphenation
    % we do this here in case the hyphennames key was omitted
    \ifcsundef{l@#1}%
      {\xpg@nopatterns{\csname xpg@langname@#1\endcsname}%
       \expandafter\adddialect\csname l@#1\endcsname\l@nohyphenation\relax}{}%
    \csdef{#1@language}{\language=\csname l@#1\endcsname}%
    }%
  \define@choicekey+[xpg@setup]{#1}{direction}[\val\nr]{LR,RL}[LR]%
    {\ifcase\nr\relax
        \togglefalse{#1@RL}%
      \or
        \toggletrue{#1@RL}%
        \ifcsundef{RTL}{\RequirePackage{bidi}}{}%
    \fi}%
    {\xpg@warning{#1: Invalid value \val\space for key "direction"}}%
  \define@key[xpg@setup]{#1}{hyphenmins}[{2,3}]%
    {\begingroup\edef\x{\endgroup
       \noexpand\setlocalhyphenmins{#1}{\xpg@first##1}{\xpg@second##1}}\x}
  \define@boolkey[xpg@setup]{#1}[#1@]{frenchspacing}[true]{%
    \ifbool{#1@frenchspacing}%
      {\csgappto{init@extras@#1}{\frenchspacing}}%
      {\csgappto{init@extras@#1}{\nonfrenchspacing}}}%
  \define@boolkey[xpg@setup]{#1}[#1@]{indentfirst}[true]{%
    \ifbool{#1@indentfirst}%
      {\csgappto{init@extras@#1}{\french@indent}}%
      {\csgappto{init@extras@#1}{\nofrench@indent}}}%
%  \define@choicekey*+[xpg@setup]{#1}{fontsetup}[\val\nr]{none,custom,auto}[none]%
%    %{\csgdef{#1@fontsetup}{\val}}%
%    {\xpg@fontsetup{\val}{#1}}%
%    {\xpg@warning{Invalid value \val\space for key "fontsetup" in module "#1"}}%
  \define@boolkey[xpg@setup]{#1}[#1@]{fontsetup}[true]{}%
  %TODO assign csnames corr. to localized alph and Alph
  %  \define@key[xpg@setup]{#1}{localalph}[{#1@alph,#1@Alph}]{%
  %  \cslet{xpg@localalph@#1}{\expandafter\csname\xpg@first##1\endcsname}%
  %  \cslet{xpg@localAlph@#1}{\expandafter\csname\xpg@second##1\endcsname}%
  %}%
  %TODO same thing with localdigits
}

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

\def\xpg@fontsetup@auto#1{\iftoggle{#1@latin}%
  {\xpg@fontsetup@latin{#1}}%
  {\xpg@fontsetup@nonlatin{#1}}%
}

\def\xpg@addfontfeature@lang#1#2{% #1 is langtag, #2 is langname
  % Turkish is a special case: tag can be TRK or TUR
  \edef\tmp@Turkish{Turkish}%
  \edef\tmp@@langname{#2}%
  %  \ifstrequal{#2}{Turkish}%
  \ifx\tmp@@langname\tmp@Turkish
    \fontspec_if_language:nTF {TRK}%
      {\addfontfeature{Language=Turkish}}%
      {\fontspec_if_language:nTF {TUR}%
        {\addfontfeature{Language=Turkish}}%
        {}}%
    % else not Turkish
  \else
     \edef\tmp@@langparam{Language=#2}%
     \expandafter\expandafter\expandafter\fontspec_if_language:nTF \expandafter{#1}%
      {\expandafter\expandafter\expandafter\addfontfeature\expandafter{\tmp@@langparam}}%
      {}%
  \fi
}

\def\xpg@addfontfeature@script#1#2{% #1 is scripttag, #2 is scriptname
  \edef\tmp@@scriptparam{Script=#2}%
  \expandafter\expandafter\expandafter\fontspec_if_script:nTF \expandafter{#1}%
    {\expandafter\expandafter\expandafter\addfontfeature\expandafter{\tmp@@scriptparam}}%
    {\xpg@error{^^J
  The~ current~ roman~ font~ does~ not~ contain~ the~ \expandafter\noexpand#2 ~ script!^^J
  Please~ define~ \expandafter\string\csname \xpg@lowercasefirst{#2}font\endcsname\space with~ \string\newfontfamily}}%
}

\def\xpg@fontsetup@latin#1{%
  \begingroup
  \csgdef{#1@font@rm}{%
    \ifcsdef{#1font}{\csname #1font\endcsname}%
      {\edef\tmp@langtag{\csuse{xpg@langtag@#1}}%
       \edef\tmp@langname{\csuse{xpg@langname@#1}}%
       \rmfamilylatin%
        \ifcsvoid{xpg@langtag@#1}{}{%
          \ifcsvoid{xpg@langname@#1}{}{%
           \xpg@addfontfeature@lang{\tmp@langtag}{\tmp@langname}}%
      }}}%
  \csgdef{#1@font@sf}{%
    \ifcsdef{#1fontsf}{\csname #1fontsf\endcsname}%
      {\edef\tmp@langtag{\csuse{xpg@langtag@#1}}%
       \edef\tmp@langname{\csuse{xpg@langname@#1}}%
       \sffamilylatin%
      \ifcsvoid{xpg@langtag@#1}{}{%
        \ifcsvoid{xpg@langname@#1}{}{%
           \xpg@addfontfeature@lang{\tmp@langtag}{\tmp@langname}}%
      }}}%
  \csgdef{#1@font@tt}{%
    \ifcsdef{#1fonttt}{\csname #1fonttt\endcsname}%
      {\edef\tmp@langtag{\csuse{xpg@langtag@#1}}%
       \edef\tmp@langname{\csuse{xpg@langname@#1}}%
       \ttfamilylatin%
      \ifcsvoid{xpg@langtag@#1}{}{%
        \ifcsvoid{xpg@langname@#1}{}{%
           \xpg@addfontfeature@lang{\tmp@langtag}{\tmp@langname}}%
      }}}%
  \endgroup
}

\def\xpg@fontsetup@nonlatin#1{%
  \begingroup
  \edef\tmp@langname@lc{#1}% eg ukrainian
  \edef\tmp@scriptname@lc{\csuse{xpg@scriptname@#1@lc}}% eg cyrillic
  \ifx\tmp@scriptname@lc\tmp@langname@lc
    \toggletrue{#1@scriptlangequal}%
  \else
    \togglefalse{#1@scriptlangequal}%
  \fi
  \csgdef{#1@font@rm}{%
    \ifcsdef{#1font}%
      {\@nameuse{#1font}}%
      {\edef\tmp@scripttag{\csuse{xpg@scripttag@#1}}% eg cyrl
       \edef\tmp@scriptname{\csuse{xpg@scriptname@#1}}% eg Cyrillic
       \edef\tmp@langtag{\csuse{xpg@langtag@#1}}% eg UKR
       \edef\tmp@langname{\csuse{xpg@langname@#1}}% eg Ukrainian
       \providetoggle{#1@use@script@font}%
       \iftoggle{#1@scriptlangequal}%
        {\rmfamilylatin}%
        {\expandafter\ifcsname\csuse{xpg@scriptname@#1@lc} font\endcsname% eg \cyrillicfont
           \toggletrue{#1@use@script@font}%
           \expandafter\csname\csuse{xpg@scriptname@#1@lc} font\endcsname
         \else
           \rmfamilylatin
         \fi}
       \iftoggle{#1@use@script@font}{}{%
         \ifcsvoid{xpg@scripttag@#1}{}{%
           \ifcsvoid{xpg@scriptname@#1}{}{%
             \xpg@addfontfeature@script{\tmp@scripttag}{\tmp@scriptname}}}}%
       \ifcsvoid{xpg@langtag@#1}{}{%
         \ifcsvoid{xpg@langname@#1}{}{%
         \xpg@addfontfeature@lang{\tmp@langtag}{\tmp@langname}}}%
      }}%
  \csgdef{#1@font@sf}{%
    \ifcsdef{#1fontsf}%
      {\@nameuse{#1fontsf}}%
      {\edef\tmp@scripttag{\csuse{xpg@scripttag@#1}}% eg cyrl
       \edef\tmp@scriptname{\csuse{xpg@scriptname@#1}}% eg Cyrillic
       \edef\tmp@langtag{\csuse{xpg@langtag@#1}}% eg UKR
       \edef\tmp@langname{\csuse{xpg@langname@#1}}% eg Ukrainian
       \providetoggle{#1@use@script@fontsf}%
       \iftoggle{#1@scriptlangequal}%
        {\sffamilylatin}%
        {\expandafter\ifcsname\csuse{xpg@scriptname@#1@lc} fontsf\endcsname% eg \cyrillicfontsf
           \toggletrue{#1@use@script@fontsf}%
           \expandafter\csname\csuse{xpg@scriptname@#1@lc} fontsf\endcsname
         \else
           \sffamilylatin
         \fi}
       \iftoggle{#1@use@script@fontsf}{}{%
         \ifcsvoid{xpg@scripttag@#1}{}{%
           \ifcsvoid{xpg@scriptname@#1}{}{%
             \xpg@addfontfeature@script{\tmp@scripttag}{\tmp@scriptname}}}}%
       \ifcsvoid{xpg@langtag@#1}{}{%
         \ifcsvoid{xpg@langname@#1}{}{%
         \xpg@addfontfeature@lang{\tmp@langtag}{\tmp@langname}}}%
      }}%
  \csgdef{#1@font@tt}{%
    \ifcsdef{#1fonttt}%
      {\@nameuse{#1fonttt}}%
      {\edef\tmp@scripttag{\csuse{xpg@scripttag@#1}}% eg cyrl
       \edef\tmp@scriptname{\csuse{xpg@scriptname@#1}}% eg Cyrillic
       \edef\tmp@langtag{\csuse{xpg@langtag@#1}}% eg UKR
       \edef\tmp@langname{\csuse{xpg@langname@#1}}% eg Ukrainian
       \providetoggle{#1@use@script@fonttt}%
       \iftoggle{#1@scriptlangequal}%
        {\ttfamilylatin}%
        {\expandafter\ifcsname\csuse{xpg@scriptname@#1@lc} fonttt\endcsname% eg \cyrillicfonttt
           \toggletrue{#1@use@script@fonttt}%
           \expandafter\csname\csuse{xpg@scriptname@#1@lc} fonttt\endcsname
         \else
           \ttfamilylatin
         \fi}
       \iftoggle{#1@use@script@fonttt}{}{%
         \ifcsvoid{xpg@scripttag@#1}{}{%
           \ifcsvoid{xpg@scriptname@#1}{}{%
             \xpg@addfontfeature@script{\tmp@scripttag}{\tmp@scriptname}}}}%
       \ifcsvoid{xpg@langtag@#1}{}{%
         \ifcsvoid{xpg@langname@#1}{}{%
         \xpg@addfontfeature@lang{\tmp@langtag}{\tmp@langname}}}%
      }}%
  \endgroup
}

%%% END OF PolyglossiaSetup

%% ensure localization of \markright and \markboth commands
%%% THIS IS NOW DISABLED BY DEFAULT
\define@boolkey{polyglossia}[xpg@]{localmarks}[false]{%
   \ifbool{xpg@localmarks}{%
      \xpg@info{Option:~ localmarks}%
      \def\local@marks##1{%
         \def\markboth####1####2{%
            \begingroup
               \let\label\relax \let\index\relax \let\glossary\relax
               \unrestored@protected@xdef\@themark
         {{\foreignlanguage{##1}{%
            \protect\@@ensure@maindir{####1}}}%
          {\foreignlanguage{##1}{%
      \protect\@@ensure@maindir{####2}}}}%
               \@temptokena \expandafter{\@themark}%
               \mark{\the\@temptokena}%
            \endgroup
            \if@nobreak\ifvmode\nobreak\fi\fi}%
            \def\markright####1{%
               \begingroup
                  \let\label\relax \let\index\relax \let\glossary\relax
                  \expandafter\@markright\@themark
      {\foreignlanguage{##1}{\protect\@@ensure@maindir{####1}}}%
                  \@temptokena \expandafter{\@themark}%
                  \mark{\the\@temptokena}%
               \endgroup
               \if@nobreak\ifvmode\nobreak\fi\fi}%
            \def\@markright####1####2####3{\@temptokena{\protect\@@ensure@maindir{####1}}%
               \unrestored@protected@xdef\@themark{{\the\@temptokena}%
               {\protect\@@ensure@maindir{####3}}}}}%
    }{% else
      \def\local@marks##1{}%
    }%
}
\setkeys{polyglossia}{localmarks=false}

% to reset the intercharclass of a character to "normal"
\newXeTeXintercharclass\xpg@normalclass %TODO

%% when no patterns are available, we use \l@nohyphenation, assigned to 255
%%  (suggestion by Enrico Gregorio)
\@ifundefined{l@nohyphenation}{\chardef\l@nohyphenation=255 }{}

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

\newcommand{\xpg@input}[1]{%
  \chardef\xpg@atcatcode\catcode`\@
  \makeatletter
  \input{#1}\catcode`\@=\xpg@atcatcode}

\newcommand{\setdefaultlanguage}[2][]{%
   \IfFileExists{gloss-#2.ldf}%
   {\ifcsundef{#2@loaded}%
     {\xpg@input{gloss-#2.ldf}%
     \xpg@info{Default~ language~ is~ #2}%
     \def\languagename{#2}%
      % This is needed because \arabic is a built-in LaTeX command:
      % so now we have \begin{Arabic}... instead of \begin{arabic}...
      \ifstrequal{#2}{arabic}%
      {\newenvironment{Arabic}[1][]{\begin{otherlanguage}[####1]{arabic}}%
        {\end{otherlanguage}}}%
      {\newenvironment{#2}[1][]{\begin{otherlanguage}[####1]{#2}}%
        {\end{otherlanguage}}}%
      \expandafter\newcommand\csname text#2\endcsname[2][]{%
        \ifcsdef{RTL}%
          {\iftoggle{#2@RL}%
            {\@ensure@RTL{\foreignlanguage[####1]{#2}{####2}}}%
            {\@ensure@LTR{\foreignlanguage[####1]{#2}{####2}}}%
          }% else bidi not loaded
          {\iftoggle{#2@RL}%
            {\xpg@error{Language~ #2~ is~ right-to-left,~ but~ bidi~ package~ was~ not~ loaded!}}%
            {\foreignlanguage[####1]{#2}{####2}}%
          }%
      }%
      \csletcs{local#2}{text#2}%
      \csgdef{#2@loaded}{}%
      \gdef\xpg@main@language{#2}%
      }%
      {\xpg@warning{gloss-#2.ldf~ is~ already~ loaded!}}%:
      %% The following settings are for the default language and script:
      \iftoggle{#2@RL}{\@RTLmaintrue}{}% this tells bidi.sty that the document is RTL
      \AtBeginDocument{%
      \selectlanguage[#1]{#2}%
      \selectbackgroundlanguage{#2}}%
   }%
   %ELSE
   {\xpg@nogloss{#2}}%
}

\let\setmainlanguage=\setdefaultlanguage

\newcommand{\resetdefaultlanguage}[2][]{%
    \ifcsundef{#2@loaded}{%
     \xpg@error{gloss-#2.ldf~ is~ not~ loaded!}}%
    {\csuse{no\xpg@main@language @globalnumbers}% disable globalnumbers of previously defined default language
    \csuse{noextras@\xpg@main@language}%
    \csuse{init@noextras@\xpg@main@language}%
    \def\languagename{#2}%
    \iftoggle{#2@RL}{\@rlmaintrue\@rl@footnotetrue}{}%
    \selectlanguage[#1]{#2}%
    \selectbackgroundlanguage{#2}}}

\expandafter\ifx\familydefault\sfdefault
  \def\familytype{sf}
\else\expandafter\ifx\familydefault\ttdefault
  \def\familytype{tt}
\else
  \def\familytype{rm}
\fi\fi
% This robustifies the redefinitions of \<xx>family (suggestion by Enrico Gregorio)
% e.g. to prevent expansion of the \familytype redefinition in auxiliary files
\csgappto{rmfamily }{\def\familytype{rm}}
\csgappto{sffamily }{\def\familytype{sf}}
\csgappto{ttfamily }{\def\familytype{tt}}
% This saves the normalfont for the latin script since we may change normalfont in other scripts
\let\normalfontlatin=\normalfont%
\let\rmfamilylatin=\rmfamily%
\let\sffamilylatin=\sffamily%
\let\ttfamilylatin=\ttfamily%

\def\resetfontlatin{%
   \let\rmfamily=\rmfamilylatin%
   \let\sffamily=\sffamilylatin%
   \let\ttfamily=\ttfamilylatin%
   \let\normalfont=\normalfontlatin}

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

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

\def\xpg@set@normalfont#1{%
  \letcs{\rmfamily}{#1@font@rm}%
  \letcs{\sffamily}{#1@font@sf}%
  \letcs{\ttfamily}{#1@font@tt}%
  \gdef\normalfont{\protect\xpg@select@fontfamily{#1}}%
  \gdef\reset@font{\protect\normalfont}%
}

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

\newcommand{\selectbackgroundlanguage}[1]{%
    \iftoggle{#1@latin}{}{\xpg@set@normalfont{#1}}%
    \csuse{#1@globalnumbers}%
    }

\newcommand{\setotherlanguage}[2][]{%
   \IfFileExists{gloss-#2.ldf}%
   {\ifcsundef{#2@loaded}%
     {\xpg@input{gloss-#2.ldf}%
      \setkeys{#2}{#1}%
      \edef\@tmpa{arabic}%
      \edef\@tmpb{#2}%
      \ifx\@tmpb\@tmpa%
      \newenvironment{Arabic}[1][]{\begin{otherlanguage}[####1]{arabic}}%
         {\end{otherlanguage}}%
      \else
      \newenvironment{#2}[1][]{\begin{otherlanguage}[####1]{#2}}%
         {\end{otherlanguage}}%
      \fi
      \expandafter\newcommand\csname text#2\endcsname[2][]{%
        \ifcsdef{RTL}%
          {\iftoggle{#2@RL}%
            {\@ensure@RTL{\foreignlanguage[####1]{#2}{####2}}}%
            {\@ensure@LTR{\foreignlanguage[####1]{#2}{####2}}}%
          }% else bidi not loaded
          {\iftoggle{#2@RL}%
            {\xpg@error{Language~ #2~ is~ right-to-left,~ but~ bidi~ package~ was~ not~ loaded!}}%
            {\foreignlanguage[####1]{#2}{####2}}%
          }%
        }%
     \csletcs{local#2}{text#2}%
     \csgdef{#2@loaded}{}%
     }%
     {\xpg@warning{gloss-#2.ldf~ is~ already~ loaded!}}%
   }%
   %ELSE
   {\xpg@nogloss{#2}}%
}

\newcommand\setotherlanguages[1]{%
  \renewcommand*{\do}[1]{\setotherlanguage{##1}}%
   \docsvlist{#1}}%

\def\common@language{% FIXME is this really needed???
   \language=\z@
   \lefthyphenmin=\tw@
   \righthyphenmin=\thr@@}

\def\noextrascurrent#1{\csuse{noextras@#1}}

\def\xpg@initial@setup{\ifcsundef{languagename}{}%
   {\noextrascurrent{\languagename}}%
   \common@language}

\AtBeginDocument{\xpg@initial@setup}

\providecommand{\foreignlanguage}{}

\renewcommand{\foreignlanguage}[3][]{%
   \ifcsundef{#2@loaded}%
     {\xpg@nogloss{#2}}%
     {{\select@@language{#2}%
      \setkeys{#2}{#1}%
      \use@localhyphenmins{#2}%
      \ifbool{#2@frenchspacing}{\frenchspacing}{\nonfrenchspacing}%
      \csuse{inlineextras@#2}%
      #3}%
     }%
}

% otherlanguage* is the environment equivalent of \foreignlanguage
\expandafter\providecommand\csname otherlanguage*\endcsname{}
\renewenvironment{otherlanguage*}[2][]{%
   \ifcsundef{#2@loaded}%
     {\xpg@nogloss{#2}}%
     {\select@@language{#2}%
      \setkeys{#2}{#1}%
      \use@localhyphenmins{#2}%
      \ifbool{#2@frenchspacing}{\frenchspacing}{\nonfrenchspacing}%
      \csuse{inlineextras@#2}\csuse{date#2}%
     }%
}{}

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

\providecommand{\selectlanguage}{}
\renewcommand{\selectlanguage}[2][]{%
   \ifcsundef{#2@loaded}%
     {\xpg@nogloss{#2}}%
     {\def\xpg@pop@language{%
         \xpg@set@language{\languagename}%
         \xpg@hook@setlanguage%
         \let\emp@langname\@undefined}%
      \aftergroup\xpg@pop@language%
      \setkeys{#2}{#1}%
      \xpg@set@language{#2}%
     }%
}

\newcommand{\xpg@set@language}[1]{%
   \select@language{#1}%
   \if@filesw%
      \protected@write\@auxout{}{\protect\select@language{#1}}%
      \addtocontents{toc}{\protect\select@language{#1}}%
      \addtocontents{lof}{\protect\select@language{#1}}%
      \addtocontents{lot}{\protect\select@language{#1}}%
   \fi
}

\def\select@language#1{%
   \xpg@initial@setup%
   \select@@language{#1}%
   \ifcsundef{setRL}{}%
   {\iftoggle{#1@RL}{\setRL}{\setLR}}%
   \csuse{captions#1}%
   \local@marks{#1}%
   \csuse{init@extras@#1}%
   \csuse{blockextras@#1}%
}

% Common code for `\select@language' and `\foreignlanguage'.
\newcommand{\select@@language}[1]{%
  \edef\languagename{#1}%
  \xpg@select@fontfamily{#1}%
  \csuse@warn{#1@language}%
  \csuse{date#1}%
  \csuse{#1@numbers}%
  \use@localhyphenmins{#1}%
}


\let\xpg@pop@language\relax

\provideenvironment{otherlanguage}{}{}

\renewenvironment{otherlanguage}[2][]
   {\selectlanguage[#1]{#2}}
   {}

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

\def\use@localhyphenmins#1{%
   \ifcsundef{#1hyphenmins}{}%
   {\expandafter\expandafter\expandafter\set@hyphenmins\csname #1hyphenmins\endcsname\relax}}

\define@boolkey{polyglossia}[system@]{babelshorthands}[false]{}

\AtEndPreamble{\@ifpackageloaded{bidi}{\newcommand*{\aemph}[1]{$\overline{\hboxR{#1}}$}}{}}

%% Package Options %%
\DeclareOption{nolocalmarks}{\setkeys{polyglossia}{localmarks=false}}
\DeclareOption{localmarks}{\setkeys{polyglossia}{localmarks=true}}
\DeclareOption{babelshorthands}{\setkeys{polyglossia}{babelshorthands=true}}
\DeclareOption{quiet}{%
   \gdef\@latex@info#1{\relax}% no latex info
   \gdef\@font@info#1{\relax}% no latex font info
   \gdef\@font@warning#1{\relax}% no latex font warnings
   \gdef\zf@PackageInfo#1{\relax}% no fontspec info
   \gdef\xpg@info#1{\relax}}% no polyglossia info
%
% FIXME these should also be loaded \AtEndOfPackage !!!
\def\xpg@option#1#2{%
  \ifcsundef{xpg@main@language}{\setdefaultlanguage}{\setotherlanguage}%
    [#1]{#2}}
%\DeclareOption{USenglish}{\xpg@option{variant=american}{english}}
%\DeclareOption{american}{\xpg@option{variant=american}{english}}
%\DeclareOption{UKenglish}{\xpg@option{variant=british}{english}}
%\DeclareOption{british}{\xpg@option{variant=british}{english}}
%\DeclareOption{australian}{\xpg@option{variant=australian}{english}}
%\DeclareOption{newzealand}{\xpg@option{variant=newzealand}{english}}
%\DeclareOption{ngerman}{\xpg@option{spelling=new}{german}}
%\DeclareOption{polygreek}{\xpg@option{variant=poly}{greek}}
%\DeclareOption{monogreek}{\xpg@option{variant=mono}{greek}}
%\DeclareOption{ancientgreek}{\xpg@option{variant=ancient}{greek}}
%%% TODO add warning message that this approach is deprecated <<<<<<<<<<<<<<
%\DeclareOption*{%
%  \edef\@temp{%
%    \noexpand\ifcsundef{xpg@main@language}%
%      \noexpand\setdefaultlanguage
%      \noexpand\setotherlanguage
%    {\CurrentOption}%
%  }%
%  \expandafter\AtEndOfPackage\expandafter{\@temp}%
%}
\ExplSyntaxOff
\ProcessOptions*
%    \end{macrocode}
% \iffalse
%</polyglossia.sty>
%<*farsical.sty>
% \fi
% \clearpage
% 
% \subsection{farsical.sty}
%    \begin{macrocode}
\ProvidesPackage{farsical}
        [2008/07/02 v0.1 %
         Farsi (jalali) calendar]
\RequirePackage{bidi,calc,arabicnumbers}

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

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

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

\newif\if@xpg@hebrewcal@marcheshvan
\DeclareOption{marcheshvan}{\@xpg@hebrewcal@marcheshvantrue}
\ifx\if@xpg@hebrew@marcheshvan\undefined
  \newif\if@xpg@hebrew@marcheshvan
  \@xpg@hebrew@marcheshvanfalse
\fi

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

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

\define@boolkey{hebrew}[@hebrew@]{fullyear}[false]{}
\setkeys{hebrew}{fullyear}

\newcount\hebrewday  \newcount\hebrewmonth \newcount\hebrewyear
\def\hebrewdate#1#2#3{%
    \HebrewFromGregorian{#1}{#2}{#3}%
                        {\hebrewday}{\hebrewmonth}{\hebrewyear}%
    \if@RTL%
      \@FormatForHebrew{\hebrewday}{\hebrewmonth}{\hebrewyear}%
    \else%
      \@FormatForEnglish{\hebrewday}{\hebrewmonth}{\hebrewyear}%
    \fi}
\def\hebrewtoday{\hebrewdate{\day}{\month}{\year}}
% The command name is capitalised in the doc, and this is consistent
% with other names such as \Hijritoday and \Jalalitoday.
\let\Hebrewtoday=\hebrewtoday
\def\hebrewsetreg{%
    \HebrewFromGregorian{\day}{\month}{\year}%
                        {\hebrewday}{\hebrewmonth}{\hebrewyear}}
\def\HebrewYearName#1{{%
   \@tempcnta=#1\divide\@tempcnta by 1000\multiply\@tempcnta by 1000
   \ifnum#1=\@tempcnta\relax % divisible by 1000: disambiguate
     \hebrewnumeral{#1}\ (לפ"ג)%
   \else % not divisible by 1000
     \ifnum#1<1000\relax     % first millennium: disambiguate
       \hebrewnumeral{#1}\ (לפ"ג)%
     \else 
       \ifnum#1<5000
         \hebrewnumeral{#1}%
       \else
         \ifnum#1<6000 % current millenium, print without thousands
           \@tempcnta=#1\relax
           \if@hebrew@fullyear\else\advance\@tempcnta by -5000\fi
           \hebrewnumeral{\@tempcnta}%
         \else % #1>6000
           \hebrewnumeral{#1}%
         \fi
       \fi
     \fi
   \fi}}
\def\HebrewMonthName#1#2{%
    \ifnum #1 = 7 %
    \@CheckLeapHebrewYear{#2}%
        \if@HebrewLeap אדר\ ב'%
           \else אדר%
        \fi%
    \else%
        \ifcase#1%
           % nothing for 0
           \or תשרי%
           \or\if@xpg@hebrewcal@marcheshvan מרחשון\else\if@xpg@hebrew@marcheshvan מרחשון\else חשון\fi\fi%
           \or כסלו%
           \or טבת%
           \or שבט%
           \or אדר\ א'%
           \or אדר\ ב'%
           \or ניסן%
           \or אייר%
           \or סיון%
           \or תמוז%
           \or אב%
           \or אלול%
        \fi%
    \fi}
\def\@FormatForHebrew#1#2#3{%
  \hebrewnumeral{#1}~ב\HebrewMonthName{#2}{#3}~%
  \HebrewYearName{#3}}
\def\HebrewMonthNameInEnglish#1#2{%
    \ifnum #1 = 7%
    \@CheckLeapHebrewYear{#2}%
        \if@HebrewLeap Adar II\else Adar\fi%
    \else%
        \ifcase #1%
            % nothing for 0
            \or Tishrei%
            % \or\if@xpg@hebrewcal@marcheshvan Marcheshvan\else\if@xpg@hebrew@marcheshvan Marcheshvan\else Heshvan\fi\fi%
            \or\if@xpg@hebrewcal@marcheshvan Marcheshvan\else\if@xpg@hebrew@marcheshvan Marcheshvan\else Heshvan\fi\fi%
            \or Kislev%
            \or Tebeth%
            \or Shebat%
            \or Adar I%
            \or Adar II%
            \or Nisan%
            \or Iyar%
            \or Sivan%
            \or Tammuz%
            \or Av%
            \or Elul%
        \fi
    \fi}
\def\@FormatForEnglish#1#2#3{%
    \HebrewMonthNameInEnglish{#2}{#3} \number#1,\ \number#3}
\newcount\@common
\newif\if@HebrewLeap
\def\@CheckLeapHebrewYear#1{%
    {%
        \countdef\tmpa = 0%       % \tmpa==\count0
        \countdef\tmpb = 1%       % \tmpb==\count1
        \tmpa = #1%
        \multiply \tmpa by 7%
        \advance \tmpa by 1%
        \@Remainder{\tmpa}{19}{\tmpb}%
        \ifnum \tmpb < 7%         % \tmpb = (7*year+1)%19
            \global\@HebrewLeaptrue%
        \else%
            \global\@HebrewLeapfalse%
        \fi}}
\def\@HebrewElapsedMonths#1#2{%
    {%
        \countdef\tmpa = 0%       % \tmpa==\count0
        \countdef\tmpb = 1%       % \tmpb==\count1
        \countdef\tmpc = 2%       % \tmpc==\count2
        \tmpa = #1%               %
        \advance \tmpa by -1%     %
        #2 = \tmpa%               % #2 = \tmpa = year-1
        \divide #2 by 19%         % Number of complete Meton cycles
        \multiply #2 by 235%      % #2 = 235*((year-1)/19)
        \@Remainder{\tmpa}{19}{\tmpb}% \tmpa = years%19-years this cycle
        \tmpc = \tmpb%            %
        \multiply \tmpb by 12%    %
        \advance #2 by \tmpb%     % add regular months this cycle
        \multiply \tmpc by 7%     %
        \advance \tmpc by 1%      %
        \divide \tmpc by 19%      % \tmpc = (1+7*((year-1)%19))/19 -
        \advance #2 by \tmpc%     %  add leap months
        \global\@common = #2}%
    #2 = \@common}
\def\@HebrewElapsedDays#1#2{%
    {%
        \countdef\tmpa = 0%       % \tmpa==\count0
        \countdef\tmpb = 1%       % \tmpb==\count1
        \countdef\tmpc = 2%       % \tmpc==\count2
        \@HebrewElapsedMonths{#1}{#2}%
        \tmpa = #2%               %
        \multiply \tmpa by 13753% %
        \advance \tmpa by 5604%   % \tmpa=MonthsElapsed*13758 + 5604
        \@Remainder{\tmpa}{25920}{\tmpc}% \tmpc == ConjunctionParts
        \divide \tmpa by 25920%
        \multiply #2 by 29%
        \advance #2 by 1%
        \advance #2 by \tmpa%     %  #2 = 1 + MonthsElapsed*29 +
        \@Remainder{#2}{7}{\tmpa}% %  \tmpa == DayOfWeek
        \ifnum \tmpc < 19440%
            \ifnum \tmpc < 9924%
            \else%                % New moon at 9 h. 204 p. or later
                \ifnum \tmpa = 2% % on Tuesday ...
                    \@CheckLeapHebrewYear{#1}% of a common year
                    \if@HebrewLeap%
                    \else%
                        \advance #2 by 1%
                    \fi%
                \fi%
            \fi%
            \ifnum \tmpc < 16789%
            \else%                 % New moon at 15 h. 589 p. or later
                \ifnum \tmpa = 1%  % on Monday ...
                    \advance #1 by -1%
                    \@CheckLeapHebrewYear{#1}% at the end of leap year
                    \if@HebrewLeap%
                        \advance #2 by 1%
                    \fi%
                \fi%
            \fi%
        \else%
            \advance #2 by 1%      %  new moon at or after midday
        \fi%
        \@Remainder{#2}{7}{\tmpa}%  %  \tmpa == DayOfWeek
        \ifnum \tmpa = 0%          %  if Sunday ...
            \advance #2 by 1%
        \else%                     %
            \ifnum \tmpa = 3%      %  Wednesday ...
                \advance #2 by 1%
            \else%
                \ifnum \tmpa = 5%  %  or Friday
                     \advance #2 by 1%
                \fi%
            \fi%
        \fi%
        \global\@common = #2}%
    #2 = \@common}
\def\@DaysInHebrewYear#1#2{%
    {%
        \countdef\tmpe = 12%   % \tmpe==\count12
        \@HebrewElapsedDays{#1}{\tmpe}%
        \advance #1 by 1%
        \@HebrewElapsedDays{#1}{#2}%
        \advance #2 by -\tmpe%
        \global\@common = #2}%
    #2 = \@common}
\def\@HebrewDaysInPriorMonths#1#2#3{%
    {%
        \countdef\tmpf= 14%    % \tmpf==\count14
        #3 = \ifcase #1%       % Days in prior month of regular year
               0 \or%          % no month number 0
               0 \or%          % Tishri
              30 \or%          % Heshvan
              59 \or%          % Kislev
              89 \or%          % Tebeth
             118 \or%          % Shebat
             148 \or%          % Adar I
             148 \or%          % Adar II
             177 \or%          % Nisan
             207 \or%          % Iyar
             236 \or%          % Sivan
             266 \or%          % Tammuz
             295 \or%          % Av
             325 \or%          % Elul
             400%              % Dummy
        \fi%
        \@CheckLeapHebrewYear{#2}%
        \if@HebrewLeap%            % in leap year
            \ifnum #1 > 6%         % if month after Adar I
                \advance #3 by 30% % add  30 days
            \fi%
        \fi%
        \@DaysInHebrewYear{#2}{\tmpf}%
        \ifnum #1 > 3%
            \ifnum \tmpf = 353%    %
                \advance #3 by -1% %
            \fi%                   %  Short Kislev
            \ifnum \tmpf = 383%    %
                \advance #3 by -1% %
            \fi%                   %
        \fi%
        \ifnum #1 > 2%
            \ifnum \tmpf = 355%    %
                \advance #3 by 1%  %
            \fi%                   %  Long Heshvan
            \ifnum \tmpf = 385%    %
                \advance #3 by 1%  %
            \fi%                   %
        \fi%
        \global\@common = #3}%
    #3 = \@common}
\def\@FixedFromHebrew#1#2#3#4{%
    {%
        #4 = #1%
        \@HebrewDaysInPriorMonths{#2}{#3}{#1}%
        \advance #4 by #1%         % Add days in prior months this year
        \@HebrewElapsedDays{#3}{#1}%
        \advance #4 by #1%         % Add days in prior years
        \advance #4 by -1373429%   % Subtract days before Gregorian
        \global\@common = #4}%     %   01.01.0001
    #4 = \@common}
\def\@GregorianDaysInPriorMonths#1#2#3{%
    {%
        #3 = \ifcase #1%
               0 \or%             % no month number 0
               0 \or%
              31 \or%
              59 \or%
              90 \or%
             120 \or%
             151 \or%
             181 \or%
             212 \or%
             243 \or%
             273 \or%
             304 \or%
             334%
        \fi%
        \@CheckIfGregorianLeap{#2}%
        \if@GregorianLeap%
            \ifnum #1 > 2%        % if month after February
                \advance #3 by 1% % add leap day
            \fi%
        \fi%
        \global\@common = #3}%
    #3 = \@common}
\def\@GregorianDaysInPriorYears#1#2{%
     {%
         \countdef\tmpc = 4%      % \tmpc==\count4
         \countdef\tmpb = 2%      % \tmpb==\count2
         \tmpb = #1%              %
         \advance \tmpb by -1%    %
         \tmpc = \tmpb%           % \tmpc = \tmpb = year-1
         \multiply \tmpc by 365%  % Days in prior years =
         #2 = \tmpc%              % = 365*(year-1) ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 4%      % \tmpc = (year-1)/4
         \advance #2 by \tmpc%    % ... plus Julian leap days ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 100%    % \tmpc = (year-1)/100
         \advance #2 by -\tmpc%   % ... minus century years ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 400%    % \tmpc = (year-1)/400
         \advance #2 by \tmpc%    % ... plus 4-century years.
         \global\@common = #2}%
    #2 = \@common}
\def\@AbsoluteFromGregorian#1#2#3#4{%
    {%
        \countdef\tmpd = 0%       % \tmpd==\count0
        #4 = #1%                  % days so far this month
        \@GregorianDaysInPriorMonths{#2}{#3}{\tmpd}%
        \advance #4 by \tmpd%     % add days in prior months
        \@GregorianDaysInPriorYears{#3}{\tmpd}%
        \advance #4 by \tmpd%     % add days in prior years
        \global\@common = #4}%
    #4 = \@common}
\def\HebrewFromGregorian#1#2#3#4#5#6{%
    {%
        \countdef\tmpx= 17%        % \tmpx==\count17
        \countdef\tmpy= 18%        % \tmpy==\count18
        \countdef\tmpz= 19%        % \tmpz==\count19
        #6 = #3%                   %
        \global\advance #6 by 3761%  approximation from above
        \@AbsoluteFromGregorian{#1}{#2}{#3}{#4}%
        \tmpz = 1  \tmpy = 1%
        \@FixedFromHebrew{\tmpz}{\tmpy}{#6}{\tmpx}%
        \ifnum \tmpx > #4%              %
            \global\advance #6 by -1% Hyear = Gyear + 3760
            \@FixedFromHebrew{\tmpz}{\tmpy}{#6}{\tmpx}%
        \fi%                            %
        \advance #4 by -\tmpx%     % Days in this year
        \advance #4 by 1%          %
        #5 = #4%                   %
        \divide #5 by 30%          % Approximation for month from below
        \loop%                     % Search for month
            \@HebrewDaysInPriorMonths{#5}{#6}{\tmpx}%
            \ifnum \tmpx < #4%
                \advance #5 by 1%
                \tmpy = \tmpx%
        \repeat%
        \global\advance #5 by -1%
        \global\advance #4 by -\tmpy}}
\ProcessOptions*
%    \end{macrocode}
% \iffalse
%</hebrewcal.sty>
%<*hijrical.sty>
% \fi
% \clearpage
% 
% \subsection{hijrical.sty}
%    \begin{macrocode}
\ProvidesPackage{hijrical}
        [2010/07/12 v0.2 %
         Islamic calendar]
\RequirePackage{calc}
\RequirePackage{arabicnumbers}
\@ifpackageloaded{bidi}{}{\newif\if@RTL\@RTLfalse}
\@ifpackageloaded{l3calc}{\PackageError{hijrical}{\MessageBreak
Package l3calc is loaded, which replaces the functionality of
calc. Computation of Hijri dates will not work properly with
% FIXME by Arthur: François couldn’t possibly mean ‘l3calc’ on the
% following line :-)  Find out if he meant ‘calc’.
l3calc! The latest version of expl3 on CTAN no longer loads
l3calc. Please update expl3!
}{}}{}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

\DefineFormatHijriDate{defaultLTR}{%
\number\value{Hijriday}\space\HijriMonthTranslit{\value{Hijrimonth}}\space\number\value{Hijriyear}}
%    \end{macrocode}
% \iffalse
%</hijrical.sty>
%<*babel-hebrewalph.def>
% \fi
% \clearpage
% 
% \subsection{babel-hebrewalph.def}
%    \begin{macrocode}
\ProvidesFile{babel-hebrewalph.def}
         [2010/03/02 %
         Babel definitions for Hebrew numerals^^J
         Adapted from hebrew.ldf (2005/03/30 v2.3h)]
\newif\if@gim@apost  % whether we print apostrophes (gereshayim)
\newif\if@gim@final  % whether we use final or initial letters
\newrobustcmd*{\hebrewnumeral}[1]      % no apostrophe, no final letters
 {{\@gim@finalfalse\@gim@apostfalse\@hebrew@numeral{#1}}}
\newrobustcmd*{\Hebrewnumeral}[1]      % apostrophe, no final letters
 {{\@gim@finalfalse\@gim@aposttrue\@hebrew@numeral{#1}}}
\newrobustcmd*{\Hebrewnumeralfinal}[1] % apostrophe, final letters
 {{\@gim@finaltrue\@gim@aposttrue\@hebrew@numeral{#1}}}
\newcommand*{\@hebrew@numeral}[1]{%
  \ifnum#1<\z@\space\xpg@warning{Illegal value (#1) for Hebrew numeral}%
  \else
    \@tempcnta=#1\@tempcntb=#1\relax
    \divide\@tempcntb by 1000
    \ifnum\@tempcntb=0\gim@nomil\@tempcnta\relax
    \else{\@gim@apostfalse\@gim@finalfalse\@hebrew@numeral\@tempcntb}׳%
          \multiply\@tempcntb by 1000\relax
          \advance\@tempcnta by -\@tempcntb\relax
          \gim@nomil\@tempcnta\relax
    \fi
  \fi
}
\def\hebrew@alph@zero{}
\newcommand*{\gim@nomil}[1]{\@tempcnta=#1\@gim@prevfalse
  \@tempcntb=\@tempcnta\divide\@tempcntb by 100\relax % hundreds digit
  \ifcase\@tempcntb                     % print nothing if no hundreds
     \or\gim@print{100}{ק}%
     \or\gim@print{200}{ר}%
     \or\gim@print{300}{ש}%
     \or\gim@print{400}{ת}%
     \or ת\@gim@prevtrue\gim@print{500}{ק}%
     \or ת\@gim@prevtrue\gim@print{600}{ר}%
     \or ת\@gim@prevtrue\gim@print{700}{ש}%
     \or ת\@gim@prevtrue\gim@print{800}{ת}%
     \or ת\@gim@prevtrue ת\gim@print{900}{ק}%
  \fi
  \@tempcntb=\@tempcnta\divide\@tempcntb by 10\relax      % tens digit
  \ifcase\@tempcntb                         % print nothing if no tens
      \or                                   % number between 10 and 19
              \ifnum\@tempcnta = 16 \gim@print {9}{ט}% tet-zayin
         \else\ifnum\@tempcnta = 15 \gim@print {9}{ט}% tet-vav
         \else                      \gim@print{10}{י}%
              \fi % \@tempcnta = 15
              \fi % \@tempcnta = 16
      \or\gim@print{20}{\if@gim@final ך\else כ\fi}%
      \or\gim@print{30}{ל}%
      \or\gim@print{40}{\if@gim@final ם\else מ\fi}%
      \or\gim@print{50}{\if@gim@final ן\else נ\fi}%
      \or\gim@print{60}{ס}%
      \or\gim@print{70}{ע}%
      \or\gim@print{80}{\if@gim@final ף\else פ\fi}%
      \or\gim@print{90}{\if@gim@final ץ\else צ\fi}%
  \fi
  \ifcase\@tempcnta
      \hebrew@alph@zero%  empty but can be defined if desired
      \or\gim@print{1}{א}%
      \or\gim@print{2}{ב}%
      \or\gim@print{3}{ג}%
      \or\gim@print{4}{ד}%
      \or\gim@print{5}{ה}%
      \or\gim@print{6}{ו}%
      \or\gim@print{7}{ז}%
      \or\gim@print{8}{ח}%
      \or\gim@print{9}{ט}%
  \fi
}
\newif\if@gim@prev % flag if a previous letter has been typeset
\newcommand*{\gim@print}[2]{%   #2 is a letter, #1 is its value.
  \advance\@tempcnta by -#1\relax% deduct the value from the remainder
  \ifnum\@tempcnta=0% if this is the last letter
     \if@gim@prev\if@gim@apost ״\fi#2%
     \else#2\if@gim@apost ׳\fi\fi%
  \else{\@gim@finalfalse#2}\@gim@prevtrue\fi}
\def\Alphfinal#1{\expandafter\@Alphfinal\csname c@#1\endcsname}%
\providecommand*{\@Alphfinal}[1]{\protect\Hebrewnumeralfinal{\number#1}}
%    \end{macrocode}
% \iffalse
%</babel-hebrewalph.def>
%<*babelsh.def>
% \fi
% \clearpage
% 
% \subsection{babelsh.def}
%    \begin{macrocode}
\ifx\initiate@active@char\@undefined
\else
  \bbl@afterfi\endinput
\fi
\ProvidesFile{babelsh.def}
         [2009/05/07 %
         Babel common definitions for shorthands^^J
         Taken verbatim from babel.def (2008/07/06 v3.8l)]
\def\bbl@add@special#1{\begingroup
    \def\do{\noexpand\do\noexpand}%
    \def\@makeother{\noexpand\@makeother\noexpand}%
    \edef\x{\endgroup
      \def\noexpand\dospecials{\dospecials\do#1}%
      \expandafter\ifx\csname @sanitize\endcsname\relax \else
        \def\noexpand\@sanitize{\@sanitize\@makeother#1}%
      \fi}%
  \x}
\def\bbl@remove@special#1{\begingroup
    \def\x##1##2{\ifnum`#1=`##2\noexpand\@empty
                 \else\noexpand##1\noexpand##2\fi}%
    \def\do{\x\do}%
    \def\@makeother{\x\@makeother}%
    \edef\x{\endgroup
      \def\noexpand\dospecials{\dospecials}%
      \expandafter\ifx\csname @sanitize\endcsname\relax \else
        \def\noexpand\@sanitize{\@sanitize}%
      \fi}%
  \x}
\long\def\bbl@afterelse#1\else#2\fi{\fi#1}
\long\def\bbl@afterfi#1\fi{\fi#1}
\def\initiate@active@char#1{%
  \expandafter\ifx\csname active@char\string##1\endcsname\relax
    \bbl@afterfi{\@initiate@active@char{#1}}%
  \fi}
\begingroup
  \catcode`\~\active
  \def\x{\endgroup
    \def\@initiate@active@char##1{%
      \ifcat\noexpand##1\noexpand~\relax
        \@ifundefined{normal@char\string##1}{%
          \expandafter\let\csname normal@char\string##1\endcsname##1%
          \expandafter\gdef
            \expandafter##1%
            \expandafter{%
              \expandafter\active@prefix\expandafter##1%
              \csname normal@char\string##1\endcsname}}{}%
      \else
        \@activated{##1}%
        \@namedef{normal@char\string##1}{##1}%
        \ifx##1'%
          \let\prim@s\bbl@prim@s
          \@namedef{normal@char\string##1}{%
            \textormath{##1}{^\bgroup\prim@s}}%
        \fi
        \ifx##1^%
          \gdef\bbl@act@caret{%
            \ifmmode
              \csname normal@char\string^\endcsname
            \else
              \bbl@afterfi
              {\if@safe@actives
                \bbl@afterelse\csname normal@char\string##1\endcsname
               \else
                \bbl@afterfi\csname user@active\string##1\endcsname
               \fi}%
            \fi}
        \fi
        %%\@ifpackagewith{babel}{KeepShorthandsActive}{}{%
          \edef\bbl@tempa{\catcode`\noexpand##1\the\catcode`##1}%
          \expandafter\AtEndOfPackage\expandafter{\bbl@tempa}%
        %%}%
        \@tempcnta=\lccode`\~
        \lccode`~=`##1%
        \lowercase{%
          \catcode`~\active
          \expandafter\bbl@add@special
            \csname \string##1\endcsname
            \AtBeginDocument{%
              \catcode`##1\active
              \if@filesw
                \immediate\write\@mainaux{%
                  \string\catcode`##1\string\active}%
              \fi}%
          \expandafter\gdef
            \expandafter~%
            \expandafter{%
            \expandafter\active@prefix\expandafter##1%
            \csname normal@char\string##1\endcsname}}%
        \lccode`\~\@tempcnta
      \fi
      \ifx##1^%
        \@namedef{active@char\string##1}{\bbl@act@caret}%
      \else
        \@namedef{active@char\string##1}{%
          \if@safe@actives
            \bbl@afterelse\csname normal@char\string##1\endcsname
          \else
            \bbl@afterfi\csname user@active\string##1\endcsname
          \fi}%
      \fi
      \@namedef{user@active\string##1}{%
        \expandafter\ifx
        \csname \user@group @sh@\string##1@\endcsname
        \relax
          \bbl@afterelse\bbl@sh@select\user@group##1%
        {user@active@arg\string##1}{language@active\string##1}%
        \else
          \bbl@afterfi\csname \user@group @sh@\string##1@\endcsname
        \fi}%
      \long\@namedef{user@active@arg\string##1}####1{%
        \expandafter\ifx
        \csname \user@group @sh@\string##1@\string####1@\endcsname
        \relax
          \bbl@afterelse
          \csname language@active\string##1\endcsname####1%
        \else
          \bbl@afterfi
          \csname \user@group @sh@\string##1@\string####1@%
          \endcsname
        \fi}%
      \@namedef{\user@group @sh@\string##1@@}{%
        \csname normal@char\string##1\endcsname}
      \@namedef{language@active\string##1}{%
        \expandafter\ifx
        \csname \language@group @sh@\string##1@\endcsname
        \relax
          \bbl@afterelse\bbl@sh@select\language@group##1%
          {language@active@arg\string##1}{system@active\string##1}%
        \else
          \bbl@afterfi
          \csname \language@group @sh@\string##1@\endcsname
        \fi}%
      \long\@namedef{language@active@arg\string##1}####1{%
        \expandafter\ifx
        \csname \language@group @sh@\string##1@\string####1@\endcsname
        \relax
          \bbl@afterelse
          \csname system@active\string##1\endcsname####1%
        \else
          \bbl@afterfi
          \csname \language@group @sh@\string##1@\string####1@%
          \endcsname
        \fi}%
      \@namedef{system@active\string##1}{%
        \expandafter\ifx
        \csname \system@group @sh@\string##1@\endcsname
        \relax
          \bbl@afterelse\bbl@sh@select\system@group##1%
          {system@active@arg\string##1}{normal@char\string##1}%
        \else
          \bbl@afterfi\csname \system@group @sh@\string##1@\endcsname
        \fi}%
      \long\@namedef{system@active@arg\string##1}####1{%
        \expandafter\ifx
        \csname \system@group @sh@\string##1@\string####1@\endcsname
        \relax
          \bbl@afterelse\csname normal@char\string##1\endcsname####1%
        \else
          \bbl@afterfi
          \csname \system@group @sh@\string##1@\string####1@\endcsname
        \fi}%
      \@namedef{user@sh@\string##1@\string\protect@}{%
        \csname user@active\string##1\endcsname}%
      }%
    }\x
\def\bbl@sh@select#1#2{%
  \expandafter\ifx\csname#1@sh@\string#2@sel\endcsname\relax
    \bbl@afterelse\bbl@scndcs
  \else
    \bbl@afterfi\csname#1@sh@\string#2@sel\endcsname
  \fi
}
\def\active@prefix#1{%
  \ifx\protect\@typeset@protect
  \else
    \ifx\protect\@unexpandable@protect
      \bbl@afterelse\bbl@afterfi\noexpand#1\@gobble
    \else
      \bbl@afterfi\bbl@afterfi\protect#1\@gobble
    \fi
  \fi}
\newif\if@safe@actives
\@safe@activesfalse
\def\bbl@restore@actives{\if@safe@actives\@safe@activesfalse\fi}
\def\bbl@activate#1{%
  \expandafter\def
  \expandafter#1\expandafter{%
    \expandafter\active@prefix
    \expandafter#1\csname active@char\string#1\endcsname}%
}
\def\bbl@deactivate#1{%
  \expandafter\def
  \expandafter#1\expandafter{%
    \expandafter\active@prefix
    \expandafter#1\csname normal@char\string#1\endcsname}%
}
\def\bbl@firstcs#1#2{\csname#1\endcsname}
\def\bbl@scndcs#1#2{\csname#2\endcsname}
\def\declare@shorthand#1#2{\@decl@short{#1}#2\@nil}
\def\@decl@short#1#2#3\@nil#4{%
  \def\bbl@tempa{#3}%
  \ifx\bbl@tempa\@empty
    \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@scndcs
    \@namedef{#1@sh@\string#2@}{#4}%
  \else
    \expandafter\let\csname #1@sh@\string#2@sel\endcsname\bbl@firstcs
    \@namedef{#1@sh@\string#2@\string#3@}{#4}%
  \fi}
\def\textormath#1#2{%
  \ifmmode
    \bbl@afterelse#2%
  \else
    \bbl@afterfi#1%
  \fi}
\def\user@group{user}
\def\language@group{english}
\def\system@group{system}
\def\useshorthands#1{%
  \def\user@group{user}%
  \initiate@active@char{#1}%
  \@tempcnta\lccode`\~
  \lccode`~=`#1%
  \lowercase{\catcode`~\active\bbl@activate{~}}%
  \lccode`\~\@tempcnta}
\def\defineshorthand{\declare@shorthand{user}}
\def\languageshorthands#1{\def\language@group{#1}}
\def\aliasshorthand#1#2{%
  \expandafter\ifx\csname active@char\string#2\endcsname\relax
     \ifx\document\@notprerr
       \@notshorthand{#2}
     \else
       \initiate@active@char{#2}%
       \@tempcnta\lccode`\~
       \lccode`~=`#2%
       \lowercase{\let~#1}%
       \lccode`\~\@tempcnta
     \fi
   \fi
}
\def\@notshorthand#1{%
       \PackageError{polyglossia}{%
         The character `\string #1' should be made
         a shorthand character;\MessageBreak
         add the command \string\useshorthands\string{#1\string} to
         the preamble.\MessageBreak
         I will ignore your instruction}{}%
   }
\newcommand*\shorthandon[1]{\bbl@switch@sh{on}#1\@nil}
\newcommand*\shorthandoff[1]{\bbl@switch@sh{off}#1\@nil}
\def\bbl@switch@sh#1#2#3\@nil{%
  \@ifundefined{active@char\string#2}{%
    \PackageError{polyglossia}{%
      The character '\string #2' is not a shorthand character
      in \languagename}{%
      Maybe you made a typing mistake?\MessageBreak
      I will ignore your instruction}}{%
    \csname bbl@switch@sh@#1\endcsname#2}%
  \ifx#3\@empty\else
    \bbl@afterfi\bbl@switch@sh{#1}#3\@nil
  \fi}
\def\bbl@switch@sh@off#1{\catcode`#112\relax}
\begingroup
  \catcode`\~\active
  \def\x{\endgroup
    \def\bbl@switch@sh@on##1{%
      \begingroup
      \lccode`~=`##1%
      \lowercase{\endgroup
        \catcode`~\active
        }%
      }%
    }
\x
\declare@shorthand{system}{"}{\csname normal@char\string"\endcsname}
\declare@shorthand{system}{'}{%
  \textormath{\csname normal@char\string'\endcsname}%
             {\sp\bgroup\prim@s}}
\declare@shorthand{system}{`}{\csname normal@char\string`\endcsname}
\def\bbl@prim@s{%
  \prime\futurelet\@let@token\bbl@pr@m@s}
\begingroup
  \catcode`\'\active\let'\relax
  \def\x{\endgroup
    \def\bbl@pr@m@s{%
      \ifx'\@let@token
        \expandafter\pr@@@s
      \else
        \ifx^\@let@token
          \expandafter\expandafter\expandafter\pr@@@t
        \else
          \egroup
        \fi
      \fi}%
    }
\x
\initiate@active@char{~}
\declare@shorthand{system}{~}{\leavevmode\nobreak\ }
\bbl@activate{~}
\def\bbl@disc#1#2{%
  \nobreak\discretionary{#2-}{}{#1}\allowhyphens}
\def\bbl@t@one{T1}
\def\allowhyphens{%
  \ifx\cf@encoding\bbl@t@one\else\bbl@allowhyphens\fi}
\def\bbl@allowhyphens{\nobreak\hskip\z@skip}
%HERE ENDS THE CODE COPIED FROM babel.def -------------------- 
\def\bbl@disc@german#1#2{%
  \nobreak\discretionary{#2-}{}{#1}}
%    \end{macrocode}
% \iffalse
%</babelsh.def>
%<*cal-util.def>
% \fi
% \clearpage
% 
% \subsection{cal-util.def}
%    \begin{macrocode}
%%%%%%%%%%%%% cal-util.def %%%%%%%%%%%%%%%%
% Macros shared by hijrical and hebrewcal %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the following is adapted from hebcal.sty in babel
\def\@Remainder#1#2#3{%
    #3 = #1%                   %  c = a
    \divide #3 by #2%          %  c = a/b
    \multiply #3 by -#2%       %  c = -b(a/b)
    \advance #3 by #1}%        %  c = a - b(a/b)
\newif\if@Divisible
\def\@CheckIfDivisible#1#2{%
    {%
      \countdef\tmpx=0%        % temporary variable
      \@Remainder{#1}{#2}{\tmpx}%
      \ifnum\tmpx=0%
          \global\@Divisibletrue%
      \else%
          \global\@Divisiblefalse%
      \fi}}
\newif\if@GregorianLeap
\def\@CheckIfGregorianLeap#1{%
   {%
   \@CheckIfDivisible{#1}{4}%
    \if@Divisible%
        \@CheckIfDivisible{#1}{100}%
        \if@Divisible%
            \@CheckIfDivisible{#1}{400}%
            \if@Divisible%
                \global\@GregorianLeaptrue%
            \else%
                \global\@GregorianLeapfalse%
            \fi%
        \else%
            \global\@GregorianLeaptrue%
        \fi%
    \else%
        \global\@GregorianLeapfalse%
    \fi%
    }}
%%

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


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

\PolyglossiaSetup{albanian}{
  hyphennames={albanian},
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=true,
}

\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-amharic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-amharic.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-amharic.ldf}[polyglossia: module for amharic]
\PolyglossiaSetup{amharic}{
  script=Ethiopic,
  scripttag=ethi,
  langtag=AMH,
  hyphennames={amharic,nohyphenation},
  %hyphenmins={2,2},
  fontsetup=true,
  %TODO localalph=ethnum
}

\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-arabic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-arabic.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-arabic.ldf}[polyglossia: module for arabic]
\RequirePackage{bidi}
\RequirePackage{arabicnumbers}
\RequirePackage{hijrical}

\PolyglossiaSetup{arabic}{
  script=Arabic,
  direction=RL,
  langtag=ARA,
  scripttag=arab,
  hyphennames={nohyphenation},
  fontsetup=true
  %TODO localalph={abjad,abjad}
  %TODO localnumber=arabicnumber
}

\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%
  \else
    \ifx\@tmpa\tmp@algeria%
      \eastern@numeralsfalse%
    \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}}%

% This should set the defaults
\setkeys{arabic}{locale,calendar,numerals,hijricorrection,abjadjimnotail=false}

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

\def\arabicnumber#1{%
  \ifeastern@numerals
    \arabicdigits{\number#1}%
  \else
    %%\RL{\protect\reset@font\number#1}%
    \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\@origalph\@alph%
   \let\@origAlph\@Alph%
   \let\@alph\abjad%
   \let\@Alph\abjad%
}
\def\noarabic@numbers{%
  \let\@alph\@origalph%
  \let\@Alph\@origAlph%
  }

\def\arabic@globalnumbers{%
  \let\orig@arabic\@arabic%
  \let\@arabic\arabicnumber%
  \renewcommand\thefootnote{\protect\arabicnumber{\c@footnote}}%
  }

\def\noarabic@globalnumbers{
   \let\@arabic\orig@arabic%
   \renewcommand\thefootnote{\protect\number{\c@footnote}}%
   }

\def\blockextras@arabic{%
   \let\orig@MakeUppercase\MakeUppercase%
   \def\MakeUppercase##1{##1}%
   % TODO disable \@Roman and \@roman ?
   }
\def\noextras@arabic{%
   \let\MakeUppercase\orig@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}{
  script=Armenian,
  scripttag=armn,
  langtag=HYE,
  hyphennames={armenian},
  hyphenmins={2,2},
  fontsetup=true
}

%\def\captionsarmenian{%
%   \def\refname{}%
%   \def\abstractname{}%
%   \def\bibname{}%
%   \def\prefacename{}%
%   \def\chaptername{}%
%   \def\appendixname{}%
%   \def\contentsname{}%
%   \def\listfigurename{}%
%   \def\listtablename{}%
%   \def\indexname{}%
%   \def\authorname{}%
%   \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\datearmenian{%
   \def\today{\ifcase\month\or
    Յունուար\or
    Փետրուար\or
    Մարտ\or
    Ապրիլ\or
    Մայիս\or
    Յունիս\or
    Յուլիս\or
    Օգոստոս\or
    Սեպտեմբեր\or
    Հոկտեմբեր\or
    Նոյեմբեր\or
    Դեկտեմբեր\fi
    \number\day,\space\number\year}}
%    \end{macrocode}
% \iffalse
%</gloss-armenian.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}{
  hyphennames={asturian,catalan},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

\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-bahasai.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bahasai.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-bahasai.ldf}[polyglossia: module for bahasa indonesia]
\RequirePackage{hijrical}

\PolyglossiaSetup{bahasai}{%
  language=Bahasa Indonesia,
  hyphennames={indonesian,indon,bahasai,bahasa,bahasam,malay,melayu},
  hyphenmins={2,2},
  fontsetup=true}

\def\captionsbahasai{%
   \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\datebahasai{%
   \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\hijrimonthbahasai#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}
\DefineFormatHijriDate{bahasai}{%
\number\value{Hijriday}\space\hijrimonthbahasai{\value{Hijrimonth}}\space\number\value{Hijriyear}}

%    \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]
\RequirePackage{hijrical}
\PolyglossiaSetup{bahasam}{%
  language=Bahasa Melayu,
  hyphennames={malay,melayu,bahasam,bahasa,bahasai,indonesian,indon},
  hyphenmins={2,2},
  fontsetup=true}

\def\captionsbahasam{%
   \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\datebahasam{%
   \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\hijrimonthbahasam#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}
\DefineFormatHijriDate{bahasam}{%
\number\value{Hijriday}\space\hijrimonthbahasam{\value{Hijrimonth}}\space\number\value{Hijriyear}}

%    \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}{
  hyphennames={basque},
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=true,
}

\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-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]
\RequirePackage{devanagaridigits}

\PolyglossiaSetup{bengali}{
  script=Bengali,
  scripttag=beng,
  langtag=BEN,
  hyphennames={bengali},
  hyphenmins={2,2},%CHECK
  fontsetup=true,
  %TODO nouppercase=true,
  %TODO localnumber=bengalinumber
}

\def\tmp@western{Western}
\newif\ifbengali@devanagari@numerals
\bengali@devanagari@numeralstrue

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

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

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

%    \end{macrocode}
% \iffalse
%</gloss-bengali.ldf>
%<*gloss-brazil.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-brazil.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-brazil.ldf}[polyglossia: module for portuguese]
\PolyglossiaSetup{brazil}{
  language=Brazilian Portuguese,
  hyphennames={brazil,portuguese,portuges},
  hyphenmins={2,3},
  fontsetup=true,
}

\def\captionsbrazil{%
   \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\thepart{}%
   \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\datebrazil{%   
   \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}%
      }
     
%    \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}{
  hyphennames={breton},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

\newXeTeXintercharclass\breton@punctthin % ! ? ;
\newXeTeXintercharclass\breton@punctthick % :

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

\def\breton@punctuation{%
    \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
}

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


\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-bulgarian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bulgarian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-bulgarian.ldf}[polyglossia: module for bulgarian]
\PolyglossiaSetup{bulgarian}{
  script=Cyrillic,
  scripttag=cyrl,
  langtag=BGR,
  hyphennames={bulgarian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup
  %TODO localalph=bulgarian@alph
}

\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\latin@Alph\@Alph%
   \let\latin@alph\@alph%
   \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-catalan.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-catalan.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-catalan.ldf}[polyglossia: module for catalan]
\PolyglossiaSetup{catalan}{
  hyphennames={catalan},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

\define@boolkey{catalan}[catalan@]{babelshorthands}[true]{}
\ifsystem@babelshorthands
  \setkeys{catalan}{babelshorthands=true}
\else
  \setkeys{catalan}{babelshorthands=false}
\fi
\ifcsundef{initiate@active@char}{%
\input{babelsh.def}%
\initiate@active@char{"}%
}{}

%%% 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{\ifnum\XeTeXcharglyph"00B7 > 0\hbox{\char"00B7}%
  \else\raise\raiselldim\hbox{.}\fi}
\def\lgem{%
  \ifmmode
    \csname normal@char\string"\endcsname l%
  \else
    \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
    \setbox0\hbox{l}\setbox1\hbox{l\/}%
    \ifnum\XeTeXcharglyph"00B7 > 0\setbox2\hbox{\char"00B7}\else\setbox2\hbox{.}\fi
    \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\/}%
    \ifnum\XeTeXcharglyph"00B7 > 0\setbox2\hbox{\char"00B7}\else\setbox2\hbox{.}\fi
    \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-coptic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-coptic.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-coptic.ldf}[polyglossia: module for coptic]
\PolyglossiaSetup{coptic}{
  script=Coptic,
  scripttag=copt,
  langtag=COP,
  hyphennames={coptic},
  hyphenmins={2,2},
  fontsetup=true
}

%\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}{
  hyphennames={croatian},
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=true,
}

\def\captionscroatian{%
   \def\refname{Literatura}%
   \def\abstractname{Sažetak}%
   \def\bibname{Bibliografija}%
   \def\prefacename{Predgovor}%
   \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\pagename{Stranica}%
   \def\seename{Vidjeti}%
   \def\alsoname{Vidjeti i}%
   \def\enclname{Prilozi}%
   \def\ccname{Kopije}%
   \def\headtoname{Prima}%
   \def\proofname{Dokaz}%
   \def\glossaryname{Kazalo}%
   }
\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 studenog\or
    prosinca\fi \space \number\year.}}

%    \end{macrocode}
% \iffalse
%</gloss-croatian.ldf>
%<*gloss-czech.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-czech.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-czech.ldf}[polyglossia: module for czech]
\PolyglossiaSetup{czech}{
  hyphennames={czech},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

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

%    \end{macrocode}
% \iffalse
%</gloss-czech.ldf>
%<*gloss-danish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-danish.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-danish.ldf}[polyglossia: module for danish]
\PolyglossiaSetup{danish}{
  hyphennames={danish},
  hyphenmins={2,3},
  frenchspacing=true,
  fontsetup=true,
}

\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\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-divehi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-divehi.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-divehi.ldf}[polyglossia: module for divehi]
\RequirePackage{bidi}
\PolyglossiaSetup{divehi}{
  script=Thaana,
  scripttag=thaa,
  direction=RL,
  hyphennames={nohyphenation},
  fontsetup=true
}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-divehi.ldf>
%<*gloss-dutch.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-dutch.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-dutch.ldf}[polyglossia: module for dutch]
\PolyglossiaSetup{dutch}{
  hyphennames={dutch},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

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

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

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

\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\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-english.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-english.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-english.ldf}[polyglossia: module for english]
\PolyglossiaSetup{english}{
  hyphennames={english,american,usenglish,USenglish},
  hyphenmins={2,3},
  fontsetup=true,
}

\newif\if@british@locale
\@british@localefalse
\providebool{@british@hyphen}
\providebool{english@ordinalmonthday}

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

%% English is a special case in that \l@english is reserved for US English, so
%% we need to handle it differently
\define@key{english}{variant}{%
  %needs to be reset for loop over hyphennames below:
  \renewcommand*{\do}[1]{%
      \ifcsdef{l@#1}%
        {\csletcs{l@english}{l@#1}\listbreak}%
        {}%
  }%
  \ifstrequal{#1}{uk}%
    {\@british@localetrue
     \xpg@info{Option: english variant=british}}%
    {\ifstrequal{#1}{british}%
      {\@british@localetrue
      \xpg@info{Option: english variant=british}}%
        {\ifstrequal{#1}{us}% these patterns are the default so we don't need to reset them
          {\@british@hyphenfalse\english@ordinalmonthdayfalse
           \xpg@info{Option: english variant=american}}%
          {\ifstrequal{#1}{american}%
            {\@british@hyphenfalse\english@ordinalmonthdayfalse
            \xpg@info{Option: english variant=american}}%
            {\ifstrequal{#1}{usmax}%
              {\@british@hyphenfalse\english@ordinalmonthdayfalse
                \setkeys[xpg@setup]{english}{hyphennames={usenglishmax}}%
                \xpg@info{Option: english variant=american (with additional patterns)}%
                \ifcsundef{l@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}{}%
                \gdef\english@language{\language=\l@usenglishmax}}%
                {\ifstrequal{#1}{australian}%
                  {\@british@hyphentrue\english@ordinalmonthdayfalse
                  \xpg@info{Option: english variant=australian}}%
                  {\ifstrequal{#1}{newzealand}%
                    {\@british@hyphentrue\english@ordinalmonthdayfalse
                      \xpg@info{Option: english variant=newzealand}}%
                      {\xpg@warning{Unknown English variant `#1'}}%
  }}}}}}%
  \if@british@locale\@british@hyphentrue\english@ordinalmonthdaytrue\fi
  \if@british@hyphen
    \setkeys[xpg@setup]{english}{hyphennames={ukenglish,british,UKenglish}}%
    \ifcsundef{l@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}{}%
    \gdef\english@language{\language=\l@ukenglish}%
  \fi
  % and we reset \do to its previous definition here:
  \renewcommand*{\do}[1]{\setotherlanguage{#1}}%
}

\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{%
    \if@british@locale
      \english@day\space\english@month\space\number\year
    \else
      \english@month\space\english@day, \number\year
    \fi}%
}

%    \end{macrocode}
% \iffalse
%</gloss-english.ldf>
%<*gloss-esperanto.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-esperanto.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-esperanto.ldf}[polyglossia: module for esperanto]
\PolyglossiaSetup{esperanto}{
  hyphennames={esperanto},
  hyphenmins={2,2},
  fontsetup=true,
  %TODO localalph={esperanto@alph,esperanto@Alph}
}

\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\latin@Alph\@Alph%
   \let\latin@alph\@alph%
   \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}{
  hyphennames={estonian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

\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-farsi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-farsi.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-farsi.ldf}[polyglossia: module for farsi]
\RequirePackage{bidi}
\RequirePackage{arabicnumbers}
\RequirePackage{farsical}
\RequirePackage{hijrical}
\PolyglossiaSetup{farsi}{
  script=Arabic,
  direction=RL,
  scripttag=arab,
  langtag=FAR,
  hyphennames={nohyphenation},
  fontsetup=true
}

\newif\if@western@numerals
\def\tmp@western{western}
\define@key{farsi}{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{farsi}{abjadjimnotail}[true]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@true\abjad@jim@notailtrue%
  \else
    \abjad@jim@notailfalse
  \fi}

% NOT YET USED
\define@key{farsi}{locale}[default]{%
  \def\@farsi@locale{#1}}

%TODO add option for CALENDAR

\setkeys{farsi}{locale,numerals}

\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{farsi}{\@ensure@RTL{%
\farsinumber{\value{Hijriday}}\space\HijriMonthArabic{\value{Hijrimonth}}\space\farsinumber{\value{Hijriyear}}}}

\def\captionsfarsi{%
\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\datefarsi{%
   \def\today{\@ensure@RTL{\farsinumber\day\space\farsigregmonth{\month}\space\farsinumber\year}}%
}

\def\farsinumber#1{%
  \if@western@numerals
    \number#1%
  \else
    \ifnum\XeTeXcharglyph"06F0 > 0%
      \farsidigits{\number#1}%
      %%{\protect\addfontfeature{Mapping=farsidigits}\number#1}%
    \else%
      \arabicdigits{\number#1}%
      %%{\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
    \fi
  \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\farsi@numbers{%
   \let\@latinalph\@alph%
   \let\@latinAlph\@Alph%
   \let\@alph\abjad%
   \let\@Alph\abjad%
}
\def\nofarsi@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
  }

\def\farsi@globalnumbers{%
   \let\orig@arabic\@arabic%
   \let\@arabic\farsinumber%
   % For some reason \thefootnote needs to be set separately:
   \renewcommand\thefootnote{\protect\farsinumber{\c@footnote}}%
   }

\def\nofarsi@globalnumbers{
   \let\@arabic\orig@arabic%
   \renewcommand\thefootnote{\protect\number{\c@footnote}}%
   }

\def\blockextras@farsi{%
   \let\@@MakeUppercase\MakeUppercase%
   \def\MakeUppercase##1{##1}%
   }
\def\noextras@farsi{%
   \let\MakeUppercase\@@MakeUppercase%
   }
%    \end{macrocode}
% \iffalse
%</gloss-farsi.ldf>
%<*gloss-finnish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-finnish.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-finnish.ldf}[polyglossia: module for finnish]
\PolyglossiaSetup{finnish}{
  hyphennames={finnish},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

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

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

\PolyglossiaSetup{french}{%
  language=French,
  script=Latin,
  hyphennames={french,francais},
  frenchspacing=true,
  indentfirst=true,
  hyphenmins={2,2},
  fontsetup=true}

\newXeTeXintercharclass\french@punctthin % ! ? ; et autres
\newXeTeXintercharclass\french@punctthick % :
\newXeTeXintercharclass\french@punctguillstart % « ‹
\newXeTeXintercharclass\french@punctguillend % » ›

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

\def\french@punctuation{%
    \lccode"2019="2019
    \XeTeXinterchartokenstate=1
    \XeTeXcharclass `\! \french@punctthin
    \XeTeXcharclass `\? \french@punctthin
    \XeTeXcharclass `\‼ \french@punctthin
    \XeTeXcharclass `\⁇ \french@punctthin
    \XeTeXcharclass `\⁈ \french@punctthin
    \XeTeXcharclass `\⁉ \french@punctthin
    \XeTeXcharclass `\; \french@punctthin
    \XeTeXcharclass `\: \french@punctthick
    \XeTeXcharclass `\« \french@punctguillstart
    \XeTeXcharclass `\» \french@punctguillend
    \XeTeXcharclass `\‹ \french@punctguillstart
    \XeTeXcharclass `\› \french@punctguillend
    \XeTeXinterchartoks \z@ \french@punctthin = {\nobreak\thinspace}%
    \XeTeXinterchartoks \z@ \french@punctthick = {\nobreakspace}%
    \XeTeXinterchartoks 255 \french@punctthin = {\xpg@unskip\nobreak\thinspace}%
    \XeTeXinterchartoks 255 \french@punctthick = {\xpg@unskip\nobreakspace}%
    \XeTeXinterchartoks \french@punctguillstart \z@ = {\nobreakspace}% "«a" -> "« a"
%   \XeTeXinterchartoks \z@ \french@punctguillstart = {\nobreakspace}% "a«" unchanged?
%   \XeTeXinterchartoks \french@punctguillend \z@ = {\nobreakspace}% "»a" unchanged?
    \XeTeXinterchartoks \z@ \french@punctguillend = {\nobreakspace}% "a»" -> "a »"
    \XeTeXinterchartoks \french@punctguillstart 255 = {\nobreakspace\xpg@nospace}% "«  " -> "«~"
    \XeTeXinterchartoks 255 \french@punctguillend = {\xpg@unskip\nobreakspace}% "  »" -> "~»"
    \XeTeXinterchartoks \french@punctguillend \french@punctthin = {\nobreak\thinspace}% "»;" -> "» ;"
    \XeTeXinterchartoks \french@punctguillend \french@punctthick = {\nobreakspace}% "»:" -> "» :"
    \XeTeXinterchartoks \french@punctthin \french@punctguillend  = {\nobreakspace}% "?»" -> "? »"
    }

\def\nofrench@punctuation{%
    \lccode"2019=\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
    }

\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{}%
   \def\partname{\protect\@Fpt partie}%
   \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%
   }

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

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

%    \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]
\makeatletter
\PolyglossiaSetup{friulan}{%
  hyphennames={friulan,furlan},
  hyphenmins={2,2},
  indentfirst=false,
  fontsetup=true,
  frenchspacing=true,
}


\def\captionsfriulan{%
    \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\datefriulan{%
  \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@friulan{%
   \lccode\string"2019=\z@
   % TODO Figure out what the two lines below were supposed to be good for.
   % \noitalian@shorthands
   % \xpgit@savedvalues
}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-friulan.ldf>
%<*gloss-galician.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-galician.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-galician.ldf}[polyglossia: module for galician]
\PolyglossiaSetup{galician}{
  hyphennames={galician},
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=true,
}

\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-german.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-german.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-german.ldf}[polyglossia: module for german]
\PolyglossiaSetup{german}{
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

\def\tmp@old{old}
\def\tmp@oldyr{1901}
\newif\if@german@oldspelling
\@german@oldspellingfalse
\define@key{german}{spelling}[new]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@oldyr\def\@tmpa{old}\fi
  \ifx\@tmpa\tmp@old
    \ifx\l@german\@undefined
      \xpg@nopatterns{german}%
      \adddialect\l@german\l@nohyphenation
    \fi
    \@german@oldspellingtrue
  \else %try ngerman
    \ifx\l@ngerman\@undefined
      \ifx\l@german\@undefined
        \xpg@nopatterns{ngerman}%
        \adddialect\l@ngerman\l@nohyphenation
      \else
        \xpg@warning{You asked for `ngerman' but only `german' hyphenation is available!}%
        \@german@oldspellingtrue
      \fi
    \else %we use ngerman
      \@german@oldspellingfalse
    \fi
  \fi
}

\newif\if@german@fraktur
\def\tmp@fraktur{fraktur}
\define@key{german}{script}[latin]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@fraktur\@german@frakturtrue\else
	  \@german@frakturfalse%
	\fi}

\define@boolkey{german}[german@]{latesthyphen}[false]{}

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

\setkeys{german}{spelling,latesthyphen,script}

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

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

\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}%
  \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%TODO add option for Austrian forms (Jänner etc)
    \or Januar\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}%
}

%%Strings for Fraktur contributed by Gerrit <z0idberg . gmx . de>
\def\captions@german@fraktur{%
  \captions@german%
  \def\abstractname{Zuſammenfaſſung}%
  \def\seename{ſiehe}%
  \def\alsoname{ſiehe auch}%
  \def\glossaryname{Gloſſar}%
}

\def\date@german@fraktur{%
  \def\today{\number\day.%
    \space \ifcase\month%TODO add option for Austrian forms (Jänner etc)
    \or Januar\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@fraktur\captions@german@fraktur\else\captions@german\fi
}

\def\dategerman{%
  \if@german@fraktur\date@german@fraktur\else\date@german\fi
}

\def\german@language{\language=%
  \csname l@\if@german@oldspelling\else n\fi german\ifgerman@latesthyphen -x-latest\fi\endcsname}

\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-greek.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-greek.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-greek.ldf}[polyglossia: module for greek]
\PolyglossiaSetup{greek}{
  script=Greek,
  scripttag=grek,
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
  %TODO localalph={greek@alph,greek@Alph}
}

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

%TODO: set these in \define@key instead:
\ifx\l@greek\@undefined
  \ifx\l@polygreek\@undefined
    \xpg@nopatterns{Greek}%
    \adddialect\l@greek\l@nohyphenation
  \else
    \let\l@greek\l@polygreek
  \fi
\fi
\ifx\l@monogreek\@undefined
  \xpg@warning{No hyphenation patterns were loaded for Monotonic Greek\MessageBreak
         I will use the patterns loaded for \string\l@greek instead}
  \adddialect\l@monogreek\l@greek
\fi
\ifx\l@ancientgreek\@undefined
  \xpg@warning{No hyphenation patterns were loaded for Ancient Greek\MessageBreak
         I will use the patterns loaded for \string\l@greek instead}
  \adddialect\l@ancientgreek\l@greek
\fi

%set monotonic as default
\def\greek@variant{\l@monogreek}% monotonic
\def\captionsgreek{\monogreekcaptions}%
\def\dategreek{\datemonogreek}%

\def\tmp@mono{mono}
\def\tmp@monotonic{monotonic}
\def\tmp@poly{poly}
\def\tmp@polytonic{polytonic}
\def\tmp@ancient{ancient}
\def\tmp@ancientgreek{ancientgreek}

\define@key{greek}{variant}[monotonic]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@poly\def\@tmpa{polytonic}\fi
  \ifx\@tmpa\tmp@ancientgreek\def\@tmpa{ancient}\fi
  \ifx\@tmpa\tmp@polytonic%
    \def\greek@variant{\l@polygreek}%
    \def\captionsgreek{\polygreekcaptions}%
    \def\dategreek{\datepolygreek}%
    \xpg@info{Option: Polytonic Greek}%
  \else
    \ifx\@tmpa\tmp@ancient
      \def\greek@variant{\l@ancientgreek}%
      \def\captionsgreek{\ancientgreekcaptions}%
      \def\dategreek{\dateancientgreek}%
      \xpg@info{Option: Ancient Greek}%
    \else %monotonic
      \def\greek@variant{\l@monogreek}% monotonic
      \def\captionsgreek{\monogreekcaptions}%
      \def\dategreek{\datemonogreek}%
      \xpg@info{Option: Monotonic Greek}%
    \fi
  \fi}

\def\greek@language{\language=\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.}}

% This sets the defaults
\setkeys{greek}{numerals}

\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 
% is copied verbatim from xgreek.sty
\DeclareRobustCommand\anw@false{%
  \DeclareRobustCommand\anw@print{}}
\DeclareRobustCommand\anw@true{%
  \DeclareRobustCommand\anw@print{ʹ}}
\anw@true

\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
}
\def\Greeknumber#1{%
  \expandafter\MakeUppercase\expandafter{\greeknumber{#1}}}
\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}

%%%% 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{%
   \let\latin@alph\@alph%
   \let\latin@Alph\@Alph%
   \if@greek@numerals
      \def\greek@alph##1{\protect\greeknumber{##1}}%
      \def\greek@Alph##1{\protect\Greeknumber{##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-hebrew.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hebrew.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-hebrew.ldf}[polyglossia: module for hebrew]
\RequirePackage{bidi}
\RequirePackage{hebrewcal}

\providebool{@hebrew@marcheshvan}

\PolyglossiaSetup{hebrew}{
  script=Hebrew,
  direction=RL,
  scripttag=hebr,
  hyphennames={nohyphenation},
  fontsetup=true,
  %TODO localalph={hebrewnumeral,Hebrewnumeral}
  %digits = hebrewnumber
}

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

\define@boolkey{hebrew}[@xpg@hebrew@]{marcheshvan}[false]{%
  \def\@tmpa{#1}%
  \def\@tmptrue{true}%
  \ifx\@tmpa\@tmptrue
    \@xpg@hebrew@marcheshvantrue
  \else
    \@xpg@hebrew@marcheshvanfalse
  \fi}

\setkeys{hebrew}{marcheshvan}

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

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

\def\hebrewnumber#1{%
   \if@hebrew@numerals
     \protect\hebrewnumeral{#1}%
   \else
     \number#1%
   \fi
}

\def\hebrew@numbers{%
   \let\@origalph\@alph%
   \let\@origAlph\@Alph%
   \let\@alph\hebrewnumeral%
   \let\@Alph\Hebrewnumeral%
}
\def\nohebrew@numbers{%
  \let\@alph\@origalph%
  \let\@Alph\@origAlph%
}

\def\hebrew@globalnumbers{%
   \let\orig@arabic\@arabic%
   \let\@arabic\hebrewnumber%
   \renewcommand\thefootnote{\protect\hebrewnumber{\c@footnote}}%
}
\def\nohebrew@globalnumbers{%
  \let\@arabic\orig@arabic%
  \renewcommand\thefootnote{\protect\number{\c@footnote}}%
}

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

%    \end{macrocode}
% \iffalse
%</gloss-hebrew.ldf>
%<*gloss-hindi.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-hindi.ldf}
%    \begin{macrocode}
% UTF-8 strings kindly provided by Zdenek Wagner, 10-03-2008
% TODO: add option for velthuis transliteration with link to
% Velthuis Devanagari project: http://devnag.sarovar.org.

\ProvidesFile{gloss-hindi.ldf}[polyglossia: module for hindi]
\RequirePackage{devanagaridigits}
\PolyglossiaSetup{hindi}{
  script=Devanagari,
  scripttag=deva,
  langtag=HIN,
%%  hyphennames={hindi,!sanskrit}, TODO: implement fallback patterns (with ! prefix)
  fontsetup=true
  %TODO nouppercase=true,
  %TODO localnumber=hindinumber
}

\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{\language=\l@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}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-hindi.ldf>
%<*gloss-icelandic.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-icelandic.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-icelandic.ldf}[polyglossia: module for icelandic]
\PolyglossiaSetup{icelandic}{
  hyphennames={icelandic},
  hyphenmins={2,2},
  fontsetup=true,
}

\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-interlingua.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-interlingua.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-interlingua.ldf}[polyglossia: module for interlingua]
\PolyglossiaSetup{interlingua}{
  hyphennames={interlingua},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

\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]
\PolyglossiaSetup{irish}{
  hyphennames={irish},
  hyphenmins={2,2},
  fontsetup=true,
}

\def\captionsirish{%
   \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\dateirish{%
   \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}}

%    \end{macrocode}
% \iffalse
%</gloss-irish.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}{
  hyphennames={italian},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}


%%% CHANGES START %%% by Enrico Gregorio
\define@boolkey{italian}[italian@]{babelshorthands}[true]{}

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

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

\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
\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-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]
\PolyglossiaSetup{kannada}{
  script=Kannada,
  scripttag=knda,
  langtag=KNDA,
  hyphennames={kannada},
  hyphenmins={2,2}, 
  fontsetup=true
}

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

%% Based on the settings displays rrespective numbers
\def\kannadanumber#1{%
  \ifkannada@numerals
  \kannadadigits{\number#1}%
  \else
  \number#1%
  \fi
}

%    \end{macrocode}
% \iffalse
%</gloss-kannada.ldf>
%<*gloss-lao.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lao.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-lao.ldf}[polyglossia: module for Lao]
\PolyglossiaSetup{lao}{
  script=Lao,
  scripttag=lao,
  hyphennames={lao},
  hyphenmins={1,1},
  fontsetup=true,
  %TODO localalph={xxx@alph,xxx@Alph}
  %TODO localdigits=laonumber
}

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

\setkeys{lao}{numerals}

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

\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}{\protect\laonumber{\c@footnote}}%
}
\def\nolao@globalnumbers{%
   \let\@arabic\orig@arabic%
   \renewcommand\thefootnote{\protect\number{\c@footnote}}%
}

%    \end{macrocode}
% \iffalse
%</gloss-lao.ldf>
%<*gloss-latin.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latin.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-latin.ldf}[polyglossia: module for latin]
\PolyglossiaSetup{latin}{
  hyphennames={latin},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

\def\captionslatin{%
   \def\prefacename{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{pagina}%
   \def\seename{cfr.}%
   \def\alsoname{cfr.}%
   \def\proofname{Demonstratio}%
   \def\glossaryname{Glossarium}%
   }
\def\datelatin{%   
   \def\today{\uppercase\expandafter{\romannumeral\day}%
      \space \ifcase\month%
      \or Januarii\or Februarii\or Martii\or Aprilis\or Maji\or Junii\or%
      Julii\or Augusti\or Septembris\or Octobris\or Novembris\or%
      Decembris\fi%
      \space \uppercase\expandafter{\romannumeral\year}}}

%    \end{macrocode}
% \iffalse
%</gloss-latin.ldf>
%<*gloss-latvian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latvian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-latvian.ldf}[polyglossia: module for latvian]
\PolyglossiaSetup{latvian}{
  hyphennames={latvian},
  hyphenmins={2,2},
  fontsetup=true,
}

\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>
% See also http://github.com/fc7/polyglossia/issues#issue/6

\ProvidesFile{gloss-lithuanian.ldf}[polyglossia: module for lithuanian]
\PolyglossiaSetup{lithuanian}{
  hyphennames={lithuanian},
  hyphenmins={2,2},
  fontsetup=true,
}

\def\captionslithuanian{%
   \def\refname{Literatūra}%
   \def\abstractname{Santrauka}%
   \def\bibname{Literatūra}%
   \def\prefacename{Pratarmė}%
   \def\chaptername{skyrius}%
   \def\appendixname{Priedas}%
   \def\contentsname{Turinys}%
   \def\listfigurename{Iliustracijų sąrašas}%
   \def\listtablename{Lentelių sąrašas}%
   \def\indexname{Rodyklė}%
   \def\figurename{pav.}%
   \def\tablename{lentelė}%
   %\def\thepart{}% Roman numerals are fine
   \def\partname{Dalis}%
   \def\pagename{puslapis}%
   \def\seename{žiūrėk}%
   \def\alsoname{taip pat}%
   \def\enclname{Įdėta}%
   \def\ccname{Kopijos}%
   \def\headtoname{Kam}%
   \def\proofname{Įrodymas}%
   \def\glossaryname{Terminų žodynas}%
}
\def\datelithuanian{%
   \def\lithuanianmonth{\ifcase\month\or
      sausio\or
      vasario\or
      kovo\or
      balandžio\or
      gegužės\or
      birželio\or
      liepos\or
      rugpjūčio\or
      rugsėjo\or
      spalio\or
      lapkričio\or
      gruodžio\fi}
   \def\today{\number\year~m.~\lithuanianmonth~\number\day~d.}%
}

\def\blockextras@lithuanian{%
  \let\fnum@figure@orig\fnum@figure
  \let\fnum@table@orig\fnum@table
  \def\fnum@figure{\thefigure\nobreakspace\figurename}%
  \def\fnum@table{\thetable\nobreakspace\tablename}%
}

\def\noblockextras@lithuanian{%
  \let\fnum@figure\fnum@figure@orig
  \let\fnum@table\fnum@table@orig
}

%    \end{macrocode}
% \iffalse
%</gloss-lithuanian.ldf>
%<*gloss-lsorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lsorbian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-lsorbian.ldf}[polyglossia: module for lower sorbian]
\PolyglossiaSetup{lsorbian}{
  hyphennames={lsorbian,lowersorbian,Lsorbian},
  hyphenmins={2,2},
  fontsetup=true,
}

\def\captionslsorbian{%
   \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\datelsorbian{%
    \def\today{\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}%
    \def\oldtoday{\textlsorbian{\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}}%
    }

%    \end{macrocode}
% \iffalse
%</gloss-lsorbian.ldf>
%<*gloss-magyar.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-magyar.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-magyar.ldf}[polyglossia: module for magyar]
\PolyglossiaSetup{magyar}{
  hyphennames={magyar,hungarian},
  hyphenmins={2,2},
  fontsetup=true,
}

\def\captionsmagyar{%
   \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\datemagyar{%   
   \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\ondatemagyar{%
    \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\ondatemagyar}

\def\noextras@magyar{%
   \let\ontoday\@undefined
}

%    \end{macrocode}
% \iffalse
%</gloss-magyar.ldf>
%<*gloss-malayalam.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-malayalam.ldf}
%    \begin{macrocode}
﻿\ProvidesFile{gloss-malayalam.ldf}[polyglossia: module for malayalam]
% Translations provided by Kevin & Siji, 01-11-2009

\PolyglossiaSetup{malayalam}{
  script=Malayalam,
  scripttag=mlym,
  langtag=MAL, %FIXME there is also MLR for "Malayalam Reformed"
  hyphennames={malayalam},
  hyphenmins={2,2}, %FIXME
  fontsetup=true,
}

\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>
% TODO implement Hindu calendar (not used in day-to-day practice)

\ProvidesFile{gloss-marathi.ldf}[polyglossia: module for marathi]
\RequirePackage{devanagaridigits}

\PolyglossiaSetup{marathi}{
  script=Devaganari,
  scripttag=deva,
  langtag=MAR,
  hyphennames={marathi},
  hyphenmins={2,2},%CHECK
  fontsetup=true,
  %TODO nouppercase=true,
  %TODO localnumber=marathinumber
}

\def\tmp@western{Western}
\newif\ifmarathi@devanagari@numerals
\marathi@devanagari@numeralstrue

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

\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\thepart{}% TODO
   \def\partname{भाग}%
   \def\pagename{पान}%
   \def\seename{पहा}%
   \def\alsoname{हे सुध्दा पहा}%
   \def\enclname{समाविष्ट}%
   \def\ccname{सि.सि.}%
   \def\headtoname{प्रति}%
   \def\proofname{कसोटी}%
   \def\glossaryname{स्पष्टीकरणकोश}%
}
\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}%
}

%    \end{macrocode}
% \iffalse
%</gloss-marathi.ldf>
%<*gloss-norsk.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-norsk.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-norsk.ldf}[polyglossia: module for norwegian]
\PolyglossiaSetup{norsk}{
  hyphennames={norsk},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

\def\captionsnorsk{%
   \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\datenorsk{%   
   \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}%
    }

%    \end{macrocode}
% \iffalse
%</gloss-norsk.ldf>
%<*gloss-nynorsk.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-nynorsk.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-nynorsk.ldf}[polyglossia: module for norwegian (Nynorsk)]
\PolyglossiaSetup{nynorsk}{
  hyphennames={nynorsk},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

\def\captionsnynorsk{%
   \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\datenynorsk{%   
   \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}%
    }

%    \end{macrocode}
% \iffalse
%</gloss-nynorsk.ldf>
%<*gloss-occitan.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-occitan.ldf}
%    \begin{macrocode}
% Translated by Cédric Valmary <cvalmary@yahoo.fr> of Tot en òc <http://www.totenoc.org/>
\ProvidesFile{gloss-occitan.ldf}[polyglossia: module for occitan]

\PolyglossiaSetup{occitan}{
  hyphennames={occitan},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

\def\captionsoccitan{%
   \def\refname{Referéncias}%
   \def\abstractname{Resumit}%
   \def\bibname{Bibliografia}%
   \def\prefacename{Prefàcia}%
   \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 \occitanmonth\space de~\number\year}%
}

%    \end{macrocode}
% \iffalse
%</gloss-occitan.ldf>
%<*gloss-polish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-polish.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-polish.ldf}[polyglossia: module for polish]
\PolyglossiaSetup{polish}{
  hyphennames={polish},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

\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 tablic}%
  \def\indexname{Indeks}%
  \def\figurename{Rysunek}%
  \def\tablename{Tablica}%
  \def\partname{Część}%
  \def\enclname{Załącznik}%
  \def\ccname{Kopie:}%
  \def\headtoname{Do}%
  \def\pagename{Strona}%
  \def\seename{Porównaj}%
  \def\alsoname{Porównaj także}%
  \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
      \number\year}%
  }

%    \end{macrocode}
% \iffalse
%</gloss-polish.ldf>
%<*gloss-portuges.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-portuges.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-portuges.ldf}[polyglossia: module for portuguese]
\PolyglossiaSetup{portuges}{
  hyphennames={portuges,portuguese},
  hyphenmins={2,3},
  fontsetup=true,
}

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

\PolyglossiaSetup{romanian}{
  hyphennames={romanian},
  hyphenmins={2,2},
  fontsetup=true,
}

\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}{%
  hyphennames={romansh},
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=true,
}


\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]
\PolyglossiaSetup{russian}{
  script=Cyrillic,
  scripttag=cyrl,
  langtag=RUS,
  hyphennames={russian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup
  %TODO localalph={russian@alph,russian@Alph}
}

\define@key{russian}{spelling}[modern]{%
  \ifstrequal{#1}{old}%
    {\def\captionsrussian{\captionsrussian@old}%
     \def\daterussian{\daterussian@old}}%
    {\def\captionsrussian{\captionsrussian@modern}%
     \def\daterussian{\daterussian@modern}}%
}

\newif\ifcyrillic@numerals
\define@key{russian}{numerals}[latin]{%
   \ifstrequal{#1}{cyrillic}%
      {\cyrillic@numeralstrue}
      {\cyrillic@numeralsfalse}
}

\define@boolkey{russian}[russian@]{babelshorthands}[false]{}

\setkeys{russian}{spelling,numerals}

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

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

\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{%
   \def\@seccntformat##1{\csname pre##1\endcsname%
      \csname the##1\endcsname%
      \csname post##1\endcsname}%
   \def\@aftersepkern{\hspace{0.5em}}%
   \def\postchapter{.\@aftersepkern}%
   \def\postsection{.\@aftersepkern}%
   \def\postsubsection{.\@aftersepkern}%
   \def\postsubsubsection{.\@aftersepkern}%
   \def\postparagraph{.\@aftersepkern}%
   \def\postsubparagraph{.\@aftersepkern}%
   \def\prechapter{}%
   \def\presection{}%
   \def\presubsection{}%
   \def\presubsubsection{}%
   \def\preparagraph{}%
   \def\presubparagraph{}}

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

\def\russian@numbers{%
   \let\latin@alph\@alph%
   \let\latin@Alph\@Alph%
   \ifcyrillic@numerals
     \let\@alph\russian@alph%
     \let\@Alph\russian@Alph%
   \fi
}

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

\def\noextras@russian{%
   \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-samin.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-samin.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-samin.ldf}[polyglossia: module for samin]

\PolyglossiaSetup{samin}{
  hyphennames={samin},
  hyphenmins={2,2},
  fontsetup=true,
}

\def\captionssamin{%
   \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\datesamin{%
  \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}%
  }

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

\PolyglossiaSetup{sanskrit}{
  langtag=SAN,
  hyphennames={sanskrit,prakrit},
  hyphenmins={1,3},
  frenchspacing=true,
  fontsetup=false, % will be done below
  %TODO localnumber=sanskritnumber
}

\define@key{sanskrit}{Script}[Devanagari]{%
  \setkeys[xpg@setup]{sanskrit}{script=#1}%
  \ifcsdef{fontsetup@sanskrit@#1}%
    {\csname fontsetup@sanskrit@#1\endcsname}%
    {\xpg@error{`#1' is not a valid script for Sanskrit}%
  }%
}

\def\fontsetup@sanskrit@Devanagari{%
  \def\xpg@scripttag@sanskrit{deva}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Gujarati{%
  \def\xpg@scripttag@sanskrit{gujr}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Malayalam{%
  \def\xpg@scripttag@sanskrit{mlym}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Bengali{%
  \def\xpg@scripttag@sanskrit{beng}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Kannada{%
  \def\xpg@scripttag@sanskrit{knda}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Telugu{%
  \def\xpg@scripttag@sanskrit{telu}%
  \xpg@fontsetup@nonlatin{sanskrit}}

\setkeys{sanskrit}{Script} %sets the default for Devanagari

%% TODO option for numerals (Devanagari or Western)
%\def\tmp@western{Western}
%\newif\ifsanskrit@devanagari@numerals
%\sanskrit@devanagari@numeralstrue
%
%\define@key{sanskrit}{numerals}[Devanagari]{%
%  \def\@tmpa{#1}%
%  \ifx\@tmpa\tmp@western
%    \sanskrit@devanagari@numeralsfalse
%  \fi}

\newXeTeXintercharclass\sanskrit@punctthin % ! ? ; : danda double_danda

\def\sanskrit@punctthinspace{{\unskip\thinspace}}

\def\sanskrit@punctuation{%
  \XeTeXinterchartokenstate=1%
  \XeTeXcharclass `\! \sanskrit@punctthin
  \XeTeXcharclass `\? \sanskrit@punctthin
  \XeTeXcharclass `\; \sanskrit@punctthin
  \XeTeXcharclass `\: \sanskrit@punctthin
  \XeTeXcharclass `\। \sanskrit@punctthin
  \XeTeXcharclass `\॥ \sanskrit@punctthin
  \XeTeXinterchartoks \z@ \sanskrit@punctthin = \sanskrit@punctthinspace
}

\def\nosanskrit@punctuation{%
  \XeTeXcharclass `\! \z@
  \XeTeXcharclass `\? \z@
  \XeTeXcharclass `\; \z@
  \XeTeXcharclass `\: \z@
  \XeTeXcharclass `\। \z@
  \XeTeXcharclass `\॥ \z@
  \XeTeXinterchartokenstate=0%
}

\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]

\PolyglossiaSetup{scottish}{
  hyphennames={scottish},
  hyphenmins={2,2},
  fontsetup=true,
}

\def\captionsscottish{%
   \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\datescottish{%
   \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}%
    }

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

\PolyglossiaSetup{serbian}{
  langtag=SRB,
  hyphennames={serbian},
  hyphenmins={2,2},
  indentfirst=true,
  fontsetup=false
  %TODO localalph
}

\newif\if@serbian@cyr

\define@key{serbian}{Script}[Cyrillic]{% TODO FIXDOC: keyname is CHANGED: script -> Script !!!
  \ifstrequal{#1}{Cyrillic}%
    {\@serbian@cyrtrue
     \setkeys[xpg@setup]{serbian}{script=Cyrillic}%
     \def\xpg@scripttag@serbian{cyrl}%
     \xpg@fontsetup@nonlatin{serbian}%
    }%
    {\ifstrequal{#1}{Latin}%
      {\@serbian@cyrfalse
      \xpg@fontsetup@latin{serbian}%
      %TODO \def\serbian@language{\language=\l@serbianlat}%
      % or should we use Croatian patterns as a fallback for the time being???
      }%
      {\xpg@error{Unknown script `#1' for Serbian language\MessageBreak
      Valid values are "Cyrillic" and "Latin"}}%
    }%
}
\define@key{serbian}{script}[Cyrillic]{\setkeys{serbian}{Script=#1}}

\setkeys{serbian}{Script}

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

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

\PolyglossiaSetup{slovak}{
  hyphennames={slovak},
  hyphenmins={2,2},
  fontsetup=true,
}

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

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

\PolyglossiaSetup{slovenian}{
  hyphennames={slovenian,slovene},
  hyphenmins={2,2},
  fontsetup=true,
}

\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{Glosar}% <-- CHECK!
   }

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

%    \end{macrocode}
% \iffalse
%</gloss-slovenian.ldf>
%<*gloss-spanish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-spanish.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-spanish.ldf}[polyglossia: module for spanish]
\PolyglossiaSetup{spanish}{
  hyphennames={spanish},
  hyphenmins={2,2},
  frenchspacing=true,
  indentfirst=true,
  fontsetup=true,
}

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

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

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

\PolyglossiaSetup{swedish}{
  hyphennames={swedish},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true,
}

\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-syriac.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-syriac.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-syriac.ldf}[polyglossia: module for syriac]
\RequirePackage{bidi}
\RequirePackage{arabicnumbers}

\PolyglossiaSetup{syriac}{
  script=Syriac,
  scripttag=syrc,
  direction=RL,
  hyphennames={syriac,nohyphenation},
  fontsetup=true,
  %TODO localalph
}

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

\setkeys{syriac}{numerals}
	
%\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
     \ifnum\XeTeXcharglyph"0661 > 0%
     %%% 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.
       %%\protect\addfontfeature{Mapping=arabicdigits}\number#1}%
       \protect\arabicdigits{\number#1}%
     \else%
       \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}}%
     \fi
   \else
     %%\RL{\protect\reset@font\number#1}%
     \number#1%
   \fi}

\def\syriac@numbers{%
   \let\@latinalph\@alph%
   \let\@latinAlph\@Alph%
   \let\@alph\abjadsyriac%
   \let\@Alph\abjadsyriac%
}
\def\nosyriac@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
  }
\def\syriac@globalnumbers{%
  \let\orig@arabic\@arabic%
  \let\@arabic\syriacnumber%
  \renewcommand\thefootnote{\protect\syriacnumber{\c@footnote}}%
}
\def\nosyriac@globalnumbers{%
  \let\@arabic\orig@arabic%
  \renewcommand\thefootnote{\protect\number{\c@footnote}}%
  }

\def\blockextras@syriac{%
   \let\@@MakeUppercase\MakeUppercase%
   \def\MakeUppercase##1{##1}%
   }
\def\noextras@syriac{%
   \let\MakeUppercase\@@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]
% Translations provided by Kevin & Siji, 01-11-2009

\PolyglossiaSetup{tamil}{
  script=Tamil,
  scripttag=taml,
  langtag=TAM,
  hyphennames={tamil},
  hyphenmins={2,2}, %FIXME?
  fontsetup=true,
}

\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]
% Translations provided by Anmol Sharma <unmole.in@gmail.com>

\PolyglossiaSetup{telugu}{
  script=Telugu,
  scripttag=telu,
  langtag=TEL,
  hyphennames={telugu},
  hyphenmins={2,2}, %FIXME
  fontsetup=true,
}

\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/
%%%%
\PolyglossiaSetup{thai}{
  script=Thai,
  scripttag=thai,
  hyphennames={nohyphenation},
  fontsetup=true
  %TODO localalph={xxx@alph,xxx@Alph}
  %TODO localdigits=thainumber
}

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

\setkeys{thai}{numerals}

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

\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{%
   \let\@latinalph\@alph%
   \let\@latinAlph\@Alph%
   \if@thai@numerals
     \let\@alph\@thaialph%
     \let\@Alph\@thaiAlph%
   \fi
}
\def\nothai@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
}

\def\thai@globalnumbers{%
   \let\orig@arabic\@arabic%
   \let\@arabic\thainumber%
   \renewcommand{\thefootnote}{\protect\thainumber{\c@footnote}}%
}
\def\nothai@globalnumbers{%
   \let\@arabic\orig@arabic%
   \renewcommand\thefootnote{\protect\number{\c@footnote}}%
}

\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-turkish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-turkish.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-turkish.ldf}[polyglossia: module for turkish]
\RequirePackage{hijrical}
\PolyglossiaSetup{turkish}{
  hyphennames={turkish},
  hyphenmins={2,2},
  langtag=TRK,
  frenchspacing=true,
  fontsetup=true
  }

\newXeTeXintercharclass\turkish@punctthin % ! :
\newXeTeXintercharclass\turkish@punctthick % =

\def\turkish@punctthinspace{{\ifdim\lastskip>\z@\unskip\penalty\@M\thinspace\fi}}
\def\turkish@punctthickspace{{\unskip\nobreakspace}}

\def\turkish@punctuation{%
   \XeTeXinterchartokenstate=1%
   \XeTeXcharclass `\! \turkish@punctthin
   \XeTeXcharclass `\: \turkish@punctthin
   \XeTeXcharclass `\= \turkish@punctthick
   \XeTeXinterchartoks \z@ \turkish@punctthin = \turkish@punctthinspace
   \XeTeXinterchartoks \z@ \turkish@punctthick = \turkish@punctthickspace
}

\def\noturkish@punctuation{%
   \XeTeXcharclass `\! \z@
   \XeTeXcharclass `\: \z@
   \XeTeXcharclass `\= \z@
   \XeTeXinterchartokenstate=0%
}

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

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

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

%    \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}{
  hyphennames={turkmen},
  hyphenmins={2,2},
  langtag=TKM,
  frenchspacing=false,
  fontsetup=true
}

\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

\PolyglossiaSetup{ukrainian}{
  script=Cyrillic,
  scripttag=cyrl,
  langtag=UKR,
  hyphennames={ukrainian},
  hyphenmins={2,2},
  frenchspacing=true,
  fontsetup=true
  %TODO localalph
}

\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~р.}}

\def\ukrainian@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}{ukrainian@Alph}\fi}
\def\ukrainian@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}{ukrainian@alph}\fi}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-ukrainian.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]
\RequirePackage{bidi}
\RequirePackage{arabicnumbers}
\RequirePackage{hijrical}

\PolyglossiaSetup{urdu}{
  script=Arabic,
  direction=RL,
  scripttag=arab,
  langtag=URD,
  hyphennames={urdu,nohyphenation},
  fontsetup=true
  %TODO localalph={abjad,abjad}
  %TODO localnumber=urdunumber
}

\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\@latinalph\@alph%
  \let\@latinAlph\@Alph%
  \let\@alph\abjad%
  \let\@Alph\abjad%
  }

\def\nourdu@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
  }

\def\urdu@globalnumbers{%
  \let\orig@arabic\@arabic%
  \let\@arabic\urdunumber%
  % For some reason \thefootnote needs to be set separately:
  \renewcommand\thefootnote{\protect\urdunumber{\c@footnote}}%
  }

\def\nourdu@globalnumbers{
  \let\@arabic\orig@arabic%
  \renewcommand\thefootnote{\protect\number{\c@footnote}}%
  }

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

\def\noextras@urdu{%
  \let\MakeUppercase\@@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]

\PolyglossiaSetup{usorbian}{
  hyphennames={usorbian,uppersorbian},
  hyphenmins={2,2},
  fontsetup=true,
}

\def\captionsusorbian{%
   \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\dateusorbian{%   
  \def\today{\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}%
  %TODO implement option olddate:
    \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}%
  }

%    \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}{
  hyphennames={nohyphenation},
  hyphenmins={2,2},
  langtag=VIT,
  frenchspacing=true,
  fontsetup=true,
}

\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}{
  hyphennames={welsh},
  hyphenmins={2,3},
  fontsetup=true,
}

\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}%
  \def\proofname{Prawf}%
  \def\glossaryname{Rhestr termau}%
  }

\def\datewelsh{%   
  \def\today{\ifnum\day=1\relax 1\/\textsuperscript{añ}\else
    \number\day\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}%
  }

%    \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>
% \fi
% \clearpage
% \PrintChanges
% \Finale
% 
% \iffalse
%<*README>

   ¦----------------------------------------------¦
   ¦                                              ¦
   ¦       THE POLYGLOSSIA PACKAGE v1.2.1         ¦
   ¦                                              ¦
   ¦ Modern multilingual typesetting with XeLaTeX ¦
   ¦                                              ¦
   ¦----------------------------------------------¦

This package for provides a complete Babel replacement for users of XeLaTeX.
This version includes support for 68 different languages.

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 package bidi, available separately).

Several features of Babel that do not make sense in the XeTeX world (like font
encodings, shorthands, etc) are not supported. For German however, several
shorthands do make sense and can be activated with the language option babelshorthands=true.

Polyglossia is distributed in the traditional way with *.dtx and *.ins files,
and also comes with a TDS-conformant ready-to-unpack zip file.

To install from source (i.e. using polyglossia.dtx), run
	xelatex polyglossia.dtx
which will generate all files and produce the pdf documentation all at once.
Alternatively if you have the file polyglossia.ins run
	xetex polyglossia.ins
and follow the instructions displayed.


BUGS

Users are encouraged to report bugs on the github tracker:
http://github.com/reutenauer/polyglossia/issues


CHANGES

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


  ------------------------------
   Arthur Reutenauer, April 2012
     <arthur 'dot' reutenauer 'at' normalesup 'dot' org>

   Original author:
   François Charette
     <firmicus ατ gmx δοτ net>
  ------------------------------
%</README>
%<*examples.tex>
\documentclass[a4paper]{article}
\usepackage[no-math]{fontspec}
\usepackage{xltxtra,url}
\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}
\setotherlanguage[calendar=gregorian,numerals=western]{urdu}
\setromanfont{Linux Libertine O}
\defaultfontfeatures{Scale=MatchLowercase,RawFeature={+locl}}
\setmonofont{Inconsolata}
\newfontfamily\arabicfont[Script=Arabic]{Scheherazade}%
\newfontfamily\syriacfont[Script=Syriac]{Serto Jerusalem}
\newfontfamily\hebrewfont[Script=Hebrew]{David CLM}
\newfontfamily\sanskritfont[Script=Devanagari]{Sanskrit 2003}
\newfontfamily\thaifont[Script=Thai]{Norasi}%{Arial Unicode MS}
\newfontfamily\thaanafont[Script=Thaana,WordSpace=2]{TITUS Cyberbit Basic}%this font does not have OT script tags, but it still seems to work
\newfontfamily\ethiopicfont[Script=Ethiopic]{Abyssinica SIL}
\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}

\end{document}
%</examples.tex>
%<*example-arabic.tex>
\documentclass[a4paper]{book}%
\usepackage[no-math]{fontspec}
\usepackage{xltxtra,url,amsmath}
\setromanfont{Linux Libertine O}
\defaultfontfeatures{Scale=MatchLowercase}
\newfontfamily\arabicfont[Script=Arabic,Scale=1.3]{Scheherazade}%
\newfontfamily\arabicfonttt[Script=Arabic,Scale=.75]{DejaVu Sans Mono}
\newfontfamily\farsifont[Script=Arabic,Scale=1.1,WordSpace=2]{IranNastaliq}
\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 لغة عربية}}»} 
أكبر لغات المجموعة السامية من حيث عدد المتحدثين، وإحدى أكثر اللغات انتشارا في
العالم، يتحدثها أكثر من ٤٢٢ مليون نسمة، ويتوزع متحدثوها في المنطقة المعروفة
باسم الوطن العربي، بالإضافة إلى العديد من المناطق الأخرى المجاورة كالأحواز وتركيا
وتشاد ومالي والسنغال. وللغة العربية أهمية قصوى لدى أتباع الديانة الإسلامية، فهي
لغة مصدري التشريع الأساسيين في الإسلام: القرآن، والأحاديث النبوية المروية عن النبي
محمد، ولا تتم الصلاة في الإسلام (وعبادات أخرى) إلا بإتقان بعض من كلمات هذه اللغة.
والعربية هي أيضًا لغة طقسية رئيسية لدى عدد من الكنائس المسيحية في العالم العربي،
كما كتبت بها الكثير من أهم الأعمال الدينية والفكرية اليهودية في العصور الوسطى.
وإثر انتشار الإسلام، وتأسيسه دولا، ارتفعت مكانة اللغة العربية، وأصبحت لغة السياسة
والعلم والأدب لقرون طويلة في الأراضي التي حكمها المسلمون، وأثرت العربية، تأثيرا
مباشرا أو غير مباشر على كثير من اللغات الأخرى في العالم الإسلامي، كالتركية
والفارسية والأردية مثلا.

\textfarsi{\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}
\setromanfont{Norasi}
\defaultfontfeatures{Scale=MatchLowercase}
\setmonofont{Inconsolata}
\setsansfont{Lucida Sans Unicode}
\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 XeTeX:}
% \typeout{*}
% \typeout{* \space\space\space all *.sty, *.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
