% hymltex3.tex is  based on Mike's masthyph.tex firstly modified Oct. 91 
% by Bernard GAULLE to define dynamically languages and load hyphenation files 
% with MLTeX. This file is adapted for MlTeX V3.
% Updates --bg:
%  2/28/92 language number setting was wrong.
%  3/20/92 allow hyphenation exceptions file (in language.dat) loading.
%  7/03/92 change c@ to @c@ to be supported by kbconfig.tex          
%  8/24/92 introduce \l@<language> being the language number
% 12/10/92 Missing \hyphenation macro reintroduced.
% 03/03/93 add dialect feature via ``='' sign.
% 05/04/93 \fhyph, \ehyph & \ghyph revisited to avoid loops when
%          \openin can't access a full PATH.
% 08/19/93 apply \c mods from MJF -- July 14, 92 
% 08/20/93 insert space after \input X for NFSS2 (H. Soulard) 
% 01/13/94 add \j def for non french language (noted by R. Lemieux).
% 03/22/94 \LANGUAGESinFORMAT now contains all languages names (proposed
%             by Michel Lavaud).
%          \input hyphen replaced by \input ushyphen (sugg. of M.Lavaud).
% 05/05/94 \patterns@loaded replace \LANGUAGESinFORMAT as in Babel.
% 08/10/94 \input replaced by \@@input.
% 12/13/94 Allow nothing else than =name in language.dat
% 12/18/94 Let language counter progress event = sign after the first language.
%-*-tex-*-
% Copyright Michael J. Ferguson, INRS-Telecommunications
% All rights reserved. 
%%
%%      checksum        = "09664 125 538 5281"
%%

% ======== Master Multilingual Pattern Inputs ======

% This file defines the changes in the \lccodes needed for Multilingual TeX
% and then inputs the patterns for English, French... 
% it uses the same pattern set as that used in Multilingual TeX ...
% you may input the "extdef.tex" conversions before the patterns are 
% processed or better use "kbconfig.tex" for customizing TeX accordingly 
% with the keystrokes of your favorite keyboard.

% =========== Special lccodes and hyphenation for Bilingual Version ====

\gdef\accenthyphcodes{
\def\oe{^^[} % \oe 
\def\i{^^P}
\def\j{^^Q}  % \j   % appropriate character subsitution for patterns
\def\'##1{\csname @ac@##1\endcsname}
\def\`##1{\csname @gr@##1\endcsname}
\def\v##1{\csname @v@##1\endcsname}
\let\^^_=\v
\def\u##1{\csname  @u@##1\endcsname}
\let\^^S=\u
\def\=##1{\csname @eq@##1\endcsname}
\def\^##1{\csname @hat@##1\endcsname}
\let\^^D=\^
\def\.##1{\csname @dot@##1\endcsname}
\def\H##1{\csname @H@##1\endcsname}
\def\~##1{\csname @til@##1\endcsname}
\def\"##1{\csname @um@##1\endcsname}
%\let\@c@@=\c
% recursive definition of \c does not work when letter is not in font
% MJF -- July 14, 92
\def\@c@@##1{\setbox\z@\hbox{##1}\ifdim\ht\z@=1ex\accent24 ##1%
  \else{\ooalign{\unhbox\z@\crcr\hidewidth\char24\hidewidth}}\fi}
\def\c##1{\csname @c@##1\endcsname}
}

\gdef\spechyphcodes{}

\let\h@yphenation=\hyphenation
\def\hyphenation#1{{\spechyphcodes\accenthyphcodes \h@yphenation{#1}}}

\language=0

% ======== Load Patterns as described in language.dat ======

% (language.dat was introduced by Johannes Braams)

{\newcount\l@nguage\newcount\initl@\newcount\workl@%
       % Compatibility with TeX 2: \language count
       \ifx\language\let\language\l@nguage\fi

\initl@=\language\l@nguage=\initl@\workl@=\l@nguage
\xdef\patterns@loaded{}% will contain all languages names
\def\@newlanguage[#1]#2{\language=#1%
        \workl@=#1\advance\workl@ by -\initl@
        \message{The #2 language is used as language number \the\workl@}%
      \expandafter\xdef\csname l@#2\endcsname{\the\workl@}% 08/24/92
      \xdef\patterns@loaded{\patterns@loaded\space #2}
      \expandafter\xdef\csname#2\endcsname{\language=\the\workl@\relax}%2/28/92
\ifx\undefined\defaultlanguage\gdef\defaultlanguage{\csname#2\endcsname}\fi}%
% test if #1 equal ``='' that means same language hyphenation but a dialect.
\def\@language#1#2 #3 #4/#5{\def\@tempa{=}\def\@tempb{#1}%
\edef\@tempc{=}%
    \ifx\@tempa\@tempb%
                    \ifnum\l@nguage > \initl@ \advance\l@nguage by -1\fi%
                    \@newlanguage[\the\l@nguage]{#2}%
                    \ifnum\l@nguage \@tempc \initl@ \advance\l@nguage by -1\fi%
    \else\edef\@tempc{<}\@l@ngu@ge#1#2 #3 #4/{#5}% 
    \fi}%
\def\@l@ngu@ge#1 #2 #3/#4{\begingroup\@newlanguage[#4]{#1}%20/3/92 mods 
 \def\@tempa{#2}
 \ifx\@tempa\empty\else\expandafter\@@input#2 \relax\fi%% loading of patterns
 \edef\@tempa{#3}\edef\@tempb{\space\space}
 \ifx\@tempb\@tempa\else\expandafter\@@input#3 \relax\fi%% loading of exceptions
                          \endgroup}
\newif\if@more\@moretrue
\openin1 = language.dat
\ifeof1\message{Error: file language.dat not found, trying to load %
                 US-english hyphenation file}\language=0\input ushyphen 
\else\advance\l@nguage by -1
\loop  \endlinechar=-1  \read1 to \@lineD  \endlinechar`\^^M
  \ifx\@lineD\empty  \else \advance\l@nguage by 1%
    \edef\@lineD{\@lineD\space\space/{\the\l@nguage}}% 
    \expandafter\@language\@lineD
  \fi
  \ifeof1 \@morefalse \fi
  \if@more\repeat
\fi\closein1

}\defaultlanguage% go to the default language (first defined in language,dat) 

% ======= definitions for fast e/f/g hyphenation =====
\def\ehyph{\language=\l@english \lccode`\'=0 \nonfrenchspacing}%
\def\fhyph{\language=\l@french  \lccode`\'=`\'  \frenchspacing}%
\def\ghyph{\language=\l@german}%
\endinput
