%\iffalse
% polyglossia.dtx generated using mkpolyglossiadtx.pl
% (derived from makedtx.pl version 0.94b (c) Nicola Talbot)
% 
% Created on 2009/11/22 16:07
%<*internal>
\iffalse
%</internal>
%<*README>

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

This package for provides a complete Babel replacement for users of XeLaTeX.
This version includes support for 55 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.

CHANGES

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 


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

  The polyglossia package         
  (C) 2009  François Charette    
  License information appended


\endpreamble
\postamble

 Copyright (C) 2009 by François Charette <firmicus ατ gmx δοτ 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 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 François Charette.


\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{babelsh.def}{\from{polyglossia.dtx}{babelsh.def}}}
\generate{\file{cal-util.def}{\from{polyglossia.dtx}{cal-util.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-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-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-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-latin.ldf}{\from{polyglossia.dtx}{gloss-latin.ldf}}}
\generate{\file{gloss-latvian.ldf}{\from{polyglossia.dtx}{gloss-latvian.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-norsk.ldf}{\from{polyglossia.dtx}{gloss-norsk.ldf}}}
\generate{\file{gloss-nynorsk.ldf}{\from{polyglossia.dtx}{gloss-nynorsk.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-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-thai.ldf}{\from{polyglossia.dtx}{gloss-thai.ldf}}}
\generate{\file{gloss-turkish.ldf}{\from{polyglossia.dtx}{gloss-turkish.ldf}}}
\generate{\file{gloss-ukrainian.ldf}{\from{polyglossia.dtx}{gloss-ukrainian.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{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{gloss-template.ldf}{\from{polyglossia.dtx}{gloss-template.ldf}}}
\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{xltxtra}
\usepackage{xspace,fancyvrb}
\usepackage[neverdecrease]{paralist}
\usepackage[dvipdfm]{color}
\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[dvipdfm,
    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{polyglossia,farsical}
\setmainlanguage[variant=uk]{english}
\setotherlanguages{arabic,hebrew,syriac,greek,russian}
\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*\TB[1]{\textcolor{myblue}{\bf #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}}

\newlength{\oldparindent}
\newcommand{\parindentoff}{\setlength{\oldparindent}{\parindent} \setlength{\parindent}{0pt}}
\newcommand{\parindenton}{\setlength{\parindent}{\oldparindent}}

%% 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$\rightarrow$}%
      \,{\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{\raggedleft
    \small\ifx\thisversion\fileversion\color{blue}\else\color[gray]{0.5}\fi
    $\rightarrow$\,{\notefont #1:~New!}}}
\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}
\defaultfontfeatures{Scale=MatchLowercase}
\setmonofont{DejaVu Sans Mono}%{Consolas}
\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}
% \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 in function of 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 numeration system, modifying the formatting 
%       of numbers appropriately (this also includes redefining the alphabetic sequence 
%       for non-Latin alphabets).
% \item Ensuring the 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 (obviously) 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 much 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 the present author). 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 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”}
% As with \Babel{}, \pkg{polyglossia} also allows to load language definition files 
% as package options. In most cases, option \texttt{⟨lang⟩} will load the file
% \file{gloss-⟨lang⟩.ldf}. Note however that the \textit{first} language listed in \\
% \centerline{\cmd{\usepackage[lang1,lang2,…]{polyglossia}}}
% will be the default language for the document, which
% is the opposite convention of \Babel.
% Note also that this method may not work in some cases, and should be 
% considered deprecated.
% 
% \subsection{Supported languages}
% 
% Table~\ref{tab:lang} lists all languages currently supported.
% Those in red have specific options and/or command 
% that are explained in section \ref{specific} below.
% 
% \begin{table}[h]\centering
% \label{tab:lang}
% \begin{tabular}{lllll}\hline
% albanian &   croatian &  galician & \TR{lsorbian}  &\TR{serbian} \\ 		       
% amharic\footnotemark  &   czech    &  \TR{german}   & \TR{magyar}&   slovak \\
% \TR{arabic}& danish   &  \TR{greek}    &   norsk    &   slovenian\\
% bahasai  &   divehi   &  \TR{hebrew}   &   nynorsk  &   spanish	\\
% bahasam  &   dutch    &    hindi       &   polish   &   swedish	\\
% basque   &\TR{english}&    icelandic   &   portuges & \TR{syriac} \\
% brazil   &\TR{esperanto}&  interlingua &   romanian & \TR{thai} \\
% breton   &   estonian &    irish       &\TR{russian}&   turkish	\\
% bulgarian&\TR{farsi}  &    italian     &   samin    &   ukrainian \\
% catalan  &   finnish  &    latin       &   sanskrit &\TR{usorbian} \\
% coptic   &   french   &    latvian     &   scottish &   welsh	\\
% \hline
% \end{tabular}
% \caption{Languages currently supported in \pkg{polyglossia}}
% \end{table}
% \footnotetext{ New in version 1.0.1. This should be considered an experimental attempt to
% port the package \pkg{ethiop}. Feedbacks are welcome.}
% 
% Some options are convenient shortcuts for loading languages with 
% specific options:
% 
% \begin{itemize}
% \item american = english with option ‘variant=american’
% \item USenglish = english with option ‘variant=american’
% \item UKenglish = english with option ‘variant=british’
% \item british = english with option ‘variant=british’
% \item australian = english with option ‘variant=australian’
% \item newzealand = english with option ‘variant=newzealand’
% \item ogerman = german with option ‘spelling=old’
% \item monogreek = greek with option ‘variant=monotonic’ (or ‘mono’)
% \item polygreek = greek with option ‘variant=polytonic’ (or ‘poly’)
% \item ancientgreek = greek with option ‘variant=ancient’
% \end{itemize}
% Another option (turned off by default) is ‘nolocalmarks’, which 
% prevents the redefinition of the internal \LaTeX\ macros 
% \cmd\markboth\ and \cmd\markright.
% 
% 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}:
% 
% \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 numeration 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.\footnote{ %
% 	The file \file{hyphen\_cfg} (available on the  
% 	\href{http://scripts.sil.org/svn-view/xetex/TRUNK/texmf/tex/xelatex/polyglossia/hyphen\_cfg}{\XeTeX\ subversion repository}) 
% 	is meant to eventually replace \Babel’s \file{hyphen.cfg}. If you want
% 	to experiment with it, rename it into \file{hyphen.cfg}, copy it to
% 	\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[⟨options⟩]\{⟨font⟩\}}. }
% See the \pkg{fontspec} documentation for more information.
% 
% 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 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}
% 
% \subsection{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 Golf 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{1.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})
% 	\end{itemize}
% 
% \subsection{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}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\hodiau\ and \Cmd\hodiaun are special forms of \cmd\today\ (see the \Babel\ documentation)
% 	\end{itemize}
% 
% \subsection{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})
% 	\end{itemize}
% 
% \subsection{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.
% 	\item\TB{babelshorthands} = \textit{false} or true: \new{1.0.3} 
% 		if this is turned on, all shorthands defined in the Babel
% 		language for fine-tuning the hyphenation of German words are
% 		activated. (NB: This feature was broken in the previous version.)
% 		\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 an 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}
% 	\end{itemize}
% 
% \subsection{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}
% \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}).
% 	\end{itemize}
% 
% 
% \subsection{lsorbian and usorbian}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\oldtoday : see the \Babel documentation.
% 	\end{itemize}
% 
% \subsection{magyar}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\ontoday\ (= \Cmd\ondatemagyar): special forms of \cmd\today\
% 		(see the \Babel\ documentation).
% 	\end{itemize}
% 
% 
% \subsection{russian}
% \textbf{Options}: 
% 	\begin{itemize}
% 	\item \TB{spelling} = \textit{modern} or old (for captions and date only, not for hyphenation)
% 	\end{itemize}
% 
% \subsection{sanskrit}
% \textbf{Options}: 
% 	\begin{itemize}
% 	\item \TB{Script} (default = Devanagari). \new{1.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.
% 	\end{itemize}
% 
% \subsection{serbian}
% \textbf{Options}: 
% 	\begin{itemize}
% 	\item \TB{script} = \textit{cyrillic} or latin
% 	\end{itemize}
% 
% \subsection{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{1.0.1}.
% 	\end{itemize}
% \textbf{Commands}:
% 	\begin{itemize}
% 	\item \Cmd\abjadsyriac (see section \ref{abjad})
% 	\end{itemize}
% 
% \subsection{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\linguacaptions{\renewcommand{\chaptername}{Caput}}
% \end{verbatim}
% 
% 
% \section{Alphabetic numeration 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}
% Note that the Hebrew implementation in \pkg{polyglossia} is currently less
% sophisticated than the one in \Babel, where various special cases are taken into
% account.
% 
% 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}}.
% 
% Hebrew numerals are generated with the command \Cmd\hebrewnumeral.
% Example:
% ¦\hebrewnumeral{1863}¦ yields {\hebrewfont\hebrewnumeral{1863}}.
% 
% Support is also provided for Syriac abjad numerals, which can be generated 
% with \Cmd\abjadsyriac. 
% Example: ¦\abjadsyriac{463}¦ yields {\syriacfont\abjadsyriac{463}}.
% 
% \section{Mappings for Arabic, Farsi and Thai numerals}
% 
% Three fontmappings are provided with polyglossia to allow the automatic
% conversion of the standard Western numerals (0123456789) in their Arabic, 
% Farsi, or Thai forms. To activate them, one should use the fontspec option 
% Mapping=arabicdigits (or farsidigits or thaidigits).
% For instance if \cmd\syriacfont\ is defined with the option ¦Mapping=arabicdigits¦,
% then by typing ¦\textsyriac{2008}¦ one obtains \textsyriac{٢٠٠٨}.
% 
% 
% \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 new package computes dates in the Islamic (Hijra) calendar, which is lunar.\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 (depending of the 
% current writing direction this is set either in Arabic or in roman transliteration). 
% It 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)}
% Again this is taken almost verbatim from ¦Arabiftoday.sty¦ (in the \pkg{Arabi} package), 
% itself a slight modification of the file ¦ftoday.sty¦ in Farsi\TeX.\footnote{ %
% 	I intend to rewrite \pkg{farsical} from scratch using the algorithm in
% 	Reingold \& Gershowitz (ref.~n.~\ref{reingold}).}
% Here we have renamed the command \cmd\ftoday\ to
% \Cmd\Jalalitoday. Example: today is \Jalalitoday.
% 
% 
% ^^A\section{Varia}
% 
% 
% \section{Acknowledgements}
% \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}). 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),
% 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. 
% 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}[2009/11/20 v1.1.0
  Babel replacement for XeLaTeX]
\RequirePackage{etoolbox}
\RequirePackage{fontspec} %which itself depends on xkeyval

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

