texlive[55143] Master/texmf-dist: babel (13may20)

commits+karl at tug.org commits+karl at tug.org
Thu May 14 23:24:22 CEST 2020


Revision: 55143
          http://tug.org/svn/texlive?view=revision&revision=55143
Author:   karl
Date:     2020-05-14 23:24:22 +0200 (Thu, 14 May 2020)
Log Message:
-----------
babel (13may20)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/babel/README.md
    trunk/Master/texmf-dist/doc/latex/babel/babel.pdf
    trunk/Master/texmf-dist/source/latex/babel/babel.dtx
    trunk/Master/texmf-dist/source/latex/babel/babel.ins
    trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx
    trunk/Master/texmf-dist/source/latex/babel/locale.zip
    trunk/Master/texmf-dist/tex/generic/babel/babel.def
    trunk/Master/texmf-dist/tex/generic/babel/babel.sty
    trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg
    trunk/Master/texmf-dist/tex/generic/babel/locale/af/babel-af.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/am/babel-am.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/as/babel-as.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/be/babel-be.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/bn/babel-bn.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu-Cyrs.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el-polyton.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-BE.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CA.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CH.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-LU.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/fur/babel-fur.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/grc/babel-grc.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/gu/babel-gu.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/hi/babel-hi.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/hy/babel-hy.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/it/babel-it.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/kn/babel-kn.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/ml/babel-ml.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/mr/babel-mr.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/oc/babel-oc.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/or/babel-or.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa-Guru.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/pms/babel-pms.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-BR.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-PT.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/rm/babel-rm.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/ru/babel-ru.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Beng.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Deva.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Gujr.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/ta/babel-ta.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/te/babel-te.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/tk/babel-tk.ini
    trunk/Master/texmf-dist/tex/generic/babel/locale/uk/babel-uk.ini
    trunk/Master/texmf-dist/tex/generic/babel/luababel.def
    trunk/Master/texmf-dist/tex/generic/babel/nil.ldf
    trunk/Master/texmf-dist/tex/generic/babel/txtbabel.def

Modified: trunk/Master/texmf-dist/doc/latex/babel/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/babel/README.md	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/doc/latex/babel/README.md	2020-05-14 21:24:22 UTC (rev 55143)
@@ -1,4 +1,4 @@
-## Babel 3.43
+## Babel 3.44
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages.  Many
@@ -7,9 +7,9 @@
 
 The latest stable version is available on <https://ctan.org/pkg/babel>.
 
-Changes in version 3.43 are described in:
+Changes in version 3.44 are described in:
 
-https://github.com/latex3/babel/wiki/What's-new-in-babel-3.43
+https://github.com/latex3/babel/wiki/What's-new-in-babel-3.44
 
 Included is a set of ini files for about 200 languages.
 
@@ -44,6 +44,23 @@
 ### Latest changes
 
 ```
+3.44   2020-05-13
+       - WARNING. If you need the Portuguese style you must update
+         babel-portuges.
+       - \localedate, to print date with the current locale.
+       - [|] syntax in dates, to represent a value with any counter
+         defined in the ini files.
+       - Amharic: line breaking (modern and traditional), counters.
+       - Improvements in French, Portuguese.
+       - Optional argument in \foreignlanguage and otherlanguage*,
+         to switch date and/or captions.
+       - Preliminary code for \babelprehyphenation.
+       - Fixes:
+         - \babelcharproperty{..}{linebreak]{..} raised an error.
+         - \babelposthyphenation raised an error if the last char in
+           the pattern was ].       
+         - \babelposthyphenation is now deativated in math.
+       
 3.43   2020-04-28
        - Autoloading based on the BCP47 codes, with basic lookup.
        - Now only a few essential commands are loaded in the format.
@@ -55,6 +72,7 @@
          - \guillemotleft and \guillemotleft renamed to \guillemetleft
            and \guillemetleft (#63).
          - A couple of bugs related to autoloading.
+https://github.com/latex3/babel/wiki/What's-new-in-babel-3.44
        
 3.42   2020-03-22
        - \getlocaleproperty, to get the value of a field from the loaded

Modified: trunk/Master/texmf-dist/doc/latex/babel/babel.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/babel/babel.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/babel.dtx	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.dtx	2020-05-14 21:24:22 UTC (rev 55143)
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2020/04/28 v3.43 The Babel package]
+\ProvidesFile{babel.dtx}[2020/05/13 v3.44 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -390,6 +390,15 @@
   it.
 \end{troubleshooting}
 
+\begin{note}
+  With \textsf{hyperref} you may want to set the document language with
+  something like:
+\begin{verbatim}
+\usepackage[_pdflang=es-MX_]{hyperref}
+\end{verbatim}
+This is not currently done by \babel{} and you must set it by hand.
+\end{note}
+
 \subsection{Multilingual documents}
 
 In multilingual documents, just use a list of the required languages as
@@ -640,19 +649,32 @@
   code with an additional grouping level.
 \end{warning}
 
-\Describe{\foreignlanguage}{\marg{language}\marg{text}}
-The command |\foreignlanguage| takes two arguments; the second
-argument is a phrase to be typeset according to the rules of the
-language named in its first one. This command (1) only switches the
-extra definitions and the hyphenation rules for the language,
-\emph{not} the names and dates, (2) does not send information about
-the language to auxiliary files (i.e., the surrounding language is
-still in force), and (3) it works even if the language has not been
-set as package option (but in such a case it only sets the hyphenation
-patterns and a warning is shown). With the |bidi| option, it also 
-enters in horizontal mode (this is not done always for backwards 
-compatibility).
+\Describe{\foreignlanguage}{\oarg{option-list}\marg{language}\marg{text}}
 
+The command |\foreignlanguage| takes two arguments; the second argument
+is a phrase to be typeset according to the rules of the language named
+in its first one.
+
+This command (1) only switches the extra definitions and the
+hyphenation rules for the language, \emph{not} the names and dates, (2)
+does not send information about the language to auxiliary files (i.e.,
+the surrounding language is still in force), and (3) it works even if
+the language has not been set as package option (but in such a case it
+only sets the hyphenation patterns and a warning is shown). With the
+|bidi| option, it also enters in horizontal mode (this is not done
+always for backwards compatibility).
+
+\New{3.44} As already said, captions and dates are not switched.
+However, with the optional argument you can switch them, too. So, you
+can write:
+\begin{verbatim}
+\foreignlanguage[date]{polish}{\today}
+\end{verbatim}
+In addition, captions can be switched with |captions| (or both, of
+course, with |date, captions|). Until 3.43 you had to write something
+like |{\selectlanguage{..} ..}|, which was not always the most
+convenient way.
+
 \subsection{Auxiliary language selectors}
 
 \Describe{\begin\menv{otherlanguage}}{\marg{language}\Eenv{otherlanguage}}
@@ -676,7 +698,7 @@
 Spaces after the environment are ignored.
 
 \Describe{\begin\menv{otherlanguage*}}%
-{\marg{language}\Eenv{otherlanguage*}}
+{\oarg{option-list}\marg{language}\Eenv{otherlanguage*}}
 
 Same as |\foreignlanguage| but as environment. Spaces after the
 environment are \textit{not} ignored.
@@ -955,7 +977,7 @@
   than |\shorthandoff|, for example if you want to define a macro
   to easy typing phonetic characters with \textsf{tipa}:
 \begin{verbatim}
-\newcommand{\myipa}[1]{{\languageshorthands{none}\tipaencoding#1}}
+\newcommand{\myipa}[1]{{_\languageshorthands{none}_\tipaencoding#1}}
 \end{verbatim}
 \end{example}
 
@@ -973,7 +995,7 @@
   |\begin{document}|, you may use this macro when defining the |\title|
   in the preamble:
 \begin{verbatim}
-\title{Documento científico\babelshorthand{"-}técnico}
+\title{Documento científico_\babelshorthand{"-}_técnico}
 \end{verbatim}
 \end{example}
 
@@ -1070,7 +1092,7 @@
 The only language shorthands activated
 are those given, like, eg:
 \begin{verbatim}
-\usepackage[esperanto,french,shorthands=:;!?]{babel}
+\usepackage[esperanto,french,_shorthands=:;!?_]{babel}
 \end{verbatim}
 If \verb|'| is included, \texttt{activeacute} is set; if \verb|`| is
 included, \texttt{activegrave} is set.  Active characters (like
@@ -1265,7 +1287,7 @@
 \documentclass{book}
 
 \usepackage{babel}
-\babelprovide[import, main]{georgian}
+_\babelprovide[import, main]{georgian}_
 
 \babelfont{rm}{DejaVu Sans}
 
@@ -1411,6 +1433,7 @@
 \tag{ebu} Embu
 \tag{ee} Ewe
 \tag{el} Greek\hascapu\hascapl
+\tag{el-polyton} Polytonic Greek\hascapu\hascapl
 \tag{en-AU} English\hascapu\hascapl
 \tag{en-CA} English\hascapu\hascapl
 \tag{en-GB} English\hascapu\hascapl
@@ -1438,6 +1461,7 @@
 \tag{ga} Irish\hascapu\hascapl
 \tag{gd} Scottish Gaelic\hascapu\hascapl
 \tag{gl} Galician\hascapu\hascapl
+\tag{grc} Ancient Greek\hascapu\hascapl
 \tag{gsw} Swiss German
 \tag{gu} Gujarati
 \tag{guz} Gusii
@@ -1639,6 +1663,7 @@
 albanian\\
 american\\
 amharic\\
+ancientgreek\\
 arabic\\
 arabic-algeria\\
 arabic-DZ\\
@@ -1848,6 +1873,7 @@
 persian\\
 piedmontese\\
 polish\\
+polytonicgreek\\
 portuguese-br\\
 portuguese-brazil\\
 portuguese-portugal\\
@@ -2198,6 +2224,13 @@
 \end{verbatim}
 There is a counterpart for code to be run when a language is
 unselected: |\noextras|\m{lang}.
+\item With data |import|’ed from |ini| files, you can modify the values
+of specific keys, like:
+\begin{verbatim}
+\babelprovide[import, _captions/listtable = Lista de tablas_]{spanish}
+\end{verbatim}
+(In this particular case, instead of the |captions| group you may need
+to modify the |captions.licr| one.)
 \end{itemize}
 
 \begin{note} Do \textit{not} redefine a caption in the following way:
@@ -2315,7 +2348,9 @@
 Besides |\today|, this option defines an additional command for dates:
 |\<language>date|, which takes three arguments, namely, year, month and
 day numbers. In fact, |\today| calls |\<language>today|, which in turn
-calls |\<language>date{\the\year}{\the\month}{\the\day}|.
+calls |\<language>date{\the\year}{\the\month}{\the\day}|. \New{3.44}
+More convenient is usually |\localedate|, with prints the date for the
+current locale.
 
 \Describe{captions=}{\meta{language-tag}}
 Loads only the strings. For example:
@@ -2610,13 +2645,29 @@
 conditions are not met, write |\BabelEnsureInfo| in the preamble.
 \end{note}
 
+\Describe{\localeid}{}
+
+Each language in the \babel{} sense has its own unique numeric
+identifier, which can be retrieved with |\localeid|.
+
+\begin{note}
+  The |\localeid| is not the same as the |\language| identifier, which
+  refers to a set of hyphenation patters (which, in turn, is just a
+  component of the line breaking algorithm described in the next
+  section). The data about preloaded patterns are store in an internal
+  macro named |\bbl at languages| (see the code for further details), but
+  note several locales may share a single |\language|, so they are
+  separated concepts. In \luatex, the |\localeid| is saved in each node
+  (where it makes sense) as an attribute, too.
+\end{note}
+
 \subsection{Hyphenation and line breaking}
 
 \Babel{} deals with three kinds of line breaking rules: Western,
 typically the LGC group, South East Asian, like Thai, and CJK, but
 support depends on the engine: \textsf{pdftex} only deals with the
-former, \xetex{} also with the second one, while \luatex{} provides
-basic rules for the latter, too.
+former, \xetex{} also with the second one (although in a limited way),
+while \luatex{} provides basic rules for the latter, too.
 
 \Describe{\babelhyphen}{%
   \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{type}}
@@ -2743,7 +2794,7 @@
 \Describe{\babelposthyphenation}{\marg{hyphenrules-name}%
           \marg{lua-pattern}\marg{replacement}}
 
-\New{3.37-3.39} With \luatex{} it is now possible to define
+\New{3.37-3.39} \textit{With \luatex{}} it is now possible to define
 non-standard hyphenation rules, like |f-f| $\to$ |ff-f|, repeated
 hyphens, ranked ruled (or more precisely, ‘penalized’ hyphenation
 points), and so on. No rules are currently provided by default, but
@@ -2793,7 +2844,7 @@
 
 \New{3.43} The recommended way to select languages is that described at
 the beginning of this document. However, BCP 47 tags are becoming
-customary, particularly in document (or parts of documents) generated
+customary, particularly in documents (or parts of documents) generated
 by external sources, and therefore \babel{} will provide a set of tools
 to select the locales in different situations, adapted to the
 particular needs of each case. Currently, \babel{} provides autoloading
@@ -2844,7 +2895,7 @@
 \item \texttt{autoload.bcp47.options}, which are passed to
   |\babelprovide|; empty by default, but you may add \texttt{import}
   (features defined in the corresponding |babel-...tex| file might not
-  available).
+  be available).
 \item \texttt{autoload.bcp47.prefix}. Although the public name used in
   selectors is the tag, the internal name will be different and
   generated by prepending a prefix, which by default is
@@ -3371,19 +3422,19 @@
 \item[Greek] greek, polutonikogreek
 \item[Hebrew] hebrew
 \item[Icelandic] icelandic
-\item[Indonesian] indonesian, bahasa, indon, bahasai
+\item[Indonesian] indonesian (bahasa, indon, bahasai)
 \item[Interlingua] interlingua
 \item[Irish Gaelic] irish
 \item[Italian] italian
 \item[Latin] latin
 \item[Lower Sorbian] lowersorbian
-\item[Malay] malay, melayu, bahasam
+\item[Malay] malay, melayu (bahasam)
 \item[North Sami] samin
 \item[Norwegian] norsk, nynorsk
 \item[Polish] polish
-\item[Portuguese] portuguese, portuges\footnote{This name comes from
-  the times when they had to be shortened to 8 characters}, brazilian,
-  brazil
+\item[Portuguese] portuguese, brazilian (portuges, brazil)\footnote{The
+two last name comes from the times when they had to be shortened to 8
+characters}
 \item[Romanian] romanian
 \item[Russian] russian
 \item[Scottish Gaelic] scottish
@@ -3588,29 +3639,28 @@
 See the code section for |\foreignlanguage*| (a new starred
 version of |\foreignlanguage|).
 
+For old an deprecated functions, see the wiki.
+
 \medskip
-\textbf{Old and deprecated stuff}
+\textbf{\string\babelprehyphenation}
 
-A couple of tentative macros were provided by \babel{} ($\ge$3.9g) with
-a partial solution for ``Unicode'' fonts. These macros are now
-deprecated --- use |\babelfont|. A short description follows, for
-reference:
-\begin{itemize}
-\item |\babelFSstore|\marg{babel-language} sets the current three
-  basic families (rm, sf, tt) as the default for the language
-  given.
-\item |\babelFSdefault|\marg{babel-language}\marg{fontspec-features}
-  patches |\fontspec| so that the given features are always passed as
-  the optional argument or added to it (not an ideal solution).
-\end{itemize}
-So, for example:
-\begin{verbatim}
-\setmainfont[Language=Turkish]{Minion Pro}
-\babelFSstore{turkish}
-\setmainfont{Minion Pro}
-\babelFSfeatures{turkish}{Language=Turkish}
-\end{verbatim}
+\New{3.44} Note it is tentative, but the current behavior for glyphs
+should be correct.
 
+It is similar to |\babelposthyphenation|, but (as its name implies)
+applied before hyphenation. There are other differences: (1) the first
+argument is the locale instead the name of hyphenation patterns; (2) in
+the search patterns |=| has no special meaning (\verb+|+ is still
+reserved, but currently unused); (3) in the replacement,
+discretionaries are not accepted, only remove, {}, and string = ...
+
+Currently it handles glyphs, not discretionaries or spaces (in
+particular, it will not catch the hyphen and you can't insert or remove
+spaces). Also, you are limited to substitutions as done by lua,
+although a future implementation may alternatively accept lpeg.
+
+Performance is still somewhat poor.
+
 \section{Loading languages with \file{language.dat}}
 
 \TeX{} and most engines based on it (pdf\TeX, \xetex, $\epsilon$-\TeX,
@@ -4458,24 +4508,24 @@
 %
 % \section{Identification and loading of required files}
 %
-%    \textit{Code documentation is still under revision.}
+% \textit{Code documentation is still under revision.}
 %
-%  \textbf{The following description is no longer valid, because switch
-%  and plain have been merged into babel.def.}
+% \textbf{The following description is no longer valid, because switch
+% and plain have been merged into babel.def.}
 %
-%    The \babel{} package after unpacking consists of the following files:
-%    \begin{description}
-%    \itemsep=-\parskip
-%    \item[switch.def] defines macros to set and switch languages.
-%    \item[babel.def] defines the rest of macros. It has tow parts: a
-%    generic one and a second one only for LaTeX{}.
-%    \item[babel.sty] is the \LaTeX{} package, which set options and
-%    load language styles.
-%  \item[plain.def] defines some \LaTeX{} macros required by
-%    \file{babel.def} and provides a few tools for Plain.
-%   \item[hyphen.cfg] is the file to be used when generating the
-%    formats to load hyphenation patterns.
-%    \end{description}
+% The \babel{} package after unpacking consists of the following files:
+% \begin{description}
+% \itemsep=-\parskip
+% \item[switch.def] defines macros to set and switch languages.
+% \item[babel.def] defines the rest of macros. It has tow parts: a
+%   generic one and a second one only for LaTeX{}.
+% \item[babel.sty] is the \LaTeX{} package, which set options and
+%   load language styles.
+% \item[plain.def] defines some \LaTeX{} macros required by
+%   \file{babel.def} and provides a few tools for Plain.
+% \item[hyphen.cfg] is the file to be used when generating the
+%   formats to load hyphenation patterns.
+% \end{description}
 %
 % The \babel{} installer extends \textsf{docstrip} with a few
 % ``pseudo-guards'' to set ``variables'' used at installation time.
@@ -4522,16 +4572,17 @@
 %
 % Keys may be further qualified in a particular language with a suffix
 % starting with a uppercase letter. It can be just a letter (eg,
-% babel.name.A, babel.name.B) or a name (eg, date.long.Nominative,
-% date.long.Formal, but no language is currently using the latter).
-% Multi-letter qualifiers are forward compatible in the sense they
-% won’t conflict with new ``global'' keys (all lowercase).
+% |babel.name.A|, |babel.name.B|) or a name (eg,
+% |date.long.Nominative|, |date.long.Formal|, but no language is
+% currently using the latter). \textit{Multi-letter} qualifiers are
+% forward compatible in the sense they won’t conflict with new
+% ``global'' keys (which start always with a lowercase case).
 %
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.43>>
-%<<date=2020/04/28>>
+%<<version=3.44>>
+%<<date=2020/05/13>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -4539,13 +4590,13 @@
 % added for replacing, trimming and looping. The older ones, like
 % |\bbl at afterfi|, will not change.
 %
-%    We define some basic macros which just make the code cleaner.
-%    |\bbl at add| is now used internally instead of |\addto| because of
-%    the unpredictable behavior of the latter. Used in
-%    \file{babel.def} and in \file{babel.sty}, which means in \LaTeX{}
-%    is executed twice, but we need them when defining options and
-%    \file{babel.def} cannot be load until options have been defined.
-%    This does not hurt, but should be fixed somehow.
+% We define some basic macros which just make the code cleaner.
+% |\bbl at add| is now used internally instead of |\addto| because of
+% the unpredictable behavior of the latter. Used in
+% \file{babel.def} and in \file{babel.sty}, which means in \LaTeX{}
+% is executed twice, but we need them when defining options and
+% \file{babel.def} cannot be load until options have been defined.
+% This does not hurt, but should be fixed somehow.
 %
 %    \begin{macrocode}
 %<<*Basic macros>>
@@ -4832,14 +4883,15 @@
 %
 % \subsection{Multiple languages}
 %
-%  \begin{macro}{\language}
-%    Plain \TeX\ version~3.0 provides the primitive |\language| that
-%    is used to store the current language. When used with a pre-3.0
-%    version this function has to be implemented by allocating a
-%    counter. The following block is used in \file{switch.def} and
-%    \file{hyphen.cfg}; the latter may seem redundant, but remember
-%    \babel{} doesn't requires loading \file{switch.def} in the format.
+% \begin{macro}{\language}
 %
