% \iffalse meta-comment
%
% Copyright 2014-2017 Namig J. Guliyev and any individual authors
% listed elsewhere in this file.  All rights reserved.
% 
% This file is part of the Babel system.
% --------------------------------------
% 
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% The Current Maintainers of this work are Namig J. Guliyev
%                                      and Javier Bezos
%
% To report error: http://www.texnia.com/contact.html
% 
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
% \fi
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{azerbaijani.dtx}
%</dtx>
%<code>\ProvidesLanguage{azerbaijani}
%\fi
%\ProvidesFile{azerbaijani.dtx}
        [2017/05/03 v1.0a Azerbaijani support from the babel system] %^^A
%\iffalse
%% File `azerbaijani.dtx'
%
%% Azerbaijani Language Definition File
%% Copyright (C) 2014-2017
%%           by Namig J. Guliyev
%
%    This file is part of the babel system, it provides the source
%    code for the Azerbaijani language definition file.
%<*filedriver>
\documentclass{ltxdoc}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\title{The Azerbaijani style for babel}
\author{Namig J. Guliyev, Javier Bezos} 
\newcommand*\TeXhax{\TeX hax}
\newcommand*\babel{\textsf{babel}}
\newcommand*\langvar{$\langle \it lang \rangle$}
\newcommand*\note[1]{}
\newcommand*\Lopt[1]{\textsf{#1}}
\newcommand*\file[1]{\texttt{#1}}
\DeclareUnicodeCharacter{018F}{\Azerbaijanischwa}
\DeclareUnicodeCharacter{0259}{\azerbaijanischwa}
\DeclareTextCommand{\Azerbaijanischwa}{T1}{%
  \UseTextSymbol{T2A}{\char154}}
\DeclareTextCommand{\azerbaijanischwa}{T1}{%
  \UseTextSymbol{T2A}{\char186}}
\begin{document}
 \maketitle
 \DocInput{azerbaijani.dtx}
\end{document}
%</filedriver>
%\fi
% \GetFileInfo{azerbaijani.dtx}
%
%  \section{The Azerbaijani language}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate.} defines all the language definition macros for the
%    Azerbaijani language.
%
%    Typical usage with pdf\TeX{} is:
%\begin{verbatim}
%\usepackage[T2A,T1]{fontenc}
%\usepackage[utf8]{inputenc}
%\usepackage[azerbaijani]{babel}
%\end{verbatim}
%
%    Note you must load two encondings: |T1| as the main one for most
%    characters, and |T2A| for the schwa, which is not provided by any
%    Latin encoding. This mixture of encodings means hyphenation in
%    traditional engines will be only partial -- words containing the
%    schwa will not be hyphenated if the point comes near this letter.
%
%    Thus, if proper handling of hyphenation is required, you must
%    switch to a Unicode engine, like Xe\TeX{} or Lua\TeX.
%
%    This style doesn't handle the \textit{fi} ligature (yet). You can
%    break it by hand with |f{}i| or |f{\kern0pt}i|, but this can be
%    done automatically, too. With pdf\TeX{} and monolingual
%    documents, use \textsf{microtype}, as for example:
%\begin{verbatim}
%\usepackage{microtype}
%\DisableLigatures[f]{encoding = *, family = *}
%\end{verbatim}
%
%    With Xe\TeX, ligatures are handled internally by the font, provided the
%    corresponding feature has been implemented (not all fonts do); e.~g.:
%\begin{verbatim}
%\usepackage{fontspec}
%\setmainfont[Language=Azerbaijani]{Iwona}
%\end{verbatim}
%
%    With Lua\TeX{} you can use either method (remember with
%    \textsf{microtype} you may need also set |Renderer=Basic| when
%    defining a font with \textsf{fontspec}, at least at the time of
%    this writing). Alternative approachs with Lua\TeX{} are the
%    \textsf{setnolig} package and
%    \verb|fonts.handlers.otf.addfeature| from \textsf{luaotfload}
%    (not done here).
%
% \StopEventually{}
%
%  \subsection*{The code}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
%    \begin{macrocode}
%<*code>
\LdfInit{azerbaijani}\captionsazerbaijani
%    \end{macrocode}
%
%    When this file is read as an option, i.e. by the |\usepackage|
%    command, \texttt{azerbaijani} could be an `unknown' language in which
%    case we have to make it known. So we check for the existence of
%    |\l@azerbaijani| to see whether we have to do something here.
%
% \changes{azerbaijani-1.2c}{1994/06/26}{Now use \cs{@nopatterns} to
%    produce the warning}
%    \begin{macrocode}
\ifx\l@azerbaijani\@undefined
  \@nopatterns{Azerbaijani}
  \adddialect\l@azerbaijani0\fi
