% \iffalse meta-comment
%
% Copyright 1989-2005 Johannes L. Braams 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 Maintainer of this work is Johannes Braams.
% 
% The list of all files belonging to the Babel system is
% given in the file `manifest.bbl. See also `legal.bbl' for additional
% information.
% 
% 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
% \CheckSum{330}
% \iffalse
%    Tell the \LaTeX\ system who we are and write an entry on the
%    transcript.
%<*dtx>
\ProvidesFile{estonian.dtx}
%</dtx>
%<code>\ProvidesLanguage{estonian}
%\fi
%\ProvidesFile{estonian.dtx}
        [2005/03/30 v1.0h Estonian support from the babel system]
%\iffalse
%% File `estonian.dtx'
%% Babel package for LaTeX version 2e
%% Copyright (C) 1989 - 2005
%%           by Johannes Braams, TeXniek
%
%% Estonian language Definition File
%% Copyright (C) 1991 - 2005
%%           by Enn Saar, Tartu Astrophysical Observatory
%              Tartu Astrophysical Observatory
%              EE-2444 T\~oravere
%              Estonia
%              tel: +372 7 410 267
%              fax: +372 7 410 205
%              saar@aai.ee
%
%              Johannes Braams, TeXniek
%
%% Please report errors to: Enn Saar saar at aai.ee
%%                          (or J.L. Braams babel atbraams.cistron.nl
%
%    This file is part of the babel system, it provides the source
%    code for the Estonian language definition file.  The original
%    version of this file was written by Enn Saar,
%    (saar@aai.ee).
%<*filedriver>
\documentclass{ltxdoc}
\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}}
\begin{document}
 \DocInput{estonian.dtx}
\end{document}
%</filedriver>
%\fi
%
% \changes{estonian-1.0b}{1995/06/16}{corrected typos}
% \changes{estonian-1.0e}{1996/10/10}{Replaced \cs{undefined} with
%    \cs{@undefined} and \cs{empty} with \cs{@empty} for consistency
%    with \LaTeX, moved the definition of \cs{atcatcode} right to the
%    beginning.}
%
% \GetFileInfo{estonian.dtx}
%
% \section{The Estonian language}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate. The original author is Enn Saar,
%    (\texttt{saar@aai.ee}).}  defines the language definition macro's
%    for the Estonian language.
%
%    This file was written as part of the TWGML project, and borrows
%    heavily from the \babel\ German and Spanish language files
%    \file{germanb.ldf} and \file{spanish.ldf}.
%
%    Estonian has the same umlauts as German (\"a, \"o, \"u), but in
%    addition to this, we have also \~o, and two recent characters
%    \v s and \v z, so we need at least two active characters.
%    We shall use |"| and |~| to type Estonian accents on ASCII
%    keyboards (in the 7-bit character world). Their use is given in
%    table~\ref{tab:estonian-quote}.
%    \begin{table}[htb]
%     \begin{center}
%     \begin{tabular}{lp{8cm}}
%      |~o| & |\~o|, (and uppercase); \\
%      |"a| & |\"a|, (and uppercase); \\
%      |"o| & |\"o|, (and uppercase); \\
%      |"u| & |\"u|, (and uppercase); \\
%      |~s| & |\v s|, (and uppercase); \\
%      |~z| & |\v z|, (and uppercase); \\
%      \verb="|= & disable ligature at this position;\\
%      |"-| & an explicit hyphen sign, allowing hyphenation
%                  in the rest of the word;\\
%      |\-| & like the old |\-|, but allowing hyphenation
%             in the rest of the word; \\
%      |"`| & for Estonian low left double quotes (same as German);\\
%      |"'| & for Estonian right double quotes;\\
%      |"<| & for French left double quotes (also rather popular)\\
%      |">| & for French right double quotes.\\
%     \end{tabular}
%     \caption{The extra definitions made
%              by \file{estonian.ldf}}\label{tab:estonian-quote}
%     \end{center}
%    \end{table}
%    These active accent characters behave according to their original
%    definitions if not followed by one of the characters indicated in
%    that table; the original quote character can be typed using the
%    macro |\dq|.
%
%    We support also the T1 output encoding (and Cork-encoded text
%    input).  You can choose the T1 encoding by the command
%    |\usepackage[T1]{fontenc}|.  This package must be loaded before
%    \babel. As the standard Estonian hyphenation file
%    \file{eehyph.tex} is in the Cork encoding, choosing this encoding
%    will give you better hyphenation.
%
%    As mentioned in the Spanish style file, it may happen that some
%    packages fail (usually in a \cs{message}). In this case you
%    should change the order of the \cs{usepackage} declarations
%    or the order of the style options in \cs{documentclass}.
%
% \StopEventually{}
%
% \subsection{Implementation}
%
%    The macro |\LdfInit| takes care of preventing that this file is
%    loaded more than once, checking the category code of the
%    \texttt{@} sign, etc.
% \changes{estonian-1.0e}{1996/10/30}{Now use \cs{LdfInit} to perform
%    initial checks} 
%    \begin{macrocode}
%<*code>
\LdfInit{estonian}\captionsestonian
%    \end{macrocode}
%
%    If Estonian is not included in the format file (does not have
%    hyphenation patterns), we shall use English hyphenation.
%
%    \begin{macrocode}
\ifx\l@estonian\@undefined
  \@nopatterns{Estonian}
  \adddialect\l@estonian0