%% custom message macros
\providecommand*{\xpg@warning}[1]{%
   \PackageWarning{polyglossia}%
   {#1}}      
\providecommand*{\xpg@info}[1]{%
   \PackageInfo{polyglossia}%
   {#1\@gobble}} %% the \@gobble is to prevent displaying the line nr
\providecommand*{\xpg@nopatterns}[1]{%
   \xpg@warning{No hyphenation patterns were loaded for `#1'\MessageBreak
         I will use the patterns loaded for \string\language=0\MessageBreak instead}}
\providecommand*{\xpg@nolang}[1]{%
   \xpg@warning{File gloss-#1.ldf does not exist!^^J
   I will nevertheless try to use hyphenation patterns for #1.}}%
      %TODO try at least to load the hyphenation patterns for #1.
\def\xpg@ill@value#1#2{%
  \xpg@warning{Illegal value (#1) for #2}}

%% use macro if defined, else warn that it is not
\def\xpg@csifdef@warn#1{%
   \ifcsundef{#1}{\PackageWarning{polyglossia}{ #1 is not defined}}%
   {\expandafter\protect\csname #1\endcsname}}
%% same without warning
\def\xpg@csifdef#1{\ifcsundef{#1}{\relax}{\expandafter\protect\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
%%
%% ensure localization of \markright and \markboth commands
\def\opt@enabled{on}
\def\opt@disabled{off}
\define@key{polyglossia}{localmarks}[on]{%
   \def\@tmpa{#1}
   \ifx\@tmpa\opt@enabled
      \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%\ifx\@tmpa\opt@disabled
      \def\local@marks##1{}
      \xpg@info{Option: localmarks=off}
      %\fi
   \fi
}
\setkeys{polyglossia}{localmarks=on}

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

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

\newcommand{\setdefaultlanguage}[2][]{%
   \IfFileExists{gloss-#2.ldf}%
   {\ifcsundef{#2@loaded}%
     {\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}...  
      \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{RL}%
      {\ifcsundef{#2@RL}%
          {\@ensure@LTR{\foreignlanguage[####1]{#2}{####2}}}%
    {\@ensure@RTL{\foreignlanguage[####1]{#2}{####2}}}}%
      {\foreignlanguage[####1]{#2}{####2}}%
      }%
      \csletcs{local#2}{text#2}%
      \csgdef{#2@loaded}{}%
      \gdef\xpg@main@language{#2}%
      }%
    {\PackageWarning{polyglossia}{gloss-#2.ldf is already loaded!}}%
    %% The following settings are for the default language and script:
    \ifcsundef{#2@RL}{}%
    {\@rlmaintrue\@rl@footnotetrue%
      \let\@@oddfoot\@oddfoot%
      \let\@@evenfoot\@evenfoot%
      \let\@oddfoot\@@evenfoot%
      \let\@evenfoot\@@oddfoot%
      \let\@@oddhead\@oddhead%
      \let\@@evenhead\@evenhead%
      \let\@oddhead\@@evenhead%
      \let\@evenhead\@@oddhead%
    }%
    \AtBeginDocument{%
    \selectlanguage[#1]{#2}%
    \selectbackgroundlanguage{#2}}%
   }%
   %ELSE
   {\xpg@nolang{#2}\hyphenrules{#2}}}%

\let\setmainlanguage=\setdefaultlanguage

\newcommand{\resetdefaultlanguage}[2][]{%
    \ifcsundef{#2@loaded}{%
     \PackageError{polyglossia}{gloss-#2.ldf is not loaded!}}%
    {\def\languagename{#2}%
    \ifcsundef{#2@RL}{}{\@rlmaintrue\@rl@footnotetrue}%
    \selectlanguage[#1]{#2}%
    \selectbackgroundlanguage{#2}}}

% 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\reset@latin@script{%
   \let\rmfamily=\rmfamilylatin%
   \let\sffamily=\sffamilylatin%
   \let\ttfamily=\ttfamilylatin%
   \normalfontlatin}

\def\reset@LR{\xpg@csifdef{setLR}}

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

\newcommand{\selectbackgroundlanguage}[1]{%
    \xpg@csifdef{selectnormalfont#1}%
    \xpg@csifdef{#1@globalnumbers}%
    }

\newcommand{\setotherlanguage}[2][]{%
   \IfFileExists{gloss-#2.ldf}%
   {\ifcsundef{#2@loaded}%
     {\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{RL}{%
    \ifcsundef{#2@RL}%
    {\@ensure@LTR{\foreignlanguage[####1]{#2}{####2}}}%
          {\@ensure@RTL{\foreignlanguage[####1]{#2}{####2}}}%
       }{% else
          \foreignlanguage[####1]{#2}{####2}%
       }}%
      \csletcs{local#2}{text#2}%
      \csgdef{#2@loaded}{}%
     }%
     {\PackageWarning{polyglossia}{gloss-#2.ldf is already loaded!}}%
   }%
   %ELSE  
   {\xpg@nolang{#2}\hyphenrules{#2}}%
   %TODO ? \expandafter\ifx\csname l@#2\endcsname\@undefined
   %\xpg@nopatterns{#2}\expandafter\adddialect\csname l@#2\endcsname 0%
   %\else\expandafter\expandafter\protect\language=\csname l@#2\endcsname\fi
}

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

\def\common@language{%
   \protect\language=0%
   \lefthyphenmin=2\righthyphenmin=3}

\def\noextrascurrent#1{\xpg@csifdef{noextras@#1}}

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

\AtBeginDocument{\xpg@initial@setup}

\ifcsundef{foreignlanguage}{}%
   {\let\foreignlanguage\@undefined}

\newcommand{\foreignlanguage}[3][]{%
   \ifcsundef{#2@loaded}{\xpg@nolang{#2}\hyphenrules{#2}}{%
     {\def\languagename{#2}%
      \setkeys{#2}{#1}%
      \xpg@csifdef@warn{#2@font}%
      \xpg@csifdef@warn{#2@language}%
      \xpg@csifdef{date#2}%
      \xpg@csifdef{#2@numbers}%
      \use@localhyphenmins{#2}%
      \xpg@csifdef{inlineextras@#2}%
      #3}%
}}

\ifcsundef{selectlanguage}{}%
   {\let\selectlanguage\@undefined}

\newcommand{\selectlanguage}[2][]{%
   \ifcsundef{#2@loaded}{\xpg@nolang{#2}\hyphenrules{#2}}{%
      \def\xpg@pop@language{%
         \xpg@set@language{\languagename}%
         \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
}

\ifcsundef{select@language}{}%
   {\let\select@language\@undefined}

\newcommand{\select@language}[1]{%
   \xpg@initial@setup%
   \edef\languagename{#1}%
   \ifcsundef{RL}{}%
   {\ifcsundef{#1@RL}{\setLR}{\setRL}}%
   \xpg@csifdef@warn{#1@font}%
   \xpg@csifdef@warn{#1@language}%
   \use@localhyphenmins{#1}%
   \xpg@csifdef{captions#1}%
   \xpg@csifdef{date#1}%
   \xpg@csifdef{#1@numbers}%
   \local@marks{#1}%
   \xpg@csifdef{blockextras@#1}%
}

\let\xpg@pop@language\relax

\ifcsundef{otherlanguage}{}%
   {\let\otherlanguage\@undefined}
\ifcsundef{endotherlanguage}{}%
   {\let\endotherlanguage\@undefined}

\newenvironment{otherlanguage}[2][]{%
   \selectlanguage[#1]{#2}%
   }{}

\newcommand{\setlocalhyphenmins}[3]{%
   \expandafter\ifx\csname l@#1\endcsname\relax%
     \xpg@warning{\string\setlocalhyphenmin useless for unknown language #1}%
   \else
      \expandafter\ifx\csname l@#1\endcsname\l@nohyphenation%
        \xpg@warning{\string\setlocalhyphenmin 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}}

%% package options

%%\DeclareOption{shorthands}{\setkeys{polyglossia}{shorthands=true}}
\DeclareOption{nolocalmarks}{\setkeys{polyglossia}{localmarks=off}}
\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
\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}}
%%% FIXME: this does not work when gloss-<option>.ldf contains a \RequirePackage command !!!
%%%        let's try with \AtEndOfPackage (not tested)
\DeclareOption*{%
\ifcsundef{xpg@main@language}%
{\edef\@temp{\noexpand\setdefaultlanguage{\CurrentOption}}}%
{\edef\@temp{\noexpand\setotherlanguage{\CurrentOption}}}%
   \AtEndOfPackage{\@temp}}
\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}

%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{\farsinumber\JALALI@d\space%
\Jalalimonth{\JALALI@m}\space\farsinumber\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}
        [2008/07/01 v2.4 %
         Hebrew calendar for polyglossia (adapted from hebcal.sty in Babel)]
\RequirePackage{bidi}

%% 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}}
\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 השון%
           \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 Heshvan%
            \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%
        \if@GregorianLeap{#2}%
            \ifnum #1 > 2%        % if month after February
                \advance #3 by 1% % add leap day
            \fi%
        \fi%
        \global\@common = #3}%
    #3 = \@common}
\def\@GregorianDaysInPriorYears#1#2{%
     {%
         \countdef\tmpc = 4%      % \tmpc==\count4
         \countdef\tmpb = 2%      % \tmpb==\count2
         \tmpb = #1%              %
         \advance \tmpb by -1%    %
         \tmpc = \tmpb%           % \tmpc = \tmpb = year-1
         \multiply \tmpc by 365%  % Days in prior years =
         #2 = \tmpc%              % = 365*(year-1) ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 4%      % \tmpc = (year-1)/4
         \advance #2 by \tmpc%    % ... plus Julian leap days ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 100%    % \tmpc = (year-1)/100
         \advance #2 by -\tmpc%   % ... minus century years ...
         \tmpc = \tmpb%           %
         \divide \tmpc by 400%    % \tmpc = (year-1)/400
         \advance #2 by \tmpc%    % ... plus 4-century years.
         \global\@common = #2}%
    #2 = \@common}
\def\@AbsoluteFromGregorian#1#2#3#4{%
    {%
        \countdef\tmpd = 0%       % \tmpd==\count0
        #4 = #1%                  % days so far this month
        \@GregorianDaysInPriorMonths{#2}{#3}{\tmpd}%
        \advance #4 by \tmpd%     % add days in prior months
        \@GregorianDaysInPriorYears{#3}{\tmpd}%
        \advance #4 by \tmpd%     % add days in prior years
        \global\@common = #4}%
    #4 = \@common}
\def\HebrewFromGregorian#1#2#3#4#5#6{%
    {%
        \countdef\tmpx= 17%        % \tmpx==\count17
        \countdef\tmpy= 18%        % \tmpy==\count18
        \countdef\tmpz= 19%        % \tmpz==\count19
        #6 = #3%                   %
        \global\advance #6 by 3761%  approximation from above
        \@AbsoluteFromGregorian{#1}{#2}{#3}{#4}%
        \tmpz = 1  \tmpy = 1%
        \@FixedFromHebrew{\tmpz}{\tmpy}{#6}{\tmpx}%
        \ifnum \tmpx > #4%              %
            \global\advance #6 by -1% Hyear = Gyear + 3760
            \@FixedFromHebrew{\tmpz}{\tmpy}{#6}{\tmpx}%
        \fi%                            %
        \advance #4 by -\tmpx%     % Days in this year
        \advance #4 by 1%          %
        #5 = #4%                   %
        \divide #5 by 30%          % Approximation for month from below
        \loop%                     % Search for month
            \@HebrewDaysInPriorMonths{#5}{#6}{\tmpx}%
            \ifnum \tmpx < #4%
                \advance #5 by 1%
                \tmpy = \tmpx%
        \repeat%
        \global\advance #5 by -1%
        \global\advance #4 by -\tmpy}}
%    \end{macrocode}
% \iffalse
%</hebrewcal.sty>
%<*hijrical.sty>
% \fi
% \clearpage
% 
% \subsection{hijrical.sty}
%    \begin{macrocode}
\ProvidesPackage{hijrical}
        [2007/12/27 v0.1 %
         Islamic calendar]
\RequirePackage{bidi}

\@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}%
    \if@RTL%
       \FormatHijriDate%
    \else%
       \FormatHijriDateEnglish%
    \fi}
% 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}

\def\FormatHijriDateEnglish{%
\number\value{Hijriday}\space\HijriMonthTranslit{\value{Hijrimonth}}\space\number\value{Hijriyear}}

%FIXME : this is already in gloss-arabic
\def\@rabicnumb@r#1{\@ifundefined{arabicnumber}{{\addfontfeature{Mapping=arabicdigits} #1}}%
{\arabicnumber{#1}}}

\def\FormatHijriDate{\@ensure@RTL{%
\@rabicnumb@r{\value{Hijriday}}\space\HijriMonthArabic{\value{Hijrimonth}}\space\@rabicnumb@r{\value{Hijriyear}}}}

%    \end{macrocode}
% \iffalse
%</hijrical.sty>
%<*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{babel}{%
         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{babel}{%
      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}
%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>
%<*gloss-albanian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-albanian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-albanian.ldf}[polyglossia: module for albanian]
\makeatletter
\def\albanian@font{\normalfontlatin}

\ifx\l@albanian\@undefined
    \xpg@nopatterns{Albanian}
    \adddialect\l@albanian\l@nohyphenation\fi

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

\def\albanian@language{\language=\l@albanian}

\setlocalhyphenmins{albanian}{2}{2}

\def\noextras@albanian{%
   \nofrench@indent%
   }

\def\blockextras@albanian{%
   \french@indent%
   }

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

\ifx\l@amharic\@undefined%
   %\xpg@nopatterns{Amharic}%
   \adddialect\l@amharic\l@nohyphenation%
\fi

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

\def\amharic@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{amharicfont}{%
      \@ifundefined{ethiopicfont}{%
        \zf@check@ot@script{ethi}%
	\if@tempswa%
	  \addfontfeature{Script=Ethiopic}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Ethiopic script!^^J
	  Please define \string\ethiopicfont\space or \string\amharicfont\space with \string\newfontfamily}%
	\fi%
	\zf@check@ot@lang{AMH}%
	\if@tempswa\addfontfeature{Language=Amharic}\fi%
	}%
      {\ethiopicfont%
	\zf@check@ot@lang{AMH}%
	\if@tempswa\addfontfeature{Language=Amharic}\fi%
      }}% 
     {\amharicfont}%
}

\def\selectnormalfontamharic{%
   \let\normalfont=\amharic@font%
   \def\reset@font{\normalfont}}

\def\amharic@language{\language=\l@amharic}


%    \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}[0.3]
\RequirePackage{hijrical}
\makeatletter

\ifx\l@arabic\@undefined
  %\xpg@nopatterns{arabic}%
  \adddialect\l@arabic\l@nohyphenation
\fi

\def\arabic@RL{\relax}

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

\newif\ifabjad@jim@notail
\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}}

\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{\addfontfeature{Mapping=arabicdigits}\number#1}\else\RL{\reset@font\number#1}\fi}

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

\ifcsdef{abjad}{}{%
\def\abjad#1{%
\ifnum#1>1999\xpg@ill@value{#1}{abjad numeral}%
\else%
\ifnum#1<\z@\space\xpg@ill@value{#1}{abjad numeral}%
  \else%
    \ifnum#1<10\expandafter\abj@num@i@iso\number#1%
    \else%
      \ifnum#1<100\expandafter\abj@num@ii\number#1%
      \else%
        \ifnum#1<\@m\expandafter\abj@num@iii\number#1%
        \else%
          \ifnum#1<\@M\expandafter\abj@num@iv\number#1%since #1<2000, we must have 1000
          \fi
        \fi
      \fi
    \fi
  \fi
\fi
}
\def\abjad@zero{}
\def\abjad@three{ج\ifabjad@jim@notail\char"200D\fi}
\def\abj@num@i@iso#1{%
  \ifcase#1\or ا\or ب\or\abjad@three\or د%
           \or ه\char"200D\or و\or ز\or ح\or ط\fi%
  \ifnum#1=\z@\abjad@zero\fi}
\def\abj@num@i#1{%
  \ifcase#1\or ا\or ب\or\abjad@three\or د%
           \or ه\or و\or ز\or ح\or ط\fi%
  \ifnum#1=\z@\abjad@zero\fi}
\def\abj@num@ii#1{%
  \ifcase#1\or ي\or ك\or ل\or م\or ن%
           \or س\or ع\or ف\or ص\fi% 
  \ifnum#1=\z@\fi\abj@num@i}
\def\abj@num@iii#1{%
  \ifcase#1\or ق\or ر\or ش\or ت\or ث%
            \or خ\or ذ\or ض\or ظ\fi%
  \ifnum#1=\z@\fi\abj@num@ii}
\def\abj@num@iv#1{%
  \ifcase#1\or غ\fi
  \ifnum#1=\z@\fi\abj@num@iii}
}

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

\def\arabic@globalnumbers{%
   \let\default@arabic\@arabic%
   \let\@arabic\arabicnumber%
   % For some reason these need to be set separately:
   \renewcommand\thefootnote{\protect\arabicnumber{\c@footnote}}%
   %%\ifcsundef{thechapter}{}{\renewcommand\thechapter{\protect\arabicnumber{\c@chapter}}}% <<<<<<<<<<
   %%\ifcsundef{thesection}{}{\renewcommand\thesection{\protect\arabicnumber{\c@section}}}% <<<<<<<<<<
   }

\def\noarabic@globalnumbers{
   \let\@arabic\default@arabic%
   \renewcommand\thefootnote{\protect\number{\c@footnote}}%
   %%\ifcsundef{thechapter}{}{\renewcommand\thechapter{\protect\number{\c@chapter}}}% <<<<<<<<<<
   %%\ifcsundef{thesection}{}{\renewcommand\thesection{\protect\number{\c@section}}}% <<<<<<<<<<
   }

\def\arabic@language{\language=\l@arabic}

\def\arabic@font{%
  \@ifundefined{arabicfont}{%
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@check@ot@script{arab}%
    \if@tempswa%
      \addfontfeature{Script=Arabic}%
    \else%
      \PackageError{polyglossia}{^^J
      The current font does not contain the Arabic script!^^J
      Please define \string\arabicfont\space with \string\newfontfamily}%
    \fi%
    }%
  {\arabicfont}% 
}
% TODO add setup to define Sans and Mono Arabic fonts if desired
\def\arabic@font@sf{%
  \@ifundefined{arabicfontsf}{%
%  \sffamily% FIXME
%    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
%  \zf@check@ot@script{arab}%
%  \if@tempswa%
%    \addfontfeature{Script=Arabic}%
%  \else%
    \arabic@font%
%  \fi%  
  }%
  {\arabicfontsf}%
}
\def\arabic@font@tt{%
  \@ifundefined{arabicfonttt}{%
%    \ttfamily% FIXME
%    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
%  \zf@check@ot@script{arab}%
%  \if@tempswa%
%    \addfontfeature{Script=Arabic}%
%  \else%
    \arabic@font%
%  \fi%  
  }%
  {\arabicfonttt}%
}

\def\selectnormalfontarabic{%
   \let\normalfont=\arabic@font%
   \let\rmfamily=\arabic@font%
   \let\sffamily=\arabic@font@sf%
   \let\ttfamily=\arabic@font@tt%
   \def\reset@font{\normalfont}}

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

%    \end{macrocode}
% \iffalse
%</gloss-arabic.ldf>
%<*gloss-bahasai.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-bahasai.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-bahasai.ldf}[polyglossia: module for bahasa indonesia]
\makeatletter
\def\bahasai@font{\normalfontlatin}

\ifx\l@bahasa\@undefined
  \ifx\l@bahasai\@undefined
    \ifx\l@indon\@undefined
      \ifx\l@indonesian\@undefined
        \ifx\l@bahasam\@undefined
          \ifx\l@malay\@undefined
            \ifx\l@meyalu\@undefined
              \xpg@nopatterns{Bahasa Indonesia}
              \adddialect\l@bahasa\l@nohyphenation\relax
            \else
              \let\l@bahasa\l@meyalu
            \fi
          \else
            \let\l@bahasa\l@malay
          \fi
        \else
          \let\l@bahasa\l@bahasam
        \fi
      \else
        \let\l@bahasa\l@indonesian
      \fi
    \else
      \let\l@bahasa\l@indon
    \fi
  \else
    \let\l@bahasa\l@bahasai
  \fi
\fi

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

\setlocalhyphenmins{bahasai}{2}{2}

%    \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 malaysia]
\makeatletter
\def\bahasam@font{\normalfontlatin}

\ifx\l@malay\@undefined
  \ifx\l@meyalu\@undefined
    \ifx\l@bahasam\@undefined
      \ifx\l@bahasa\@undefined
        \ifx\l@bahasai\@undefined
          \ifx\l@indon\@undefined
            \ifx\l@indonesian\@undefined
              \xpg@nopatterns{Bahasa Malaysia}
              \adddialect\l@malay\l@nohyphenation\relax
            \else
              \let\l@malay\l@indonesian
            \fi
          \else
            \let\l@malay\l@indon
          \fi
        \else
          \let\l@malay\l@bahasai
        \fi
      \else
        \let\l@malay\l@bahasa
      \fi
    \else
      \let\l@malay\l@bahasam
    \fi
  \else
    \let\l@malay\l@meyalu
  \fi
\fi

\def\captionsbahasam{%
   \def\refname{Pustaka}%
   \def\abstractname{Ringkasan}%
   \def\bibname{Bibliografi}%
   \def\prefacename{Pendahuluan}%
   \def\chaptername{Bab}%
   \def\appendixname{Lampiran}%
   \def\contentsname{Kandungan}%
   \def\listfigurename{Senarai Gambar}%
   \def\listtablename{Senarai Jadual}%
   \def\indexname{Indeks}%
   \def\figurename{Gambar}%
   \def\tablename{Jadual}%
   \def\thepart{}%
   \def\partname{Bahagian}%
   \def\pagename{Halaman}%
   \def\seename{lihat}%
   \def\alsoname{lihat juga}%
   \def\enclname{Lampiran}%
   \def\ccname{cc}%
   \def\headtoname{Kepada}%
   \def\proofname{Bukti}%
   \def\glossaryname{Istilah}%
   }
\def\datebahasam{%
   \def\today{\number\day~\ifcase\month\or
    Januari\or Pebruari\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\bahasam@language{\language=\l@bahasam}

\setlocalhyphenmins{bahasam}{2}{2}

%    \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]
\makeatletter
\def\basque@font{\normalfontlatin}

\ifx\l@basque\@undefined%
   \xpg@nopatterns{Basque}%
   \adddialect\l@basque\l@nohyphenation%
\fi

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

\def\basque@language{\language=\l@basque}

\setlocalhyphenmins{basque}{2}{2}

%    \end{macrocode}
% \iffalse
%</gloss-basque.ldf>
%<*gloss-brazil.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-brazil.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-brazil.ldf}[polyglossia: module for portuguese]
\makeatletter
\def\brazil@font{\normalfontlatin}

%FIXME check this:
\ifx\l@brazil\@undefined
  \ifx\l@portuguese\@undefined
    \xpg@nopatterns{Brazilian Portuguese}
    \adddialect\l@brazil\l@nohyphenation
  \else
    \let\l@brazil\l@portuguese
  \fi
\fi

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

\setlocalhyphenmins{brazil}{2}{3}

%    \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]
\makeatletter
\def\breton@font{\normalfontlatin}

\ifx\l@breton\@undefined%
   \xpg@nopatterns{Breton}%
   \adddialect\l@breton\l@nohyphenation%
\fi

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

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

\def\breton@punctuation{%
    \frenchspacing%
    \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{%
    \nonfrenchspacing%
    \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\breton@language{\language=\l@breton}

\setlocalhyphenmins{breton}{2}{2}

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

\ifx\l@bulgarian\@undefined%
   \xpg@nopatterns{Bulgarian}%
   \adddialect\l@bulgarian\l@nohyphenation%
\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 Я\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~г.}%
    }

\def\bulgarian@language{\language=\l@bulgarian}

\def\bulgarian@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{bulgarianfont}{%
      \@ifundefined{cyrillicfont}{%
        \zf@check@ot@script{cyrl}%
	\if@tempswa%
	  \addfontfeature{Script=Cyrillic}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Cyrillic script!^^J
	  Please define \string\cyrillicfont\space or \string\bulgarianfont\space with \string\newfontfamily}%
	\fi%
	\zf@check@ot@lang{BGR}%
	\if@tempswa\addfontfeature{Language=Bulgarian}\fi
	}%
      {\cyrillicfont%
	\zf@check@ot@lang{BGR}%
	\if@tempswa\addfontfeature{Language=Bulgarian}\fi%
      }}% 
{\bulgarianfont}}

\setlocalhyphenmins{bulgarian}{2}{2}%

\def\noextras@bulgarian{%
   \nonfrenchspacing%
   }

\def\blockextras@bulgarian{%
   \frenchspacing%
   }

\def\inlineextras@bulgarian{%
   \frenchspacing%
   }

%    \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]
\makeatletter
\def\catalan@font{\normalfontlatin}

\ifx\l@catalan\@undefined%
   \xpg@nopatterns{Catalan}%
   \adddialect\l@catalan\l@nohyphenation%
\fi

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

\setlocalhyphenmins{catalan}{2}{2}

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

\ifx\l@coptic\@undefined%
   \xpg@nopatterns{Coptic}%
   \adddialect\l@coptic\l@nohyphenation%
\fi

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

\def\coptic@language{\language=\l@coptic}

\def\coptic@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{copticfont}{%
        \zf@check@ot@script{copt}%
	\if@tempswa%
	  \addfontfeature{Script=Coptic}%
	  \zf@check@ot@lang{COP}%
	  \if@tempswa\addfontfeature{Language=Coptic}\fi%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Coptic script!^^J
	  Please define \string\copticfont\space with \string\newfontfamily}%
	\fi%
	}%
     {\copticfont}%
}

\def\selectnormalfontcoptic{%
   \let\normalfont=\coptic@font%
   \def\reset@font{\normalfont}}

\setlocalhyphenmins{coptic}{2}{2}

%    \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]
\makeatletter
\def\croatian@font{\normalfontlatin}

\ifx\l@croatian\@undefined%
   \xpg@nopatterns{Croatian}%
   \adddialect\l@croatian\l@nohyphenation%
\fi

\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{Deo}% <<< CHECK (taken from Serbian)
   \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.}}

\def\croatian@language{\language=\l@croatian}

\setlocalhyphenmins{croatian}{2}{2}

%    \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]
\makeatletter
\def\czech@font{\normalfontlatin}

\ifx\l@czech\@undefined%
   \xpg@nopatterns{Czech}%
   \adddialect\l@czech\l@nohyphenation%
\fi

\def\captionsczech{%
   \def\refname{Reference}%
   \def\abstractname{Abstrakt}%
   \def\bibname{Literatura}%
   \def\prefacename{Předmluva}%
   \def\chaptername{Kapitola}%
   \def\appendixname{Dodatek}%
   \def\contentsname{Obsah}%
   \def\listfigurename{Seznam obrázků}%
   \def\listtablename{Seznam tabulek}%
   \def\indexname{Index}%
   \def\figurename{Obrázek}%
   \def\tablename{Tabulka}%
   %\def\thepart{}%
   \def\partname{Část}%
   \def\pagename{Strana}%
   \def\seename{viz}%
   \def\alsoname{viz}%
   \def\enclname{Příloha}%
   \def\ccname{Na vědomí:}%
   \def\headtoname{Komu}%
   \def\proofname{Důkaz}%
   \def\glossaryname{Slovník}%was Glosář
   }
\def\dateczech{%
   \def\today{\number\day.~\ifcase\month\or
    ledna\or února\or března\or dubna\or května\or
    června\or července\or srpna\or září\or
    října\or listopadu\or prosince\fi
    \space \number\year}}

\def\czech@language{\language=\l@czech}

\setlocalhyphenmins{czech}{2}{2}%

\def\noextras@czech{%
   \nonfrenchspacing%
   }

\def\blockextras@czech{%
   \frenchspacing%
   }

\def\inlineextras@czech{%
   \frenchspacing%
   }

%    \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]
\makeatletter
\def\danish@font{\normalfontlatin}

\ifx\l@danish\@undefined
         \xpg@nopatterns{Danish}
         \adddialect\l@danish\l@nohyphenation
\fi

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

\def\danish@language{%
   \language=\l@danish}

\setlocalhyphenmins{danish}{2}{3}%

\def\noextras@danish{%
   \nonfrenchspacing%
   }

\def\blockextras@danish{%
   \frenchspacing%
   }

\def\inlineextras@danish{%
   \frenchspacing%
   }

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

\ifx\l@divehi\@undefined%
   %\xpg@nopatterns{Divehi}%
   \adddialect\l@divehi\l@nohyphenation%
\fi

\def\divehi@RL{\relax}

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

\def\divehi@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{divehifont}{%
      \@ifundefined{thaanafont}{%
        \zf@check@ot@script{thaa}%
	\if@tempswa%
	  \addfontfeature{Script=Thaana}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Thaana script!^^J
	  Please define \string\thaanafont\space or \string\divehifont\space with \string\newfontfamily}%
	\fi%
	}%
      {\thaanafont}}% 
{\divehifont}%
}

\def\selectnormalfontdivehi{%
   \let\normalfont=\divehi@font%
   \let\rmfamily=\divehi@font%
   % TODO add setup to define Sans and Mono fonts if desired
   \let\sffamily=\divehi@font%
   \let\ttfamily=\divehi@font%
   \def\reset@font{\normalfont}}

\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]
\makeatletter
\def\dutch@font{\normalfontlatin}

\ifx\l@dutch\@undefined
   \xpg@nopatterns{Dutch}
   \adddialect\l@dutch\l@nohyphenation
\fi

\def\dutch@punctuation{%
   \frenchspacing%
}

\def\nodutch@punctuation{%
   \nonfrenchspacing%
}

\def\captionsdutch{%
    \def\prefacename{Voorwoord}%
    \def\refname{Referenties}%
    \def\abstractname{Samenvatting}%
    \def\bibname{Bibliografie}%
    \def\chaptername{Hoofdstuk}%
    \def\appendixname{Bĳlage}%
    \def\contentsname{Inhoudsopgave}%
    \def\listfigurename{Lĳst van figuren}%
    \def\listtablename{Lĳst van tabellen}%
    \def\indexname{Index}%
    \def\figurename{Figuur}%
    \def\tablename{Tabel}%
    \def\partname{Deel}%
    \def\enclname{Bĳlage(n)}%
    \def\ccname{cc}%
    \def\headtoname{Aan}%
    \def\pagename{Pagina}%
    \def\seename{zie}%
    \def\alsoname{zie ook}%
    \def\proofname{Bewĳs}%
    \def\glossaryname{Verklarende Woordenlĳst}%
    \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\dutch@language{\language=\l@dutch}

\setlocalhyphenmins{dutch}{2}{2}%

\def\noextras@dutch{%
   \nodutch@punctuation%
}

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

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

%    \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]
\makeatletter
\def\english@font{\normalfontlatin}

\ifx\l@english\@undefined%
   \ifx\l@USenglish\@undefined%
      \ifx\l@american\@undefined%
         \xpg@nopatterns{English}%
         \adddialect\l@english\l@nohyphenation%
      \else%
         \let\l@english\l@american%
      \fi%
   \else%
      \let\l@english\l@USenglish%
   \fi%
\fi
\ifx\l@american\@undefined%
   \let\l@american\l@english%
\fi
\ifx\l@british\@undefined%
   \ifx\l@UKenglish\@undefined%
      \adddialect\l@british\l@english%
  \else%
      \let\l@british\l@UKenglish%
  \fi%
\fi

\def\tmp@us{us}
\def\tmp@usmax{usmax}
\def\tmp@uk{uk}
\def\tmp@british{british}
\def\tmp@american{american}
\def\tmp@australian{australian}
\def\tmp@newzealand{newzealand}
\def\en@variant{english}
\def\english@language{\expandafter\protect\expandafter\language=\csname l@\en@variant\endcsname}

\newif\if@ordinalmonthday

\define@key{english}{variant}[american]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@uk\def\en@variant{british}\@ordinalmonthdaytrue%
     \xpg@info{Option: english variant=british}%
  \else\ifx\@tmpa\tmp@british\def\en@variant{british}\@ordinalmonthdaytrue%
     \xpg@info{Option: english variant=british}%
  \else\ifx\@tmpa\tmp@us\def\en@variant{american}\@ordinalmonthdayfalse%
     \xpg@info{Option: english variant=american}%
  \else\ifx\@tmpa\tmp@usmax\def\en@variant{usenglishmax}\@ordinalmonthdayfalse%
     \xpg@info{Option: english variant=american (with additional patterns)}%
  \else\ifx\@tmpa\tmp@australian\def\en@variant{british}\@ordinalmonthdayfalse%
     \xpg@info{Option: english variant=australian}%
  \else\ifx\@tmpa\tmp@newzealand\def\en@variant{british}\@ordinalmonthdayfalse%
     \xpg@info{Option: english variant=newzealand}%
  \fi\fi\fi\fi\fi\fi}

\def\tmp@true{true}
\define@key{english}{ordinalmonthday}[false]{%
  \def\@tmpa{#1}%
  \ifx\@tmpa\tmp@true\@ordinalmonthdaytrue%
  \else\@ordinalmonthdayfalse%
  \fi}

\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{%
     \if@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\today{%
    \ifx\en@variant\tmp@british%
      \english@day\space%
     \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\year%
     \else%
     \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\english@day, \number\year%
      \fi}%
  }

%\setlocalhyphenmins{english}{2}{3}% this is the default in babel

%    \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]
\makeatletter
\def\esperanto@font{\normalfontlatin}

\ifx\l@esperanto\@undefined%
   \xpg@nopatterns{Esperanto}%
   \adddialect\l@esperanto\l@nohyphenation%
\fi

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

\def\esperanto@language{\language=\l@esperanto}

\setlocalhyphenmins{esperanto}{2}{2}%

%    \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]
\makeatletter
\def\estonian@font{\normalfontlatin}

\ifx\l@estonian\@undefined%
   \xpg@nopatterns{Estonian}%
   \adddialect\l@estonian\l@nohyphenation%
\fi

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

\def\estonian@language{\language=\l@estonian}

\setlocalhyphenmins{estonian}{2}{2}%

\def\noextras@estonian{%
   \nonfrenchspacing%
   }

\def\blockextras@estonian{%
   \frenchspacing%
   }

\def\inlineextras@estonian{%
   \frenchspacing%
   }

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

\ifx\l@farsi\@undefined
  %\xpg@nopatterns{Farsi}%
  \adddialect\l@farsi\l@nohyphenation
\fi

\def\farsi@RL{\relax}

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

% 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 نوامبر\or دسامبر\fi}
\def\farsimonth#1{\ifcase#1%
  \or کانون ثانی\or شباط\or اذار%؛\or ادار
    \or نیسان\or ایار\or حزیران\or تموز\or آب\or ایلول\or تشرین اول\or تشرین ثانی\or کانون اول\fi}

\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{}}%<-- Needs translation
%\def\ccname{\@ensure@RTL{}}%<-- Needs translation
%\def\headtoname{\@ensure@RTL{}}%<-- Needs translation
\def\pagename{\@ensure@RTL{صفحة}}%
%\def\seename{\@ensure@RTL{}}%<-- Needs translation
%\def\alsoname{\@ensure@RTL{}}%<-- Needs translation
\def\proofname{\@ensure@RTL{برهان}}%
\def\glossaryname{\@ensure@RTL{لغت‌نامه}}%<-- Needs to be checked
}
\def\datefarsi{%
   \def\today{\@ensure@RTL{\farsinumber\day\space\farsigregmonth{\month}\space\farsinumber\year}}%
}

\def\farsinumber#1{\if@western@numerals\RL{\number#1}\else%
\ifnum\XeTeXcharglyph"06F0 > 0%
{\protect\addfontfeature{Mapping=farsidigits}\number#1}%
\else%
{\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}

\ifcsdef{abjad}{}{%
\def\abjad#1{%
\ifnum#1>1999 \xpg@warning{Illegal value (#1) for abjad numeral} {#1}
\else
  \ifnum#1<\z@\space\xpg@warning{Illegal value (#1) for abjad numeral}%
  \else
    \ifnum#1<10\expandafter\abj@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\abj@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\abj@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\abj@num@iv\number#1%since #1<2000, we must have 1000
          \fi
        \fi
      \fi
    \fi
  \fi
\fi
}
\def\abjad@zero{}
\def\abj@num@i#1{%
  \ifcase#1\or ا\or ب\or ج\char"200D\or د% 
           \or ه\or و\or ز\or ح\or ط\fi
  \ifnum#1=\z@\abjad@zero\fi}
\def\abj@num@ii#1{%
  \ifcase#1\or ي\or ك\or ل\or م\or ن%
           \or س\or ع\or ف\or ص\fi 
  \ifnum#1=\z@\fi\abj@num@i}
\def\abj@num@iii#1{%
  \ifcase#1\or ق\or ر\or ش\or ت\or ث%
            \or خ\or ذ\or ض\or ظ\fi
  \ifnum#1=\z@\fi\abj@num@ii}
\def\abj@num@iv#1{%
  \ifcase#1\or غ\fi
  \ifnum#1=\z@\fi\abj@num@iii}
}

\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\@latinarabic\@arabic%
   \let\@arabic\farsinumber%
   % For some reason \thefootnote needs to be set separately:
   \renewcommand\thefootnote{\protect\farsinumber{\c@footnote}}%
   }

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

\def\farsi@language{\language=\l@farsi}

\def\farsi@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{farsifont}{%
      \@ifundefined{arabicfont}{%
        \zf@check@ot@script{arab}%
	\if@tempswa%
	  \addfontfeature{Script=Arabic}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Arabic script!^^J
	  Please define \string\arabicfont\space or \string\farsifont\space with \newfontfamily}%
	\fi%
	\zf@check@ot@lang{FAR}%
	\if@tempswa\addfontfeature{Language=Farsi}\fi
	}%
      {\arabicfont%
       \zf@check@ot@lang{FAR}%
       \if@tempswa\addfontfeature{Language=Farsi}\fi}
      }% 
{\farsifont}}
% TODO add setup to define Sans and Mono Arabic fonts if desired
\def\farsi@font@sf{%
  \@ifundefined{farsifontsf}{%
%  \sffamily% FIXME
%    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
%  \zf@check@ot@script{arab}%
%  \if@tempswa%
%    \addfontfeature{Script=Arabic}%
%  \else%
    \farsi@font%
%  \fi%  
  }%
  {\farsifontsf}%
}
\def\farsi@font@tt{%
  \@ifundefined{farsifonttt}{%
%    \ttfamily% FIXME
%    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
%  \zf@check@ot@script{arab}%
%  \if@tempswa%
%    \addfontfeature{Script=Arabic}%
%  \else%
    \farsi@font%
%  \fi%  
  }%
  {\farsifonttt}%
}

\def\selectnormalfontfarsi{%
   \let\normalfont=\farsi@font%
   \let\rmfamily=\farsi@font%
   \let\sffamily=\farsi@font@sf%
   \let\ttfamily=\farsi@font@tt%
   \def\reset@font{\normalfont}}

\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]
\makeatletter
\def\finnish@font{\normalfontlatin}

\ifx\l@finnish\@undefined%
   \xpg@nopatterns{Finnish}%
   \adddialect\l@finnish\l@nohyphenation%
\fi

\def\captionsfinnish{%
   \def\refname{Viitteet}%
   \def\abstractname{Tiivistelmä}%
   \def\bibname{Kirjallisuutta}%
   \def\prefacename{Esipuhe}%
   \def\chaptername{Luku}%
   \def\appendixname{Liite}%
   \def\contentsname{Sisältö}%
   \def\listfigurename{Kuvat}%
   \def\listtablename{Taulukot}%
   \def\indexname{Hakemisto}%
   \def\figurename{Kuva}%
   \def\tablename{Taulukko}%
   %\def\thepart{}%
   \def\partname{Osa}%
   \def\pagename{Sivu}%
   \def\seename{katso}%
   \def\alsoname{katso myös}%
   \def\enclname{Liitteet}%
   \def\ccname{Jakelu}%
   \def\headtoname{Vastaanottaja}%
   \def\proofname{Todistus}%
   \def\glossaryname{Sanasto}%
   }
\def\datefinnish{%
   \def\today{\number\day.~\ifcase\month\or
    tammikuuta\or helmikuuta\or maaliskuuta\or huhtikuuta\or
    toukokuuta\or kesäkuuta\or heinäkuuta\or elokuuta\or
    syyskuuta\or lokakuuta\or marraskuuta\or joulukuuta\fi
    \space\number\year}}

\def\finnish@language{\language=\l@finnish}

\setlocalhyphenmins{finnish}{2}{2}%

\def\noextras@finnish{%
   \nonfrenchspacing%
   }

\def\blockextras@finnish{%
   \frenchspacing%
   }

\def\inlineextras@finnish{%
   \frenchspacing%
   }

%    \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]
\makeatletter
\def\french@font{\normalfontlatin}

\ifx\l@french\@undefined%
   \xpg@nopatterns{French}%
   \adddialect\l@french\l@nohyphenation%
\fi

\newXeTeXintercharclass\french@punctthin % ! ? ;
\newXeTeXintercharclass\french@punctthick % :
\newXeTeXintercharclass\french@punctguill % « »

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

\def\french@punctuation{%
    \frenchspacing
    \lccode"2019="2019
    \XeTeXinterchartokenstate=1
    \XeTeXcharclass `\! \french@punctthin
    \XeTeXcharclass `\? \french@punctthin
    \XeTeXcharclass `\; \french@punctthin
    \XeTeXcharclass `\: \french@punctthick
    \XeTeXinterchartoks \z@ \french@punctthin = \french@punctthinspace
    \XeTeXinterchartoks \z@ \french@punctthick = \french@punctthickspace
    }

\def\nofrench@punctuation{%
    \nonfrenchspacing
    \lccode"2019=\z@
    \XeTeXinterchartokenstate=0
}

\def\french@guillemets{%
    \XeTeXinterchartokenstate=1
    \XeTeXcharclass `\« \french@punctguill
    \XeTeXcharclass `\» \french@punctguill
    \XeTeXinterchartoks \french@punctguill \z@ = \french@punctthickspace
    \XeTeXinterchartoks \z@ \french@punctguill = \french@punctthickspace
    \XeTeXinterchartoks \french@punctguill \french@punctthin = \french@punctthinspace
        % "»;" -> "» ;"
    \XeTeXinterchartoks \french@punctguill \french@punctthick = \french@punctthickspace
        % "»:" -> "» :"
    \XeTeXinterchartoks \french@punctthin \french@punctguill  = \french@punctthickspace
        % "?»" -> "? »"
}

\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{\scshape Fig.}%
   \def\tablename{\scshape 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\french@language{\language=\l@french}

\setlocalhyphenmins{french}{2}{2}%

\def\noextras@french{%
   \nofrench@punctuation%
   \nofrench@indent}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-french.ldf>
%<*gloss-galician.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-galician.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-galician.ldf}[polyglossia: module for galician]
\makeatletter
\def\galician@font{\normalfontlatin}

\ifx\l@galician\@undefined%
   \xpg@nopatterns{Galician}%
   \adddialect\l@galician\l@nohyphenation%
\fi

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

\def\galician@language{\language=\l@galician}

\setlocalhyphenmins{galician}{2}{2}%

%    \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]
\makeatletter
\def\german@font{\normalfontlatin}

\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@old%
	\ifx\l@german\@undefined%
	   \xpg@nopatterns{german}%
	   \adddialect\l@german\l@nohyphenation%
	\fi%
        \@german@oldspellingtrue%
   \else%
     \ifx\@tmpa\tmp@oldyr%
        \ifx\l@german\@undefined%
	   \xpg@nopatterns{german}%
	   \adddialect\l@german\l@nohyphenation%
        \fi%
        \@german@oldspellingtrue%
     \else%
	\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%
            \@german@oldspellingfalse
	\fi%
      \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}[false]{}

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

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

\setlocalhyphenmins{german}{2}{2}%

\def\noextras@german{%
   \nonfrenchspacing%
   \nogerman@shorthands%
}

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

\def\inlineextras@german{%
   \frenchspacing%
   \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]
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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

\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}%
\def\captionsgreek{\polygreekcaptions}%
\ifx\@tmpa\tmp@polytonic%
   \def\greek@variant{\l@polygreek}%
   \def\captionsgreek{\polygreekcaptions}%
   \def\dategreek{\datepolygreek}%
   \xpg@info{Option: Polytonic Greek}%
\else%
   \ifx\@tmpa\tmp@poly%
      \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%
         \ifx\@tmpa\tmp@ancientgreek%
	    \def\greek@variant{\l@ancientgreek}%
            \def\captionsgreek{\ancientgreekcaptions}%
	    \def\dategreek{\dateancientgreek}%
            \xpg@info{Option: Ancient Greek}%
	 \else%
	     \def\greek@variant{\l@monogreek}% monotonic
             \def\captionsgreek{\monogreekcaptions}%
	     \def\dategreek{\datemonogreek}%
             \xpg@info{Option: Monotonic Greek}%
	 \fi%
      \fi%
   \fi%
\fi}

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

\def\tmp@false{false}
\newif\if@attic@numerals
\define@key{greek}{attic}[true]{%
\def\@tmpa{#1}
\ifx\@tmpa\tmp@false\@attic@numeralsfalse
\else\@attic@numeralstrue\fi}

% This sets the defaults
\setkeys{greek}{numerals,attic=false}

\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 (optional)
\if@attic@numerals%
\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
\fi
%%%%

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

\def\greek@language{\language=\greek@variant}

\def\greek@font{%
  \@ifundefined{greekfont}{%
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@check@ot@script{grek}%
    \if@tempswa%
      \addfontfeature{Script=Greek}%
    \else%
      \PackageError{polyglossia}{^^J
      The current font does not contain the Greek script!^^J
      Please define \string\greekfont\space with \string\newfontfamily}%
    \fi%
    }%
    {\greekfont}} 

\def\selectnormalfontgreek{%
   \let\normalfont=\greek@font%
   \def\reset@font{\normalfont}}

\setlocalhyphenmins{greek}{2}{2}%

\def\noextras@greek{%
   \nofrench@indent%
   }

\def\blockextras@greek{%
   \frenchspacing%
   \french@indent%
   }

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

\ifx\l@hebrew\@undefined
  %\xpg@nopatterns{Hebrew}%
  \adddialect\l@hebrew\l@nohyphenation
\fi

\def\hebrew@RL{\relax}

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

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


\def\hebrewalph#1{%
\ifnum#1>9999 \xpg@warning{Illegal value (#1) for Hebrew numeral} {#1}
\else
  \ifnum#1<\z@\space\xpg@warning{Illegal value (#1) for Hebrew numeral}%
  \else
    \ifnum#1<10\expandafter\heb@num@i\number#1%
    \else
      \ifnum#1<100\expandafter\heb@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\heb@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\heb@num@iv\number#1%
          \fi
        \fi
      \fi
    \fi
  \fi
\fi
}
\let\hebrewnumeral\hebrewalph

\def\hebnum@zero{}

%Hebrew alphabetic numerals (primitive implementation -- the code in Babel is more complex):
\def\heb@num@i#1{%
  \ifcase#1\or\char"05D0\or\char"05D1\or\char"05D2\or\char"05D3\or\char"05D4%
           \or\char"05D5\or\char"05D6\or\char"05D7\or\char"05D8\fi
  \ifnum#1=\z@\hebnum@zero\fi}
\def\heb@num@ii#1{%
  \ifcase#1\or\char"05D9\or\char"05DB\or\char"05DC\or\char"05DE\or\char"05E0%
           \or\char"05E1\or\char"05E2\or\char"05E4\or\char"05E6\fi 
  \ifnum#1=\z@\fi\heb@num@i}
\def\heb@num@iii#1{%
  \ifcase#1\or\char"05E7\or\char"05E8\or\char"05E9\or\char"05EA\or\char"05DA%
           \or\char"05DD\or\char"05DF\or\char"05E3\or\char"05E5\fi
  \ifnum#1=\z@\fi\heb@num@ii}
\def\heb@num@iv#1{%
  \ifcase#1\or\char"05D0\char"05F3\or\char"05D1\char"05F3\or\char"05D2\char"05F3%
           \or\char"05D3\char"05F3\or\char"05D4\char"05F3\or\char"05D5\char"05F3%
	   \or\char"05D6\char"05F3\or\char"05D7\char"05F3\or\char"05D8\char"05F3\fi
  \ifnum#1=\z@\fi\heb@num@iii}
%TODO [optionally] 
% -insert gereshayim (\char"05F4) before last letter of a sequence of two letters or more
% -insert geresh (\char"05F3) after letter if it is alone

\def\hebrew@numbers{%
   \let\@latinalph\@alph%
   \let\@latinAlph\@Alph%
   \let\@alph\hebrewalph%
   \let\@Alph\hebrewalph%
}
\def\nohebrew@numbers{%
  \let\@alph\@latinalph%
  \let\@Alph\@latinAlph%
  }

\def\hebrewnumber#1{%
   \if@hebrew@numerals\hebrewalph{#1}%
   \else{\reset@font\number#1}%
   \fi}

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

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

\def\hebrew@language{\language=\l@hebrew}

\def\hebrew@font{%
  \@ifundefined{hebrewfont}{%
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@check@ot@script{hebr}%
    \if@tempswa%
      \addfontfeature{Script=Hebrew}%
    \else%
      \PackageError{polyglossia}{^^J
      The current font does not contain the Hebrew script!^^J
      Please define \string\hebrewfont\space with \string\newfontfamily}%
    \fi%
    }%
{\hebrewfont}}

% TODO add setup to define Sans and Mono Hebrew fonts if desired
\def\hebrew@font@sf{%
  \@ifundefined{hebrewfontsf}{%
%  \sffamily% FIXME
%    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
%  \zf@check@ot@script{arab}%
%  \if@tempswa%
%    \addfontfeature{Script=Hebrew}%
%  \else%
    \hebrew@font%
%  \fi%  
  }%
  {\hebrewfontsf}%
}
\def\hebrew@font@tt{%
  \@ifundefined{hebrewfonttt}{%
%    \ttfamily% FIXME
%    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
%  \zf@check@ot@script{arab}%
%  \if@tempswa%
%    \addfontfeature{Script=Hebrew}%
%  \else%
    \hebrew@font%
%  \fi%  
  }%
  {\hebrewfonttt}%
}
\def\selectnormalfonthebrew{%
   \let\normalfont=\hebrew@font%
   \let\rmfamily=\hebrew@font%
   \let\sffamily=\hebrew@font@sf%
   \let\ttfamily=\hebrew@font@tt%
   \def\reset@font{\normalfont}}

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

\ifx\l@hindi\@undefined%
  \ifx\l@sanskrit\@undefined%
    \xpg@nopatterns{Hindi}%
    \adddialect\l@hindi\l@nohyphenation%
  \else
    \let\l@hindi\l@sanskrit%
  \fi
\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{\number\day\space\ifcase\month\or
     जनवरी\or
     फ़रवरी\or
     मार्च\or
     अपरैल\or
     मई\or
     जून\or
     जलाई\or
     अगस्त\or
     सितम्बर\or
     अक्तूबर\or
     नवम्बर\or
     दिसम्बर\fi
     \space\number\year}%
}

\def\hindi@language{\language=\l@hindi}

\def\hindi@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{hindifont}{%
      \@ifundefined{devanagarifont}{%
        \zf@check@ot@script{deva}%
	\if@tempswa%
	  \addfontfeature{Script=Devanagari}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Devanagari script!^^J
	  Please define \string\devanagarifont\space or \string\hindifont\space with \string\newfontfamily}%
	\fi%
	\zf@check@ot@lang{HIN}%
	\if@tempswa\addfontfeature{Language=Hindi}\fi%
	}%
      {\devanagarifont%
	\zf@check@ot@lang{HIN}%
	\if@tempswa\addfontfeature{Language=Hindi}\fi%
      }}% 
     {\hindifont}%
}

\def\selectnormalfonthindi{%
   \let\normalfont=\hindi@font%
   \let\rmfamily=\hindi@font%
   % TODO add setup to define Sans and Mono fonts if desired
   \let\sffamily=\hindi@font%
   \let\ttfamily=\hindi@font%
   \def\reset@font{\normalfont}}

\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]
\makeatletter
\def\icelandic@font{\normalfontlatin}

\ifx\l@icelandic\@undefined%
   \xpg@nopatterns{Icelandic}%
   \adddialect\l@icelandic\l@nohyphenation%
\fi

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

\def\icelandic@language{\language=\l@icelandic}

\setlocalhyphenmins{icelandic}{2}{2}%

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

\ifx\l@interlingua\@undefined%
   \xpg@nopatterns{Interlingua}%
   \adddialect\l@interlingua\l@nohyphenation%
\fi

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

\def\interlingua@language{\language=\l@interlingua}

\setlocalhyphenmins{interlingua}{2}{2}%

%    \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]
\makeatletter
\def\irish@font{\normalfontlatin}

\ifx\l@irish\@undefined%
   \xpg@nopatterns{Irish}%
   \adddialect\l@irish\l@nohyphenation%
\fi

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

\def\irish@language{\language=\l@irish}

\setlocalhyphenmins{irish}{2}{2}%

%    \end{macrocode}
% \iffalse
%</gloss-irish.ldf>
%<*gloss-italian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-italian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-italian.ldf}[polyglossia: module for italian]
\makeatletter
\def\italian@font{\normalfontlatin}

\ifx\l@italian\@undefined
   \xpg@nopatterns{Italian}
   \adddialect\l@italian\l@nohyphenation
\fi

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

\def\italian@language{\language=\l@italian}

\setlocalhyphenmins{italian}{2}{2}%

\def\noextras@italian{%
   \lccode"2019=0%
   \nofrench@indent}

\def\blockextras@italian{%
   \lccode"2019="2019
   %TODO ? \clubpenalty3000\widowpenalty3000\finalhyphendemerits50000000 << in Babel
   \french@indent%
   }

\def\inlineextras@italian{%
   \lccode"2019="2019
   }

%    \end{macrocode}
% \iffalse
%</gloss-italian.ldf>
%<*gloss-latin.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-latin.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-latin.ldf}[polyglossia: module for latin]
\makeatletter
\def\latin@font{\normalfontlatin}

\ifx\l@latin\@undefined
   \xpg@nopatterns{latin}
   \adddialect\l@latin\l@nohyphenation
\fi

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

\def\latin@language{\language=\l@latin}

\setlocalhyphenmins{latin}{2}{2}%

\def\noextras@latin{%
   \nonfrenchspacing%
}

\def\blockextras@latin{%
   \frenchspacing%
}

\def\inlineextras@latin{%
   \frenchspacing%
}

%    \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]
\makeatletter
\def\latvian@font{\normalfontlatin}

\ifx\l@latvian\@undefined
   \xpg@nopatterns{Latvian}
   \adddialect\l@latvian\l@nohyphenation
\fi

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

\def\latvian@language{\language=\l@latvian}

\setlocalhyphenmins{latvian}{2}{2}%

%    \end{macrocode}
% \iffalse
%</gloss-latvian.ldf>
%<*gloss-lsorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-lsorbian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-lsorbian.ldf}[polyglossia: module for lower sorbian]
\makeatletter
\def\lsorbian@font{\normalfontlatin}

\ifx\l@lowersorbian\@undefined
  \ifx\l@lsorbian\@undefined
    \xpg@nopatterns{Lsorbian}
    \adddialect\l@lsorbian\z@
    \let\l@lowersorbian\l@lsorbian
  \else
    \let\l@lowersorbian\l@lsorbian
  \fi
\else
  \let\l@lsorbian\l@lowersorbian
\fi

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

\def\lsorbian@language{\language=\l@lsorbian}

\setlocalhyphenmins{lsorbian}{2}{2}%

%    \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]
\makeatletter
\def\magyar@font{\normalfontlatin}

\ifx\l@magyar\@undefined
  \ifx\l@hungarian\@undefined
    \xpg@nopatterns{Magyar}
    \adddialect\l@magyar\l@nohyphenation
  \else
    \let\l@magyar\l@hungarian
  \fi
\fi
\ifx\l@hungarian\@undefined
  \let\l@hungarian\l@magyar
\fi

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

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

\setlocalhyphenmins{magyar}{2}{2}%

%    \end{macrocode}
% \iffalse
%</gloss-magyar.ldf>
%<*gloss-norsk.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-norsk.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-norsk.ldf}[polyglossia: module for norwegian]
\makeatletter
\def\norsk@font{\normalfontlatin}

\ifx\l@norsk\@undefined%
   \xpg@nopatterns{Norsk}%
   \adddialect\l@norsk\l@nohyphenation%
\fi

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

\def\norsk@language{\language=\l@norsk}

\setlocalhyphenmins{norsk}{2}{2}%

\def\noextras@norsk{%
   \nonfrenchspacing%
   }

\def\blockextras@norsk{%
   \frenchspacing%
   }

\def\inlineextras@norsk{%
   \frenchspacing%
   }

%    \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)]
\makeatletter
\def\nynorsk@font{\normalfontlatin}

\ifx\l@nynorsk\@undefined%
   \xpg@nopatterns{Nynorsk}%
   \adddialect\l@nynorsk\l@nohyphenation%
\fi

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

\def\norsk@language{\language=\l@nynorsk}

\setlocalhyphenmins{nynorsk}{2}{2}%

\def\noextras@nynorsk{%
   \nonfrenchspacing%
   }

\def\blockextras@nynorsk{%
   \frenchspacing%
   }

\def\inlineextras@nynorsk{%
   \frenchspacing%
   }

%    \end{macrocode}
% \iffalse
%</gloss-nynorsk.ldf>
%<*gloss-polish.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-polish.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-polish.ldf}[polyglossia: module for polish]
\makeatletter
\def\polish@font{\normalfontlatin}

\ifx\l@polish\@undefined
   \xpg@nopatterns{polish}
   \adddialect\l@polish\l@nohyphenation
\fi

\def\captionspolish{%
  \def\prefacename{Przedmowa}%
  \def\refname{Literatura}%
  \def\abstractname{Streszczenie}%
  \def\bibname{Bibliografia}%
  \def\chaptername{Rozdział}%
  \def\appendixname{Dodatek}%
  \def\contentsname{Spis treści}%
  \def\listfigurename{Spis rysunków}%
  \def\listtablename{Spis 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{\ifcase\month\or%
      stycznia\or lutego\or marca\or kwietnia\or maja\or czerwca\or%
      lipca\or sierpnia\or września\or października\or%
      listopada\or grudnia\fi%
      \space\number\day, \number\year}}

\def\polish@language{\language=\l@polish}

\setlocalhyphenmins{polish}{2}{2}%

\def\noextras@polish{%
   \nonfrenchspacing%
}

\def\blockextras@polish{%
   \frenchspacing%
}

\def\inlineextras@polish{%
   \frenchspacing%
}

%    \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]
\makeatletter
\def\portuges@font{\normalfontlatin}

\ifx\l@portuges\@undefined
  \ifx\l@portuguese\@undefined
    \xpg@nopatterns{Portuguese}
    \adddialect\l@portuges\l@nohyphenation
  \else
    \let\l@portuges\l@portuguese
  \fi
\fi

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

%\setlocalhyphenmins{portuges}{2}{3}% this is the default

%    \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]
\makeatletter
\def\romanian@font{\normalfontlatin}

\ifx\l@romanian\@undefined%
   \xpg@nopatterns{Romanian}%
   \adddialect\l@romanian\l@nohyphenation%
\fi

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

\def\romanian@language{\language=\l@romanian}

\setlocalhyphenmins{romanian}{2}{2}%

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

\ifx\l@russian\@undefined
   \xpg@nopatterns{Russian}
   \adddialect\l@russian\l@nohyphenation
\fi

\def\russian@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{russianfont}{%
      \@ifundefined{cyrillicfont}{%
        \zf@check@ot@script{cyrl}%
	\if@tempswa%
	  \addfontfeature{Script=Cyrillic}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Cyrillic script!^^J
	  Please define \string\cyrillicfont\space or \string\russianfont\space with \string\newfontfamily}%
	\fi%
	\zf@check@ot@lang{RUS}%
	\if@tempswa\addfontfeature{Language=Russian}\fi%
	}%
        {\cyrillicfont%
	\zf@check@ot@lang{RUS}%
	\if@tempswa\addfontfeature{Language=Russian}\fi}%
     }% 
     {\russianfont}%
}

\def\tmp@old{old}
\define@key{russian}{spelling}[modern]{%
   \def\@tmpa{#1}%
   \ifx\@tmpa\tmp@old
    \def\captionsrussian{\captionsrussian@old}
    \def\daterussian{\daterussian@old}%
   \else%
     \def\captionsrussian{\captionsrussian@modern}
     \def\daterussian{\daterussian@modern}%
   \fi}

\setkeys{russian}{spelling}

\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\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@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% 
   \let\@Alph\russian@Alph%
   \let\@alph\russian@alph%
}

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

\def\russian@language{\language=\l@russian}

\setlocalhyphenmins{russian}{2}{2}%

\def\noextras@russian{%
   \nonfrenchspacing%
   \def\@seccntformat##1{\csname the##1\endcsname\quad}% = LaTeX kernel
   }
   
\def\blockextras@russian{%
   \frenchspacing%
   \russian@capsformat%
   }

\def\inlineextras@russian{%
   \frenchspacing%
   }

%    \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]
\makeatletter
\def\samin@font{\normalfontlatin}

\ifx\l@samin\@undefined%
   \xpg@nopatterns{Samin}%
   \adddialect\l@samin\l@nohyphenation%
\fi

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

\def\samin@language{\language=\l@samin}

\setlocalhyphenmins{samin}{2}{2}%

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

\ifx\l@sanskrit\@undefined%
  \ifx\l@prakrit\@undefined%
    \xpg@nopatterns{Sanskrit}%
    \adddialect\l@sanskrit\l@nohyphenation%
  \else%
    \let\l@sanskrit=\l@prakrit%
  \fi%
\fi

\def\tmp@deva{Devanagari}
\define@key{sanskrit}{Script}[Devanagari]{%
    \gdef\sanskrit@script{#1}}

\setkeys{sanskrit}{Script}

\newXeTeXintercharclass\sanskrit@punctthin % ! ? ; : danda double_danda
\def\sanskrit@punctthinspace{{\unskip\thinspace}}

\def\sanskrit@punctuation{%
    \frenchspacing%
    \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{%
    \nonfrenchspacing%
    \XeTeXinterchartokenstate=0%
}

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

\def\sanskrit@font{%
\@ifundefined{sanskritfont}{%
      \@ifundefined{devanagarifont}{%
        \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
        \zf@check@ot@script{deva}%
        \ifx\sanskrit@script\tmp@deva%
		\if@tempswa%
		  \addfontfeature{Script=Devanagari}%
		\else%
		  \PackageError{polyglossia}{^^J
		  The current font does not contain the devanagari script!^^J
		  Please define \string\devanagarifont\space or \string\sanskritfont\space with \string\newfontfamily}%
		\fi%
	\else%
		\addfontfeature{Script=\sanskrit@script}%
	\fi%
	\zf@check@ot@lang{SAN}%
	\if@tempswa\addfontfeature{Language=Sanskrit}\fi%
	}%
        {\devanagarifont%
         \zf@check@ot@lang{SAN}%
         \if@tempswa\addfontfeature{Language=Sanskrit}\fi%
	}%
     }% 
     {\sanskritfont}%
}

\def\selectnormalfontsanskrit{%
   \let\normalfont=\sanskrit@font%
   \let\rmfamily=\sanskrit@font%
   % TODO add setup to define Sans and Mono Sanskrit fonts if desired
   \let\sffamily=\sanskrit@font%
   \let\ttfamily=\sanskrit@font%
   \def\reset@font{\normalfont}}

\def\sanskrit@language{\language=\l@sanskrit}

\setlocalhyphenmins{sanskrit}{1}{5}%

\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]
\makeatletter
\def\scottish@font{\normalfontlatin}

\ifx\l@scottish\@undefined%
   \xpg@nopatterns{Scottish}%
   \adddialect\l@scottish\l@nohyphenation%
\fi

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

\def\scottish@language{\language=\l@scottish}

\setlocalhyphenmins{scottish}{2}{2}%

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

%TODO eventually there will be patterns for Serbian-Latin as well as Serbian-Cyrillic
\ifx\l@serbian\@undefined%
   \xpg@nopatterns{Serbian}%
   \adddialect\l@serbian\l@nohyphenation%
\fi

\newif\if@serbian@cyr
\def\tmp@cyrillic{cyrillic}
\define@key{serbian}{script}[cyrillic]{%
	\def\@tmpa{#1}%
	\ifx\@tmpa\tmp@cyrillic\@serbian@cyrtrue\else%
	  \@serbian@cyrfalse\fi%
	\fi}

\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{Literatura}%
   \def\abstractname{Sažetak}%
   \def\bibname{Bibliografija}%
   \def\prefacename{Predgovor}%
   \def\chaptername{Glava}%
   \def\appendixname{Dodatak}%
   \def\contentsname{Sadržaj}%
   \def\listfigurename{Slike}%
   \def\listtablename{Tabele}%
   \def\indexname{Indeks}%
   \def\figurename{Slika}%
   \def\tablename{Tabela}%
   \def\partname{Deo}%
   \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{Glosar}% <-- CHECK
   }
\def\dateserbian@lat{%   
   \def\today{\number\day .~\ifcase\month\or
    januar\or februar\or mart\or april\or maj\or
    juni\or juli\or avgust\or septembar\or oktobar\or novembar\or
    decembar\fi \space \number\year}%
    }

%%%TODO ASK SOMEONE TO CHECK THESE!
\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\thepart{}%
   \def\partname{Део}%
   \def\pagename{Страна}%
   \def\seename{Види}%
   \def\alsoname{Види такође}%
   \def\enclname{Прилоzи}%
   \def\ccname{Копије}%
   \def\headtoname{Прима}%
   \def\proofname{Докаz}%
   \def\glossaryname{Глосар}% <-- CHECK
   }
\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}%
    }

\def\serbian@font@cyr{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{serbianfont}{%
      \@ifundefined{cyrillicfont}{%
        \zf@check@ot@script{cyrl}%
	\if@tempswa%
	  \addfontfeature{Script=Cyrillic}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Cyrillic script!^^J
	  Please define \string\cyrillicfont\space or \string\serbianfont\space with \string\newfontfamily}%
	\fi%
	\zf@check@ot@lang{SRB}%
	\if@tempswa\addfontfeature{Language=Serbian}\fi%
	}%
        {\cyrillicfont%
         \zf@check@ot@lang{SRB}%
	 \if@tempswa\addfontfeature{Language=Serbian}\fi%
        }%
     }% 
     {\serbianfont}%
}

\def\serbian@font@lat{%
  \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
   \@ifundefined{serbianfontlatin}{%
     \zf@check@ot@lang{SRB}%
     \if@tempswa\addfontfeature{Language=Serbian}\fi}%
    {\serbianfontlatin}%
}

\def\serbian@font{%
   \if@serbian@cyr\serbian@font@cyr\else\serbian@font@lat\fi}

%TODO when available load latin hyphenation patterns as well!
\def\serbian@language{\language=\l@serbian}

\setlocalhyphenmins{serbian}{2}{2}%

\def\noextras@serbian{%
   \nofrench@indent%
   }

\def\blockextras@serbian{%
   \french@indent%
   }
%    \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]
\makeatletter
\def\slovak@font{\normalfontlatin}

\ifx\l@slovak\@undefined%
   \xpg@nopatterns{Slovak}%
   \adddialect\l@slovak\l@nohyphenation%
\fi

\def\captionsslovak{%
   \def\refname{Referencie}%
   \def\abstractname{Abstrakt}%
   \def\bibname{Literatúra}%
   \def\prefacename{Úvod}%
   \def\chaptername{Kapitola}%
   \def\appendixname{Dodatok}%
   \def\contentsname{Obsah}%
   \def\listfigurename{Zoznam obrázkov}%
   \def\listtablename{Zoznam tabuliek}%
   \def\indexname{Index}%
   \def\figurename{Obrázok}%
   \def\tablename{Tabuľka}%
   %\def\thepart{}%
   \def\partname{Časť}%
   \def\pagename{Strana}%
   \def\seename{viď}%
   \def\alsoname{viď tiež}%
   \def\enclname{Prílohy}%
   \def\ccname{cc.}%
   \def\headtoname{Pre}% was komu
   \def\proofname{Dôkaz}%
   \def\glossaryname{Slovník}%
   }
\def\dateslovak{%   
   \def\today{\number\day.~\ifcase\month\or
    januára\or februára\or marca\or apríla\or mája\or
    júna\or júla\or augusta\or septembra\or októbra\or
    novembra\or decembra\fi
    \space \number\year}%
    }

\def\slovak@language{\language=\l@slovak}

\setlocalhyphenmins{slovak}{2}{2}%

%    \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]
\makeatletter
\def\slovenian@font{\normalfontlatin}

\ifx\l@slovenian\@undefined%
 \ifx\l@slovene\@undefined%
   \xpg@nopatterns{Slovenian}%
   \adddialect\l@slovenian\l@nohyphenation%
\fi\fi

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

\def\slovenian@language{\language=\l@slovenian}

\setlocalhyphenmins{slovenian}{2}{2}%

%    \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]
\makeatletter
\def\spanish@font{\normalfontlatin}

\ifx\l@spanish\@undefined
   \xpg@nopatterns{spanish}
   \adddialect\l@spanish\l@nohyphenation
\fi

\def\captionsspanish{%
   \def\prefacename{Prefacio}%
   \def\refname{Referencias}%
   \def\abstractname{Resumen}%
   \def\bibname{Bibliografía}%
   \def\chaptername{Capítulo}%
   \def\appendixname{Apéndice}%
   \def\contentsname{Índice general}%
   \def\listfigurename{Índice de figuras}%
   \def\listtablename{Índice de cuadros}%
   \def\indexname{Índice alfabético}%
   \def\figurename{Figura}%
   \def\tablename{Cuadro}%
   \def\partname{Parte}%
   \def\enclname{Adjunto(s)}%
   \def\ccname{Copia a}%
   \def\headtoname{A}%
   \def\pagename{Página}%
   \def\seename{véase}%
   \def\alsoname{véase también}%
   \def\proofname{Prueba}%
   \def\glossaryname{Glosario}%
   }
\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}%
}

\def\spanish@language{\language=\l@spanish}

\setlocalhyphenmins{spanish}{2}{2}%

\def\noextras@spanish{%
   \nonfrenchspacing%
}

\def\blockextras@spanish{%
   \frenchspacing%
}

\def\inlineextras@spanish{%
   \frenchspacing%
}

%    \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]
\makeatletter
\def\swedish@font{\normalfontlatin}

\ifx\l@swedish\@undefined%
   \xpg@nopatterns{Swedish}%
   \adddialect\l@swedish\l@nohyphenation%
\fi

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

\def\swedish@language{\language=\l@swedish}

\setlocalhyphenmins{swedish}{2}{2}%

\def\noextras@swedish{%
   \nonfrenchspacing%
   }

\def\blockextras@swedish{%
   \frenchspacing%
   }

\def\inlineextras@swedish{%
   \frenchspacing%
   }

%    \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}[0.3]
\makeatletter

\ifx\l@syriac\@undefined
  %\xpg@nopatterns{Syriac}%
  \adddialect\l@syriac\l@nohyphenation
\fi

\def\syriac@RL{\relax}

\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}
	
\def\syriac@font{%
  \@ifundefined{syriacfont}{%
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@check@ot@script{syrc}%
    \if@tempswa%
      \addfontfeature{Script=Syriac}%
    \else%
      \PackageError{polyglossia}{^^J
      The current font does not contain the Syriac script!^^J
      Please define \string\syriacfont\space with \string\newfontfamily}%
    \fi%
    }%
  {\syriacfont}%
}

\def\selectnormalfontsyriac{%
   \let\normalfont=\syriac@font%
   \let\rmfamily=\syriac@font%
   % TODO add setup to define Sans and Mono Syriac fonts if desired
   \let\sffamily=\syriac@font%
   \let\ttfamily=\syriac@font%
   \def\reset@font{\normalfont}}

%\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}%
     \else%
         \ifcsdef{arabicfont}%
         {{\protect\arabicfont\protect\addfontfeature{Mapping=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}}%
	 {\RL{\reset@font\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{\reset@font\number#1}%
   \fi}

\def\syriac@globalnumbers{%
   \let\@latinarabic\@arabic%
   \let\@arabic\syriacnumber%
   \renewcommand\thefootnote{\protect\syriacnumber{\c@footnote}}%
   }
\def\nosyriac@globalnumbers{%
   \let\@arabic\@latinarabic%
   }
\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@language{\language=\l@syriac}

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

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

\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\thainumber#1{\if@thai@numerals{\protect\addfontfeature{Mapping=thaidigits}\protect\number#1}\else{\protect\reset@font\protect\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\@latinarabic\@arabic%
   \let\@arabic\thainumber%
   \renewcommand{\thefootnote}{\protect\thainumber{\c@footnote}}%
   }
\def\nothai@globalnumbers{%
   \let\@arabic\@latinarabic%
   \renewcommand{\thefootnote}{\protect\number{\c@footnote}}%
   }

\def\thai@font{%
  \@ifundefined{thaifont}{%
    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
    \zf@check@ot@script{thai}%
    \if@tempswa%
      \addfontfeature{Script=Thai}%
    \else%
      \PackageError{polyglossia}{^^J
      The current font does not contain the Thai script!^^J
      Please define \string\thaifont\space with \string\newfontfamily}%
    \fi%
    }%
    {\thaifont}}

\def\selectnormalfontthai{%
   \let\normalfont=\thai@font%
   \let\rmfamily=\thai@font%
   \let\sffamily=\thai@font%
   \let\ttfamily=\thai@font%
   \def\reset@font{\normalfont}}

\def\thai@language{\language=\l@nohyphenation}

\def\blockextras@thai{%
   \renewcommand{\baselinestretch}{1.2}% FIXME restore default value in noextras?
   }
%    \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]
\makeatletter

\def\turkish@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{turkishfont}{%
	\zf@check@ot@lang{TUR}%
	\if@tempswa
	\addfontfeature{Language=Turkish}%
	\else
	\zf@check@ot@lang{TRK}%
	\if@tempswa
	\addfontfeature{Language=Turkish}\fi%
	\fi}
     {\turkishfont}%
}%

\ifx\l@turkish\@undefined
   \xpg@nopatterns{turkish}
   \adddialect\l@turkish\l@nohyphenation
\fi

\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{%
   \frenchspacing%
   \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{%
   \nonfrenchspacing%
   \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\turkish@language{\language=\l@turkish}

\setlocalhyphenmins{turkish}{2}{2}%

\def\noextras@turkish{%
   \noturkish@punctuation%
}

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

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

%    \end{macrocode}
% \iffalse
%</gloss-turkish.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
%
\makeatletter

\ifx\l@ukrainian\@undefined%
   \xpg@nopatterns{Ukrainian}%
   \adddialect\l@ukrainian\l@nohyphenation%
\fi

\def\ukrainian@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{ukrainianfont}{%
      \@ifundefined{cyrillicfont}{%
        \zf@check@ot@script{cyrl}%
	\if@tempswa%
	  \addfontfeature{Script=Cyrillic}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the Cyrillic script!^^J
	  Please define \string\cyrillicfont\space or \string\ukrainianfont\space with \newfontfamily}%
	\fi%
	\zf@check@ot@lang{UKR}%
	\if@tempswa\addfontfeature{Language=Ukrainian}\fi
	}%
        {\cyrillicfont%
	\zf@check@ot@lang{UKR}%
	\if@tempswa\addfontfeature{Language=Ukrainian}\fi%
        }%
     }% 
     {\ukrainianfont}%
}%

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

\setlocalhyphenmins{ukrainian}{2}{2}%

\def\noextras@ukrainian{%
   \nonfrenchspacing%
   }

\def\blockextras@ukrainian{%
   \frenchspacing%
   }

\def\inlineextras@ukrainian{%
   \frenchspacing%
   }

%    \end{macrocode}
% \iffalse
%</gloss-ukrainian.ldf>
%<*gloss-usorbian.ldf>
% \fi
% \clearpage
% 
% \subsection{gloss-usorbian.ldf}
%    \begin{macrocode}
\ProvidesFile{gloss-usorbian.ldf}[polyglossia: module for upper sorbian]
\makeatletter
\def\usorbian@font{\normalfontlatin}

\ifx\l@uppersorbian\@undefined
  \ifx\l@usorbian\@undefined
    \xpg@nopatterns{Upper Sorbian}
    \adddialect\l@usorbian\l@nohyphenation
    \let\l@uppersorbian\l@usorbian
  \else
    \let\l@uppersorbian\l@usorbian
  \fi
\else
  \let\l@usorbian\l@uppersorbian
\fi

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

\def\usorbian@language{\language=\l@usorbian}

\setlocalhyphenmins{usorbian}{2}{2}%

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

\def\vietnamese@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{vietnamesefont}{%
	\zf@check@ot@lang{VIT}%
	\if@tempswa\addfontfeature{Language=Vietnamese}\fi}
     {\vietnamesefont}%
}%

\ifx\l@vietnamese\@undefined%
   \xpg@nopatterns{Vietnamese}%
   \adddialect\l@vietnamese\l@nohyphenation%
\fi

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

\def\vietnamese@language{\language=\l@vietnamese}

\setlocalhyphenmins{vietnamese}{2}{2}%

\def\noextras@vietnamese{%
    \nonfrenchspacing%
}

\def\blockextras@vietnamese{%
    \frenchspacing%
}

\def\inlineextras@vietnamese{%
    \frenchspacing%
}
%    \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]
\makeatletter
\def\welsh@font{\normalfontlatin}

\ifx\l@welsh\@undefined%
   \xpg@nopatterns{Welsh}%
   \adddialect\l@welsh\l@nohyphenation%
\fi

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

\def\welsh@language{\language=\l@welsh}

\setlocalhyphenmins{welsh}{2}{3}%

%    \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>
%<*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.1.0a         ¦
   ¦                                              ¦
   ¦ Modern multilingual typesetting with XeLaTeX ¦
   ¦                                              ¦
   ¦----------------------------------------------¦

This package for provides a complete Babel replacement for users of XeLaTeX.
This version includes support for 55 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.

CHANGES

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 


  ------------------------------
   François Charette, Dec 2009
    <firmicus ατ gmx δοτ net>
  ------------------------------
%</README>
%<*gloss-template.ldf>
\ProvidesFile{gloss-<lang>.ldf}[polyglossia: module for <lang>]
\makeatletter

\ifx\l@<lang>\@undefined%
   \xpg@nopatterns{<Lang>}%
   \adddialect\l@<lang>0%
\fi

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

%\def\<lang>@font{\normalfontlatin} % <== if the script is Latin
% else:
\def\<lang>@font{%
\font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
\@ifundefined{<lang>font}{%
      \@ifundefined{<script>font}{%
        \zf@check@ot@script{<xxxx>}%xxx
	\if@tempswa%
	  \addfontfeature{Script=<Script>}%
	\else%
	  \PackageError{polyglossia}{^^J
	  The current font does not contain the <Script> script!^^J
	  Please define \string\<script>font\space or \string\<lang>font\space with \string\newfontfamily}%
	\fi%
	\zf@check@ot@lang{<XXX>}%xxx
	\if@tempswa\addfontfeature{Language=<Lang>}\fi%
	}%
      {\<script>font%
	\zf@check@ot@lang{<XXX>}%xxx
	\if@tempswa\addfontfeature{Language=<Lang>}\fi%
      }}% 
     {\<lang>font}%
}
% If script and lang are identical (e.g. Greek, Arabic, Syriac, …), then use this:
%\def\<lang>@font{%
%  \@ifundefined{<lang>font}{%
%    \font\zf@basefont="\csname zf@family@fontdef\f@family\endcsname" at \f@size pt
%    \zf@check@ot@script{<xxx>}%
%    \if@tempswa%
%      \addfontfeature{Script=<Lang>}%
%    \else%
%      \PackageError{polyglossia}{The current font does not contain the <Lang> script!^^J
%      Please define \string\<lang>font\space with \string\newfontfamily}%
%    \fi%
%    }%
%  {\<lang>font}}

\def\selectnormalfont<lang>{%
   \let\normalfont=\<lang>@font%
   \def\reset@font{\normalfont}}

\def\<lang>@language{\protect\language=\l@<lang>}

\setlocalhyphenmins{<lang>}{2}{2}%

\def\noextras@<lang>{%
   }

\def\blockextras@<lang>{%
   }

\def\inlineextras@<lang>{%
   }

%</gloss-template.ldf>
%<*examples.tex>
\documentclass[a4paper]{article}
\usepackage[no-math]{fontspec}
\usepackage{xltxtra,url}
\usepackage{polyglossia}
\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{german,latin,russian,turkish,polish,latvian,sanskrit,ukrainian,farsi,syriac,divehi,hebrew,amharic}
\setromanfont{Linux Libertine}
\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}
\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. \\
(Aujourd'hui! \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}%\footnotesize
ܠܫܢܐ ܐܪܡܝܐ ܐܘ ܐܪܡܝܬ ܗܘ ܠܫܢ̈ܐ ܥܡ ܬܫܥܝܬܐ ܕ\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. \\
(Bugün: \today)
\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)
\end{farsi}

\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}
\usepackage[quiet]{polyglossia}
\setdefaultlanguage[calendar=gregorian,hijricorrection=1,locale=mashriq]{arabic}
\setotherlanguage[variant=british]{english}
\setotherlanguage{farsi}
\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}
\parindent 0pt
\makeatletter
\makeatother
\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} = \LR{\today} = \today\ = \Hijritoday\footnote{ 
	محسوب بـ \textenglish{\textsf{hijrical.sty}}} 

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