%    \end{macrocode}
%
%    The next step consists of defining commands to switch to (and
%    from) the Azerbaijani language.
%
% \begin{macro}{\captionsazerbaijani}
% \begin{macro}{\dateazerbaijani}
%    The macro |\captionsazerbaijani| defines all strings used in the four
%    standard documentclasses provided with \LaTeX. 
%
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackagewith{inputenc}{utf8}{%
    \DeclareUnicodeCharacter{018F}{\Azerbaijanischwa}%
    \DeclareUnicodeCharacter{0259}{\azerbaijanischwa}}%
  {\@ifpackagewith{inputenc}{utf8x}{%
     \DeclareUnicodeCharacter{399}{\Azerbaijanischwa}%
     \DeclareUnicodeCharacter{601}{\azerbaijanischwa}}{}}}
\StartBabelCommands*{azerbaijani}{captions}
    [unicode, charset=utf8, fontenc=EU1 EU2 TU]
  \SetString\prefacename{Ön söz}
  \SetString\refname{Ədəbiyyat}
  \SetString\abstractname{Annotasiya}
  \SetString\bibname{Ədəbiyyat}
  \SetString\chaptername{Fəsil}
  \SetString\appendixname{Əlavə}
  \SetString\contentsname{Mündəricat}
  \SetString\listfigurename{Şəkillərin siyahısı}
  \SetString\listtablename{Cədvəllərin siyahısı}
  \SetString\indexname{Mövzu göstəricisi}
  \SetString\figurename{Şəkil}
  \SetString\tablename{Cədvəl}
  \SetString\partname{Hissə}
  \SetString\enclname{encl}
  \SetString\ccname{cc}
  \SetString\headtoname{To}
  \SetString\pagename{səh.}
  \SetString\seename{baxın}
  \SetString\alsoname{həmçinin baxın}
  \SetString\proofname{İsbatı}
  \SetString\glossaryname{Terminlər lüğəti}
  \SetCase[\azerbaijanischwa\Azerbaijanischwa]
    {\uccode`i=`İ\relax
     \uccode`ı=`I\relax}
    {\lccode`İ=`i\relax
     \lccode`I=`ı\relax}
  \SetHyphenMap{%
    \BabelLower{`İ}{`i}%
    \BabelLower{`I}{`ı}}
  \AfterBabelCommands{%
    \DeclareTextCommandDefault{\Azerbaijanischwa}{Ə}%
    \DeclareTextCommandDefault{\azerbaijanischwa}{ə}}
\StartBabelCommands*{azerbaijani}{}[generic, fontenc=T1]
  \AfterBabelCommands{%
    \@ifundefined{T@T1}%
    {\PackageWarning{azerbaijani}%
       {The font encoding T1 has not been loaded. Expect errors\MessageBreak
        and wrong hyphenations}}
    {\@ifundefined{T@T2C}{}{\gdef\aze@cyrenc{T2C}}%
     \@ifundefined{T@T2B}{}{\gdef\aze@cyrenc{T2B}}%
     \@ifundefined{T@T2A}{}{\gdef\aze@cyrenc{T2A}}%
     \@ifundefined{T@X2}{}{\gdef\aze@cyrenc{X2}}%
     \ifx\aze@cyrenc\@undefined
       \PackageError{azerbaijani}%
         {No font containing the schwa has been detected.\MessageBreak
          Please, load a Cyrillic encoding (T2A, T2B, T2C, X2)}%
         {See the manual for further details.}%
     \else
       \AtBeginDocument{%
         \DeclareTextCommand{\Azerbaijanischwa}{T1}{%
           \UseTextSymbol{\aze@cyrenc}{\char154}\bbl@allowhyphens}
         \DeclareTextCommand{\azerbaijanischwa}{T1}{%
           \UseTextSymbol{\aze@cyrenc}{\char186}\bbl@allowhyphens}}%
     \fi}}