\fi
%    \end{macrocode}
%
%    Now come the commands to switch to (and from) Estonian.
%
%  \begin{macro}{\captionsestonian}
%    The macro |\captionsestonian| defines all strings used in the
%    four standard documentclasses provided with \LaTeX.
%
% \changes{estonian-1.0c}{1995/07/04}{Added \cs{proofname} for
%    AMS-\LaTeX}
% \changes{estonian-1.0d}{1995/07/27}{Added translation of `Proof'}
% \changes{estonian-1.0h}{2000/09/20}{Added \cs{glossaryname}}
%    \begin{macrocode}
\addto\captionsestonian{%
  \def\prefacename{Sissejuhatus}%
  \def\refname{Viited}%
  \def\bibname{Kirjandus}%
  \def\appendixname{Lisa}%
  \def\contentsname{Sisukord}%
  \def\listfigurename{Joonised}%
  \def\listtablename{Tabelid}%
  \def\indexname{Indeks}%
  \def\figurename{Joonis}%
  \def\tablename{Tabel}%
  \def\partname{Osa}%
  \def\enclname{Lisa(d)}%
  \def\ccname{Koopia(d)}%
  \def\headtoname{}%
  \def\pagename{Lk.}%
  \def\seename{vt.}%
  \def\alsoname{vt. ka}%
  \def\proofname{Korrektuur}%
  \def\glossaryname{Glossary}% <-- Needs translation
  }
%    \end{macrocode}
%
%    These captions contain accented characters.
%
%    \begin{macrocode}
\begingroup \catcode`\"\active
\def\x{\endgroup
\addto\captionsestonian{%
  \def\abstractname{Kokkuv~ote}%
  \def\chaptername{Peat"ukk}}}
\x
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\dateestonian}
%    The macro |\dateestonian| redefines the command |\today| to
%    produce Estonian dates.
% \changes{estonian-1.0f}{1997/10/01}{Use \cs{edef} to define
%    \cs{today} to save memory}
% \changes{estonian-1.0f}{1998/03/28}{use \cs{def} instead of
%    \cs{edef}} 
%    \begin{macrocode}
\begingroup \catcode`\"\active
\def\x{\endgroup
  \def\month@estonian{\ifcase\month\or
    jaanuar\or veebruar\or m"arts\or aprill\or mai\or juuni\or
    juuli\or august\or september\or oktoober\or november\or
    detsember\fi}}
\x
\def\dateestonian{%
  \def\today{\number\day.\space\month@estonian
    \space\number\year.\space a.}}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\extrasestonian}
%  \begin{macro}{\noextrasestonian}
%    The macro |\extrasestonian| will perform all the extra
%    definitions needed for Estonian. The macro |\noextrasestonian| is
%    used to cancel the actions of |\extrasestonian|. For Estonian,
%    |"| is made active and has to be treated as `special' (|~| is
%    active already).
%
%    \begin{macrocode}
\initiate@active@char{"}
\initiate@active@char{~}
\addto\extrasestonian{\languageshorthands{estonian}}
\addto\extrasestonian{\bbl@activate{"}\bbl@activate{~}}
%    \end{macrocode}
%    Store the original macros, and redefine accents.
%
%    \begin{macrocode}
\addto\extrasestonian{\babel@save\"\umlautlow\babel@save\~\tildelow}
%    \end{macrocode}
%
% \changes{estonian-1.0d}{1995/07/27}{Removed the code that changes
%    category, lower case, uper case and space factor codes }
%
%    Estonian does not use extra spaces after sentences.
%
%    \begin{macrocode}
\addto\extrasestonian{\bbl@frenchspacing}
\addto\noextrasestonian{\bbl@nonfrenchspacing}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%
%  \begin{macro}{\estonianhyphenmins}
%     For Estonian, |\lefthyphenmin| and |\righthyphenmin| are
%    both~2. 
% \changes{estonian-1.0h}{2000/09/22}{Now use \cs{providehyphenmins} to
%    provide a default value}
%    \begin{macrocode}
\providehyphenmins{\CurrentOption}{\tw@\tw@}
%    \end{macrocode}
%  \end{macro}
%
%  \begin{macro}{\tildelow}
%  \begin{macro}{\gentilde}
%  \begin{macro}{\newtilde}
%  \begin{macro}{\newcheck}
%    The standard \TeX\ accents are too high for Estonian typography,
%    we have to lower them (following the \babel\ German style).  For
%    a detailed explanation see the file \file{glyphs.dtx}.
%
%    \begin{macrocode}
\def\tildelow{\def\~{\protect\gentilde}}
\def\gentilde#1{\if#1o\newtilde{#1}\else\if#1O\newtilde{#1}%
    \else\newcheck{#1}%
    \fi\fi}
\def\newtilde#1{\leavevmode\allowhyphens
  {\U@D 1ex%
  {\setbox\z@\hbox{\char126}\dimen@ -.45ex\advance\dimen@\ht\z@
  \ifdim 1ex<\dimen@ \fontdimen5\font\dimen@ \fi}%
  \accent126\fontdimen5\font\U@D #1}\allowhyphens}
\def\newcheck#1{\leavevmode\allowhyphens
  {\U@D 1ex%
  {\setbox\z@\hbox{\char20}\dimen@ -.45ex\advance\dimen@\ht\z@
  \ifdim 1ex<\dimen@ \fontdimen5\font\dimen@ \fi}%
  \accent20\fontdimen5\font\U@D #1}\allowhyphens}
%    \end{macrocode}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%  \end{macro}
%
%    We save the double quote character in |\dq|, and  tilde in |\til|,
%    and store the original definitions of |\"| and |\~| as |\dieresis|
%    and |\texttilde|.
%
%    \begin{macrocode}
\begingroup \catcode`\"12
\edef\x{\endgroup
  \def\noexpand\dq{"}
  \def\noexpand\til{~}}
\x
\let\dieresis\"
\let\texttilde\~
%    \end{macrocode}
%
%    This part follows closely \file{spanish.ldf}. We check the
%    encoding and if it is T1, we have to tell \TeX\ about our
%    redefined accents.
%
% \changes{estonian-1.0g}{1999/04/11}{use \cs{bbl@t@one} instead of
%    \cs{bbl@next}} 
%    \begin{macrocode}
\ifx\f@encoding\bbl@t@one
  \let\@umlaut\dieresis
  \let\@tilde\texttilde
  \DeclareTextComposite{\~}{T1}{s}{178}
  \DeclareTextComposite{\~}{T1}{S}{146}
  \DeclareTextComposite{\~}{T1}{z}{186}
  \DeclareTextComposite{\~}{T1}{Z}{154}
  \DeclareTextComposite{\"}{T1}{'}{17}
  \DeclareTextComposite{\"}{T1}{`}{18}
  \DeclareTextComposite{\"}{T1}{<}{19}
  \DeclareTextComposite{\"}{T1}{>}{20}
%    \end{macrocode}
%
%    If the encoding differs from T1, we expand the accents, enabling
%    hyphenation beyond the accent. In this case \TeX\ will not find
%    all possible breaks, and we have to warn people.
%
%    \begin{macrocode}
\else
  \wlog{Warning: Hyphenation would work better for the T1 encoding.}
  \let\@umlaut\newumlaut
  \let\@tilde\gentilde
\fi
%    \end{macrocode}
%
%     Now we define the shorthands.
%
% \changes{estonian-1.0d}{1995/07/27}{The second argument was missing
%    in the definition of some of the double-quote shorthands}
%    \begin{macrocode}
\declare@shorthand{estonian}{"a}{\textormath{\"{a}}{\ddot a}}
\declare@shorthand{estonian}{"A}{\textormath{\"{A}}{\ddot A}}
\declare@shorthand{estonian}{"o}{\textormath{\"{o}}{\ddot o}}
\declare@shorthand{estonian}{"O}{\textormath{\"{O}}{\ddot O}}
\declare@shorthand{estonian}{"u}{\textormath{\"{u}}{\ddot u}}
\declare@shorthand{estonian}{"U}{\textormath{\"{U}}{\ddot U}}
%    \end{macrocode}
%    german and french quotes,
% \changes{estonian-1.0f}{1997/04/03}{Removed empty groups after
%    double quote and guillemot characters}
%    \begin{macrocode}
\declare@shorthand{estonian}{"`}{%
  \textormath{\quotedblbase}{\mbox{\quotedblbase}}}
\declare@shorthand{estonian}{"'}{%
  \textormath{\textquotedblleft}{\mbox{\textquotedblleft}}}
\declare@shorthand{estonian}{"<}{%
  \textormath{\guillemotleft}{\mbox{\guillemotleft}}}
\declare@shorthand{estonian}{">}{%
  \textormath{\guillemotright}{\mbox{\guillemotright}}}
%    \end{macrocode}
%    
%    \begin{macrocode}
\declare@shorthand{estonian}{~o}{\textormath{\@tilde o}{\tilde o}}
\declare@shorthand{estonian}{~O}{\textormath{\@tilde O}{\tilde O}}
\declare@shorthand{estonian}{~s}{\textormath{\@tilde s}{\check s}}
\declare@shorthand{estonian}{~S}{\textormath{\@tilde S}{\check S}}
\declare@shorthand{estonian}{~z}{\textormath{\@tilde z}{\check z}}
\declare@shorthand{estonian}{~Z}{\textormath{\@tilde Z}{\check Z}}
%    \end{macrocode}
%    and some additional commands:
%    \begin{macrocode}
\declare@shorthand{estonian}{"-}{\nobreak\-\bbl@allowhyphens}
\declare@shorthand{estonian}{"|}{%
  \textormath{\nobreak\discretionary{-}{}{\kern.03em}%
              \allowhyphens}{}}
\declare@shorthand{estonian}{""}{\dq}
\declare@shorthand{estonian}{~~}{\til}
%    \end{macrocode}
%
%    The macro |\ldf@finish| takes care of looking for a
%    configuration file, setting the main language to be switched on
%    at |\begin{document}| and resetting the category code of
%    \texttt{@} to its original value.
% \changes{estonian-1.0e}{1996/11/02}{Now use \cs{ldf@finish} to wrap
%    up} 
%    \begin{macrocode}
\ldf@finish{estonian}
%</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