+% Plain \TeX\ version~3.0 provides the primitive |\language| that
+% is used to store the current language. When used with a pre-3.0
+% version this function has to be implemented by allocating a
+% counter. The following block is used in \file{switch.def} and
+% \file{hyphen.cfg}; the latter may seem redundant, but remember
+% \babel{} doesn't requires loading \file{switch.def} in the format.
+%
 %    \begin{macrocode}
 %<<*Define core switching macros>>
 \ifx\language\@undefined
@@ -4848,29 +4900,30 @@
 %<</Define core switching macros>>
 %    \end{macrocode}
 %
-%  \end{macro}
+% \end{macro}
 %
-%  \begin{macro}{\last at language}
-%    Another counter is used to store the last language defined.  For
-%    pre-3.0 formats an extra counter has to be allocated.
+% \begin{macro}{\last at language}
 %
-%  \begin{macro}{\addlanguage}
+% Another counter is used to store the last language defined.  For
+% pre-3.0 formats an extra counter has to be allocated.
 %
-%    To add languages to \TeX's memory plain \TeX\ version~3.0
-%    supplies |\newlanguage|, in a pre-3.0 environment a similar macro
-%    has to be provided. For both cases a new macro is defined here,
-%    because the original |\newlanguage| was defined to be |\outer|.
+% \begin{macro}{\addlanguage}
 %
-%    For a format based on plain version~2.x, the definition of
-%    |\newlanguage| can not be copied because |\count 19| is used for
-%    other purposes in these formats. Therefore |\addlanguage| is
-%    defined using a definition based on the macros used to define
-%    |\newlanguage| in plain \TeX\ version~3.0.
+% To add languages to \TeX's memory plain \TeX\ version~3.0
+% supplies |\newlanguage|, in a pre-3.0 environment a similar macro
+% has to be provided. For both cases a new macro is defined here,
+% because the original |\newlanguage| was defined to be |\outer|.
 %
-%    For formats based on plain version~3.0 the definition of
-%    |\newlanguage| can be simply copied, removing |\outer|.
-%    Plain \TeX\ version 3.0 uses |\count 19| for this purpose.
+% For a format based on plain version~2.x, the definition of
+% |\newlanguage| can not be copied because |\count 19| is used for
+% other purposes in these formats. Therefore |\addlanguage| is
+% defined using a definition based on the macros used to define
+% |\newlanguage| in plain \TeX\ version~3.0.
 %
+% For formats based on plain version~3.0 the definition of
+% |\newlanguage| can be simply copied, removing |\outer|.
+% Plain \TeX\ version 3.0 uses |\count 19| for this purpose.
+%
 %    \begin{macrocode}
 %<<*Define core switching macros>>
 \ifx\newlanguage\@undefined
@@ -5054,68 +5107,6 @@
   \endinput}{}%
 % \end{macrocode}
 %
-% TODO. Code for lua bidi options must be moved to a logical place. The
-% problem is |\RequirePackage|, which is forbidden allowed in the options
-% section.
-%
-% \begin{macrocode}
-\ifodd\bbl at engine
-  \def\bbl at activate@preotf{%
-    \let\bbl at activate@preotf\relax  % only once
-    \directlua{
-      Babel = Babel or {}
-      %
-      function Babel.pre_otfload_v(head)
-        if Babel.numbers and Babel.digits_mapped then
-          head = Babel.numbers(head)
-        end
-        if Babel.bidi_enabled then
-          head = Babel.bidi(head, false, dir)
-        end
-        return head
-      end
-      %
-      function Babel.pre_otfload_h(head, gc, sz, pt, dir)
-        if Babel.numbers and Babel.digits_mapped then
-          head = Babel.numbers(head)
-        end
-        if Babel.bidi_enabled then
-          head = Babel.bidi(head, false, dir)
-        end
-        return head
-      end
-      %
-      luatexbase.add_to_callback('pre_linebreak_filter',
-        Babel.pre_otfload_v,
-        'Babel.pre_otfload_v',
-        luatexbase.priority_in_callback('pre_linebreak_filter',
-          'luaotfload.node_processor') or nil)
-      %
-      luatexbase.add_to_callback('hpack_filter',
-        Babel.pre_otfload_h,
-        'Babel.pre_otfload_h',
-        luatexbase.priority_in_callback('hpack_filter',
-          'luaotfload.node_processor') or nil)
-    }}
-  \let\bbl at tempa\relax
-  \@ifpackagewith{babel}{bidi=basic}%
-    {\def\bbl at tempa{basic}}%
-    {\@ifpackagewith{babel}{bidi=basic-r}%
-      {\def\bbl at tempa{basic-r}}%
-      {}}
-  \ifx\bbl at tempa\relax\else
-    \let\bbl at beforeforeign\leavevmode
-    \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
-    \RequirePackage{luatexbase}%
-    \directlua{
-      require('babel-data-bidi.lua')
-      require('babel-bidi-\bbl at tempa.lua')
-    }
-    \bbl at activate@preotf
-  \fi
-\fi
-%    \end{macrocode}
-%
 % \subsection{\texttt{key=value} options and other general option}
 %
 %    The following macros extract language modifiers, and only real
@@ -5217,7 +5208,7 @@
   \fi}
 %    \end{macrocode}
 %
-%    Now we finish the first pass (and start over).
+% Now we finish the first pass (and start over).
 %
 %    \begin{macrocode}
 \ProcessOptions*
@@ -5225,14 +5216,14 @@
 %
 % \subsection{Conditional loading of shorthands}
 %
-%    If there is no |shorthands=<chars>|, the original \textsf{babel}
-%    macros are left untouched, but if there is, these macros are
-%    wrapped (in |babel.def|) to define only those given.
+% If there is no |shorthands=<chars>|, the original \textsf{babel}
+% macros are left untouched, but if there is, these macros are
+% wrapped (in |babel.def|) to define only those given.
 %
-%    A bit of optimization: if there is no |shorthands=|, then
-%    |\bbl at ifshorthand| is always true, and it is always false if
-%    |shorthands| is empty. Also, some code makes sense only with
-%    |shorthands=...|.
+% A bit of optimization: if there is no |shorthands=|, then
+% |\bbl at ifshorthand| is always true, and it is always false if
+% |shorthands| is empty. Also, some code makes sense only with
+% |shorthands=...|.
 %
 %    \begin{macrocode}
 \bbl at trace{Conditional loading of shorthands}
@@ -5264,8 +5255,8 @@
     \fi}
 %    \end{macrocode}
 %
-%    We make sure all chars in the string are `other', with the help
-%    of an auxiliary macro defined above (which also zaps spaces).
+% We make sure all chars in the string are `other', with the help
+% of an auxiliary macro defined above (which also zaps spaces).
 %
 %    \begin{macrocode}
   \edef\bbl at opt@shorthands{%
@@ -5272,8 +5263,8 @@
     \expandafter\bbl at sh@string\bbl at opt@shorthands\@empty}%
 %    \end{macrocode}
 %