\StartBabelCommands*{azerbaijani}{captions}
  \SetString\prefacename{\"{O}n s\"{o}z}
  \SetString\refname{{\Azerbaijanischwa}d{\azerbaijanischwa}biyyat}
  \SetString\abstractname{Annotasiya}
  \SetString\bibname{{\Azerbaijanischwa}d{\azerbaijanischwa}biyyat}
  \SetString\chaptername{F{\azerbaijanischwa}sil}
  \SetString\appendixname{{\Azerbaijanischwa}lav{\azerbaijanischwa}}
  \SetString\contentsname{M\"{u}nd{\azerbaijanischwa}ricat}
  \SetString\listfigurename{%
    \c{S}{\azerbaijanischwa}kill{\azerbaijanischwa}rin siyah{\i}s{\i}}
  \SetString\listtablename{%
    C{\azerbaijanischwa}dv{\azerbaijanischwa}ll{\azerbaijanischwa}rin
    siyah{\i}s{\i}}
  \SetString\indexname{M\"{o}vzu g\"{o}st{\azerbaijanischwa}ricisi}
  \SetString\figurename{\c{S}{\azerbaijanischwa}kil}
  \SetString\tablename{C{\azerbaijanischwa}dv{\azerbaijanischwa}l}
  \SetString\partname{Hiss{\azerbaijanischwa}}
  \SetString\enclname{encl}
  \SetString\ccname{cc}
  \SetString\headtoname{To}
  \SetString\pagename{s{\azerbaijanischwa}h.}
  \SetString\seename{bax{\i}n}
  \SetString\alsoname{h{\azerbaijanischwa}m\c{c}inin bax{\i}n}
  \SetString\proofname{\.{I}sbat{\i}}
  \SetString\glossaryname{Terminl{\azerbaijanischwa}r l\"{u}\u{g}əti}
  \SetCase[\azerbaijanischwa\Azerbaijanischwa]
    {\uccode`i="9D\relax
     \uccode"19=`I\relax}
    {\lccode"9D=`i\relax
     \lccode`I="19\relax}
  \SetHyphenMap{%
    \BabelLower{"9D}{`i}
    \BabelLower{`I}{"19}}
\StartBabelCommands*{azerbaijani}{date}
  \SetStringLoop{month#1name}{%
    yanvar,fevral,mart,aprel,may,iyun,iyul,%
    avqust,sentyabr,oktyabr,noyabr,dekabr}
  \SetString\today{%
    \number\day~\@nameuse{month\romannumeral\month name}%
    \space\number\year}
\EndBabelCommands
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\extrasazerbaijani}
% \begin{macro}{\noextrasazerbaijani}
%    The macro |\extrasazerbaijani| will perform all the extra definitions
%    needed for the Azerbaijani language. The macro |\noextrasazerbaijani| is
%    used to cancel the actions of |\extrasazerbaijani|.
%
%    We specify that the azerbaijani group of shorthands should be used.
%    These characters are `turned on' once, later their definition may
%    vary. 
%
%    \begin{macrocode}
\providehyphenmins{azerbaijani}{\tw@\tw@}
\initiate@active@char{"}
\declare@shorthand{azerbaijani}{"-}{\bbl@hy@soft}
\declare@shorthand{azerbaijani}{"=}{\bbl@hy@hard}
\addto\extrasazerbaijani{%
  \bbl@activate{"}%
  \languageshorthands{azerbaijani}%
  \bbl@frenchspacing}
\addto\noextrasazerbaijani{%
  \bbl@deactivate{"}%
  \bbl@nonfrenchspacing}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%    The macro |\ldf@finish| takes care of looking for a
%    configuration file, setting the main language to be switched on
%    at |\begin{document}|.
%    \begin{macrocode}
\ldf@finish{azerbaijani}
%</code>
%    \end{macrocode}
%
% \Finale
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\endinput
