summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/babel/babel.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-02-25 22:40:43 +0000
committerKarl Berry <karl@freefriends.org>2016-02-25 22:40:43 +0000
commitb66747a1d8288392c4e1f855d26bfbde89b481da (patch)
tree8a529ead7ff5a2ed4c2c0ffca7ae0dd04f558082 /Master/texmf-dist/source/latex/babel/babel.dtx
parent561ad89d0840ad3b9ddb197efec1739e5089f1b6 (diff)
babel (25feb16)
git-svn-id: svn://tug.org/texlive/trunk@39867 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.dtx191
1 files changed, 130 insertions, 61 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx
index 4d8444ab9fe..612d5a9c08e 100644
--- a/Master/texmf-dist/source/latex/babel/babel.dtx
+++ b/Master/texmf-dist/source/latex/babel/babel.dtx
@@ -36,7 +36,7 @@
%\iffalse
%% File 'babel.dtx'
%\fi
-%%\ProvidesFile{babel.dtx}[2016/01/08 v3.9n The Babel package]
+%%\ProvidesFile{babel.dtx}[2016/02/24 v3.9q The Babel package]
%\iffalse
%
% Babel DOCUMENT-STYLE option for LaTeX version 2.09 or plain TeX;
@@ -45,7 +45,7 @@
%% Copyright (C) 1989-2008 by Johannes Braams,
%% TeXniek
%% all rights reserved.
-%% Copyright (C) 2013-2014 by Johannes Braams
+%% Copyright (C) 2013-2016 by Johannes Braams
%% TeXniek
%% by Javier Bezos
%% all rights reserved.
@@ -196,8 +196,8 @@
\vspace{2cm}\hspace{1.5cm}
\begin{minipage}{5cm}
\Large
-Version 3.9n\newline
-2016/01/08
+Version 3.9q\newline
+2016/02/24
\vspace{1cm}
\textit{Original author}\newline
@@ -1291,9 +1291,6 @@ Then you preprocess it with |devnag| \m{file}, which creates
|"8000|) as a shorthand can make \TeX{} enter in an infinite loop in
some rare cases. (Another issue in the `to do' list, although there
is a partial solution.)
-\item Plain \luatex{} does not load patterns on the fly. Since this
- format is not based on \babel{} but on \file{etex.src} further
- investigation is required. This is another task in the `to do' list.
\end{itemize}
The following packages can be useful, too (the list is still
@@ -1313,6 +1310,7 @@ far from complete):
some languages (kerning and spacing). Ligatures can be disabled.
\item[substitutefont] Combines fonts in several encodings.
\item[mkpattern] Generates hyphenation patterns.
+\item[tracklang] Tracks which languages have been requested.
\end{description}
\subsection{Future work}
@@ -1366,17 +1364,47 @@ Note you can set any feature required for the language -- not only
|Language|, but also |Script| or a local |.fea|. This makes those macros
a bit more verbose, but also more powerful.
-\section{Preloading languages with \file{language.dat}}
+\section{Loading languages with \file{language.dat}}
\TeX{} and most engines based on it (pdf\TeX, \xetex, $\epsilon$-\TeX,
the main exception being \luatex) require hyphenation patterns to be
-loaded when a format is created (eg, \LaTeX, Xe\LaTeX,
+preloaded when a format is created (eg, \LaTeX, Xe\LaTeX,
pdf\LaTeX). \babel{} provides a tool which has become standand in many
distributions and based on a ``configuration file'' named
\file{language.dat}. The exact way this file is used depends on the
distribution, so please, read the documentation for the latter (note
also some distributions generate the file with some tool).
+\New{3.9q} With \luatex, however, patterns are loaded on the fly when
+requested by the language (except the ``0th'' language, typically
+\textsf{english}, which is preloaded always).\footnote{This feature
+was added to 3.9o, but it was buggy. Both 3.9o and 3.9p are
+deprecated.} Until 3.9n, this task was delegated to the package
+\textsf{luatex-hyphen}, by Khaled Hosny, \'Elie Roux, and Manuel
+P\'egouri\'e-Gonnard, and required an extra file named
+|language.dat.lua|, but now a new mechanism has been devised based
+solely on |language.dat|. \textbf{You must rebuild the formats} if
+upgrading from a previous version. You may want to have a local
+|language.dat| for a particular project (for example, a book on
+Chemistry).\footnote{The loader for lua(e)tex is slightly different as
+it's not based on \babel{} but on \texttt{etex.src}. Until 3.9p it
+just didn't work, but thanks to the new code it works by reloading the
+data in the \babel{} way, i.e., with \texttt{language.dat}.}
+
+Unfortunately, the new model is intrinsically incompatible with the
+previous one, which means you can experience some problems with
+\textsf{polyglossia}. If using the latter, you must load the patterns
+with \babel{} as shown in the following example:
+\begin{verbatim}
+\usepackage[base,french,dutch,spanish,english]{babel}
+\usepackage{polyglossia}
+\setmainlanguage{french}
+\setotherlanguages{dutch,spanish,english}
+\end{verbatim}
+Be aware this is, very likely, a temporary solution.
+
+\subsection{Format}
+
In that file the person who maintains a \TeX\ environment has to record
for which languages he has hyphenation patterns \emph{and} in which
files these are stored\footnote{This is because different operating
@@ -1622,7 +1650,7 @@ explained in in sec. \ref{s:strings} (\babel{} 3.9 and later).
\begin{verbatim}
\ProvidesLanguage{<language>}
- [2016/01/08 v0.0 <Language> support from the babel system]
+ [2016/02/24 v0.0 <Language> support from the babel system]
\LdfInit{<language>}{captions<language>}
\ifx\undefined\l@<language>
@@ -2405,8 +2433,8 @@ help from Bernd Raichle, for which I am grateful.
% little bit of literate programming.
%
% \begin{macrocode}
-%<<version=3.9n>>
-%<<date=2016/01/08>>
+%<<version=3.9q>>
+%<<date=2016/02/24>>
% \end{macrocode}
%
% We define some basic macros which just make the code cleaner.
@@ -2436,9 +2464,9 @@ help from Bernd Raichle, for which I am grateful.
%<</Basic macros>>
% \end{macrocode}
%
-% Some files identify themselves with a \LaTeX{} macro. The following
-% code is placed before them to define (and then undefine) if not in
-% \LaTeX.
+% Some files identify themselves with a \LaTeX{} macro. The following
+% code is placed before them to define (and then undefine) if not in
+% \LaTeX.
%
% \begin{macrocode}
%<<*Make sure ProvidesFile is defined>>
@@ -2450,9 +2478,9 @@ help from Bernd Raichle, for which I am grateful.
%<</Make sure ProvidesFile is defined>>
% \end{macrocode}
%
-% The following code is used in \file{babel.sty} and
-% \file{babel.def}, and makes sure the current version of
-% |switch.ldf| is used, if different from that in the format.
+% The following code is used in \file{babel.sty} and \file{babel.def},
+% and makes sure the current version of |switch.ldf| is used, if
+% different from that in the format.
%
% \begin{macrocode}
%<<*Load switch if newer>>
@@ -2463,6 +2491,19 @@ help from Bernd Raichle, for which I am grateful.
%<</Load switch if newer>>
% \end{macrocode}
%
+% The following code is also used in \file{babel.sty} and
+% \file{babel.def}, and loads (only once) the data in |language.dat|.
+%
+% \begin{macrocode}
+%<<*Load patterns in luatex>>
+\ifx\directlua\@undefined\else
+ \ifx\bbl@luapatterns\@undefined
+ \input luababel.def
+ \fi
+\fi
+%<</Load patterns in luatex>>
+% \end{macrocode}
+%
% The following code is used in \file{babel.def} and
% \file{switch.def}.
%
@@ -2611,6 +2652,8 @@ help from Bernd Raichle, for which I am grateful.
% December 1994}
% \changes{babel~3.6k}{1999/03/18}{We need at least \LaTeX\ from
% June 1998}
+% \changes{babel~3.9q}{2016/02/11}{Load patterns with option base.
+% To be improved. Moved showlanguages before base}
% \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
@@ -2618,12 +2661,46 @@ help from Bernd Raichle, for which I am grateful.
\@ifpackagewith{babel}{debug}
{\input switch.def\relax}
{<@Load switch if newer@>}
+<@Load patterns in luatex@>
<@Basic macros@>
\def\AfterBabelLanguage#1{%
\global\expandafter\bbl@add\csname#1.ldf-h@@k\endcsname}%
+% \end{macrocode}
+% If the format created a list of loaded languages (in
+% |\bbl@languages|), get the name of the 0-th to show the actual
+% language used.
+% \begin{macrocode}
+\ifx\bbl@languages\@undefined\else
+ \begingroup
+ \catcode`\^^I=12
+ \@ifpackagewith{babel}{showlanguages}{%
+ \begingroup
+ \def\bbl@elt#1#2#3#4{\wlog{#2^^I#1^^I#3^^I#4}}%
+ \wlog{<*languages>}%
+ \bbl@languages
+ \wlog{</languages>}%
+ \endgroup}{}
+ \endgroup
+ \def\bbl@elt#1#2#3#4{%
+ \ifnum#2=\z@
+ \gdef\bbl@nulllanguage{#1}%
+ \def\bbl@elt##1##2##3##4{}%
+ \fi}%
+ \bbl@languages
+\fi
+% \end{macrocode}
+% Now the \texttt{base} option. With it we can define (and load, with
+% \luatex) hyphenation patterns, even if we are not interesed in the
+% rest of babel. Useful for \textsf{polyglossia}, too.
+% \begin{macrocode}
\@ifpackagewith{babel}{base}{%
- \DeclareOption*{\bbl@patterns{\CurrentOption}}%
+ \ifx\directlua\@undefined
+ \DeclareOption*{\bbl@patterns{\CurrentOption}}%
+ \else
+ \DeclareOption*{\bbl@patterns@lua{\CurrentOption}}%
+ \fi
\DeclareOption{base}{}%
+ \DeclareOption{showlanguages}{}%
\ProcessOptions
\global\expandafter\let\csname opt@babel.sty\endcsname\relax
\global\expandafter\let\csname ver@babel.sty\endcsname\relax
@@ -2819,29 +2896,6 @@ help from Bernd Raichle, for which I am grateful.
\bbl@opt@main}
\fi
% \end{macrocode}
-% If the format created a list of loaded languages (in
-% |\bbl@languages|), get the name of the 0-th to show the actual
-% language used.
-% \begin{macrocode}
-\ifx\bbl@languages\@undefined\else
- \begingroup
- \catcode`\^^I=12
- \@ifpackagewith{babel}{showlanguages}{%
- \begingroup
- \def\bbl@elt#1#2#3#4{\wlog{#2^^I#1^^I#3^^I#4}}%
- \wlog{<*languages>}%
- \bbl@languages
- \wlog{</languages>}%
- \endgroup}{}
- \endgroup
- \def\bbl@elt#1#2#3#4{%
- \ifnum#2=\z@
- \gdef\bbl@nulllanguage{#1}%
- \def\bbl@elt##1##2##3##4{}%
- \fi}%
- \bbl@languages
-\fi
-% \end{macrocode}
%
% \subsection{Language options}
%
@@ -3165,6 +3219,8 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.9k}{2014/03/24}{Added definition for
% \cs{uselanguage}}
% \changes{babel~3.9n}{2015/12/21}{Define a few macros for 2.09}
+% \changes{babel~3.9p}{2016/02/05}{Added a test for lua(e)tex.}
+% \changes{babel~3.9q}{2016/02/12}{Load lua patterns if not lualatex.}
%
% \begin{macrocode}
%<*core>
@@ -3180,24 +3236,27 @@ help from Bernd Raichle, for which I am grateful.
\fi
<@Load switch if newer@>
\ifx\bbl@languages\@undefined
- \openin1 = language.def
- \ifeof1
- \closein1
- \message{I couldn't find the file language.def}
- \else
- \closein1
- \begingroup
- \def\addlanguage#1#2#3#4#5{%
- \expandafter\ifx\csname lang@#1\endcsname\relax\else
- \global\expandafter\let\csname l@#1\expandafter\endcsname
- \csname lang@#1\endcsname
- \fi}%
- \def\uselanguage#1{}%
- \input language.def
- \endgroup
+ \ifx\directlua\@undefined
+ \openin1 = language.def
+ \ifeof1
+ \closein1
+ \message{I couldn't find the file language.def}
+ \else
+ \closein1
+ \begingroup
+ \def\addlanguage#1#2#3#4#5{%
+ \expandafter\ifx\csname lang@#1\endcsname\relax\else
+ \global\expandafter\let\csname l@#1\expandafter\endcsname
+ \csname lang@#1\endcsname
+ \fi}%
+ \def\uselanguage#1{}%
+ \input language.def
+ \endgroup
+ \fi
\fi
\chardef\l@english\z@
\fi
+<@Load patterns in luatex@>
<@Basic macros@>
\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
\chardef\bbl@engine=%
@@ -6625,11 +6684,17 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.6u}{1999/04/20}{Moved this code to
% \file{babel.def}}
% \changes{babel~3.9l}{2014/08/02}{fontspec used to set
-% \cs{latinencoding} to EUx, but now it doesn't. So, it's done here.}
+% \cs{latinencoding} to EUx, but now it doesn't. So, it's done
+% here.}
+% \changes{babel~3.9o}{2016/01/27}{With fontspec, first check if
+% \cs{UTFencname} exists.}
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{fontspec}%
- {\xdef\latinencoding{EU\ifcase\bbl@engine\or2\or1\fi}}%
+ {\xdef\latinencoding{%
+ \@ifundefined{UTFencname}%
+ {EU\ifcase\bbl@engine\or2\or1\fi}%
+ {\UTFencname}}}%
{\gdef\latinencoding{OT1}%
\ifx\cf@encoding\bbl@t@one
\xdef\latinencoding{\bbl@t@one}%
@@ -8270,11 +8335,14 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.9g}{2013/07/28}{In non-LaTeX formats the number of
% languages were not printed. Moved from \cs{dump} and cleaned up:
% now \cs{toks}8 is expanded here.}
+% \changes{babel~3.9o}{2016/01/25}{The number of languages loaded was
+% off by 1.}
% \begin{macrocode}
\if/\the\toks@/\else
\errhelp{language.dat loads no language, only synonyms}
\errmessage{Orphan language synonym}
\fi
+\advance\last@language\@ne
\edef\bbl@tempa{%
\everyjob{%
\the\everyjob
@@ -8283,7 +8351,8 @@ help from Bernd Raichle, for which I am grateful.
\else
\noexpand\typeout
\fi
- {\the\toks8 \the\last@language\space languages loaded.}}}
+ {\the\toks8 \the\last@language\space language(s) loaded.}}}
+\advance\last@language\m@ne
\bbl@tempa
% \end{macrocode}
% Also remove some macros from memory and raise an error
@@ -8759,7 +8828,7 @@ help from Bernd Raichle, for which I am grateful.
\fi
\def\@testopt#1#2{%
\@ifnextchar[{#1}{#1[#2]}}
-\def\@protected@testopt#1{%%
+\def\@protected@testopt#1{%
\ifx\protect\@typeset@protect
\expandafter\@testopt
\else