-%    The following is ignored with |shorthands=off|, since it is
-%    intended to take some aditional actions for certain chars.
+% The following is ignored with |shorthands=off|, since it is
+% intended to take some aditional actions for certain chars.
 %
 %    \begin{macrocode}
   \bbl at ifshorthand{'}%
@@ -5283,9 +5274,9 @@
 \fi\fi
 %    \end{macrocode}
 %
-%    With |headfoot=lang| we can set the language used in heads/foots.
-%    For example, in babel/3796 just adds |headfoot=english|.  It
-%    misuses \cs{@resetactivechars} but seems to work.
+% With |headfoot=lang| we can set the language used in heads/foots.
+% For example, in babel/3796 just adds |headfoot=english|.  It
+% misuses \cs{@resetactivechars} but seems to work.
 %
 %    \begin{macrocode}
 \ifx\bbl at opt@headfoot\@nnil\else
@@ -5339,23 +5330,23 @@
 %
 % \subsection{Cross referencing macros}
 %
-%    The \LaTeX\ book states:
-%  \begin{quote}
-%    The \emph{key} argument is any sequence of letters, digits, and
-%    punctuation symbols; upper- and lowercase letters are regarded as
-%    different.
-%  \end{quote}
-%    When the above quote should still be true when a document is
-%    typeset in a language that has active characters, special care
-%    has to be taken of the category codes of these characters when
-%    they appear in an argument of the cross referencing macros.
+% The \LaTeX\ book states:
+% \begin{quote}
+%   The \emph{key} argument is any sequence of letters, digits, and
+%   punctuation symbols; upper- and lowercase letters are regarded as
+%   different.
+% \end{quote}
+% When the above quote should still be true when a document is
+% typeset in a language that has active characters, special care
+% has to be taken of the category codes of these characters when
+% they appear in an argument of the cross referencing macros.
 %
-%    When a cross referencing command processes its argument, all
-%    tokens in this argument should be character tokens with category
-%    `letter' or `other'.
+% When a cross referencing command processes its argument, all
+% tokens in this argument should be character tokens with category
+% `letter' or `other'.
 %
-%    The following package options control which macros are to be
-%    redefined.
+% The following package options control which macros are to be
+% redefined.
 %
 %    \begin{macrocode}
 %<<*More package options>>
@@ -5365,12 +5356,12 @@
 %<</More package options>>
 %    \end{macrocode}
 %
-%  \begin{macro}{\@newl at bel}
+% \begin{macro}{\@newl at bel}
 %
-%    First we open a new group to keep the changed setting of
-%    |\protect| local and then we set the |@safe at actives| switch to
-%    true to make sure that any shorthand that appears in any of the
-%    arguments immediately expands to its non-active self.
+% First we open a new group to keep the changed setting of
+% |\protect| local and then we set the |@safe at actives| switch to
+% true to make sure that any shorthand that appears in any of the
+% arguments immediately expands to its non-active self.
 %
 %    \begin{macrocode}
 \bbl at trace{Cross referencing macros}
@@ -5389,9 +5380,9 @@
 %
 %  \begin{macro}{\@testdef}
 %
-%    An internal \LaTeX\ macro used to test if the labels that have
-%    been written on the |.aux| file have changed.  It is called by
-%    the |\enddocument| macro.
+% An internal \LaTeX\ macro used to test if the labels that have
+% been written on the |.aux| file have changed.  It is called by
+% the |\enddocument| macro.
 %
 %    \begin{macrocode}
   \CheckCommand*\@testdef[3]{%
@@ -5402,13 +5393,13 @@
     \fi}
 %    \end{macrocode}
 %
-%  Now that we made sure that |\@testdef| still has the same definition
-%  we can rewrite it. First we make the shorthands `safe'. Then we use
-%  |\bbl at tempa| as an `alias' for the macro that contains the label
-%  which is being checked. Then we define |\bbl at tempb| just as
-%  |\@newl at bel| does it. When the label is defined we replace the
-%  definition of |\bbl at tempa| by its meaning. If the label didn't
-%  change, |\bbl at tempa| and |\bbl at tempb| should be identical macros.
+% Now that we made sure that |\@testdef| still has the same definition
+% we can rewrite it. First we make the shorthands `safe'. Then we use
+% |\bbl at tempa| as an `alias' for the macro that contains the label
+% which is being checked. Then we define |\bbl at tempb| just as
+% |\@newl at bel| does it. When the label is defined we replace the
+% definition of |\bbl at tempa| by its meaning. If the label didn't
+% change, |\bbl at tempa| and |\bbl at tempb| should be identical macros.
 %
 %    \begin{macrocode}
   \def\@testdef#1#2#3{%  TODO. With @samestring?
@@ -5430,13 +5421,13 @@
 %
 %  \end{macro}
 %
-%  \begin{macro}{\ref}
-%  \begin{macro}{\pageref}
+% \begin{macro}{\ref}
+% \begin{macro}{\pageref}
 %
-%    The same holds for the macro |\ref| that references a label and
-%    |\pageref| to reference a page. We make them robust as well (if
-%    they weren't already) to prevent problems if they should become
-%    expanded at the wrong moment.
+% The same holds for the macro |\ref| that references a label and
+% |\pageref| to reference a page. We make them robust as well (if
+% they weren't already) to prevent problems if they should become
+% expanded at the wrong moment.
 %
 %    \begin{macrocode}
 \bbl at xin@{R}\bbl at opt@safe
@@ -5454,14 +5445,15 @@
 %  \end{macro}
 %  \end{macro}
 %
-%  \begin{macro}{\@citex}
-%    The macro used to cite from a bibliography, |\cite|, uses an
-%    internal macro, |\@citex|.
-%    It is this internal macro that picks up the argument(s),
-%    so we redefine this internal macro and leave |\cite| alone. The
-%    first argument is used for typesetting, so the shorthands need
-%    only be deactivated in the second argument.
+% \begin{macro}{\@citex}
 %
+% The macro used to cite from a bibliography, |\cite|, uses an
+% internal macro, |\@citex|.
+% It is this internal macro that picks up the argument(s),
+% so we redefine this internal macro and leave |\cite| alone. The
+% first argument is used for typesetting, so the shorthands need
+% only be deactivated in the second argument.
+%
 %    \begin{macrocode}
 \bbl at xin@{B}\bbl at opt@safe
 \ifin@
@@ -5470,12 +5462,12 @@
     \org@@citex[#1]{\@tempa}}
 %    \end{macrocode}
 %
-%    Unfortunately, the packages \pkg{natbib} and \pkg{cite} need a
-%    different definition of |\@citex|...
-%    To begin with, \pkg{natbib} has a definition for |\@citex| with
-%    \emph{three} arguments... We only know that a package is loaded
-%    when |\begin{document}| is executed, so we need to postpone the
-%    different redefinition.
+% Unfortunately, the packages \pkg{natbib} and \pkg{cite} need a
+% different definition of |\@citex|...
+% To begin with, \pkg{natbib} has a definition for |\@citex| with
+% \emph{three} arguments... We only know that a package is loaded
+% when |\begin{document}| is executed, so we need to postpone the
+% different redefinition.
 %
 %    \begin{macrocode}
   \AtBeginDocument{%
@@ -5482,13 +5474,13 @@
     \@ifpackageloaded{natbib}{%
 %    \end{macrocode}
 %
-%    Notice that we use |\def| here instead of |\bbl at redefine| because
-%    |\org@@citex| is already defined and we don't want to overwrite
-%    that definition (it would result in parameter stack overflow
-%    because of a circular definition).
+% Notice that we use |\def| here instead of |\bbl at redefine| because
+% |\org@@citex| is already defined and we don't want to overwrite
+% that definition (it would result in parameter stack overflow
+% because of a circular definition).
 %
-%   (Recent versions of \pkg{natbib} change dynamically |\@citex|, so PR4087
-%    doesn't seem fixable in a simple way. Just load \pkg{natbib} before.)
+% (Recent versions of \pkg{natbib} change dynamically |\@citex|, so PR4087
+% doesn't seem fixable in a simple way. Just load \pkg{natbib} before.)
 %
 %    \begin{macrocode}
     \def\@citex[#1][#2]#3{%
@@ -5497,8 +5489,8 @@
     }{}}
 %    \end{macrocode}
 %
-%    The package \pkg{cite} has a definition of |\@citex| where the
-%    shorthands need to be turned off in both arguments.
+% The package \pkg{cite} has a definition of |\@citex| where the
+% shorthands need to be turned off in both arguments.
 %
 %    \begin{macrocode}
   \AtBeginDocument{%
@@ -5510,10 +5502,11 @@
 %
 %  \end{macro}
 %
-%  \begin{macro}{\nocite}
-%    The macro |\nocite| which is used to instruct BiB\TeX\ to
-%    extract uncited references from the database.
+% \begin{macro}{\nocite}
 %
+% The macro |\nocite| which is used to instruct BiB\TeX\ to
+% extract uncited references from the database.
+%
 %    \begin{macrocode}
   \bbl at redefine\nocite#1{%
     \@safe at activestrue\org at nocite{#1}\@safe at activesfalse}
@@ -5521,20 +5514,21 @@
 %
 %  \end{macro}
 %
-%  \begin{macro}{\bibcite}
-%  The macro that is used in the |.aux| file to
-%  define citation labels. When packages such as \pkg{natbib} or
-%  \pkg{cite} are not loaded its second argument is used to typeset the
-%  citation label. In that case, this second argument can contain
-%  active characters but is used in an environment where
-%  |\@safe at activestrue| is in effect. This switch needs to be reset
-%  inside the |\hbox| which contains the citation label. In order to
-%  determine during \file{.aux} file processing which definition of
-%  |\bibcite| is needed we define |\bibcite| in such a way that it
-%  redefines itself with the proper definition. We call
-%  |\bbl at cite@choice| to select the proper definition for |\bibcite|.
-%  This new definition is then activated.
+% \begin{macro}{\bibcite}
 %
+% The macro that is used in the |.aux| file to
+% define citation labels. When packages such as \pkg{natbib} or
+% \pkg{cite} are not loaded its second argument is used to typeset the
+% citation label. In that case, this second argument can contain
+% active characters but is used in an environment where
+% |\@safe at activestrue| is in effect. This switch needs to be reset
+% inside the |\hbox| which contains the citation label. In order to
+% determine during \file{.aux} file processing which definition of
+% |\bibcite| is needed we define |\bibcite| in such a way that it
+% redefines itself with the proper definition. We call
+% |\bbl at cite@choice| to select the proper definition for |\bibcite|.
+% This new definition is then activated.
+%
 %    \begin{macrocode}
   \bbl at redefine\bibcite{%
     \bbl at cite@choice
@@ -5543,10 +5537,11 @@
 %
 %  \end{macro}
 %
-%  \begin{macro}{\bbl at bibcite}
-%    The macro |\bbl at bibcite| holds the definition of |\bibcite|
-%    needed when neither \pkg{natbib} nor \pkg{cite} is loaded.
+% \begin{macro}{\bbl at bibcite}
 %
+% The macro |\bbl at bibcite| holds the definition of |\bibcite|
+% needed when neither \pkg{natbib} nor \pkg{cite} is loaded.
+%
 %    \begin{macrocode}
   \def\bbl at bibcite#1#2{%
     \org at bibcite{#1}{\@safe at activesfalse#2}}
@@ -5554,11 +5549,12 @@
 %
 %  \end{macro}
 %
-%  \begin{macro}{\bbl at cite@choice}
-%    The macro |\bbl at cite@choice| determines which definition of
-%    |\bibcite| is needed. First we give |\bibcite| its default
-%    definition.
+% \begin{macro}{\bbl at cite@choice}
 %
+% The macro |\bbl at cite@choice| determines which definition of
+% |\bibcite| is needed. First we give |\bibcite| its default
+% definition.
+%
 %    \begin{macrocode}
   \def\bbl at cite@choice{%
     \global\let\bibcite\bbl at bibcite
@@ -5567,9 +5563,9 @@
     \global\let\bbl at cite@choice\relax}
 %    \end{macrocode}
 %
-%    When a document is run for the first time, no \file{.aux} file is
-%    available, and |\bibcite| will not yet be properly defined. In
-%    this case, this has to happen before the document starts.
+% When a document is run for the first time, no \file{.aux} file is
+% available, and |\bibcite| will not yet be properly defined. In
+% this case, this has to happen before the document starts.
 %
 %    \begin{macrocode}
   \AtBeginDocument{\bbl at cite@choice}
@@ -5577,10 +5573,11 @@
 %
 %  \end{macro}
 %
-%  \begin{macro}{\@bibitem}
-%    One of the two internal \LaTeX\ macros called by |\bibitem|
-%    that write the citation label on the |.aux| file.
+% \begin{macro}{\@bibitem}
 %
+% One of the two internal \LaTeX\ macros called by |\bibitem|
+% that write the citation label on the |.aux| file.
+%
 %    \begin{macrocode}
   \bbl at redefine\@bibitem#1{%
     \@safe at activestrue\org@@bibitem{#1}\@safe at activesfalse}
@@ -5673,30 +5670,30 @@
 %
 % \subsubsection{\pkg{ifthen}}
 %
-%  \begin{macro}{\ifthenelse}
+% \begin{macro}{\ifthenelse}
 %
-%    Sometimes a document writer wants to create a special effect
-%    depending on the page a certain fragment of text appears on. This
-%    can be achieved by the following piece of code:
+% Sometimes a document writer wants to create a special effect
+% depending on the page a certain fragment of text appears on. This
+% can be achieved by the following piece of code:
 %\begin{verbatim}
 %    \ifthenelse{\isodd{\pageref{some:label}}}
 %               {code for odd pages}
 %               {code for even pages}
 %\end{verbatim}
-%    In order for this to work the argument of |\isodd| needs to be
-%    fully expandable. With the above redefinition of |\pageref| it is
-%    not in the case of this example. To overcome that, we add some
-%    code to the definition of |\ifthenelse| to make things work.
+% In order for this to work the argument of |\isodd| needs to be
+% fully expandable. With the above redefinition of |\pageref| it is
+% not in the case of this example. To overcome that, we add some
+% code to the definition of |\ifthenelse| to make things work.
 %
-%    We want to revert the definition of |\pageref| and |\ref| to
-%    their original definition for the first argument of |\ifthenelse|,
-%    so we first need to store their current meanings.
+% We want to revert the definition of |\pageref| and |\ref| to
+% their original definition for the first argument of |\ifthenelse|,
+% so we first need to store their current meanings.
 %
-%    Then we can set the |\@safe at actives| switch and call the original
-%    |\ifthenelse|. In order to be able to use shorthands in the
-%    second and third arguments of |\ifthenelse| the resetting of the
-%    switch \emph{and} the definition of |\pageref| happens inside
-%    those arguments. 
+% Then we can set the |\@safe at actives| switch and call the original
+% |\ifthenelse|. In order to be able to use shorthands in the
+% second and third arguments of |\ifthenelse| the resetting of the
+% switch \emph{and} the definition of |\pageref| happens inside
+% those arguments. 
 %
 %    \begin{macrocode}
 \bbl at trace{Preventing clashes with other packages}
@@ -5728,14 +5725,14 @@
 %
 % \subsubsection{\pkg{varioref}}
 %
-%  \begin{macro}{\@@vpageref}
-%  \begin{macro}{\vrefpagenum}
-%  \begin{macro}{\Ref}
+% \begin{macro}{\@@vpageref}
+% \begin{macro}{\vrefpagenum}
+% \begin{macro}{\Ref}
 %
-%    When the package varioref is in use we need to modify its
-%    internal command |\@@vpageref| in order to prevent problems when
-%    an active character ends up in the argument of |\vref|. The same
-%    needs to happen for |\vrefpagenum|.
+% When the package varioref is in use we need to modify its
+% internal command |\@@vpageref| in order to prevent problems when
+% an active character ends up in the argument of |\vref|. The same
+% needs to happen for |\vrefpagenum|.
 %
 %    \begin{macrocode}
   \AtBeginDocument{%
@@ -5750,14 +5747,14 @@
         \@safe at activesfalse}%
 %    \end{macrocode}
 %
-%    The package \pkg{varioref} defines |\Ref| to be a robust command
-%    wich uppercases the first character of the reference text. In
-%    order to be able to do that it needs to access the expandable form
-%    of |\ref|. So we employ a little trick here. We redefine the
-%    (internal) command \verb*|\Ref | to call |\org at ref| instead of
-%    |\ref|. The disadvantage of this solution is that whenever the
-%    definition of |\Ref| changes, this definition needs to be updated
-%    as well.
+% The package \pkg{varioref} defines |\Ref| to be a robust command
+% wich uppercases the first character of the reference text. In
+% order to be able to do that it needs to access the expandable form
+% of |\ref|. So we employ a little trick here. We redefine the
+% (internal) command \verb*|\Ref | to call |\org at ref| instead of
+% |\ref|. The disadvantage of this solution is that whenever the
+% definition of |\Ref| changes, this definition needs to be updated
+% as well.
 %
 %    \begin{macrocode}
       \expandafter\def\csname Ref \endcsname#1{%
@@ -5773,15 +5770,16 @@
 %
 % \subsubsection{\pkg{hhline}}
 %
-%  \begin{macro}{\hhline}
-%    Delaying the activation of the shorthand characters has introduced
-%    a problem with the \pkg{hhline} package. The reason is that it
-%    uses the `:' character which is made active by the french support
-%    in \babel. Therefore we need to \emph{reload} the package when
-%    the `:' is an active character. Note that this happens
-%    \emph{after} the category code of the @-sign has been changed to
-%    other, so we need to temporarily change it to letter again.
+% \begin{macro}{\hhline}
 %
+% Delaying the activation of the shorthand characters has introduced
+% a problem with the \pkg{hhline} package. The reason is that it
+% uses the `:' character which is made active by the french support
+% in \babel. Therefore we need to \emph{reload} the package when
+% the `:' is an active character. Note that this happens
+% \emph{after} the category code of the @-sign has been changed to
+% other, so we need to temporarily change it to letter again.
+%
 %    \begin{macrocode}
 \AtEndOfPackage{%
   \AtBeginDocument{%
@@ -5798,15 +5796,15 @@
 %
 % \subsubsection{\pkg{hyperref}}
 %
-%  \begin{macro}{\pdfstringdefDisableCommands}
+% \begin{macro}{\pdfstringdefDisableCommands}
 %
-%    A number of interworking problems between \pkg{babel} and
-%    \pkg{hyperref} are tackled by \pkg{hyperref} itself. The
-%    following code was introduced to prevent some annoying warnings
-%    but it broke bookmarks. This was quickly fixed in \pkg{hyperref},
-%    which essentially made it no-op. However, it will not removed for
-%    the moment because \pkg{hyperref} is expecting it. TODO. Still
-%    true? 
+% A number of interworking problems between \pkg{babel} and
+% \pkg{hyperref} are tackled by \pkg{hyperref} itself. The
+% following code was introduced to prevent some annoying warnings
+% but it broke bookmarks. This was quickly fixed in \pkg{hyperref},
+% which essentially made it no-op. However, it will not removed for
+% the moment because \pkg{hyperref} is expecting it. TODO. Still
+% true? 
 %
 %    \begin{macrocode}
 \AtBeginDocument{%
@@ -5819,14 +5817,15 @@
 %
 % \subsubsection{\pkg{fancyhdr}}
 %
-%  \begin{macro}{\FOREIGNLANGUAGE}
-%    The package \pkg{fancyhdr} treats the running head and fout lines
-%    somewhat differently as the standard classes. A symptom of this is
-%    that the command |\foreignlanguage| which \babel\ adds to the
-%    marks can end up inside the argument of |\MakeUppercase|. To
-%    prevent unexpected results we need to define |\FOREIGNLANGUAGE|
-%    here.
+% \begin{macro}{\FOREIGNLANGUAGE}
 %
+% The package \pkg{fancyhdr} treats the running head and fout lines
+% somewhat differently as the standard classes. A symptom of this is
+% that the command |\foreignlanguage| which \babel\ adds to the
+% marks can end up inside the argument of |\MakeUppercase|. To
+% prevent unexpected results we need to define |\FOREIGNLANGUAGE|
+% here.
+%
 %    \begin{macrocode}
 \DeclareRobustCommand{\FOREIGNLANGUAGE}[1]{%
   \lowercase{\foreignlanguage{#1}}}
@@ -5834,12 +5833,12 @@
 %
 %  \end{macro}
 %
-%  \begin{macro}{\substitutefontfamily}
+% \begin{macro}{\substitutefontfamily}
 %
-%    The command |\substitutefontfamily| creates an
-%    \file{.fd} file on the fly. The first argument is an encoding
-%    mnemonic, the second and third arguments are font family names.
-%    This command is deprecated. Use the tools provides by \LaTeX.
+% The command |\substitutefontfamily| creates an
+% \file{.fd} file on the fly. The first argument is an encoding
+% mnemonic, the second and third arguments are font family names.
+% This command is deprecated. Use the tools provides by \LaTeX.
 %
 %    \begin{macrocode}
 \def\substitutefontfamily#1#2#3{%
@@ -6020,25 +6019,147 @@
 % by introducing a “middle layer” just below the user interface
 % (sectioning, footnotes).
 %
-%    \begin{itemize}
-%    \item pdftex provides a minimal support for bidi text, and it
-%      must be done by hand. Vertical typesetting is not possible.
-%    \item \xetex{} is somewhat better, thanks to its font engine
-%      (even if not always reliable) and a few additional tools. However,
-%      very little is done at the paragraph level. Another challenging
-%      problem is text direction does not honour \TeX{} grouping.
-%    \item \luatex{} can provide the most complete solution, as we can
-%      manipulate almost freely the node list, the generated lines,
-%      and so on, but bidi text does not work out of the box and some
-%      development is necessary. It also provides tools to properly
-%      set left-to-right and right-to-left page layouts. As Lua\TeX-ja
-%      shows, vertical typesetting is possible, too.
-%    \end{itemize}
+% \begin{itemize}
+% \item pdftex provides a minimal support for bidi text, and it
+%   must be done by hand. Vertical typesetting is not possible.
+% \item \xetex{} is somewhat better, thanks to its font engine
+%   (even if not always reliable) and a few additional tools. However,
+%   very little is done at the paragraph level. Another challenging
+%   problem is text direction does not honour \TeX{} grouping.
+% \item \luatex{} can provide the most complete solution, as we can
+%   manipulate almost freely the node list, the generated lines,
+%   and so on, but bidi text does not work out of the box and some
+%   development is necessary. It also provides tools to properly
+%   set left-to-right and right-to-left page layouts. As Lua\TeX-ja
+%   shows, vertical typesetting is possible, too.
+% \end{itemize}
 %
+% As a frist step, add a handler for bidi and digits (and potentially
+% other processes) just before \textsf{luaoftload} is applied, which is
+% loaded by default by \LaTeX. Just in case, consider the possibility
+% it has not been loaded.
+%
 %    \begin{macrocode}
-\bbl at trace{Basic (internal) bidi support}
+\ifodd\bbl at engine
+  \def\bbl at activate@preotf{%
+    \let\bbl at activate@preotf\relax  % only once
+    \directlua{
+      Babel = Babel or {}
+      %
+      function Babel.pre_otfload_v(head)
+        if Babel.numbers and Babel.digits_mapped then
+          head = Babel.numbers(head)
+        end
+        if Babel.bidi_enabled then
+          head = Babel.bidi(head, false, dir)
+        end
+        return head
+      end
+      %
+      function Babel.pre_otfload_h(head, gc, sz, pt, dir)
+        if Babel.numbers and Babel.digits_mapped then
+          head = Babel.numbers(head)
+        end
+        if Babel.bidi_enabled then
+          head = Babel.bidi(head, false, dir)
+        end
+        return head
+      end
+      %
+      luatexbase.add_to_callback('pre_linebreak_filter',
+        Babel.pre_otfload_v,
+        'Babel.pre_otfload_v',
+        luatexbase.priority_in_callback('pre_linebreak_filter',
+          'luaotfload.node_processor') or nil)
+      %
+      luatexbase.add_to_callback('hpack_filter',
+        Babel.pre_otfload_h,
+        'Babel.pre_otfload_h',
+        luatexbase.priority_in_callback('hpack_filter',
+          'luaotfload.node_processor') or nil)
+    }}
+\fi
+%    \end{macrocode}
+%
+% The basic setup. In luatex, the output is modified at a very low
+% level to set the |\bodydir| to the |\pagedir|.
+%
+%    \begin{macrocode}
+\bbl at trace{Loading basic (internal) bidi support}
+\ifodd\bbl at engine
+  \ifnum\bbl at bidimode>100 \ifnum\bbl at bidimode<200
+    \let\bbl at beforeforeign\leavevmode
+    \AtEndOfPackage{\EnableBabelHook{babel-bidi}}
+    \RequirePackage{luatexbase}
+    \bbl at activate@preotf
+    \directlua{
+      require('babel-data-bidi.lua')
+      \ifcase\expandafter\@gobbletwo\the\bbl at bidimode\or
+        require('babel-bidi-basic.lua')
+      \or
+        require('babel-bidi-basic-r.lua')
+      \fi}
+    % TODO - to locale_props, not as separate attribute
+    \newattribute\bbl at attr@dir
+    % TODO. I don't like it, hackish:
+    \bbl at exp{\output{\bodydir\pagedir\the\output}}
+    \AtEndOfPackage{\EnableBabelHook{babel-bidi}}
+  \fi\fi
+\else
+  \ifnum\bbl at bidimode>100 \ifnum\bbl at bidimode<200
+    \bbl at error
+      {The bidi method `basic' is available only in\\%
+       luatex. I'll continue with `bidi=default', so\\%
+       expect wrong results}%
+      {See the manual for further details.}%
+    \let\bbl at beforeforeign\leavevmode
+    \AtEndOfPackage{%
+      \EnableBabelHook{babel-bidi}%
+      \bbl at xebidipar}
+  \fi\fi
+  \def\bbl at loadxebidi#1{%
+    \ifx\RTLfootnotetext\@undefined
+      \AtEndOfPackage{%
+        \EnableBabelHook{babel-bidi}%
+        \ifx\fontspec\@undefined
+          \usepackage{fontspec}% bidi needs fontspec
+        \fi
+        \usepackage#1{bidi}}%
+    \fi}
+  \ifnum\bbl at bidimode>200
+    \ifcase\expandafter\@gobbletwo\the\bbl at bidimode\or
+      \bbl at tentative{bidi=bidi}
+      \bbl at loadxebidi{}
+    \or
+      \bbl at tentative{bidi=bidi-r}
+      \bbl at loadxebidi{[rldocument]}
+    \or
+      \bbl at tentative{bidi=bidi-l}
+      \bbl at loadxebidi{}
+    \fi
+  \fi
+\fi
+\ifnum\bbl at bidimode=\@ne
+  \let\bbl at beforeforeign\leavevmode
+  \ifodd\bbl at engine
+    \newattribute\bbl at attr@dir
+    \bbl at exp{\output{\bodydir\pagedir\the\output}}%
+  \fi
+  \AtEndOfPackage{%
+    \EnableBabelHook{babel-bidi}%
+    \ifodd\bbl at engine\else
+      \bbl at xebidipar
+    \fi}
+\fi
+%    \end{macrocode}
+%
+% Now come the macros used to set the direction when a language is
+% switched. First the (mostly) common macros.
+%
+%    \begin{macrocode}
+\bbl at trace{Macros to switch the text direction}
 \def\bbl at alscripts{,Arabic,Syriac,Thaana,}
-\def\bbl at rscripts{%
+\def\bbl at rscripts{% TODO. Base on codes ??
   ,Imperial Aramaic,Avestan,Cypriot,Hatran,Hebrew,%
   Old Hungarian,Old Hungarian,Lydian,Mandaean,Manichaean,%
   Manichaean,Meroitic Cursive,Meroitic,Old North Arabian,%
@@ -6075,9 +6196,16 @@
     \bbl at pardir{#1}%
   \fi
   \bbl at textdir{#1}}
+% TODO. Only if \bbl at bidimode > 0?:
+\AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
+\DisableBabelHook{babel-bidi}
+%    \end{macrocode}
+%
+% Now the engine-dependent macros. TODO. Must be moved to the engine
+% files?
+%
+%    \begin{macrocode} 
 \ifodd\bbl at engine  % luatex=1
-  \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
-  \DisableBabelHook{babel-bidi}
   \chardef\bbl at thetextdir\z@
   \chardef\bbl at thepardir\z@
   \def\bbl at getluadir#1{%
@@ -6115,9 +6243,11 @@
     \else
       \everyhbox{\textdir TRT\relax}%
     \fi}
+  \frozen at everymath\expandafter{%
+    \expandafter\bbl at mathboxdir\the\frozen at everymath}
+  \frozen at everydisplay\expandafter{%
+    \expandafter\bbl at mathboxdir\the\frozen at everydisplay}
 \else % pdftex=0, xetex=2
-  \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
-  \DisableBabelHook{babel-bidi}
   \newcount\bbl at dirlevel
   \chardef\bbl at thetextdir\z@
   \chardef\bbl at thepardir\z@
@@ -6182,20 +6312,18 @@
     \newtoks\everypar
     \everypar=\bbl at severypar
     \bbl at severypar{\bbl at xeeverypar\the\everypar}}
-  \def\bbl at tempb{%
+  \ifnum\bbl at bidimode>200
     \let\bbl at textdir@i\@gobbletwo
     \let\bbl at xebidipar\@empty
     \AddBabelHook{bidi}{foreign}{%
-      \def\bbl at tempa{\def\BabelText########1}%
+      \def\bbl at tempa{\def\BabelText####1}%
       \ifcase\bbl at thetextdir
-        \expandafter\bbl at tempa\expandafter{\BabelText{\LR{####1}}}%
+        \expandafter\bbl at tempa\expandafter{\BabelText{\LR{##1}}}%
       \else
-        \expandafter\bbl at tempa\expandafter{\BabelText{\RL{####1}}}%
+        \expandafter\bbl at tempa\expandafter{\BabelText{\RL{##1}}}%
       \fi}
-    \def\bbl at pardir##1{\ifcase##1\relax\setLR\else\setRL\fi}}
-  \@ifpackagewith{babel}{bidi=bidi}{\bbl at tempb}{}%
-  \@ifpackagewith{babel}{bidi=bidi-l}{\bbl at tempb}{}%
-  \@ifpackagewith{babel}{bidi=bidi-r}{\bbl at tempb}{}%
+    \def\bbl at pardir#1{\ifcase#1\relax\setLR\else\setRL\fi}
+  \fi
 \fi
 %    \end{macrocode}
 %
@@ -6214,17 +6342,18 @@
 %
 % \subsection{Local Language Configuration}
 %
-%  \begin{macro}{\loadlocalcfg}
-%    At some sites it may be necessary to add site-specific actions to
-%    a language definition file. This can be done by creating a file
-%    with the same name as the language definition file, but with the
-%    extension \file{.cfg}. For instance the file \file{norsk.cfg}
-%    will be loaded when the language definition file \file{norsk.ldf}
-%    is loaded.
+% \begin{macro}{\loadlocalcfg}
 %
-%    For plain-based formats we don't want to override the definition
-%    of |\loadlocalcfg| from \file{plain.def}.
+% At some sites it may be necessary to add site-specific actions to
+% a language definition file. This can be done by creating a file
+% with the same name as the language definition file, but with the
+% extension \file{.cfg}. For instance the file \file{norsk.cfg}
+% will be loaded when the language definition file \file{norsk.ldf}
+% is loaded. 
 %
+% For plain-based formats we don't want to override the definition
+% of |\loadlocalcfg| from \file{plain.def}.
+%
 %    \begin{macrocode}
 \bbl at trace{Local Language Configuration}
 \ifx\loadlocalcfg\@undefined
@@ -6240,8 +6369,8 @@
 %    \end{macrocode}%
 %    \end{macro}
 %
-%    Just to be compatible with \LaTeX$\:$2.09 we add a few more lines
-%    of code. TODO. Necessary? Correct place? Used by some ldf file?
+% Just to be compatible with \LaTeX$\:$2.09 we add a few more lines
+% of code. TODO. Necessary? Correct place? Used by some ldf file?
 %
 %    \begin{macrocode}
 \ifx\@unexpandable at protect\@undefined
@@ -6259,11 +6388,11 @@
 %
 % \subsection{Language options}
 %
-%    Languages are loaded when processing the corresponding option
-%    \textit{except} if a |main| language has been set. In such a
-%    case, it is not loaded until all options has been processed.
-%    The following macro inputs the ldf file and does some additional
-%    checks (|\input| works, too, but possible errors are not catched).
+% Languages are loaded when processing the corresponding option
+% \textit{except} if a |main| language has been set. In such a
+% case, it is not loaded until all options has been processed.
+% The following macro inputs the ldf file and does some additional
+% checks (|\input| works, too, but possible errors are not catched).
 %
 %    \begin{macrocode}
 \bbl at trace{Language options}
@@ -6286,7 +6415,10 @@
        headfoot=, strings=, config=, hyphenmap=, or a language name.}}}
 %    \end{macrocode}
 %
-%    Now, we set language options whose names are different from |ldf| files.
+% Now, we set a few language options whose names are different from
+% |ldf| files. These declarations are preserved for backwards
+% compatibility, but they must be eventually removed. Use proxy files
+% instead.
 %
 %    \begin{macrocode}
 \def\bbl at try@load at lang#1#2#3{%
@@ -6294,8 +6426,6 @@
       {\bbl at load@language{\CurrentOption}}%
       {#1\bbl at load@language{#2}#3}}
 \DeclareOption{afrikaans}{\bbl at try@load at lang{}{dutch}{}}
-\DeclareOption{brazil}{\bbl at try@load at lang{}{portuges}{}}
-\DeclareOption{brazilian}{\bbl at try@load at lang{}{portuges}{}}
 \DeclareOption{hebrew}{%
   \input{rlbabel.def}%
   \bbl at load@language{hebrew}}
@@ -6304,19 +6434,18 @@
 \DeclareOption{nynorsk}{\bbl at try@load at lang{}{norsk}{}}
 \DeclareOption{polutonikogreek}{%
   \bbl at try@load at lang{}{greek}{\languageattribute{greek}{polutoniko}}}
-\DeclareOption{portuguese}{\bbl at try@load at lang{}{portuges}{}}
 \DeclareOption{russian}{\bbl at try@load at lang{}{russianb}{}}
 \DeclareOption{ukrainian}{\bbl at try@load at lang{}{ukraineb}{}}
 \DeclareOption{uppersorbian}{\bbl at try@load at lang{}{usorbian}{}}
 %    \end{macrocode}
 %
-%    Another way to extend the list of `known' options for \babel\ was
-%    to create the file \file{bblopts.cfg} in which one can add option
-%    declarations. However, this mechanism is deprecated -- if you
-%    want an alternative name for a language, just create a new |.ldf|
-%    file loading the actual one. You can also set the name
-%    of the file with the package option |config=<name>|, which will
-%    load |<name>.cfg| instead.
+% Another way to extend the list of `known' options for \babel\ was
+% to create the file \file{bblopts.cfg} in which one can add option
+% declarations. However, this mechanism is deprecated -- if you
+% want an alternative name for a language, just create a new |.ldf|
+% file loading the actual one. You can also set the name
+% of the file with the package option |config=<name>|, which will
+% load |<name>.cfg| instead.
 %
 %    \begin{macrocode}
 \ifx\bbl at opt@config\@nnil
@@ -6337,13 +6466,13 @@
 \fi
 %    \end{macrocode}
 %
-%    Recognizing global options in packages not having a closed set of
-%    them is not trivial, as for them to be processed they must be
-%    defined explicitly. So, package options not yet taken into
-%    account and stored in |bbl at language@opts| are assumed to be
-%    languages (note this list also contains the language given with
-%    |main|). If not declared above, the names of the option and the
-%    file are the same.
+% Recognizing global options in packages not having a closed set of
+% them is not trivial, as for them to be processed they must be
+% defined explicitly. So, package options not yet taken into
+% account and stored in |bbl at language@opts| are assumed to be
+% languages (note this list also contains the language given with
+% |main|). If not declared above, the names of the option and the
+% file are the same.
 %
 %    \begin{macrocode}
 \bbl at for\bbl at tempa\bbl at language@opts{%
@@ -6356,11 +6485,11 @@
      \@empty}
 %    \end{macrocode}
 %
-%    Now, we make sure an option is explicitly declared for any
-%    language set as global option, by checking if an |ldf|
-%    exists. The previous step was, in fact, somewhat redundant, but
-%    that way we minimize accesing the file system just to see if the
-%    option could be a language.
+% Now, we make sure an option is explicitly declared for any
+% language set as global option, by checking if an |ldf|
+% exists. The previous step was, in fact, somewhat redundant, but
+% that way we minimize accesing the file system just to see if the
+% option could be a language.
 %
 %    \begin{macrocode}
 \bbl at foreach\@classoptionslist{%
@@ -6381,13 +6510,13 @@
 \fi
 %    \end{macrocode}
 %
-%    And we are done, because all options for this pass has been
-%    declared. Those already processed in the first pass are just
-%    ignored.
+% And we are done, because all options for this pass has been
+% declared. Those already processed in the first pass are just
+% ignored.
 %
-%    The options have to be processed in the order in which the user
-%    specified them (except, of course, global options, which \LaTeX{}
-%    processes before):
+% The options have to be processed in the order in which the user
+% specified them (except, of course, global options, which \LaTeX{}
+% processes before):
 %
 %    \begin{macrocode}
 \def\AfterBabelLanguage#1{%
@@ -6396,13 +6525,13 @@
 \ProcessOptions*
 %    \end{macrocode}
 %
-%    This finished the second pass. Now the third one begins, which
-%    loads the main language set with the key |main|. A warning is
-%    raised if the main language is not the same as the last named
-%    one, or if the value of the key |main| is not a language. Then
-%    execute directly the option (because it could be used only in
-%    |main|). After loading all languages, we deactivate
-%    |\AfterBabelLanguage|.
+% This finished the second pass. Now the third one begins, which
+% loads the main language set with the key |main|. A warning is
+% raised if the main language is not the same as the last named
+% one, or if the value of the key |main| is not a language. Then
+% execute directly the option (because it could be used only in
+% |main|). After loading all languages, we deactivate
+% |\AfterBabelLanguage|.
 %
 %    \begin{macrocode}
 \bbl at trace{Option 'main'}
@@ -6434,10 +6563,10 @@
     {Languages have been loaded, so I can do nothing}}
 %    \end{macrocode}
 %      
-%    In order to catch the case where the user forgot to specify a
-%    language we check whether |\bbl at main@language|, has become
-%    defined. If not, no language has been loaded and an error
-%    message is displayed.
+% In order to catch the case where the user forgot to specify a
+% language we check whether |\bbl at main@language|, has become
+% defined. If not, no language has been loaded and an error
+% message is displayed.
 %
 %    \begin{macrocode}
 \ifx\bbl at main@language\@undefined
@@ -6512,6 +6641,7 @@
   \ifx\@uclclist\@undefined\let\@uclclist\@empty\fi
   \ifx\bbl at trace\@undefined\def\bbl at trace#1{}\fi
   \expandafter\newif\csname ifbbl at single\endcsname
+  \chardef\bbl at bidimode\z@
 \fi
 %    \end{macrocode}
 %
@@ -7006,13 +7136,24 @@
       \csname date#1\endcsname\relax
     \fi
   \else
-    \ifbbl at usedategroup   % if \foreign... within \<lang>date
-      \bbl at usedategroupfalse
-      \ifhmode
-        \hskip\z at skip % trick to ignore spaces
+    \ifhmode
+      \hskip\z at skip % trick to ignore spaces
+      \bbl at xin@{,captions,}{,\bbl at select@opts,}%
+      \ifin@
+        \csname captions#1\endcsname\relax
+      \fi
+      \bbl at xin@{,date,}{,\bbl at select@opts,}%
+      \ifin@  % if \foreign... within \<lang>date
         \csname date#1\endcsname\relax
-        \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
-      \else
+      \fi
+      \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
+    \else
+      \bbl at xin@{,captions,}{,\bbl at select@opts,}%
+      \ifin@ 
+        \csname captions#1\endcsname\relax
+      \fi
+      \bbl at xin@{,date,}{,\bbl at select@opts,}%
+      \ifin@
         \csname date#1\endcsname\relax
       \fi
     \fi
@@ -7085,9 +7226,12 @@
 % This environment makes use of |\foreign at language|.
 %
 %    \begin{macrocode}
-\expandafter\def\csname otherlanguage*\endcsname#1{%
+\expandafter\def\csname otherlanguage*\endcsname{%
+  \@ifnextchar[\bbl at otherlanguage@s{\bbl at otherlanguage@s[]}}
+\def\bbl at otherlanguage@s[#1]#2{%
   \ifnum\bbl at hymapsel=\@cclv\chardef\bbl at hymapsel4\relax\fi
-  \foreign at language{#1}}
+  \def\bbl at select@opts{#1}%
+  \foreign at language{#2}}
 %    \end{macrocode}
 %
 % At the end of the environment we need to switch off the extra
@@ -7146,13 +7290,14 @@
   \expandafter\noexpand\csname foreignlanguage \endcsname}
 \expandafter\def\csname foreignlanguage \endcsname{%
   \@ifstar\bbl at foreign@s\bbl at foreign@x}
-\def\bbl at foreign@x#1#2{%
+\newcommand\bbl at foreign@x[3][]{%
   \begingroup
+    \def\bbl at select@opts{#1}%
     \let\BabelText\@firstofone
     \bbl at beforeforeign
-    \foreign at language{#1}%
+    \foreign at language{#2}%
     \bbl at usehooks{foreign}{}%
-    \BabelText{#2}% Now in horizontal mode!
+    \BabelText{#3}% Now in horizontal mode!
   \endgroup}
 \def\bbl at foreign@s#1#2{% TODO - \shapemode, \@setpar, ?\@@par
   \begingroup
@@ -7179,6 +7324,10 @@
 \def\foreign at language#1{%
   % set name
   \edef\languagename{#1}%
+  \ifbbl at usedategroup
+    \bbl at add\bbl at select@opts{,date,}%
+    \bbl at usedategroupfalse
+  \fi
   \bbl at fixname\languagename
   % TODO. name at map here?
   \bbl at provide@locale
@@ -9932,17 +10081,17 @@
 %
 %  \end{macro}
 %
-%    For all vowels we declare |\"| to be a composite command which
-%    uses |\bbl at umlauta| or |\bbl at umlaute| to position the umlaut
-%    character. We need to be sure that these definitions override the
-%    ones that are provided when the package \pkg{fontenc} with
-%    option \Lopt{OT1} is used. Therefore these declarations are
-%    postponed until the beginning of the document. Note these
-%    definitions only apply to some languages, but
-%    babel sets them for \textit{all} languages -- you may want to
-%    redefine |\bbl at umlauta| and/or |\bbl at umlaute| for a language
-%    in the corresponding |ldf| (using the babel switching mechanism,
-%    of course).
+% For all vowels we declare |\"| to be a composite command which
+% uses |\bbl at umlauta| or |\bbl at umlaute| to position the umlaut
+% character. We need to be sure that these definitions override the
+% ones that are provided when the package \pkg{fontenc} with
+% option \Lopt{OT1} is used. Therefore these declarations are
+% postponed until the beginning of the document. Note these
+% definitions only apply to some languages, but
+% babel sets them for \textit{all} languages -- you may want to
+% redefine |\bbl at umlauta| and/or |\bbl at umlaute| for a language
+% in the corresponding |ldf| (using the babel switching mechanism,
+% of course).
 %
 %    \begin{macrocode}
 \AtBeginDocument{%
@@ -9956,17 +10105,21 @@
   \DeclareTextCompositeCommand{\"}{OT1}{E}{\bbl at umlaute{E}}%
   \DeclareTextCompositeCommand{\"}{OT1}{I}{\bbl at umlaute{I}}%
   \DeclareTextCompositeCommand{\"}{OT1}{O}{\bbl at umlauta{O}}%
-  \DeclareTextCompositeCommand{\"}{OT1}{U}{\bbl at umlauta{U}}%
-}
+  \DeclareTextCompositeCommand{\"}{OT1}{U}{\bbl at umlauta{U}}}
 %    \end{macrocode}
 %
 % Finally, make sure the default hyphenrules are defined (even if
-% empty). 
+% empty). For internal use, another empty |\language| is defined.
+% Currently used in Amharic.
 %
 %    \begin{macrocode}
 \ifx\l at english\@undefined
   \chardef\l at english\z@
 \fi
+% The following is used to cancel rules in ini files (see Amharic).
+\ifx\l at babelnohyhens\@undefined
+  \newlanguage\l at babelnohyphens
+\fi
 %    \end{macrocode}
 %
 % \subsection{Layout}
@@ -10109,7 +10262,8 @@
   \bbl at ifunset{bbl at lname@#2}%  TODO. Duplicated
     {\def\BabelBeforeIni##1##2{%
        \begingroup
-         \catcode`\[=12 \catcode`\]=12 \catcode`\==12  \catcode`\;=12 %
+         \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+         \catcode`\;=12 \catcode`\|=12 %
          \let\bbl at ini@captions at aux\@gobbletwo
          \def\bbl at inidate ####1.####2.####3.####4\relax ####5####6{}%
          \bbl at read@ini{##1}{basic data}%
@@ -10120,7 +10274,8 @@
          \bbl at exportkey{lfthm}{typography.lefthyphenmin}{2}%
          \bbl at exportkey{rgthm}{typography.righthyphenmin}{3}%
          \bbl at exportkey{hyphr}{typography.hyphenrules}{}%
-         \bbl at exportkey{hyoth}{typography.hyphenate.other}{}%
+         \bbl at exportkey{hyotl}{typography.hyphenate.other.locale}{}%
+         \bbl at exportkey{hyots}{typography.hyphenate.other.script}{}%
          \bbl at exportkey{intsp}{typography.intraspace}{}%
          \ifx\bbl at initoload\relax\endinput\fi
        \endgroup}%
@@ -10227,11 +10382,11 @@
     \bbl at csarg\edef{intsp@#2}{\bbl at KVP@intraspace}%
   \fi
   \bbl at provide@intraspace
-  % == hyphenate.other ==
-  \bbl at ifunset{bbl at hyoth@\languagename}{}%
-    {\bbl at csarg\bbl at replace{hyoth@\languagename}{ }{,}%
+  % == hyphenate.other.locale ==
+  \bbl at ifunset{bbl at hyotl@\languagename}{}%
+    {\bbl at csarg\bbl at replace{hyotl@\languagename}{ }{,}%
      \bbl at startcommands*{\languagename}{}%
-       \bbl at csarg\bbl at foreach{hyoth@\languagename}{%
+       \bbl at csarg\bbl at foreach{hyotl@\languagename}{%
          \ifcase\bbl at engine
            \ifnum##1<257
              \SetHyphenMap{\BabelLower{##1}{##1}}%
@@ -10240,6 +10395,17 @@
            \SetHyphenMap{\BabelLower{##1}{##1}}%
          \fi}%
      \bbl at endcommands}%
+  % == hyphenate.other.script ==
+  \bbl at ifunset{bbl at hyots@\languagename}{}%
+    {\bbl at csarg\bbl at replace{hyots@\languagename}{ }{,}%
+     \bbl at csarg\bbl at foreach{hyots@\languagename}{%
+       \ifcase\bbl at engine
+         \ifnum##1<257
+           \global\lccode##1=##1\relax
+         \fi
+       \else
+         \global\lccode##1=##1\relax
+       \fi}}%
   % == maparabic ==
   % Native digits, if provided in ini (TeX level, xe and lua)
   \ifcase\bbl at engine\else
@@ -10341,9 +10507,12 @@
 %
 % A tool to define the macros for native digits from the list provided 
 % in the |ini| file. Somewhat convoluted because there are 10 digits, 
-% but only 9 arguments in \TeX.
+% but only 9 arguments in \TeX. Non-digits characters are kept. The
+% first macro is the generic “localized” command.
 %
 %    \begin{macrocode}
+% TODO. Merge with \localenumeral:
+% \newcommand\localedigits{\@nameuse{\languagename digits}}
 \def\bbl at setdigits#1#2#3#4#5{%
   \bbl at exp{%
     \def\<\languagename digits>####1{%       ie, \langdigits
@@ -10414,7 +10583,8 @@
   \bbl at ifunset{bbl at lname@#1}%     TODO. Duplicated
     {\def\BabelBeforeIni##1##2{%
        \begingroup
-         \catcode`\[=12 \catcode`\]=12 \catcode`\==12  \catcode`\;=12 %
+         \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+         \catcode`\;=12 \catcode`\|=12 %
          \let\bbl at ini@captions at aux\@gobbletwo
          \def\bbl at inidate ####1.####2.####3.####4\relax ####5####6{}%
          \bbl at read@ini{##1}{basic data}%
@@ -10422,8 +10592,8 @@
          \bbl at exportkey{lnbrk}{typography.linebreaking}{h}%
          \bbl at exportkey{lfthm}{typography.lefthyphenmin}{2}%
          \bbl at exportkey{rgthm}{typography.righthyphenmin}{3}%
-         \bbl at exportkey{hyphr}{typography.hyphenrules}{}%
-         \bbl at exportkey{hyoth}{typography.hyphenate.other}{}%
+         \bbl at exportkey{hyotl}{typography.hyphenate.other.locale}{}%
+         \bbl at exportkey{hyots}{typography.hyphenate.other.script}{}%
          \bbl at exportkey{intsp}{typography.intraspace}{}%
          \bbl at exportkey{chrng}{characters.ranges}{}%
          \bbl at exportkey{dgnat}{numbers.digits.native}{}%
@@ -10662,6 +10832,11 @@
 \let\bbl at inikv@characters\bbl at inikv
 \let\bbl at inikv@numbers\bbl at inikv
 \def\bbl at inikv@counters#1=#2\@@{%
+  \bbl at ifsamestring{#1}{digits}%
+    {\bbl at error{The counter name 'digits' is reserved for mapping\\%
+                decimal digits}%
+               {Use another name.}}%
+    {}%
   \def\bbl at tempc{#1}%
   \bbl at trim@def{\bbl at tempb*}{#2}%
   \in@{.1$}{#1$}%
@@ -10685,7 +10860,8 @@
   \bbl at exportkey{prehc}{typography.prehyphenchar}{}%
   \bbl at exportkey{lnbrk}{typography.linebreaking}{h}%
   \bbl at exportkey{hyphr}{typography.hyphenrules}{}%
-  \bbl at exportkey{hyoth}{typography.hyphenate.other}{}%
+  \bbl at exportkey{hyotl}{typography.hyphenate.other.locale}{}%
+  \bbl at exportkey{hyots}{typography.hyphenate.other.script}{}%
   \bbl at exportkey{intsp}{typography.intraspace}{}%
   \bbl at exportkey{jstfy}{typography.justify}{w}%
   \bbl at exportkey{chrng}{characters.ranges}{}%
@@ -10747,6 +10923,8 @@
   \bbl at csarg\def{secpre at date.gregorian.licr}{%         discard uni
     \ifcase\bbl at engine\let\bbl at savedate\@empty\fi}
 \fi
+% TODO. With the following there is no need to ensure if \select...
+\newcommand\localedate{\@nameuse{bbl at date@\languagename}}
 % eg: 1=months, 2=wide, 3=1, 4=dummy
 \def\bbl at inidate#1.#2.#3.#4\relax#5#6{% TODO - ignore with 'captions'
   \bbl at trim@def\bbl at tempa{#1.#2}%
@@ -10813,9 +10991,13 @@
   \bbl at replace\bbl at toreplace{[y]}{\BabelDatey{####1}}%
   \bbl at replace\bbl at toreplace{[yy]}{\BabelDateyy{####1}}%
   \bbl at replace\bbl at toreplace{[yyyy]}{\BabelDateyyyy{####1}}%
+  \bbl at replace\bbl at toreplace{[y|}{\bbl at datecntr[####1|}%
+  \bbl at replace\bbl at toreplace{[m|}{\bbl at datecntr[####2|}%
+  \bbl at replace\bbl at toreplace{[d|}{\bbl at datecntr[####3|}%
 % Note after \bbl at replace \toks@ contains the resulting string.
 % TODO - Using this implicit behavior doesn't seem a good idea.
   \bbl at replace@finish at iii\bbl at toreplace}
+\def\bbl at datecntr[#1|#2]{\localenumeral{#2}{#1}}
 %    \end{macrocode}
 %
 % Language and Script values to be used when defining a font or
@@ -10854,7 +11036,8 @@
   \def\BabelBeforeIni##1##2{%
     \begingroup
       \bbl at add\bbl at secpost@identification{\closein\bbl at readstream }%
-      \catcode`\[=12 \catcode`\]=12 \catcode`\==12 \catcode`\;=12 %
+      \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+      \catcode`\;=12 \catcode`\|=12 %
       \bbl at read@ini{##1}{font and identification data}%   
       \endinput          % babel- .tex may contain onlypreamble's
     \endgroup}%            boxed, to avoid extra spaces:
@@ -10882,11 +11065,13 @@
 % number of digits in the number to be converted. This explains the
 % reverse set |76543210|. Digits above 10000 are not handled yet. When
 % the key contains the subkey |.F.|, the number after is treated as an
-% special case. for a fixed form (see |babel-he.ini|, for example).
+% special case, for a fixed form (see |babel-he.ini|, for example).
 %
 %    \begin{macrocode}
 \newcommand\localenumeral[2]{\bbl at cs{cntr@#1@\languagename}{#2}}
 \def\bbl at localecntr#1#2{\localenumeral{#2}{#1}}
+% TODO. \localecounter{digits}{..} What a mistake on my part!!
+% But the solution seems even logical ;-)
 \newcommand\localecounter[2]{%
   \expandafter\bbl at localecntr\csname c@#2\endcsname{#1}}
 \def\bbl at alphnumeral#1#2{%
@@ -10905,7 +11090,7 @@
      \bbl at cs{cntr@#1.3@\languagename}#6%
      \bbl at cs{cntr@#1.2@\languagename}#7%
      \bbl at cs{cntr@#1.1@\languagename}#8%
-     \ifnum#6#7#8>\z@ % An ad hod rule for Greek. Ugly. To be fixed.
+     \ifnum#6#7#8>\z@ % TODO. An ad hoc rule for Greek. Ugly.
        \bbl at ifunset{bbl at cntr@#1.S.321@\languagename}{}%
          {\bbl at cs{cntr@#1.S.321@\languagename}}%
      \fi}%
@@ -11464,63 +11649,13 @@
 %
 %    \begin{macrocode}
 %<<*More package options>>
-\ifodd\bbl at engine
-  \DeclareOption{bidi=basic-r}%
-    {\ExecuteOptions{bidi=basic}}
-  \DeclareOption{bidi=basic}%
-    {\let\bbl at beforeforeign\leavevmode
-     % TODO - to locale_props, not as separate attribute
-     \newattribute\bbl at attr@dir
-     % I don't like it, hackish:
-     \frozen at everymath\expandafter{%
-       \expandafter\bbl at mathboxdir\the\frozen at everymath}%
-     \frozen at everydisplay\expandafter{%
-       \expandafter\bbl at mathboxdir\the\frozen at everydisplay}%
-     \bbl at exp{\output{\bodydir\pagedir\the\output}}%
-     \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
-\else
-  \DeclareOption{bidi=basic-r}%
-    {\ExecuteOptions{bidi=basic}}
-  \DeclareOption{bidi=basic}%
-    {\bbl at error
-      {The bidi method `basic' is available only in\\%
-       luatex. I'll continue with `bidi=default', so\\%
-       expect wrong results}%
-      {See the manual for further details.}%
-    \let\bbl at beforeforeign\leavevmode
-    \AtEndOfPackage{%
-      \EnableBabelHook{babel-bidi}%
-      \bbl at xebidipar}}
-  \def\bbl at loadxebidi#1{%
-    \ifx\RTLfootnotetext\@undefined
-      \AtEndOfPackage{% 
-        \EnableBabelHook{babel-bidi}%
-        \ifx\fontspec\@undefined
-          \usepackage{fontspec}% bidi needs fontspec 
-        \fi
-        \usepackage#1{bidi}}%
-    \fi}
-  \DeclareOption{bidi=bidi}%
-    {\bbl at tentative{bidi=bidi}%
-     \bbl at loadxebidi{}}
-  \DeclareOption{bidi=bidi-r}%
-    {\bbl at tentative{bidi=bidi-r}%
-     \bbl at loadxebidi{[rldocument]}}
-  \DeclareOption{bidi=bidi-l}%
-    {\bbl at tentative{bidi=bidi-l}%
-     \bbl at loadxebidi{}}
-\fi
-\DeclareOption{bidi=default}%
-  {\let\bbl at beforeforeign\leavevmode
-   \ifodd\bbl at engine
-     \newattribute\bbl at attr@dir
-     \bbl at exp{\output{\bodydir\pagedir\the\output}}%
-   \fi
-   \AtEndOfPackage{%
-     \EnableBabelHook{babel-bidi}%
-     \ifodd\bbl at engine\else
-       \bbl at xebidipar
-     \fi}}
+\chardef\bbl at bidimode\z@
+\DeclareOption{bidi=default}{\chardef\bbl at bidimode=\@ne}
+\DeclareOption{bidi=basic}{\chardef\bbl at bidimode=101 }
+\DeclareOption{bidi=basic-r}{\chardef\bbl at bidimode=102 }
+\DeclareOption{bidi=bidi}{\chardef\bbl at bidimode=201 }
+\DeclareOption{bidi=bidi-r}{\chardef\bbl at bidimode=202 }
+\DeclareOption{bidi=bidi-l}{\chardef\bbl at bidimode=203 }
 %<</More package options>>
 %    \end{macrocode}
 %
@@ -11780,7 +11915,7 @@
 %    \begin{macrocode}
 %<<*Footnote changes>>
 \bbl at trace{Bidi footnotes}
-\ifx\bbl at beforeforeign\leavevmode
+\ifnum\bbl at bidimode>\z@
   \def\bbl at footnote#1#2#3{%
     \@ifnextchar[%
       {\bbl at footnote@o{#1}{#2}{#3}}%
@@ -12278,6 +12413,7 @@
 \endgroup
 \ifx\newattribute\@undefined\else
   \newattribute\bbl at attr@locale
+  \directlua{ Babel.attr_locale = luatexbase.registernumber'bbl at attr@locale'}
   \AddBabelHook{luatex}{beforeextras}{%
     \setattribute\bbl at attr@locale\localeid}
 \fi
@@ -12774,8 +12910,8 @@
 \let\bbl at chprop@bmg\bbl at chprop@mirror
 \def\bbl at chprop@linebreak#1{%
   \directlua{
-    Babel.Babel.cjk_characters[\the\count@] = Babel.Babel.cjk_characters[\the\count@] or {}
-    Babel.Babel.cjk_characters[\the\count@]['c'] = '#1'
+    Babel.cjk_characters[\the\count@] = Babel.cjk_characters[\the\count@] or {}
+    Babel.cjk_characters[\the\count@]['c'] = '#1'
   }}
 \let\bbl at chprop@lb\bbl at chprop@linebreak
 \def\bbl at chprop@locale#1{%
@@ -12814,7 +12950,8 @@
 \catcode`\%=12
 \catcode`\&=14
 \directlua{
-  Babel.linebreaking.replacements = {}
+  Babel.linebreaking.post_replacements = {}
+  Babel.linebreaking.pre_replacements = {}
 
   function Babel.str_to_nodes(fn, matches, base)
     local n, head, last    
@@ -12840,6 +12977,7 @@
     local word_nodes = {}
     local lang
     local item = head
+    local inmath = false
 
     while item do
 
@@ -12846,18 +12984,22 @@
       if item.id == 29
           and not(item.char == 124) &% ie, not |
           and not(item.char == 61)  &% ie, not =
+          and not inmath
           and (item.lang == lang or lang == nil) then
         lang = lang or item.lang
         word_string = word_string .. unicode.utf8.char(item.char)
         word_nodes[#word_nodes+1] = item
 
-      elseif item.id == 7 and item.subtype == 2 then
+      elseif item.id == 7 and item.subtype == 2 and not inmath then
         word_string = word_string .. '='
         word_nodes[#word_nodes+1] = item
 
-      elseif item.id == 7 and item.subtype == 3 then
+      elseif item.id == 7 and item.subtype == 3 and not inmath then
         word_string = word_string .. '|'       
         word_nodes[#word_nodes+1] = item
+        
+      elseif item.id == node.id'math' then
+        inmath = (item.subtype == 0)
 
       elseif word_string == '' then
         &% pass
@@ -12872,7 +13014,7 @@
 
   function Babel.post_hyphenate_replace(head)
     local u = unicode.utf8
-    local lbkr = Babel.linebreaking.replacements
+    local lbkr = Babel.linebreaking.post_replacements
     local word_head = head
 
     while true do
@@ -12977,7 +13119,153 @@
     end  &% for words
     return head
   end
+  
+  &%%%
+  &% Preliminary code for \babelprehyphenation
+  &% TODO. Copypaste pattern. Merge with fetch_word
+  function Babel.fetch_subtext(head, funct)
+    local word_string = ''
+    local word_nodes = {}
+    local lang
+    local item = head
+    local inmath = false
 
+    while item do
+
+      if item.id == 29 then     
+        local locale = node.get_attribute(item, Babel.attr_locale)
+
+        if not(item.char == 124) &% ie, not | = space
+            and not inmath
+            and (locale == lang or lang == nil) then
+          lang = lang or locale
+          word_string = word_string .. unicode.utf8.char(item.char)
+          word_nodes[#word_nodes+1] = item
+        end
+
+        if item == node.tail(head) then 
+          item = nil
+          return word_string, word_nodes, item, lang
+        end
+
+      elseif item.id == 12 and item.subtype == 13 and not inmath then
+        word_string = word_string .. '|'       
+        word_nodes[#word_nodes+1] = item
+
+        if item == node.tail(head) then 
+          item = nil
+          return word_string, word_nodes, item, lang
+        end
+      
+      elseif item.id == node.id'math' then
+        inmath = (item.subtype == 0)
+
+      elseif word_string == '' then
+        &% pass
+
+      else
+        return word_string, word_nodes, item, lang
+      end
+
+      item = item.next
+    end
+  end
+  
+  &% TODO. Copypaste pattern. Merge with pre_hyphenate_replace
+  function Babel.pre_hyphenate_replace(head)
+    local u = unicode.utf8
+    local lbkr = Babel.linebreaking.pre_replacements
+    local word_head = head
+
+    while true do
+      local w, wn, nw, lang = Babel.fetch_subtext(word_head)
+      if not lang then return head end
+
+      if not lbkr[lang] then
+        break
+      end
+
+      for k=1, #lbkr[lang] do
+        local p = lbkr[lang][k].pattern 
+        local r = lbkr[lang][k].replace
+
+        while true do
+          local matches = { u.match(w, p) }
+          if #matches < 2 then break end
+
+          local first = table.remove(matches, 1)
+          local last =  table.remove(matches, #matches)
+
+          &% Fix offsets, from bytes to unicode.
+          first = u.len(w:sub(1, first-1)) + 1
+          last  = u.len(w:sub(1, last-1))
+
+          local new  &% used when inserting and removing nodes
+          local changed = 0
+
+          &% This loop traverses the replace list and takes the
+          &% corresponding actions
+          for q = first, last do   
+            local crep = r[q-first+1]
+            local char_node = wn[q]
+            local char_base = char_node
+
+            if crep and crep.data then
+              char_base = wn[crep.data+first-1]
+            end
+
+            if crep == {} then
+              break
+            elseif crep == nil then
+              changed = changed + 1
+              node.remove(head, char_node)
+            elseif crep and crep.string then
+              changed = changed + 1
+              local str = crep.string(matches)
+              if str == '' then 
+                if q == 1 then
+                  word_head = char_node.next
+                end
+                head, new = node.remove(head, char_node)
+              elseif char_node.id == 29 and u.len(str) == 1 then
+                char_node.char = string.utfvalue(str)
+              else
+                local n
+                for s in string.utfvalues(str) do
+                  if char_node.id == 7 then
+                    log('Automatic hyphens cannot be replaced, just removed.')
+                  else
+                    n = node.copy(char_base)
+                  end
+                  n.char = s
+                  if q == 1 then
+                    head, new = node.insert_before(head, char_node, n)   
+                    word_head = new
+                  else 
+                    node.insert_before(head, char_node, n)   
+                  end
+                end
+
+                node.remove(head, char_node)
+              end  &% string length
+            end  &% if char and char.string
+          end  &% for char in match
+          if changed > 20 then
+            texio.write('Too many changes. Ignoring the rest.')
+          elseif changed > 0 then
+            &% For one-to-one can we modifiy directly the
+            &% values without re-fetching? Very likely.
+            w, wn, nw = Babel.fetch_subtext(word_head)   
+          end
+
+        end  &% for match
+      end  &% for patterns
+      word_head = nw
+    end  &% for words
+    return head
+  end
+  &%%% end of preliminary code for \babelprehyphenation
+
   &% The following functions belong to the next macro
 
   &% This table stores capture maps, numbered consecutively
@@ -13011,7 +13299,6 @@
     return "]]..Babel.capt_map(m[" .. capno .. "]," ..
            (mlen) .. ").." .. "[["
   end
-
 }
 %    \end{macrocode}
 %
@@ -13048,10 +13335,10 @@
            tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
          }}}&%
     \directlua{
-      local lbkr = Babel.linebreaking.replacements
+      local lbkr = Babel.linebreaking.post_replacements
       local u = unicode.utf8
       &% Convert pattern:
-      local patt = string.gsub([[#2]], '%s', '')
+      local patt = string.gsub([==[#2]==], '%s', '')
       if not u.find(patt, '()', nil, true) then
         patt = '()' .. patt .. '()'
       end
@@ -13064,6 +13351,37 @@
                    { pattern = patt, replace = { \babeltempb } })
     }&%
   \endgroup}
+% TODO. Working !!! Copypaste pattern. 
+\gdef\babelprehyphenation#1#2#3{&%
+  \bbl at activateprehyphen
+  \begingroup
+    \def\babeltempa{\bbl at add@list\babeltempb}&%
+    \let\babeltempb\@empty
+    \bbl at foreach{#3}{&%
+      \bbl at ifsamestring{##1}{remove}&%
+        {\bbl at add@list\babeltempb{nil}}&%
+        {\directlua{
+           local rep = [[##1]]
+           rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func)
+           tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
+         }}}&%
+    \directlua{
+      local lbkr = Babel.linebreaking.pre_replacements
+      local u = unicode.utf8
+      &% Convert pattern:
+      local patt = string.gsub([==[#2]==], '%s', '')
+      if not u.find(patt, '()', nil, true) then
+        patt = '()' .. patt .. '()'
+      end
+      patt = u.gsub(patt, '{(.)}', 
+                function (n)
+                  return '%' .. (tonumber(n) and (tonumber(n)+1) or n)
+                end)
+      lbkr[\the\csname bbl at id@@#1\endcsname] = lbkr[\the\csname  bbl at id@@#1\endcsname] or {}
+      table.insert(lbkr[\the\csname bbl at id@@#1\endcsname],
+                   { pattern = patt, replace = { \babeltempb } })
+    }&%
+  \endgroup}
 \endgroup
 \def\bbl at activateposthyphen{%
   \let\bbl at activateposthyphen\relax
@@ -13070,12 +13388,16 @@
   \directlua{
     Babel.linebreaking.add_after(Babel.post_hyphenate_replace)
   }}
+% TODO. Working !!! 
+\def\bbl at activateprehyphen{%
+  \let\bbl at activateprehyphen\relax
+  \directlua{
+    Babel.linebreaking.add_before(Babel.pre_hyphenate_replace)
+  }}
 %    \end{macrocode}
 %
 % \subsection{Layout}
 %
-% \textbf{Work in progress}.
-%
 % Unlike \xetex{}, \luatex{} requires only minimal changes for
 % right-to-left layouts, particularly in monolingual documents (the
 % engine itself reverses boxes -- including column order or headings
@@ -13107,7 +13429,7 @@
   \fi
 \fi
 \ifx\bbl at opt@layout\@nnil\endinput\fi  % if no layout
-\ifx\bbl at beforeforeign\leavevmode % A poor test for bidi=
+\ifnum\bbl at bidimode>\z@
   \def\bbl at nextfake#1{%  non-local changes, use always inside a group!
     \bbl at exp{%
       \mathdir\the\bodydir  
@@ -20045,6 +20367,8 @@
 %<*cjkdata>
 Babel = Babel or {}
 
+
+
 Babel.cjk_characters = {
   [0x0021]={c='ex'},
   [0x0024]={c='pr'},

Modified: trunk/Master/texmf-dist/source/latex/babel/babel.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/babel.ins	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.ins	2020-05-14 21:24:22 UTC (rev 55143)
@@ -26,7 +26,7 @@
 %% and covered by LPPL is defined by the unpacking scripts (with
 %% extension .ins) which are part of the distribution.
 %%
-\def\filedate{2020/04/28}
+\def\filedate{2020/05/13}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 

Modified: trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx	2020-05-14 21:24:22 UTC (rev 55143)
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2020/04/28 v3.43]
+\ProvidesFile{bbcompat.dtx}[2020/05/13 v3.44]
 %</dtx>
 %
 %% File 'bbcompat.dtx'

Modified: trunk/Master/texmf-dist/source/latex/babel/locale.zip
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.def	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.def	2020-05-14 21:24:22 UTC (rev 55143)
@@ -39,7 +39,7 @@
     \wlog{File: #1 #4 #3 <#2>}%
     \let\ProvidesFile\@undefined}
 \fi
-\ProvidesFile{babel.def}[2020/04/28 3.43 Babel common definitions]
+\ProvidesFile{babel.def}[2020/05/13 3.44 Babel common definitions]
 \ifx\AtBeginDocument\@undefined  % TODO. change test.
     % == Code for plain ==
 \def\@empty{}
@@ -390,6 +390,7 @@
   \ifx\@uclclist\@undefined\let\@uclclist\@empty\fi
   \ifx\bbl at trace\@undefined\def\bbl at trace#1{}\fi
   \expandafter\newif\csname ifbbl at single\endcsname
+  \chardef\bbl at bidimode\z@
 \fi
 \ifx\bbl at trace\@undefined
   \let\LdfInit\endinput
@@ -412,8 +413,8 @@
   \countdef\last at language=19
   \def\addlanguage{\alloc at 9\language\chardef\@cclvi}
 \fi
-\def\bbl at version{3.43}
-\def\bbl at date{2020/04/28}
+\def\bbl at version{3.44}
+\def\bbl at date{2020/05/13}
 \def\adddialect#1#2{%
   \global\chardef#1#2\relax
   \bbl at usehooks{adddialect}{{#1}{#2}}%
@@ -660,13 +661,24 @@
       \csname date#1\endcsname\relax
     \fi
   \else
-    \ifbbl at usedategroup   % if \foreign... within \<lang>date
-      \bbl at usedategroupfalse
-      \ifhmode
-        \hskip\z at skip % trick to ignore spaces
+    \ifhmode
+      \hskip\z at skip % trick to ignore spaces
+      \bbl at xin@{,captions,}{,\bbl at select@opts,}%
+      \ifin@
+        \csname captions#1\endcsname\relax
+      \fi
+      \bbl at xin@{,date,}{,\bbl at select@opts,}%
+      \ifin@  % if \foreign... within \<lang>date
         \csname date#1\endcsname\relax
-        \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
-      \else
+      \fi
+      \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
+    \else
+      \bbl at xin@{,captions,}{,\bbl at select@opts,}%
+      \ifin@
+        \csname captions#1\endcsname\relax
+      \fi
+      \bbl at xin@{,date,}{,\bbl at select@opts,}%
+      \ifin@
         \csname date#1\endcsname\relax
       \fi
     \fi
@@ -709,9 +721,12 @@
   \ignorespaces}
 \long\def\endotherlanguage{%
   \global\@ignoretrue\ignorespaces}
-\expandafter\def\csname otherlanguage*\endcsname#1{%
+\expandafter\def\csname otherlanguage*\endcsname{%
+  \@ifnextchar[\bbl at otherlanguage@s{\bbl at otherlanguage@s[]}}
+\def\bbl at otherlanguage@s[#1]#2{%
   \ifnum\bbl at hymapsel=\@cclv\chardef\bbl at hymapsel4\relax\fi
-  \foreign at language{#1}}
+  \def\bbl at select@opts{#1}%
+  \foreign at language{#2}}
 \expandafter\let\csname endotherlanguage*\endcsname\relax
 \providecommand\bbl at beforeforeign{}
 \edef\foreignlanguage{%
@@ -719,13 +734,14 @@
   \expandafter\noexpand\csname foreignlanguage \endcsname}
 \expandafter\def\csname foreignlanguage \endcsname{%
   \@ifstar\bbl at foreign@s\bbl at foreign@x}
-\def\bbl at foreign@x#1#2{%
+\newcommand\bbl at foreign@x[3][]{%
   \begingroup
+    \def\bbl at select@opts{#1}%
     \let\BabelText\@firstofone
     \bbl at beforeforeign
-    \foreign at language{#1}%
+    \foreign at language{#2}%
     \bbl at usehooks{foreign}{}%
-    \BabelText{#2}% Now in horizontal mode!
+    \BabelText{#3}% Now in horizontal mode!
   \endgroup}
 \def\bbl at foreign@s#1#2{% TODO - \shapemode, \@setpar, ?\@@par
   \begingroup
@@ -740,6 +756,10 @@
 \def\foreign at language#1{%
   % set name
   \edef\languagename{#1}%
+  \ifbbl at usedategroup
+    \bbl at add\bbl at select@opts{,date,}%
+    \bbl at usedategroupfalse
+  \fi
   \bbl at fixname\languagename
   % TODO. name at map here?
   \bbl at provide@locale
@@ -2161,11 +2181,13 @@
   \DeclareTextCompositeCommand{\"}{OT1}{E}{\bbl at umlaute{E}}%
   \DeclareTextCompositeCommand{\"}{OT1}{I}{\bbl at umlaute{I}}%
   \DeclareTextCompositeCommand{\"}{OT1}{O}{\bbl at umlauta{O}}%
-  \DeclareTextCompositeCommand{\"}{OT1}{U}{\bbl at umlauta{U}}%
-}
+  \DeclareTextCompositeCommand{\"}{OT1}{U}{\bbl at umlauta{U}}}
 \ifx\l at english\@undefined
   \chardef\l at english\z@
 \fi
+\ifx\l at babelnohyhens\@undefined
+  \newlanguage\l at babelnohyphens
+\fi
 \bbl at trace{Bidi layout}
 \providecommand\IfBabelLayout[3]{#3}%
 \newcommand\BabelPatchSection[1]{%
@@ -2283,7 +2305,8 @@
   \bbl at ifunset{bbl at lname@#2}%  TODO. Duplicated
     {\def\BabelBeforeIni##1##2{%
        \begingroup
-         \catcode`\[=12 \catcode`\]=12 \catcode`\==12  \catcode`\;=12 %
+         \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+         \catcode`\;=12 \catcode`\|=12 %
          \let\bbl at ini@captions at aux\@gobbletwo
          \def\bbl at inidate ####1.####2.####3.####4\relax ####5####6{}%
          \bbl at read@ini{##1}{basic data}%
@@ -2294,7 +2317,8 @@
          \bbl at exportkey{lfthm}{typography.lefthyphenmin}{2}%
          \bbl at exportkey{rgthm}{typography.righthyphenmin}{3}%
          \bbl at exportkey{hyphr}{typography.hyphenrules}{}%
-         \bbl at exportkey{hyoth}{typography.hyphenate.other}{}%
+         \bbl at exportkey{hyotl}{typography.hyphenate.other.locale}{}%
+         \bbl at exportkey{hyots}{typography.hyphenate.other.script}{}%
          \bbl at exportkey{intsp}{typography.intraspace}{}%
          \ifx\bbl at initoload\relax\endinput\fi
        \endgroup}%
@@ -2401,11 +2425,11 @@
     \bbl at csarg\edef{intsp@#2}{\bbl at KVP@intraspace}%
   \fi
   \bbl at provide@intraspace
-  % == hyphenate.other ==
-  \bbl at ifunset{bbl at hyoth@\languagename}{}%
-    {\bbl at csarg\bbl at replace{hyoth@\languagename}{ }{,}%
+  % == hyphenate.other.locale ==
+  \bbl at ifunset{bbl at hyotl@\languagename}{}%
+    {\bbl at csarg\bbl at replace{hyotl@\languagename}{ }{,}%
      \bbl at startcommands*{\languagename}{}%
-       \bbl at csarg\bbl at foreach{hyoth@\languagename}{%
+       \bbl at csarg\bbl at foreach{hyotl@\languagename}{%
          \ifcase\bbl at engine
            \ifnum##1<257
              \SetHyphenMap{\BabelLower{##1}{##1}}%
@@ -2414,6 +2438,17 @@
            \SetHyphenMap{\BabelLower{##1}{##1}}%
          \fi}%
      \bbl at endcommands}%
+  % == hyphenate.other.script ==
+  \bbl at ifunset{bbl at hyots@\languagename}{}%
+    {\bbl at csarg\bbl at replace{hyots@\languagename}{ }{,}%
+     \bbl at csarg\bbl at foreach{hyots@\languagename}{%
+       \ifcase\bbl at engine
+         \ifnum##1<257
+           \global\lccode##1=##1\relax
+         \fi
+       \else
+         \global\lccode##1=##1\relax
+       \fi}}%
   % == maparabic ==
   % Native digits, if provided in ini (TeX level, xe and lua)
   \ifcase\bbl at engine\else
@@ -2576,7 +2611,8 @@
   \bbl at ifunset{bbl at lname@#1}%     TODO. Duplicated
     {\def\BabelBeforeIni##1##2{%
        \begingroup
-         \catcode`\[=12 \catcode`\]=12 \catcode`\==12  \catcode`\;=12 %
+         \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+         \catcode`\;=12 \catcode`\|=12 %
          \let\bbl at ini@captions at aux\@gobbletwo
          \def\bbl at inidate ####1.####2.####3.####4\relax ####5####6{}%
          \bbl at read@ini{##1}{basic data}%
@@ -2584,8 +2620,8 @@
          \bbl at exportkey{lnbrk}{typography.linebreaking}{h}%
          \bbl at exportkey{lfthm}{typography.lefthyphenmin}{2}%
          \bbl at exportkey{rgthm}{typography.righthyphenmin}{3}%
-         \bbl at exportkey{hyphr}{typography.hyphenrules}{}%
-         \bbl at exportkey{hyoth}{typography.hyphenate.other}{}%
+         \bbl at exportkey{hyotl}{typography.hyphenate.other.locale}{}%
+         \bbl at exportkey{hyots}{typography.hyphenate.other.script}{}%
          \bbl at exportkey{intsp}{typography.intraspace}{}%
          \bbl at exportkey{chrng}{characters.ranges}{}%
          \bbl at exportkey{dgnat}{numbers.digits.native}{}%
@@ -2781,6 +2817,11 @@
 \let\bbl at inikv@characters\bbl at inikv
 \let\bbl at inikv@numbers\bbl at inikv
 \def\bbl at inikv@counters#1=#2\@@{%
+  \bbl at ifsamestring{#1}{digits}%
+    {\bbl at error{The counter name 'digits' is reserved for mapping\\%
+                decimal digits}%
+               {Use another name.}}%
+    {}%
   \def\bbl at tempc{#1}%
   \bbl at trim@def{\bbl at tempb*}{#2}%
   \in@{.1$}{#1$}%
@@ -2804,7 +2845,8 @@
   \bbl at exportkey{prehc}{typography.prehyphenchar}{}%
   \bbl at exportkey{lnbrk}{typography.linebreaking}{h}%
   \bbl at exportkey{hyphr}{typography.hyphenrules}{}%
-  \bbl at exportkey{hyoth}{typography.hyphenate.other}{}%
+  \bbl at exportkey{hyotl}{typography.hyphenate.other.locale}{}%
+  \bbl at exportkey{hyots}{typography.hyphenate.other.script}{}%
   \bbl at exportkey{intsp}{typography.intraspace}{}%
   \bbl at exportkey{jstfy}{typography.justify}{w}%
   \bbl at exportkey{chrng}{characters.ranges}{}%
@@ -2844,6 +2886,7 @@
   \bbl at csarg\def{secpre at date.gregorian.licr}{%         discard uni
     \ifcase\bbl at engine\let\bbl at savedate\@empty\fi}
 \fi
+\newcommand\localedate{\@nameuse{bbl at date@\languagename}}
 \def\bbl at inidate#1.#2.#3.#4\relax#5#6{% TODO - ignore with 'captions'
   \bbl at trim@def\bbl at tempa{#1.#2}%
   \bbl at ifsamestring{\bbl at tempa}{months.wide}%      to savedate
@@ -2901,7 +2944,11 @@
   \bbl at replace\bbl at toreplace{[y]}{\BabelDatey{####1}}%
   \bbl at replace\bbl at toreplace{[yy]}{\BabelDateyy{####1}}%
   \bbl at replace\bbl at toreplace{[yyyy]}{\BabelDateyyyy{####1}}%
+  \bbl at replace\bbl at toreplace{[y|}{\bbl at datecntr[####1|}%
+  \bbl at replace\bbl at toreplace{[m|}{\bbl at datecntr[####2|}%
+  \bbl at replace\bbl at toreplace{[d|}{\bbl at datecntr[####3|}%
   \bbl at replace@finish at iii\bbl at toreplace}
+\def\bbl at datecntr[#1|#2]{\localenumeral{#2}{#1}}
 \def\bbl at provide@lsys#1{%
   \bbl at ifunset{bbl at lname@#1}%
     {\bbl at ini@basic{#1}}%
@@ -2923,7 +2970,8 @@
   \def\BabelBeforeIni##1##2{%
     \begingroup
       \bbl at add\bbl at secpost@identification{\closein\bbl at readstream }%
-      \catcode`\[=12 \catcode`\]=12 \catcode`\==12 \catcode`\;=12 %
+      \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+      \catcode`\;=12 \catcode`\|=12 %
       \bbl at read@ini{##1}{font and identification data}%
       \endinput          % babel- .tex may contain onlypreamble's
     \endgroup}%            boxed, to avoid extra spaces:
@@ -2957,7 +3005,7 @@
      \bbl at cs{cntr@#1.3@\languagename}#6%
      \bbl at cs{cntr@#1.2@\languagename}#7%
      \bbl at cs{cntr@#1.1@\languagename}#8%
-     \ifnum#6#7#8>\z@ % An ad hod rule for Greek. Ugly. To be fixed.
+     \ifnum#6#7#8>\z@ % TODO. An ad hoc rule for Greek. Ugly.
        \bbl at ifunset{bbl at cntr@#1.S.321@\languagename}{}%
          {\bbl at cs{cntr@#1.S.321@\languagename}}%
      \fi}%

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.sty	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.sty	2020-05-14 21:24:22 UTC (rev 55143)
@@ -33,7 +33,7 @@
 %%
 
 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
-\ProvidesPackage{babel}[2020/04/28 3.43 The Babel package]
+\ProvidesPackage{babel}[2020/05/13 3.44 The Babel package]
 \@ifpackagewith{babel}{debug}
   {\providecommand\bbl at trace[1]{\message{^^J[ #1 ]}}%
    \let\bbl at debug\@firstofone}
@@ -285,61 +285,6 @@
   \global\let\@ifl at ter@@\@ifl at ter
   \def\@ifl at ter#1#2#3#4#5{\global\let\@ifl at ter\@ifl at ter@@}%
   \endinput}{}%
-\ifodd\bbl at engine
-  \def\bbl at activate@preotf{%
-    \let\bbl at activate@preotf\relax  % only once
-    \directlua{
-      Babel = Babel or {}
-      %
-      function Babel.pre_otfload_v(head)
-        if Babel.numbers and Babel.digits_mapped then
-          head = Babel.numbers(head)
-        end
-        if Babel.bidi_enabled then
-          head = Babel.bidi(head, false, dir)
-        end
-        return head
-      end
-      %
-      function Babel.pre_otfload_h(head, gc, sz, pt, dir)
-        if Babel.numbers and Babel.digits_mapped then
-          head = Babel.numbers(head)
-        end
-        if Babel.bidi_enabled then
-          head = Babel.bidi(head, false, dir)
-        end
-        return head
-      end
-      %
-      luatexbase.add_to_callback('pre_linebreak_filter',
-        Babel.pre_otfload_v,
-        'Babel.pre_otfload_v',
-        luatexbase.priority_in_callback('pre_linebreak_filter',
-          'luaotfload.node_processor') or nil)
-      %
-      luatexbase.add_to_callback('hpack_filter',
-        Babel.pre_otfload_h,
-        'Babel.pre_otfload_h',
-        luatexbase.priority_in_callback('hpack_filter',
-          'luaotfload.node_processor') or nil)
-    }}
-  \let\bbl at tempa\relax
-  \@ifpackagewith{babel}{bidi=basic}%
-    {\def\bbl at tempa{basic}}%
-    {\@ifpackagewith{babel}{bidi=basic-r}%
-      {\def\bbl at tempa{basic-r}}%
-      {}}
-  \ifx\bbl at tempa\relax\else
-    \let\bbl at beforeforeign\leavevmode
-    \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
-    \RequirePackage{luatexbase}%
-    \directlua{
-      require('babel-data-bidi.lua')
-      require('babel-bidi-\bbl at tempa.lua')
-    }
-    \bbl at activate@preotf
-  \fi
-\fi
 \bbl at trace{key=value and another general options}
 \bbl at csarg\let{tempa\expandafter}\csname opt at babel.sty\endcsname
 \def\bbl at tempb#1.#2{%
@@ -384,63 +329,13 @@
 \DeclareOption{hyphenmap=select}{\chardef\bbl at opt@hyphenmap\tw@}
 \DeclareOption{hyphenmap=other}{\chardef\bbl at opt@hyphenmap\thr@@}
 \DeclareOption{hyphenmap=other*}{\chardef\bbl at opt@hyphenmap4\relax}
-\ifodd\bbl at engine
-  \DeclareOption{bidi=basic-r}%
-    {\ExecuteOptions{bidi=basic}}
-  \DeclareOption{bidi=basic}%
-    {\let\bbl at beforeforeign\leavevmode
-     % TODO - to locale_props, not as separate attribute
-     \newattribute\bbl at attr@dir
-     % I don't like it, hackish:
-     \frozen at everymath\expandafter{%
-       \expandafter\bbl at mathboxdir\the\frozen at everymath}%
-     \frozen at everydisplay\expandafter{%
-       \expandafter\bbl at mathboxdir\the\frozen at everydisplay}%
-     \bbl at exp{\output{\bodydir\pagedir\the\output}}%
-     \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
-\else
-  \DeclareOption{bidi=basic-r}%
-    {\ExecuteOptions{bidi=basic}}
-  \DeclareOption{bidi=basic}%
-    {\bbl at error
-      {The bidi method `basic' is available only in\\%
-       luatex. I'll continue with `bidi=default', so\\%
-       expect wrong results}%
-      {See the manual for further details.}%
-    \let\bbl at beforeforeign\leavevmode
-    \AtEndOfPackage{%
-      \EnableBabelHook{babel-bidi}%
-      \bbl at xebidipar}}
-  \def\bbl at loadxebidi#1{%
-    \ifx\RTLfootnotetext\@undefined
-      \AtEndOfPackage{%
-        \EnableBabelHook{babel-bidi}%
-        \ifx\fontspec\@undefined
-          \usepackage{fontspec}% bidi needs fontspec
-        \fi
-        \usepackage#1{bidi}}%
-    \fi}
-  \DeclareOption{bidi=bidi}%
-    {\bbl at tentative{bidi=bidi}%
-     \bbl at loadxebidi{}}
-  \DeclareOption{bidi=bidi-r}%
-    {\bbl at tentative{bidi=bidi-r}%
-     \bbl at loadxebidi{[rldocument]}}
-  \DeclareOption{bidi=bidi-l}%
-    {\bbl at tentative{bidi=bidi-l}%
-     \bbl at loadxebidi{}}
-\fi
-\DeclareOption{bidi=default}%
-  {\let\bbl at beforeforeign\leavevmode
-   \ifodd\bbl at engine
-     \newattribute\bbl at attr@dir
-     \bbl at exp{\output{\bodydir\pagedir\the\output}}%
-   \fi
-   \AtEndOfPackage{%
-     \EnableBabelHook{babel-bidi}%
-     \ifodd\bbl at engine\else
-       \bbl at xebidipar
-     \fi}}
+\chardef\bbl at bidimode\z@
+\DeclareOption{bidi=default}{\chardef\bbl at bidimode=\@ne}
+\DeclareOption{bidi=basic}{\chardef\bbl at bidimode=101 }
+\DeclareOption{bidi=basic-r}{\chardef\bbl at bidimode=102 }
+\DeclareOption{bidi=bidi}{\chardef\bbl at bidimode=201 }
+\DeclareOption{bidi=bidi-r}{\chardef\bbl at bidimode=202 }
+\DeclareOption{bidi=bidi-l}{\chardef\bbl at bidimode=203 }
 \let\bbl at opt@shorthands\@nnil
 \let\bbl at opt@config\@nnil
 \let\bbl at opt@main\@nnil
@@ -778,9 +673,114 @@
 \else
   \DeclareTextFontCommand{\textlatin}{\latintext}
 \fi
-\bbl at trace{Basic (internal) bidi support}
+\ifodd\bbl at engine
+  \def\bbl at activate@preotf{%
+    \let\bbl at activate@preotf\relax  % only once
+    \directlua{
+      Babel = Babel or {}
+      %
+      function Babel.pre_otfload_v(head)
+        if Babel.numbers and Babel.digits_mapped then
+          head = Babel.numbers(head)
+        end
+        if Babel.bidi_enabled then
+          head = Babel.bidi(head, false, dir)
+        end
+        return head
+      end
+      %
+      function Babel.pre_otfload_h(head, gc, sz, pt, dir)
+        if Babel.numbers and Babel.digits_mapped then
+          head = Babel.numbers(head)
+        end
+        if Babel.bidi_enabled then
+          head = Babel.bidi(head, false, dir)
+        end
+        return head
+      end
+      %
+      luatexbase.add_to_callback('pre_linebreak_filter',
+        Babel.pre_otfload_v,
+        'Babel.pre_otfload_v',
+        luatexbase.priority_in_callback('pre_linebreak_filter',
+          'luaotfload.node_processor') or nil)
+      %
+      luatexbase.add_to_callback('hpack_filter',
+        Babel.pre_otfload_h,
+        'Babel.pre_otfload_h',
+        luatexbase.priority_in_callback('hpack_filter',
+          'luaotfload.node_processor') or nil)
+    }}
+\fi
+\bbl at trace{Loading basic (internal) bidi support}
+\ifodd\bbl at engine
+  \ifnum\bbl at bidimode>100 \ifnum\bbl at bidimode<200
+    \let\bbl at beforeforeign\leavevmode
+    \AtEndOfPackage{\EnableBabelHook{babel-bidi}}
+    \RequirePackage{luatexbase}
+    \bbl at activate@preotf
+    \directlua{
+      require('babel-data-bidi.lua')
+      \ifcase\expandafter\@gobbletwo\the\bbl at bidimode\or
+        require('babel-bidi-basic.lua')
+      \or
+        require('babel-bidi-basic-r.lua')
+      \fi}
+    % TODO - to locale_props, not as separate attribute
+    \newattribute\bbl at attr@dir
+    % TODO. I don't like it, hackish:
+    \bbl at exp{\output{\bodydir\pagedir\the\output}}
+    \AtEndOfPackage{\EnableBabelHook{babel-bidi}}
+  \fi\fi
+\else
+  \ifnum\bbl at bidimode>100 \ifnum\bbl at bidimode<200
+    \bbl at error
+      {The bidi method `basic' is available only in\\%
+       luatex. I'll continue with `bidi=default', so\\%
+       expect wrong results}%
+      {See the manual for further details.}%
+    \let\bbl at beforeforeign\leavevmode
+    \AtEndOfPackage{%
+      \EnableBabelHook{babel-bidi}%
+      \bbl at xebidipar}
+  \fi\fi
+  \def\bbl at loadxebidi#1{%
+    \ifx\RTLfootnotetext\@undefined
+      \AtEndOfPackage{%
+        \EnableBabelHook{babel-bidi}%
+        \ifx\fontspec\@undefined
+          \usepackage{fontspec}% bidi needs fontspec
+        \fi
+        \usepackage#1{bidi}}%
+    \fi}
+  \ifnum\bbl at bidimode>200
+    \ifcase\expandafter\@gobbletwo\the\bbl at bidimode\or
+      \bbl at tentative{bidi=bidi}
+      \bbl at loadxebidi{}
+    \or
+      \bbl at tentative{bidi=bidi-r}
+      \bbl at loadxebidi{[rldocument]}
+    \or
+      \bbl at tentative{bidi=bidi-l}
+      \bbl at loadxebidi{}
+    \fi
+  \fi
+\fi
+\ifnum\bbl at bidimode=\@ne
+  \let\bbl at beforeforeign\leavevmode
+  \ifodd\bbl at engine
+    \newattribute\bbl at attr@dir
+    \bbl at exp{\output{\bodydir\pagedir\the\output}}%
+  \fi
+  \AtEndOfPackage{%
+    \EnableBabelHook{babel-bidi}%
+    \ifodd\bbl at engine\else
+      \bbl at xebidipar
+    \fi}
+\fi
+\bbl at trace{Macros to switch the text direction}
 \def\bbl at alscripts{,Arabic,Syriac,Thaana,}
-\def\bbl at rscripts{%
+\def\bbl at rscripts{% TODO. Base on codes ??
   ,Imperial Aramaic,Avestan,Cypriot,Hatran,Hebrew,%
   Old Hungarian,Old Hungarian,Lydian,Mandaean,Manichaean,%
   Manichaean,Meroitic Cursive,Meroitic,Old North Arabian,%
@@ -817,9 +817,9 @@
     \bbl at pardir{#1}%
   \fi
   \bbl at textdir{#1}}
+\AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
+\DisableBabelHook{babel-bidi}
 \ifodd\bbl at engine  % luatex=1
-  \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
-  \DisableBabelHook{babel-bidi}
   \chardef\bbl at thetextdir\z@
   \chardef\bbl at thepardir\z@
   \def\bbl at getluadir#1{%
@@ -857,9 +857,11 @@
     \else
       \everyhbox{\textdir TRT\relax}%
     \fi}
+  \frozen at everymath\expandafter{%
+    \expandafter\bbl at mathboxdir\the\frozen at everymath}
+  \frozen at everydisplay\expandafter{%
+    \expandafter\bbl at mathboxdir\the\frozen at everydisplay}
 \else % pdftex=0, xetex=2
-  \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
-  \DisableBabelHook{babel-bidi}
   \newcount\bbl at dirlevel
   \chardef\bbl at thetextdir\z@
   \chardef\bbl at thepardir\z@
@@ -916,20 +918,18 @@
     \newtoks\everypar
     \everypar=\bbl at severypar
     \bbl at severypar{\bbl at xeeverypar\the\everypar}}
-  \def\bbl at tempb{%
+  \ifnum\bbl at bidimode>200
     \let\bbl at textdir@i\@gobbletwo
     \let\bbl at xebidipar\@empty
     \AddBabelHook{bidi}{foreign}{%
-      \def\bbl at tempa{\def\BabelText########1}%
+      \def\bbl at tempa{\def\BabelText####1}%
       \ifcase\bbl at thetextdir
-        \expandafter\bbl at tempa\expandafter{\BabelText{\LR{####1}}}%
+        \expandafter\bbl at tempa\expandafter{\BabelText{\LR{##1}}}%
       \else
-        \expandafter\bbl at tempa\expandafter{\BabelText{\RL{####1}}}%
+        \expandafter\bbl at tempa\expandafter{\BabelText{\RL{##1}}}%
       \fi}
-    \def\bbl at pardir##1{\ifcase##1\relax\setLR\else\setRL\fi}}
-  \@ifpackagewith{babel}{bidi=bidi}{\bbl at tempb}{}%
-  \@ifpackagewith{babel}{bidi=bidi-l}{\bbl at tempb}{}%
-  \@ifpackagewith{babel}{bidi=bidi-r}{\bbl at tempb}{}%
+    \def\bbl at pardir#1{\ifcase#1\relax\setLR\else\setRL\fi}
+  \fi
 \fi
 \DeclareRobustCommand\babelsublr[1]{\leavevmode{\bbl at textdir\z@#1}}
 \AtBeginDocument{%
@@ -984,8 +984,6 @@
       {\bbl at load@language{\CurrentOption}}%
       {#1\bbl at load@language{#2}#3}}
 \DeclareOption{afrikaans}{\bbl at try@load at lang{}{dutch}{}}
-\DeclareOption{brazil}{\bbl at try@load at lang{}{portuges}{}}
-\DeclareOption{brazilian}{\bbl at try@load at lang{}{portuges}{}}
 \DeclareOption{hebrew}{%
   \input{rlbabel.def}%
   \bbl at load@language{hebrew}}
@@ -994,7 +992,6 @@
 \DeclareOption{nynorsk}{\bbl at try@load at lang{}{norsk}{}}
 \DeclareOption{polutonikogreek}{%
   \bbl at try@load at lang{}{greek}{\languageattribute{greek}{polutoniko}}}
-\DeclareOption{portuguese}{\bbl at try@load at lang{}{portuges}{}}
 \DeclareOption{russian}{\bbl at try@load at lang{}{russianb}{}}
 \DeclareOption{ukrainian}{\bbl at try@load at lang{}{ukraineb}{}}
 \DeclareOption{uppersorbian}{\bbl at try@load at lang{}{usorbian}{}}

Modified: trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg	2020-05-14 21:24:22 UTC (rev 55143)
@@ -37,10 +37,10 @@
     \wlog{File: #1 #4 #3 <#2>}%
     \let\ProvidesFile\@undefined}
 \fi
-\ProvidesFile{hyphen.cfg}[2020/04/28 3.43 Babel hyphens]
+\ProvidesFile{hyphen.cfg}[2020/05/13 3.44 Babel hyphens]
 \xdef\bbl at format{\jobname}
-\def\bbl at version{3.43}
-\def\bbl at date{2020/04/28}
+\def\bbl at version{3.44}
+\def\bbl at date{2020/05/13}
 \ifx\AtBeginDocument\@undefined
   \def\@empty{}
   \let\orig at dump\dump

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/af/babel-af.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/af/babel-af.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/af/babel-af.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05
 name.local = Afrikaans
 name.english = Afrikaans
 name.babel = afrikaans
@@ -157,7 +157,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27 "2D
+hyphenate.other.locale = "27 "2D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/am/babel-am.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/am/babel-am.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/am/babel-am.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.1
-date = 2020-03-22
+version = 1.2
+date = 2020-05-05
 name.local = አማርኛ
 name.english = Amharic
 name.babel = amharic
@@ -148,9 +148,10 @@
 
 [typography]
 frenchspacing = 
-hyphenrules = 
-lefthyphenmin = 2
-righthyphenmin = 2
+; Modern practice. Use 'amharic' for the traditional one:
+hyphenrules = babelnohyphens
+lefthyphenmin = 1
+righthyphenmin = 1
 hyphenchar = 
 prehyphenchar = 
 posthyphenchar = 
@@ -158,8 +159,13 @@
 preexhyphenchar = 
 postexhyphenchar = 
 hyphenationmin = 
+linebreaking = s
+intraspace = 0 .1 0
+; The syntax is liable to change in 'other' values
+hyphenate.other.script = "1361 "1362 "1363 "1364 "1365 "1366 "1367 "1368
 
 [characters]
+ranges = 1200..139F 2D80..2DDF AB00..AB2F
 delimiters.quotes = «»‹›
 auxiliary = []
 exemplarCharacters = [ሀ ሁ ሂ ሃ ሄ ህ ሆ ለ ሉ ሊ ላ ሌ ል ሎ ሏ ሐ ሑ ሒ ሓ ሔ ሕ ሖ ሗ መ ሙ ሚ ማ ሜ ም ሞ ሟ ሠ ሡ ሢ ሣ ሤ ሥ ሦ ሧ ረ ሩ ሪ ራ ሬ ር ሮ ሯ ሰ ሱ ሲ ሳ ሴ ስ ሶ ሷ ሸ ሹ ሺ ሻ ሼ ሽ ሾ ሿ ቀ ቁ ቂ ቃ ቄ ቅ ቆ ቈ ቊ ቋ ቌ ቍ በ ቡ ቢ ባ ቤ ብ ቦ ቧ ቨ ቩ ቪ ቫ ቬ ቭ ቮ ቯ ተ ቱ ቲ ታ ቴ ት ቶ ቷ ቸ ቹ ቺ ቻ ቼ ች ቾ ቿ ኀ ኁ ኂ ኃ ኄ ኅ ኆ ኈ ኊ ኋ ኌ ኍ ነ ኑ ኒ ና ኔ ን ኖ ኗ ኘ ኙ ኚ ኛ ኜ ኝ ኞ ኟ አ ኡ ኢ ኣ ኤ እ ኦ ኧ ከ ኩ ኪ ካ ኬ ክ ኮ ኰ ኲ ኳ ኴ ኵ ኸ ኹ ኺ ኻ ኼ ኽ ኾ ወ ዉ ዊ ዋ ዌ ው ዎ ዐ ዑ ዒ ዓ ዔ ዕ ዖ ዘ ዙ ዚ ዛ ዜ ዝ ዞ ዟ ዠ ዡ ዢ ዣ ዤ ዥ ዦ ዧ የ ዩ ዪ ያ ዬ ይ ዮ ደ ዱ ዲ ዳ ዴ ድ ዶ ዷ ጀ ጁ ጂ ጃ ጄ ጅ ጆ ጇ ገ ጉ ጊ ጋ ጌ ግ ጎ ጐ ጒ ጓ ጔ ጕ ጠ ጡ ጢ ጣ ጤ ጥ ጦ ጧ ጨ ጩ ጪ ጫ ጬ ጭ ጮ ጯ ጰ ጱ ጲ ጳ ጴ ጵ ጶ ጷ ጸ ጹ ጺ ጻ ጼ ጽ ጾ ጿ ፀ ፁ ፂ ፃ ፄ ፅ ፆ ፈ ፉ ፊ ፋ ፌ ፍ ፎ ፏ ፐ ፑ ፒ ፓ ፔ ፕ ፖ ፗ]
@@ -181,3 +187,28 @@
 superscriptingExponent = ×
 
 [counters]
+; suffix is ፦
+; These counters actually belong to different Ethiopic languages
+; They have been taken directly from CSS
+afar    = ሀ ለ ሐ መ ረ ሰ በ ተ ነ አ ከ ወ ዐ የ ደ ዸ ገ ጸ ፈ
+agaw    = ሀ ለ ሐ መ ረ ሰ ሸ ቀ ቐ በ ቨ ተ ቸ ነ ኘ ጀ ገ ጘ ጠ ጨ ጰ ጸ ፈ ፐ
+ari     = ሀ ለ መ ረ ሰ ሸ በ ቨ ተ ቸ ነ ጀ ገ ጨ ፀ ፐ
+blin    = ሀ ለ ሐ መ ሰ ሸ ረ ቀ ቐ በ ተ ነ ጀ ገ ጘ ጠ ጨ ፈ ቸ ኘ ጸ ጰ ፐ
+dizi    = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ኘ ጀ ገ ጠ ጨ ጸ ፀ ፈ
+gedeo   = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ጀ ገ ጠ ጨ ጰ ጸ ፈ ፐ
+gumuz   = ሀ ሐ ለ ሐ መ ረ ሰ ሸ ቀ በ ቨ ተ ቸ ነ ኘ ገ ጨ ጰ ፀ ፐ
+hadiyya = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ጀ ገ ጠ ጨ ጰ ፈ ፐ
+harari  = ሐ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ኘ ጀ ገ ጠ ጨ ፈ
+kaffa   = ሀ ለ ሐ መ ሠ ረ ሰ ሸ ቀ በ ተ ቸ ኀ ነ ጀ ገ ጠ ጨ ጰ ፈ ፐ
+kebena  = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ጀ ገ ጠ ጨ ጰ ፈ ፐ
+kembata = ሀ ለ መ ረ ሰ ሸ ቀ በ ቨ ተ ቸ ነ ጀ ገ ጠ ጨ ጰ ፈ
+konso   = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ኘ ጀ ፈ ፐ
+kunama  = ሀ ለ መ ረ ሰ ሸ በ ተ ቸ ነ ኘ ጀ ገ
+meen    = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ኀ ነ ኘ ጀ ገ ጠ ጨ ጰ ፐ ፀ
+oromo   = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ኘ አ ከ ወ የ ደ ዸ ጀ ገ ጠ ጨ ጰ ጸ ፈ
+saho    = ሀ ለ ሐ መ ረ ሰ ቀ በ ተ ነ ገ ጠ ጨ ጰ ጸ ፈ
+sidama  = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ኘ አ ከ ወ የ ደ ዸ ጀ ገ ጠ ጨ ጰ ጸ ፈ
+silti   = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ኘ ጀ ገ ጠ ጨ ጰ ፈ
+tigre   = ሀ ለ ሐ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ አ ከ ወ ዐ ዘ የ ደ ጀ ገ ጠ ጨ ጰ ጸ ፈ ፐ
+wolaita = ሀ ለ መ ረ ሰ ሸ ቀ በ ተ ቸ ነ ኘ ሰ ገ ጠ ጨ ጰ ጸ ፀ ፈ ፐ
+yemsa   = ሀ ለ መ ረ ሰ ሸ ቀ በ ቨ ተ ቸ ነ ኘ ጀ ገ ጘ ጠ ጨ ጰ ፈ ፐ
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/as/babel-as.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/as/babel-as.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/as/babel-as.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -12,8 +12,8 @@
 
 [identification]
 charset = utf8
-version = 1.5
-date = 2020-04-07
+version = 1.6
+date = 2020-05-05
 name.local = অসমীয়া
 name.english = Assamese
 name.babel = assamese
@@ -122,7 +122,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/be/babel-be.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/be/babel-be.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/be/babel-be.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.3
-date = 2020-03-22
+version = 1.4
+date = 2020-05-05
 name.local = беларуская
 name.english = Belarusian
 name.babel = belarusian
@@ -159,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27 "2D 
+hyphenate.other.locale = "27 "2D 
 
 [characters]
 delimiters.quotes = «»„“

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/bn/babel-bn.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/bn/babel-bn.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/bn/babel-bn.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.5
-date = 2020-04-22
+version = 1.6
+date = 2020-05-05
 name.local = বাংলা
 name.english = Bangla
 name.babel = bengali
@@ -122,7 +122,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu-Cyrs.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu-Cyrs.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu-Cyrs.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -9,8 +9,8 @@
 
 [identification]
 charset = utf8
-version = 1.1
-date = 2020-03-22
+version = 1.2
+date = 2020-05-05
 name.local = словѣ́ньскъ ѩꙁꙑ́къ
 name.english = Church Slavic
 name.babel = churchslavic-oldcyrillic
@@ -81,7 +81,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "2D 
+hyphenate.other.locale = "2D 
 
 [characters]
 delimiters.quotes.0 = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/cu/babel-cu.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -9,8 +9,8 @@
 
 [identification]
 charset = utf8
-version = 1.1
-date = 2020-03-22
+version = 1.2
+date = 2020-05-05
 name.local = црькъвьнословѣньскъ ѩзыкъ
 name.english = Church Slavic
 name.babel = churchslavic churchslavonic
@@ -81,7 +81,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "2D 
+hyphenate.other.locale = "2D 
 
 [characters]
 delimiters.quotes.0 = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el-polyton.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el-polyton.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el-polyton.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -4,8 +4,8 @@
 
 [identification]
 charset             = utf8
-version = 0.4
-date = 2020-03-22
+version = 0.5
+date = 2020-05-05
 name.local          = Ἐλληνικά
 ; Name from https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
 name.english        = Polytonic Greek
@@ -154,7 +154,8 @@
 postexhyphenchar = 
 hyphenationmin   = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "0027 "2019 "02BC "1FBD "1FBF
+hyphenate.other.locale = "0027 "2019 "02BC
+hyphenate.other.script = "1FBD "1FBF
 
 [characters]
 delimiters.quotes  = «»“”

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/el/babel-el.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.3
-date = 2020-03-22
+version = 1.4
+date = 2020-05-05
 name.local = Ελληνικά
 name.english = Greek
 name.babel = greek
@@ -160,7 +160,8 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "0027 "2019 "02BC "1FBD "1FBF
+hyphenate.other.locale = "0027 "2019 "02BC
+hyphenate.other.script = "1FBD "1FBF
 
 [characters]
 delimiters.quotes = «»“”

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-BE.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-BE.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-BE.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.96
-date = 2020-03-22
+version = 0.97
+date = 2020-05-05
 name.local = français
 name.english = French
 name.babel = french-belgium french-be
@@ -27,7 +27,6 @@
 level = 1
 encodings = T1 OT1 LY1
 derivate = no
-warning = The `french' date format may not be suitable\\for proper typesetting, and therefore very likely\\it will change in a future release.
 
 [captions]
 preface = Préface
@@ -76,7 +75,7 @@
 glossary = Glossaire
 
 [date.gregorian]
-date.long = [d] [MMMM] [y]
+date.long = [d|date.day] [MMMM] [y]
 date.short = [d]/[MM]/[yy]
 months.wide.1 = janvier
 months.wide.2 = février
@@ -161,7 +160,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27 
+hyphenate.other.locale = "27 
 
 [characters]
 delimiters.quotes = «»«»
@@ -186,3 +185,4 @@
 superscriptingExponent = ×
 
 [counters]
+date.day = 1\textsuperscript{er} 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CA.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CA.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CA.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.96
-date = 2020-03-22
+version = 0.97
+date = 2020-05-05
 name.local = français
 name.english = French
 name.babel = french-canada
@@ -28,7 +28,6 @@
 level = 1
 encodings = T1 OT1 LY1
 derivate = no
-warning = The `french' date format may not be suitable\\for proper typesetting, and therefore very likely\\it will change in a future release.
 
 [captions]
 preface = Préface
@@ -77,7 +76,7 @@
 glossary = Glossaire
 
 [date.gregorian]
-date.long = [d] [MMMM] [y]
+date.long = [d|date.day] [MMMM] [y]
 date.short = [yy]-[MM]-[dd]
 months.wide.1 = janvier
 months.wide.2 = février
@@ -162,7 +161,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27
+hyphenate.other.locale = "27
 
 [characters]
 delimiters.quotes = «»”“
@@ -187,3 +186,4 @@
 superscriptingExponent = ×
 
 [counters]
+date.day = 1\textsuperscript{er} 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CH.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CH.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-CH.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.96
-date = 2020-03-22
+version = 0.97
+date = 2020-05-05
 name.local = français
 name.english = French
 name.babel = french-switzerland
@@ -28,7 +28,6 @@
 level = 1
 encodings = T1 OT1 LY1
 derivate = no
-warning = The `french' date format may not be suitable\\for proper typesetting, and therefore very likely\\it will change in a future release.
 
 [captions]
 preface = Préface
@@ -77,7 +76,7 @@
 glossary = Glossaire
 
 [date.gregorian]
-date.long = [d] [MMMM] [y]
+date.long = [d|date.day] [MMMM] [y]
 date.short = [dd].[MM].[yy]
 months.wide.1 = janvier
 months.wide.2 = février
@@ -162,7 +161,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27
+hyphenate.other.locale = "27
 
 [characters]
 delimiters.quotes = «»‹›
@@ -187,3 +186,4 @@
 superscriptingExponent = ×
 
 [counters]
+date.day = 1\textsuperscript{er} 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-LU.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-LU.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr-LU.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.96
-date = 2020-03-22
+version = 0.97
+date = 2020-05-05
 name.local = français
 name.english = French
 name.babel = french-luxembourg
@@ -28,7 +28,6 @@
 level = 1
 encodings = T1 OT1 LY1
 derivate = no
-warning = The `french' date format may not be suitable\\for proper typesetting, and therefore very likely\\it will change in a future release.
 
 [captions]
 preface = Préface
@@ -77,7 +76,7 @@
 glossary = Glossaire
 
 [date.gregorian]
-date.long = [d] [MMMM] [y]
+date.long = [d|date.day] [MMMM] [y]
 date.short = [dd]/[MM]/[y]
 months.wide.1 = janvier
 months.wide.2 = février
@@ -162,7 +161,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27 
+hyphenate.other.locale = "27 
 
 [characters]
 delimiters.quotes = «»«»
@@ -187,3 +186,4 @@
 superscriptingExponent = ×
 
 [counters]
+date.day = 1\textsuperscript{er} 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/fr/babel-fr.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.96
-date = 2020-03-22
+version = 0.97
+date = 2020-05-05
 name.local = français
 name.english = French
 name.babel = french
@@ -26,7 +26,6 @@
 level = 1
 encodings = T1 OT1 LY1
 derivate = no
-warning = The `french' date format may not be suitable\\for proper typesetting, and therefore very likely\\it will change in a future release.
 
 [captions]
 preface = Préface
@@ -75,7 +74,7 @@
 glossary = Glossaire
 
 [date.gregorian]
-date.long = [d] [MMMM] [y]
+date.long = [d|date.day] [MMMM] [y]
 date.short = [dd]/[MM]/[y]
 months.wide.1 = janvier
 months.wide.2 = février
@@ -160,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27
+hyphenate.other.locale = "27
 
 [characters]
 delimiters.quotes = «»«»
@@ -185,3 +184,4 @@
 superscriptingExponent = ×
 
 [counters]
+date.day = 1\textsuperscript{er} 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
\ No newline at end of file

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/fur/babel-fur.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/fur/babel-fur.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/fur/babel-fur.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05
 name.local = furlan
 name.english = Friulian
 name.babel = friulian
@@ -159,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27
+hyphenate.other.locale = "27
 
 [characters]
 delimiters.quotes = ‘’“”

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/grc/babel-grc.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/grc/babel-grc.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/grc/babel-grc.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05 
 name.local = Αρχαία ελληνικά
 name.english = Ancient Greek 
 name.babel = greek
@@ -147,7 +147,8 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "0027 "2019 "02BC "1FBD "1FBF
+hyphenate.other.locale = "0027 "2019 "02BC
+hyphenate.other.script = "1FBD "1FBF
 
 [characters]
 delimiters.quotes = «»“”

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/gu/babel-gu.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/gu/babel-gu.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/gu/babel-gu.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = ગુજરાતી
 name.english = Gujarati
 name.babel = gujarati
@@ -144,7 +144,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/hi/babel-hi.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/hi/babel-hi.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/hi/babel-hi.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -12,8 +12,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = हिन्दी
 name.english = Hindi
 name.babel = hindi
@@ -172,7 +172,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/hy/babel-hy.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/hy/babel-hy.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/hy/babel-hy.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -13,8 +13,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-04-20
+version = 1.5
+date = 2020-05-05
 name.local = հայերեն
 name.english = Armenian
 name.babel = armenian
@@ -147,7 +147,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = «»«»

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/it/babel-it.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/it/babel-it.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/it/babel-it.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05
 name.local = italiano
 name.english = Italian
 name.babel = italian
@@ -159,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27 
+hyphenate.other.locale = "27 
 
 [characters]
 delimiters.quotes = «»“”

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/kn/babel-kn.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/kn/babel-kn.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/kn/babel-kn.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = ಕನ್ನಡ
 name.english = Kannada
 name.babel = kannada
@@ -127,7 +127,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/ml/babel-ml.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/ml/babel-ml.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/ml/babel-ml.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = മലയാളം
 name.english = Malayalam
 name.babel = malayalam
@@ -133,7 +133,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/mr/babel-mr.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/mr/babel-mr.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/mr/babel-mr.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -12,8 +12,8 @@
 
 [identification]
 charset = utf8
-version = 1.5
-date = 2020-04-23
+version = 1.6
+date = 2020-05-05
 name.local = मराठी
 name.english = Marathi
 name.babel = marathi
@@ -123,7 +123,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/oc/babel-oc.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/oc/babel-oc.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/oc/babel-oc.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.96
-date = 2020-03-22
+version = 0.97
+date = 2020-05-05
 name.english = Occitan
 name.babel = occitan
 name.polyglossia = occitan
@@ -115,7 +115,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27 
+hyphenate.other.locale = "27 
 
 [characters]
 delimiters.quotes = 

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/or/babel-or.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/or/babel-or.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/or/babel-or.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = ଓଡ଼ିଆ
 name.english = Odia
 name.babel = oriya
@@ -144,7 +144,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa-Guru.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa-Guru.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa-Guru.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = ਪੰਜਾਬੀ
 name.english = Punjabi
 name.babel = punjabi-gurmukhi punjabi-guru
@@ -143,7 +143,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/pa/babel-pa.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = ਪੰਜਾਬੀ
 name.english = Punjabi
 name.babel = punjabi
@@ -144,7 +144,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/pms/babel-pms.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/pms/babel-pms.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/pms/babel-pms.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -12,7 +12,7 @@
 [identification]
 charset = utf8
 version = 1.2
-date = 2020-03-22
+date = 2020-05-05
 name.english = Piedmontese
 name.babel = piedmontese
 name.polyglossia = piedmontese
@@ -114,7 +114,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27
+hyphenate.other.locale = "27
 
 [characters]
 delimiters.quotes = 

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-BR.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-BR.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-BR.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05
 name.local = português
 name.english = Portuguese
 name.babel = brazilian portuguese-brazil portuguese-br
@@ -162,7 +162,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "2D 
+hyphenate.other.locale = "2D 
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-PT.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-PT.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt-PT.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-04
 name.local = português
 name.english = Portuguese
 name.babel = portuguese portuguese-portugal portuguese-pt
@@ -79,18 +79,18 @@
 [date.gregorian]
 date.long = [d] de [MMMM] de [y]
 date.short = [dd]/[MM]/[y]
-months.wide.1 = Janeiro
-months.wide.2 = Fevereiro
-months.wide.3 = Março
-months.wide.4 = Abril
-months.wide.5 = Maio
-months.wide.6 = Junho
-months.wide.7 = Julho
-months.wide.8 = Agosto
-months.wide.9 = Setembro
-months.wide.10 = Outubro
-months.wide.11 = Novembro
-months.wide.12 = Dezembro
+months.wide.1 = janeiro
+months.wide.2 = fevereiro
+months.wide.3 = março
+months.wide.4 = abril
+months.wide.5 = maio
+months.wide.6 = junho
+months.wide.7 = julho
+months.wide.8 = agosto
+months.wide.9 = setembro
+months.wide.10 = outubro
+months.wide.11 = novembro
+months.wide.12 = dezembro
 months.narrow.1 = J
 months.narrow.2 = F
 months.narrow.3 = M
@@ -132,18 +132,18 @@
 dayPeriods.wide.pm = PM
 
 [date.gregorian.licr]
-months.wide.1 = Janeiro
-months.wide.2 = Fevereiro
-months.wide.3 = Mar\c co
-months.wide.4 = Abril
-months.wide.5 = Maio
-months.wide.6 = Junho
-months.wide.7 = Julho
-months.wide.8 = Agosto
-months.wide.9 = Setembro
-months.wide.10 = Outubro
-months.wide.11 = Novembro
-months.wide.12 = Dezembro
+months.wide.1 = janeiro
+months.wide.2 = fevereiro
+months.wide.3 = mar\c co
+months.wide.4 = abril
+months.wide.5 = maio
+months.wide.6 = junho
+months.wide.7 = julho
+months.wide.8 = agosto
+months.wide.9 = setembro
+months.wide.10 = outubro
+months.wide.11 = novembro
+months.wide.12 = dezembro
 
 [time.gregorian]
 time.medium = [HH]:[mm]:[ss]
@@ -162,7 +162,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "2D 
+hyphenate.other.locale = "2D 
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/pt/babel-pt.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05
 name.local = português
 name.english = Portuguese
 name.babel = portuguese
@@ -159,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "2D 
+hyphenate.other.locale = "2D 
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/rm/babel-rm.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/rm/babel-rm.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/rm/babel-rm.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05
 name.local = rumantsch
 name.english = Romansh
 name.babel = romansh
@@ -159,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27
+hyphenate.other.locale = "27
 
 [characters]
 delimiters.quotes = «»‹›

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/ru/babel-ru.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/ru/babel-ru.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/ru/babel-ru.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.3
-date = 2020-03-22
+version = 1.4
+date = 2020-05-05
 name.local = русский
 name.english = Russian
 name.babel = russian
@@ -159,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "2D 
+hyphenate.other.locale = "2D 
 
 [characters]
 delimiters.quotes = «»„“

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Beng.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Beng.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Beng.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.8
-date = 2020-03-22
+version = 0.9
+date = 2020-05-05
 name.english = Sanskrit
 name.babel = sanskrit
 tag.bcp47 = sa
@@ -85,7 +85,8 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D "0CF1 "0CF2
+hyphenate.other.locale = "200C "200D
+hyphenate.other.script = "0CF1 "0CF2
 
 [characters]
 delimiters.quotes.0 = 

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Deva.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Deva.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Deva.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.8
-date = 2020-03-22
+version = 0.9
+date = 2020-05-05
 name.local = संस्कृत
 name.english = Sanskrit
 name.babel = sanskrit
@@ -86,7 +86,8 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D "0CF1 "0CF2
+hyphenate.other.locale = "200C "200D
+hyphenate.other.script = "0CF1 "0CF2
 
 [characters]
 delimiters.quotes = 

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Gujr.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Gujr.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa-Gujr.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.8
-date = 2020-03-22
+version = 0.9
+date = 2020-05-05
 name.english = Sanskrit
 name.babel = sanskrit
 tag.bcp47 = sa
@@ -85,7 +85,8 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D "0CF1 "0CF2
+hyphenate.other.locale = "200C "200D
+hyphenate.other.script = "0CF1 "0CF2
 
 [characters]
 delimiters.quotes.0 = 

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/sa/babel-sa.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 0.8
-date = 2020-03-22
+version = 0.9
+date = 2020-05-05
 name.english = Sanskrit
 name.babel = sanskrit
 name.polyglossia = sanskrit
@@ -87,7 +87,8 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D "0CF1 "0CF2
+hyphenate.other.locale = "200C "200D
+hyphenate.other.script = "0CF1 "0CF2
 
 [characters]
 delimiters.quotes.0 = 

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/ta/babel-ta.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/ta/babel-ta.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/ta/babel-ta.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.5
-date = 2020-03-22
+version = 1.6
+date = 2020-05-05
 name.local = தமிழ்
 name.english = Tamil
 name.babel = tamil
@@ -145,7 +145,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/te/babel-te.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/te/babel-te.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/te/babel-te.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.4
-date = 2020-03-22
+version = 1.5
+date = 2020-05-05
 name.local = తెలుగు
 name.english = Telugu
 name.babel = telugu
@@ -122,7 +122,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "200C "200D
+hyphenate.other.locale = "200C "200D
 
 [characters]
 delimiters.quotes = “”‘’

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/tk/babel-tk.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/tk/babel-tk.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/tk/babel-tk.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.2
-date = 2020-03-22
+version = 1.3
+date = 2020-05-05
 name.local = tk
 name.english = Turkmen
 name.babel = turkmen
@@ -120,7 +120,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "2D 
+hyphenate.other.locale = "2D 
 
 [characters]
 delimiters.quotes = “”“”

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/uk/babel-uk.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/uk/babel-uk.ini	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/uk/babel-uk.ini	2020-05-14 21:24:22 UTC (rev 55143)
@@ -11,8 +11,8 @@
 
 [identification]
 charset = utf8
-version = 1.3
-date = 2020-03-22
+version = 1.4
+date = 2020-05-05
 name.local = українська
 name.english = Ukrainian
 name.babel = ukrainian
@@ -159,7 +159,7 @@
 postexhyphenchar = 
 hyphenationmin = 
 ; The syntax is liable to change in 'other' values
-hyphenate.other = "27 "2D 
+hyphenate.other.locale = "27 "2D 
 
 [characters]
 delimiters.quotes = «»„“

Modified: trunk/Master/texmf-dist/tex/generic/babel/luababel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/luababel.def	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/luababel.def	2020-05-14 21:24:22 UTC (rev 55143)
@@ -251,6 +251,7 @@
 \endgroup
 \ifx\newattribute\@undefined\else
   \newattribute\bbl at attr@locale
+  \directlua{ Babel.attr_locale = luatexbase.registernumber'bbl at attr@locale'}
   \AddBabelHook{luatex}{beforeextras}{%
     \setattribute\bbl at attr@locale\localeid}
 \fi
@@ -859,8 +860,8 @@
 \let\bbl at chprop@bmg\bbl at chprop@mirror
 \def\bbl at chprop@linebreak#1{%
   \directlua{
-    Babel.Babel.cjk_characters[\the\count@] = Babel.Babel.cjk_characters[\the\count@] or {}
-    Babel.Babel.cjk_characters[\the\count@]['c'] = '#1'
+    Babel.cjk_characters[\the\count@] = Babel.cjk_characters[\the\count@] or {}
+    Babel.cjk_characters[\the\count@]['c'] = '#1'
   }}
 \let\bbl at chprop@lb\bbl at chprop@linebreak
 \def\bbl at chprop@locale#1{%
@@ -874,7 +875,8 @@
 \catcode`\%=12
 \catcode`\&=14
 \directlua{
-  Babel.linebreaking.replacements = {}
+  Babel.linebreaking.post_replacements = {}
+  Babel.linebreaking.pre_replacements = {}
 
   function Babel.str_to_nodes(fn, matches, base)
     local n, head, last
@@ -900,6 +902,7 @@
     local word_nodes = {}
     local lang
     local item = head
+    local inmath = false
 
     while item do
 
@@ -906,19 +909,23 @@
       if item.id == 29
           and not(item.char == 124) &% ie, not |
           and not(item.char == 61)  &% ie, not =
+          and not inmath
           and (item.lang == lang or lang == nil) then
         lang = lang or item.lang
         word_string = word_string .. unicode.utf8.char(item.char)
         word_nodes[#word_nodes+1] = item
 
-      elseif item.id == 7 and item.subtype == 2 then
+      elseif item.id == 7 and item.subtype == 2 and not inmath then
         word_string = word_string .. '='
         word_nodes[#word_nodes+1] = item
 
-      elseif item.id == 7 and item.subtype == 3 then
+      elseif item.id == 7 and item.subtype == 3 and not inmath then
         word_string = word_string .. '|'
         word_nodes[#word_nodes+1] = item
 
+      elseif item.id == node.id'math' then
+        inmath = (item.subtype == 0)
+
       elseif word_string == '' then
         &% pass
 
@@ -932,7 +939,7 @@
 
   function Babel.post_hyphenate_replace(head)
     local u = unicode.utf8
-    local lbkr = Babel.linebreaking.replacements
+    local lbkr = Babel.linebreaking.post_replacements
     local word_head = head
 
     while true do
@@ -1038,6 +1045,152 @@
     return head
   end
 
+  &%%%
+  &% Preliminary code for \babelprehyphenation
+  &% TODO. Copypaste pattern. Merge with fetch_word
+  function Babel.fetch_subtext(head, funct)
+    local word_string = ''
+    local word_nodes = {}
+    local lang
+    local item = head
+    local inmath = false
+
+    while item do
+
+      if item.id == 29 then
+        local locale = node.get_attribute(item, Babel.attr_locale)
+
+        if not(item.char == 124) &% ie, not | = space
+            and not inmath
+            and (locale == lang or lang == nil) then
+          lang = lang or locale
+          word_string = word_string .. unicode.utf8.char(item.char)
+          word_nodes[#word_nodes+1] = item
+        end
+
+        if item == node.tail(head) then
+          item = nil
+          return word_string, word_nodes, item, lang
+        end
+
+      elseif item.id == 12 and item.subtype == 13 and not inmath then
+        word_string = word_string .. '|'
+        word_nodes[#word_nodes+1] = item
+
+        if item == node.tail(head) then
+          item = nil
+          return word_string, word_nodes, item, lang
+        end
+
+      elseif item.id == node.id'math' then
+        inmath = (item.subtype == 0)
+
+      elseif word_string == '' then
+        &% pass
+
+      else
+        return word_string, word_nodes, item, lang
+      end
+
+      item = item.next
+    end
+  end
+
+  &% TODO. Copypaste pattern. Merge with pre_hyphenate_replace
+  function Babel.pre_hyphenate_replace(head)
+    local u = unicode.utf8
+    local lbkr = Babel.linebreaking.pre_replacements
+    local word_head = head
+
+    while true do
+      local w, wn, nw, lang = Babel.fetch_subtext(word_head)
+      if not lang then return head end
+
+      if not lbkr[lang] then
+        break
+      end
+
+      for k=1, #lbkr[lang] do
+        local p = lbkr[lang][k].pattern
+        local r = lbkr[lang][k].replace
+
+        while true do
+          local matches = { u.match(w, p) }
+          if #matches < 2 then break end
+
+          local first = table.remove(matches, 1)
+          local last =  table.remove(matches, #matches)
+
+          &% Fix offsets, from bytes to unicode.
+          first = u.len(w:sub(1, first-1)) + 1
+          last  = u.len(w:sub(1, last-1))
+
+          local new  &% used when inserting and removing nodes
+          local changed = 0
+
+          &% This loop traverses the replace list and takes the
+          &% corresponding actions
+          for q = first, last do
+            local crep = r[q-first+1]
+            local char_node = wn[q]
+            local char_base = char_node
+
+            if crep and crep.data then
+              char_base = wn[crep.data+first-1]
+            end
+
+            if crep == {} then
+              break
+            elseif crep == nil then
+              changed = changed + 1
+              node.remove(head, char_node)
+            elseif crep and crep.string then
+              changed = changed + 1
+              local str = crep.string(matches)
+              if str == '' then
+                if q == 1 then
+                  word_head = char_node.next
+                end
+                head, new = node.remove(head, char_node)
+              elseif char_node.id == 29 and u.len(str) == 1 then
+                char_node.char = string.utfvalue(str)
+              else
+                local n
+                for s in string.utfvalues(str) do
+                  if char_node.id == 7 then
+                    log('Automatic hyphens cannot be replaced, just removed.')
+                  else
+                    n = node.copy(char_base)
+                  end
+                  n.char = s
+                  if q == 1 then
+                    head, new = node.insert_before(head, char_node, n)
+                    word_head = new
+                  else
+                    node.insert_before(head, char_node, n)
+                  end
+                end
+
+                node.remove(head, char_node)
+              end  &% string length
+            end  &% if char and char.string
+          end  &% for char in match
+          if changed > 20 then
+            texio.write('Too many changes. Ignoring the rest.')
+          elseif changed > 0 then
+            &% For one-to-one can we modifiy directly the
+            &% values without re-fetching? Very likely.
+            w, wn, nw = Babel.fetch_subtext(word_head)
+          end
+
+        end  &% for match
+      end  &% for patterns
+      word_head = nw
+    end  &% for words
+    return head
+  end
+  &%%% end of preliminary code for \babelprehyphenation
+
   &% The following functions belong to the next macro
 
   &% This table stores capture maps, numbered consecutively
@@ -1071,7 +1224,6 @@
     return "]]..Babel.capt_map(m[" .. capno .. "]," ..
            (mlen) .. ").." .. "[["
   end
-
 }
 \catcode`\#=6
 \gdef\babelposthyphenation#1#2#3{&%
@@ -1091,10 +1243,10 @@
            tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
          }}}&%
     \directlua{
-      local lbkr = Babel.linebreaking.replacements
+      local lbkr = Babel.linebreaking.post_replacements
       local u = unicode.utf8
       &% Convert pattern:
-      local patt = string.gsub([[#2]], '%s', '')
+      local patt = string.gsub([==[#2]==], '%s', '')
       if not u.find(patt, '()', nil, true) then
         patt = '()' .. patt .. '()'
       end
@@ -1107,6 +1259,36 @@
                    { pattern = patt, replace = { \babeltempb } })
     }&%
   \endgroup}
+\gdef\babelprehyphenation#1#2#3{&%
+  \bbl at activateprehyphen
+  \begingroup
+    \def\babeltempa{\bbl at add@list\babeltempb}&%
+    \let\babeltempb\@empty
+    \bbl at foreach{#3}{&%
+      \bbl at ifsamestring{##1}{remove}&%
+        {\bbl at add@list\babeltempb{nil}}&%
+        {\directlua{
+           local rep = [[##1]]
+           rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func)
+           tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
+         }}}&%
+    \directlua{
+      local lbkr = Babel.linebreaking.pre_replacements
+      local u = unicode.utf8
+      &% Convert pattern:
+      local patt = string.gsub([==[#2]==], '%s', '')
+      if not u.find(patt, '()', nil, true) then
+        patt = '()' .. patt .. '()'
+      end
+      patt = u.gsub(patt, '{(.)}',
+                function (n)
+                  return '%' .. (tonumber(n) and (tonumber(n)+1) or n)
+                end)
+      lbkr[\the\csname bbl at id@@#1\endcsname] = lbkr[\the\csname  bbl at id@@#1\endcsname] or {}
+      table.insert(lbkr[\the\csname bbl at id@@#1\endcsname],
+                   { pattern = patt, replace = { \babeltempb } })
+    }&%
+  \endgroup}
 \endgroup
 \def\bbl at activateposthyphen{%
   \let\bbl at activateposthyphen\relax
@@ -1113,6 +1295,11 @@
   \directlua{
     Babel.linebreaking.add_after(Babel.post_hyphenate_replace)
   }}
+\def\bbl at activateprehyphen{%
+  \let\bbl at activateprehyphen\relax
+  \directlua{
+    Babel.linebreaking.add_before(Babel.pre_hyphenate_replace)
+  }}
 \bbl at trace{Redefinitions for bidi layout}
 \ifx\@eqnnum\@undefined\else
   \ifx\bbl at attr@dir\@undefined\else
@@ -1122,7 +1309,7 @@
   \fi
 \fi
 \ifx\bbl at opt@layout\@nnil\endinput\fi  % if no layout
-\ifx\bbl at beforeforeign\leavevmode % A poor test for bidi=
+\ifnum\bbl at bidimode>\z@
   \def\bbl at nextfake#1{%  non-local changes, use always inside a group!
     \bbl at exp{%
       \mathdir\the\bodydir
@@ -1211,7 +1398,7 @@
       \let\bbl at OL@p at enumiii\p at enumiii
       \def\p at enumiii{\p at enumii)\theenumii(}}{}}{}
 \bbl at trace{Bidi footnotes}
-\ifx\bbl at beforeforeign\leavevmode
+\ifnum\bbl at bidimode>\z@
   \def\bbl at footnote#1#2#3{%
     \@ifnextchar[%
       {\bbl at footnote@o{#1}{#2}{#3}}%

Modified: trunk/Master/texmf-dist/tex/generic/babel/nil.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/nil.ldf	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/nil.ldf	2020-05-14 21:24:22 UTC (rev 55143)
@@ -32,7 +32,7 @@
 %% extension |.ins|) which are part of the distribution.
 %%
 
-\ProvidesLanguage{nil}[2020/04/28 3.43 Nil language]
+\ProvidesLanguage{nil}[2020/05/13 3.44 Nil language]
 \LdfInit{nil}{datenil}
 \ifx\l at nil\@undefined
   \newlanguage\l at nil

Modified: trunk/Master/texmf-dist/tex/generic/babel/txtbabel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/txtbabel.def	2020-05-14 21:16:02 UTC (rev 55142)
+++ trunk/Master/texmf-dist/tex/generic/babel/txtbabel.def	2020-05-14 21:24:22 UTC (rev 55143)
@@ -94,7 +94,7 @@
        \hskip\columnwidth}}}%
   {}
 \bbl at trace{Bidi footnotes}
-\ifx\bbl at beforeforeign\leavevmode
+\ifnum\bbl at bidimode>\z@
   \def\bbl at footnote#1#2#3{%
     \@ifnextchar[%
       {\bbl at footnote@o{#1}{#2}{#3}}%



More information about the tex-live-commits mailing list.