texlive[72469] Master/texmf-dist: babel (5oct24)

commits+karl at tug.org commits+karl at tug.org
Sat Oct 5 21:35:50 CEST 2024


Revision: 72469
          https://tug.org/svn/texlive?view=revision&revision=72469
Author:   karl
Date:     2024-10-05 21:35:50 +0200 (Sat, 05 Oct 2024)
Log Message:
-----------
babel (5oct24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/babel/README.md
    trunk/Master/texmf-dist/doc/latex/babel/babel-code.pdf
    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-bidi-basic-r.lua
    trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua
    trunk/Master/texmf-dist/tex/generic/babel/babel-data-bidi.lua
    trunk/Master/texmf-dist/tex/generic/babel/babel-data-cjk.lua
    trunk/Master/texmf-dist/tex/generic/babel/babel-transforms.lua
    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/zh/babel-zh.ini
    trunk/Master/texmf-dist/tex/generic/babel/luababel.def
    trunk/Master/texmf-dist/tex/generic/babel/nil.ldf

Modified: trunk/Master/texmf-dist/doc/latex/babel/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/babel/README.md	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/doc/latex/babel/README.md	2024-10-05 19:35:50 UTC (rev 72469)
@@ -1,8 +1,8 @@
-## Babel 24.10
+## Babel 24.11
 
-2024-09-18
+2024-10-05
 
-`babel` is the multilingual framework for localizing documents in
+`babel` is the multilingual framework to localize documents in
 LaTeX, LuaLaTeX, XeLaTeX. It manages culturally-determined
 typographical (and other) rules for about 170 to 300 languages,
 depending on the engine, with several levels of coverage. A few
@@ -10,9 +10,9 @@
 
 The latest stable version is available on <https://ctan.org/pkg/babel>.
 
-Changes in version 24.10 are described in:
+Changes in version 24.11 are described in:
 
-https://latex3.github.io/babel/news/whats-new-in-babel-24.10.html
+https://latex3.github.io/babel/news/whats-new-in-babel-24.11.html
 
 Apart from the manual, you can find information on some aspects of babel at:
 
@@ -48,11 +48,9 @@
 
 ### Summary of latest changes
 ```
-24.10  2024-09-18
-       * \localename replaces the buggy \languagename. Added
-         \mainlocalename.
-       * \babelhyphenmins for better control of those parameters and,
-         in lualatex, \hyphenationmin.
+24.11  2024-10-05
+       * Start a thorough review of the manual.
+       * (lua) Transform variables.
 ```
 
 ### Previous changes

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

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	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.dtx	2024-10-05 19:35:50 UTC (rev 72469)
@@ -32,7 +32,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2024/09/18 v24.10 The Babel package]
+\ProvidesFile{babel.dtx}[2024/10/05 v24.11 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -50,9 +50,10 @@
   {NotoSans-Regular.ttf}
 \setmonofont[Scale=.86, FakeStretch=.97]{DejaVu Sans Mono}
 \raggedright
+\setlength{\parindent}{.8em}
 \frenchspacing
-\addtolength{\oddsidemargin}{1em}
-\addtolength{\textwidth}{25pt}
+\addtolength{\oddsidemargin}{-2em}
+\addtolength{\textwidth}{25.5pt}
 \addtolength{\textheight}{3.5cm}
 \addtolength{\topmargin}{-2cm}
 \font\manual=logo10 % font used for the METAFONT logo, etc.
@@ -90,12 +91,17 @@
   pdfkeywords={TeX, LaTeX, pdfTeX, LuaTeX, XeTeX, internationalization,
     localization}}
 \ExplSyntaxOn
+\normalmarginpar
 \newcommand\New[1]{%
   \regex_extract_once:nnN{(\d\d?)\.(\d\d?)}{#1}\bbltempa
   \seq_pop_right:NN\bbltempa\bbltempb
   \seq_pop_right:NN\bbltempa\bbltempa
+  \leavevmode%\marginpar
+  {\scriptsize
+  % \enspace
   \colorbox[rgb]{.92, .86, .73}%
-    {New~#1%
+    {%New~
+     #1%
     \quark_if_no_value:NTF\bbltempb{}%
       {~
        \ifnum\bbltempa>2 \ifnum\bbltempb>34
@@ -107,17 +113,21 @@
          \href{https://latex3.github.io/babel/news/%
                whats-new-in-babel-\bbltempa.\bbltempb.html}%
               {\raisebox{.15ex}{$\oplus$}}%
-       \fi}}\enspace\ignorespaces}
+       \fi}}}\enspace\ignorespaces}
 \ExplSyntaxOff
 \definecolor{thered}{rgb}{0.65,0.04,0.07}
 \definecolor{thegrey}{gray}{0.8}
+\definecolor{thegreyed}{gray}{0.6}
 \definecolor{shadecolor}{rgb}{1,1,0.97}
 \definecolor{messages}{rgb}{.66,.13,.27}
 \makeatletter
+\def\@seccntformat#1{%
+  \llap{\makebox[1.7cm][l]{\csname the#1\endcsname.}}%
+  \hspace{-.7cm}}
 \def\@begintheorem#1#2{%
   \list{}{}%
   \global\advance\@listdepth\m at ne
-  \item[{\sffamily\bfseries\color{messages}\hspace*{1.3em}%
+  \item[{\sffamily\bfseries\color{messages}\hspace*{1.4em}%\hspace*{2.8em}%
         \MakeUppercase{#1}}]}%
 \makeatother
 \newtheorem{warning}{Warning}
@@ -124,7 +134,6 @@
 \newtheorem{note}{Note}
 \newtheorem{example}{Example}
 \newtheorem{troubleshooting}{Troubleshooting}
-\newtheorem{more}{More}
 \let\bblxv\verbatim
 \let\bblexv\endverbatim
 \newcommand\setengine{\def\engine}
@@ -137,37 +146,50 @@
     \gdef|{\verb|\def<##1>{$\langle${\rmfamily\itshape##1}$\rangle$}}}
 \endgroup
 \def\verbatim{%
-  \begin{shaded*}%
+  \fboxsep=.8em
+  \begin{snugshade*}%
     \ifx\engine\relax\else
-      \vskip-1.08\baselineskip
-      \leavevmode\llap{\fbox{\footnotesize\textsc{\engine}}\hskip2.8em}%
-      \vskip-1.5\baselineskip
+      \vskip-.75\baselineskip
+      \leavevmode\llap{%
+        \fboxsep=2pt\fbox{\scriptsize\textsc{\engine}}\hskip2.8em}%
+      \vskip-1.6\baselineskip
       \vskip0pt
       \global\let\engine\relax
     \fi
-    \bblxv\vskip-\baselineskip\vskip2.5\parsep}
-\def\endverbatim{\bblexv\vskip-2\baselineskip\end{shaded*}}
+    \bblxv\vskip0pt }
+\def\endverbatim{%
+  \bblexv\vskip-7.5ex \end{snugshade*}}
 \catcode`\_=\active
 \def_{\bgroup\let_\egroup\leavevmode\color{thered}}
 \def\MacroFont{\fontencoding \encodingdefault \fontfamily\ttdefault
   \fontseries\mddefault \fontshape\updefault \small \catcode`\_=\active}
 \definecolor{shadecolor}{rgb}{0.96,0.96,0.93}
-\AtBeginDocument{%
-  \def\PrintDescribeMacro#1{%
-    \strut\MacroFont\color{thered}\normalsize\string#1}}
-\def\Describe#1{%
-  \par\penalty-500\vskip3ex\noindent
-  \DescribeMacro{#1}\args}
-\def\DescribeOther{\vskip-4ex\Describe}
-\makeatletter
+%
+\makeatletter   
+\def\Describe#1#2{%
+  \@startsection{subsubsection}{100}{\z@}%
+    {2.5ex\@plus .7ex \@minus .2ex}%
+    {1.5ex \@plus .2ex}%
+    {\hspace{-2cm}\color{thegreyed}\normalsize\ttfamily}*%
+    {\underline{\strut{\color{thered}\string#1}\color{black}#2}}}
+\def\DescribeOther{\addvspace{-1.5ex}\Describe}
+\AtBeginDocument{\def\DescribeMacro#1{{\ttfamily\color{thered}\string#1}}}
+\def\macro#1{% WIP
+  \if at noskipsec\leavevmode\vskip-1.2\baselineskip\vskip0pt\fi
+  \@startsection{paragraph}{101}{\z@}%
+    {3.25ex \@plus1ex \@minus.2ex}%
+    {-1em}%
+    {\sffamily\bfseries\color{thered}}*{\hspace*{-1em}\string#1}}
+\let\environment\macro
+\def\optstar{%
+  \kern1pt\relax
+  \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
+  \kern1pt}
 \def\trouble#1{\addcontentsline{tsh}{trouble}{#1}}
 \def\listoftroubles{\section*{Troubleshoooting}\@starttoc{tsh}}
 \let\l at trouble\l at figure
 \let\saved at check@percent\check at percent
 \let\check at percent\relax
-\def\args#1{%
-  \def\bbl at tempa{#1}%
-  \ifx\bbl at tempa\@empty\else#1\vskip1ex\fi\ignorespaces}
 % Changes to doc.sty (add <<...>> syntax)
 \def\Module#1{%
   \mod at math@codes$\langle${\color{thered}$\mathsf{#1}$}$\rangle$}
@@ -217,7 +239,7 @@
 \date{Typeset \today}
 \begin{titlepage}
 \begin{minipage}[t][0pt]{30cm}
-\vspace{-3cm}\hspace{-7cm}
+\vspace{-3cm}\hspace{-6cm}
 \sffamily
 \begin{tabular}{p{8cm}p{15cm}}
 \cellcolor[rgb]{.86,.73,.67}
@@ -285,11 +307,8 @@
 are also some notes on its use with e-Plain and pdf-Plain \TeX.
 
 \item[\sffamily\color{messages}I only need learn the most basic
-features.] The first subsections (1.1-1.3) describe the traditional way
-of loading a language (with |ldf| files), which is usually all you need.
-The alternative way based on |ini| files, which complements the
-previous one (it does \textit{not} replace it, although it is still
-necessary in some languages), is described below; go to \ref{inifiles}.
+features.] The first subsections (1.1-1.6) describe the ways
+of loading a language, which is usually all you need.
 
 \item[\sffamily\color{messages}I don’t like manuals. I prefer sample
   files.] This manual contains lots of examples and tips, but in GitHub
@@ -332,10 +351,32 @@
   Run |lualatex --jobname=babel-code \let\babelcode\relax\input{babel.dtx}|.
 \end{description}
 
-\section{The user interface}\label{U-I}
+\section{The basic user interface}\label{U-I}
 
-\subsection{Monolingual documents}
+There are two ways to load a language with babel, namely, the old good
+‘classical’ one, based on mostly self-contained declarations in a file
+with |ldf| extension, and the ‘modern’ one, based on a brand new
+mechanism based on descriptive |ini| files. 
 
+‘Classical’ doesn’t mean outdated or obsolete. In fact, this is the
+recommended method in most languages where an |ldf| file exists. Below
+is a list of the supported languages. See also
+\href{https://latex3.github.io/%
+babel/guides/which-method-for-which-language.html}{Which
+method for which language} in the \babel{} site.
+
+Basically, what you need is typically:
+\begin{itemize}
+\bfseries
+\item Tell \babel{} which language or languages are required.
+\item With non-Latin scripts and Unicode engines, select a suitable
+font (sec.~\ref{fonts})
+\item In multilingual documents, switch the language in the text body
+(sec.~\ref{selectors}).
+\end{itemize}
+
+\subsection{Monolingual documents: the ‘classical’ way}
+
 In most cases, a single language is required, and then all you need in
 \LaTeX{} is to load the package using its standard mechanism for this
 purpose, namely, passing that language as an optional argument. In
@@ -344,15 +385,15 @@
 Another approach is making the language a global option in order to let
 other packages detect and use it. This is the standard way in \LaTeX{}
 for an option – in this case a language – to be recognized by several
-packages.
+packages (in other words, \babel{} doesn’t set the languages, it just
+recognizes the options passed to the class or the package).
 
-Many languages are compatible with \textsf{xetex} and \textsf{luatex}.
-With them you can use \babel{} to localize the documents. When these
-engines are used, the Latin script is covered by default in current
-\LaTeX{} (provided the document encoding is UTF-8), because the font
-loader is preloaded and the font is switched to |lmroman|. Other
-scripts require loading \textsf{fontspec}. You may want to set the font
-attributes with \textsf{fontspec}, too.
+Many languages are compatible with \textsf{xetex} and \textsf{luatex},
+but a few only work with \pdftex. When these engines are used, the
+Latin script is covered by default in current \LaTeX{} (provided the
+document encoding is UTF-8). Other scripts require loading
+\textsf{fontspec}, although \babel{} provides a higher level interface
+(see |\babelfont| below). 
 
 \begin{example}
   Here is a simple full example for “traditional” \TeX{} engines
@@ -386,11 +427,10 @@
 \end{example}
 
 \begin{example}
-And now a simple monolingual document in Russian (text from the
-Wikipedia) with \xetex{} or \luatex{}. Note neither \textsf{fontenc}
-nor \textsf{inputenc} are necessary, but the document should be encoded
-in UTF-8 and a so-called Unicode font must be loaded (in this example
-|\babelfont| is used, described below).
+Now a simple monolingual document in Russian (text from the Wikipedia)
+with \xetex{} or \luatex{}. Note neither \textsf{fontenc} nor
+\textsf{inputenc} are necessary, and a so-called Unicode font must be
+loaded (in this example with the help of |\babelfont|, described below).
 
 \setengine{luatex/xetex}
 \begin{verbatim}
@@ -411,35 +451,81 @@
 \end{verbatim}
 \end{example}
 
-\begin{troubleshooting}
-\trouble{Paragraph ended before \textbackslash UTFviii at three@octets
-was complete}
-A common source of trouble is a wrong setting of the input encoding.
-Depending on the \LaTeX{} version you can get the following somewhat
-cryptic error:
+\begin{note}
+  Because of the way \babel{} has evolved, ``language'' can refer to
+  (1) a set of hyphenation patterns as preloaded into the format, (2) a
+  package option, (3) an |ldf| file, and (4) a name used in the
+  document to select a language or dialect. Please, read the
+  documentation for specific languages for further info.
+\end{note}
+
+\begin{note}
+  \Babel{} does not make any readjustments by default in font size,
+  vertical positioning or line height by default. This is on purpose
+  because the optimal solution depends on the document layout and the
+  font, and very likely the most appropriate one is a combination of
+  these settings.
+\end{note}
+
+\begin{note}
+  Although it has been customary to recommend placing |\title|,
+  |\author| and other elements printed by |\maketitle| after
+  |\begin{document}|, mainly because of shorthands, it is advisable to
+  keep them in the preamble. Currently there is no real need to use
+  shorthands in those macros.
+\end{note}
+
+\begin{note}
+  With \textsf{hyperref} you may want to set the PDF document language
+  with something like:
 \begin{verbatim}
-! Paragraph ended before \UTFviii at three@octets was complete.
+\usepackage[_pdflang=es-MX_]{hyperref}
 \end{verbatim}
-Or the more explanatory:
+This is not currently done by \babel{} and you must set it by hand. The
+PDF document language can be also set with |\DocumentMetadata|, before
+|\documentclass|; for example:
 \begin{verbatim}
-! Package inputenc Error: Invalid UTF-8 byte ...
+\DocumentMetadata{_lang=es-MX_}
 \end{verbatim}
-Make sure you set the encoding actually used by your editor.
+\end{note}
+
+\begin{warning}
+  In the preamble, \textit{no} language has been selected, except
+  hyphenation patterns and the name assigned to |\localename| (and
+  |\languagename|) (in particular, shorthands, captions and date are not
+  activated). If you need to define boxes and the like in the preamble,
+  you might want to use some of the language selectors described below.
+\end{warning}
+
+\begin{troubleshooting}
+\trouble{Package inputenc Error: Invalid UTF-8 byte ...}
+\textit{Package inputenc Error: Invalid UTF-8 byte ...}
+A common source of trouble is a wrong setting of the input encoding.
+Make sure you set the encoding actually used by your editor, or
+even better, make sure the encoding in your editor is set to UTF-8.
 \end{troubleshooting}
 
-\begin{note}
-  Because of the way \babel{} has evolved, ``language'' can refer to
-  (1) a set of hyphenation patterns as preloaded into the format, (2)
-  a package option, (3) an |ldf| file, and (4) a name used in the
-  document to select a language or dialect. So, a package option
-  refers to a language in a generic way -- sometimes it is the actual
-  language name used to select it, sometimes it is a file name loading
-  a language with a different name, sometimes it is a file name
-  loading several languages. Please, read the documentation for
-  specific languages for further info.
-\end{note}
+\begin{troubleshooting}
+Another typical error when using \babel{} is the
+  following:\footnote{In old versions the error read ``You haven't
+  loaded the language LANG yet''.}
+\trouble{Unknown language `LANG'}
+\begin{verbatim}
+! Package babel Error: Unknown language `#1'. Either you have
+(babel)                misspelled its name, it has not been installed,
+(babel)                or you requested it in a previous run. Fix its name,
+(babel)                install it or just rerun the file, respectively. In
+(babel)                some cases, you may need to remove the aux file
+\end{verbatim}
+  The most frequent reason is, by far, the latest (for example, you
+  included |spanish|, but you realized this language is not used after
+  all, and therefore you removed it from the option list). In most
+  cases, the error vanishes when the document is typeset again, but in
+  more severe ones you will need to remove the |aux| file.
+\end{troubleshooting}
 
 \begin{troubleshooting}
+\textit{No hyphenation patterns were preloaded...}
   The following warning is about hyphenation patterns, which are
   not under the direct control of \babel:
 \trouble{No hyphenation patterns were preloaded for (babel) the
@@ -458,180 +544,112 @@
   etc.) for further info about how to configure it.
 \end{troubleshooting}
 
-\begin{note}
-  With \textsf{hyperref} you may want to set the document language with
-  something like:
+\begin{troubleshooting}
+\textit{You are loading directly a language style.}
+Loading directly |sty| files in \LaTeX{} (ie,
+    |\usepackage{<language>}|) was deprecated many years ago and you will get the
+    error:\footnote{In old versions the error read ``You have used an
+    old interface to call babel'', not very helpful.}
+  \trouble{You are loading directly a language style}
 \begin{verbatim}
-\usepackage[_pdflang=es-MX_]{hyperref}
+! Package babel Error: You are loading directly a language style.
+(babel)                This syntax is deprecated and you must use
+(babel)                \usepackage[language]{babel}.
 \end{verbatim}
-This is not currently done by \babel{} and you must set it by hand. The
-document language can be also set with |\DocumentMetadata|, before
-|\documentclass|; for example:
-\begin{verbatim}
-\DocumentMetadata{_lang=es-MX_}
-\end{verbatim}
-\end{note}
+\end{troubleshooting}
 
 \begin{note}
-  Although it has been customary to recommend placing |\title|,
-  |\author| and other elements printed by |\maketitle| after
-  |\begin{document}|, mainly because of shorthands, it is advisable to
-  keep them in the preamble. Currently there is no real need to use
-  shorthands in those macros.
+  You will see an ‘info’ in the log file stating some data is being
+  loaded from an |ini| file. It includes standardized names for
+  language and script used by |\babelfont|, and the BCP-47 tag, required in
+  some cases by |\Make<Xxxxx>case|.
 \end{note}
 
-\begin{note}
-  \Babel{} does not make any readjustments by default in font size,
-  vertical positioning or line height by default. This is on purpose
-  because the optimal solution depends on the document layout and the
-  font, and very likely the most appropriate one is a combination of
-  these settings.
-\end{note}
+\subsection{Monolingual documents: the ‘modern’ way}
 
-\subsection{Multilingual documents}
+When, for whatever reason, the ‘classical’ way with the |ldf| is not
+suitable for the needs of a document or a document system, you have to
+resort to a different mechanism, which is activated with the package
+option |provide=*| (in monolingual documents).
 
-In multilingual documents, just use a list of the required languages as
-package or class options. The last language is considered the main one,
-activated by default. Sometimes, the main language changes the document
-layout (eg, |spanish| and |french|).
-
 \begin{example}
-  In \LaTeX, the preamble of the document:
+  Although Georgian has its own \texttt{ldf} file, here is how to
+  declare this language in Unicode engines. Here, as in a previous
+  example, we resort to |\babelfont| to set the font for this language
+  (with the |Harfbuzz| renderer).
+\setengine{luatex/xetex}
 \begin{verbatim}
-\documentclass{article}
-\usepackage[dutch,english]{babel}
-\end{verbatim}
-  would tell \LaTeX\ that the document would be written in two
-  languages, Dutch and English, and that English would be the first
-  language in use, and the main one.
-\end{example}
+\documentclass{book}
 
-You can also set the main language explicitly, but it is discouraged
-except if there is a real reason to do so:
-\begin{verbatim}
-\documentclass{article}
-\usepackage[_main=english_,dutch]{babel}
-\end{verbatim}
+\usepackage[_georgian, provide=*_]{babel}
 
-Examples of cases where |main| is useful are the following.
+_\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans}_
 
-\begin{example}
-Some classes load \babel{} with a hardcoded language option. Sometimes,
-the main language can be overridden with something like that before
-|\documentclass|:
-\begin{verbatim}
-\PassOptionsToPackage{main=english}{babel}
-\end{verbatim}
-\end{example}
-
-\begin{note}
-  Languages may be set as global and as package option at the same
-  time, but in such a case you should set explicitly the main language
-  with the package option |main|:
-\begin{verbatim}
-\documentclass[_italian_]{book}
-\usepackage[ngerman,_main=italian_]{babel}
-\end{verbatim}
-\end{note}
-
-\begin{warning}
-  In the preamble the main language has \textit{not} been selected,
-  except hyphenation patterns and the name assigned to |\languagename|
-  (in particular, shorthands, captions and date are not activated). If
-  you need to define boxes and the like in the preamble, you might
-  want to use some of the language selectors described below.
-\end{warning}
-
-To switch the language there are two basic macros, described below in
-detail: |\selectlanguage| is used for blocks of text, while
-|\foreignlanguage| is for chunks of text inside paragraphs.
-
-\begin{example}
-A full bilingual document with \pdftex{} follows. The main language is
-|french|, which is activated when the document begins. It assumes UTF-8:
-\setengine{pdftex}
-\begin{verbatim}
-\documentclass{article}
-
-\usepackage[T1]{fontenc}
-
-_\usepackage[english,french]{babel}_
-
 \begin{document}
 
-Plus ça change, plus c'est la même chose!
+\tableofcontents
 
-_\selectlanguage{english}_
+\chapter{სამზარეულო და სუფრის ტრადიციები}
 
-And an English paragraph, with a short text in
-_\foreignlanguage{french}{français}_.
+ქართული ტრადიციული სამზარეულო ერთ-ერთი უმდიდრესია მთელ მსოფლიოში.
 
 \end{document}
 \end{verbatim}
-\end{example}
-
-\begin{example}
-  With \xetex{} and \luatex, the following bilingual, single script
-  document in UTF-8 encoding just prints a couple of ‘captions’ and
-  |\today| in Danish and Vietnamese. No additional packages are
-  required, because the default font supports both languages.
-\setengine{luatex/xetex}
+And with a global option:
 \begin{verbatim}
-\documentclass{article}
-
-_\usepackage[vietnamese,danish]{babel}_
-
-\begin{document}
-
-\prefacename, \alsoname, \today.
-
-\selectlanguage{vietnamese}
-
-\prefacename, \alsoname, \today.
-
-\end{document}
+\documentclass[_georgian_]{book}
+\usepackage[_provide=*_]{babel}
+\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans}
 \end{verbatim}
 \end{example}
 
 \begin{note}
-  Once loaded a language, you can select it with the corresponding
-  BCP47 tag. See section \ref{bcp47} for further details.
+  This option actually loads the language with |\babelprovide| and the
+  |import| option, described below. Instead of an asterisk, you may
+  provide a list of options for |\babelprovide| enclosed in braces
+  (|import| is included by default).
 \end{note}
 
-\begin{note}
-  Documents with several input encodings are not frequent, but
-  sometimes are useful. You can set different encodings for different
-  languages as the following example shows:
+\begin{example}
+For a text in Chinese, you can write in the preamble:
+\setengine{luatex/xetex}
 \begin{verbatim}
-\addto\extrasfrench{\inputencoding{latin1}}
-\addto\extrasrussian{\inputencoding{koi8-r}}
+\usepackage[_chinese, provide=*_]{babel}
+_\babelfont{rm}{FandolSong}_
 \end{verbatim}
-\end{note}
+The skip between characters is 0 pt plus .1 pt, which can be modified
+with an option (explained below) in |provide|. For example:
+\setengine{luatex/xetex}
+\begin{verbatim}
+\usepackage[chinese, provide=_{ intraspace=0 .2 0 }_]{babel}
+\end{verbatim}
+\end{example}
 
-\subsection{Mostly monolingual documents}
+\subsection{Mostly monolingual documents: lazy loading}
 \label{mostlymono}
 
 \New{3.39} Very often, multilingual documents consist of a main
 language with small pieces of text in another languages (words, idioms,
 short sentences). Typically, all you need is to set the line breaking
-rules and, perhaps, the font. In such a case, \babel{} now does not
-require declaring these secondary languages explicitly, because the
-basic settings are loaded on the fly when the language is selected (and
-also when provided in the optional argument of |\babelfont|, if used).
+rules and, perhaps, the font. In such a case, there is no need to
+clutter the preamble (particularly the class and package options)
+because \babel{} does not require declaring these secondary languages
+explicitly — the basic settings are loaded on the fly when the language
+is first selected.
 
-This is particularly useful, too, when there are short texts of this
-kind coming from an external source whose contents are not known on
-beforehand (for example, titles in a bibliography). At this regard, it
-is worth remembering that |\babelfont| does \textit{not} load any font
-until required, so that it can be used just in case.
+This is particularly useful in documents with many languages, and also
+when there are short texts of this kind coming from an external source
+whose contents are not known on beforehand (for example, titles in a
+bibliography). At this regard, it is worth remembering that
+|\babelfont| does \textit{not} load any font until required, so that it
+can be used just in case.
 
 \New{3.84} With \pdftex, when a language is loaded on the fly
-(actually, with |\babelprovide|, because this is the macro used
-internally to load it) selectors now set the font encoding based on the
-list provided when loading |fontenc|. Not all scripts have an
-associated encoding, so this feature works only with Latin, Cyrillic,
-Greek, Arabic, Hebrew, Cherokee, Armenian, and Georgian, provided a
-suitable font is found.
+(internally it's loaded with |\babelprovide|) selectors now set the
+font encoding based on the list provided when loading |fontenc|. Not
+all scripts have an associated encoding, so this feature works only
+with Latin, Cyrillic, Greek, Arabic, Hebrew, Cherokee, Armenian, and
+Georgian, provided a suitable font is found.
 
 \begin{example}
   A trivial document with the default font in English and Spanish, and
@@ -650,6 +668,11 @@
 
 \end{document}
 \end{verbatim}
+If you need the ‘modern’ way to load the main language set as global
+option, just write:
+\begin{verbatim}
+\usepackage[provide=*]{babel}
+\end{verbatim}
 \end{example}
 
 \begin{note}
@@ -660,1040 +683,285 @@
   for |lubakatanga|). See section \ref{bcp47} for further details.
 \end{note}
 
-\subsection{Languages supported by \babel{} with \textsf{ldf} files}
+\subsection{Multilingual documents: the ‘classical’ way}
 
-(To be updated.) In the following table most of the languages supported
-by \babel{} with and |.ldf| file are listed, together with the names of
-the option which you can load \babel\ with for each language. Note this
-list is open and the current options may be different. It does not
-include |ini| files (see below). Except in a few cases (eg, |ngerman|,
-|serbianc|, |acadian|) names are those of the Unicode CLDR (or based on
-them).
+In multilingual documents, just use a list of the required languages
+either as package or as class options. The last language is considered the
+main one, activated by default. Sometimes, the main language changes
+the document layout (eg, |spanish| and |french|).
 
-\begin{description}
-\itemsep=-\parskip
-\sffamily
-\item[Afrikaans] afrikaans
-\item[Azerbaijani] azerbaijani
-\item[Basque] basque
-\item[Breton] breton
-\item[Bulgarian] bulgarian
-\item[Catalan] catalan
-\item[Croatian] croatian
-\item[Czech] czech
-\item[Danish] danish
-\item[Dutch] dutch
-\item[English] english, american (\textit{preferred to} USenglish), british (\textit{preferred to} 
-  UKenglish), canadian, australian, newzealand
-\item[Esperanto] esperanto
-\item[Estonian] estonian
-\item[Finnish] finnish
-\item[French] french, acadian
-\item[Galician] galician
-\item[German] ngerman, naustrian, german, austrian
-\item[Greek] greek, polutonikogreek
-\item[Hebrew] hebrew
-\item[Icelandic] icelandic
-\item[Indonesian] indonesian
-\item[Interlingua] interlingua
-\item[Irish Gaelic] irish
-\item[Italian] italian
-\item[Latin] latin
-\item[Lower Sorbian] lowersorbian
-\item[Malay] malay (\textit{preferred to} melayu)
-\item[Northern Sami] northernsami
-\item[Norwegian] norsk, nynorsk
-\item[Polish] polish
-\item[Portuguese] portuguese, brazilian
-\item[Romanian] romanian
-\item[Russian] russian
-\item[Scottish Gaelic] scottishgaelic (\textit{preferred to} scottish)
-\item[Spanish]  spanish
-\item[Slovakian] slovak
-\item[Slovenian]  slovene
-\item[Swedish] swedish
-\item[Serbian] serbian
-\item[Turkish] turkish
-\item[Ukrainian] ukrainian
-\item[Upper Sorbian] uppersorbian
-\item[Welsh] welsh
-\end{description}
+To switch the language there are two basic macros, described below in
+detail: |\selectlanguage| is used for blocks of text, while
+|\foreignlanguage| is for chunks of text inside paragraphs.
 
-There are more languages not listed above, including \textsf{hindi,
-thai, thaicjk, latvian, turkmen, magyar, mongolian, romansh,
-lithuanian, spanglish, vietnamese, japanese, pinyin, arabic, farsi,
-ibygreek, bgreek, serbianc, frenchle, ethiop} and \textsf{friulan}.
-
-\begin{note}
-  There are also some deprecated names (a few has been even removed):
-  \textsf{frenchb} or \textsf{francais}, as well as \textsf{canadien}
-  (\textsf{french}), \textsf{germanb} (\textsf{german}),
-  \textsf{bahasa}, \textsf{indon} or \textsf{bahasai}
-  (\textsf{indonesian}), \textsf{lsorbian} (\textsf{lowersorbian}),
-  \textsf{bahasam} (\textsf{malay}), \textsf{portuges}
-  (\textsf{portuguese}), \textsf{brazil} (\textsf{brazilian}),
-  \textsf{russianb} (\textsf{russian}), \textsf{usorbian}
-  (\textsf{uppersorbian}), \textsf{vietnam} (\textsf{vietnamese}),
-  \textsf{samin} (\textsf{northernsami}), \textsf{ukraineb}
-  (\textsf{ukrainian}). Deprecated names come in many cases from the
-  times when they had to be shortened to 8 characters. 
-\end{note}
-
-Most of them work out of the box, but some may require extra fonts,
-encoding files, a preprocessor or even a complete framework (like
-\textsf{CJK} or \textsf{luatexja}). For example, if you have got the
-\textsf{velthuis/devnag} package, you can create a file with extension
-|.dn|:
+\begin{example}
+  In \LaTeX, the preamble of the document:
 \begin{verbatim}
 \documentclass{article}
-\usepackage[hindi]{babel}
-\begin{document}
-{\dn devaanaa.m priya.h}
-\end{document}
+\usepackage[dutch,english]{babel}
 \end{verbatim}
-Then you preprocess it with |devnag| \m{file}, which creates
-\m{file}|.tex|; you can then typeset the latter with \LaTeX.
+  would tell \LaTeX\ that the document would be written in two
+  languages, Dutch and English, and that English would be the first
+  language in use, and the main one.
+\end{example}
 
-\subsection{Modifiers}
-
-\New{3.9c} The basic behavior of some languages can be modified when
-loading \babel{} by means of \textit{modifiers}. They are set after
-the language name, and are prefixed with a dot (only when the language
-is set as package option -- neither global options nor the |main| key
-accepts them). An example is (spaces are not significant and they can
-be added or removed):\footnote{No predefined ``axis'' for modifiers
-are provided because languages and their scripts have quite different
-needs.}
+\begin{example}
+A full bilingual document with \pdftex{} follows. The main language is
+|french|, which is activated when the document begins. It assumes UTF-8:
+\setengine{pdftex}
 \begin{verbatim}
-\usepackage[latin_.medieval_, spanish_.notilde.lcroman_, danish]{babel}
-\end{verbatim}
+\documentclass{article}
 
-Attributes (described below) are considered modifiers, ie, you can
-set an attribute by including it in the list of modifiers.
+\usepackage[T1]{fontenc}
 
-\New{3.89} Alternatively, modifiers can be set with a separate option,
-with the keyword |modifiers| followed by a dot and the language name
-(note the language is not selected or loaded with this option). It is
-useful to activate some feature when the language is declared as a
-class option:
-\begin{verbatim}
-\documentclass[spanish]{report}
-\usepackage[_modifiers.spanish = notilde.lcroman_]{babel}
-\end{verbatim}
+_\usepackage[english,french]{babel}_
 
-\subsection{Troubleshooting}
+\begin{document}
 
-\begin{itemize}
-\item Loading directly |sty| files in \LaTeX{} (ie,
-  |\usepackage{<language>}|) is deprecated and you will get the
-  error:\footnote{In old versions the error read ``You have used an
-  old interface to call babel'', not very helpful.}
-\trouble{You are loading directly a language style}
-\begin{verbatim}
-! Package babel Error: You are loading directly a language style.
-(babel)                This syntax is deprecated and you must use
-(babel)                \usepackage[language]{babel}.
-\end{verbatim}
+Plus ça change, plus c'est la même chose!
 
-\item  Another typical error when using \babel{} is the
-  following:\footnote{In old versions the error read ``You haven't
-  loaded the language LANG yet''.}
-\trouble{Unknown language `LANG'}
-\begin{verbatim}
-! Package babel Error: Unknown language `#1'. Either you have
-(babel)                misspelled its name, it has not been installed,
-(babel)                or you requested it in a previous run. Fix its name,
-(babel)                install it or just rerun the file, respectively. In
-(babel)                some cases, you may need to remove the aux file
-\end{verbatim}
-  The most frequent reason is, by far, the latest (for example, you
-  included |spanish|, but you realized this language is not used after
-  all, and therefore you removed it from the option list). In most
-  cases, the error vanishes when the document is typeset again, but in
-  more severe ones you will need to remove the |aux| file.
-\end{itemize}
+_\selectlanguage{english}_
 
-\subsection{Plain}
+And an English paragraph, with a short text in
+_\foreignlanguage{french}{français}_.
 
-In e-Plain and pdf-Plain, load languages styles with |\input| and then use
-|\begindocument| (the latter is defined by \babel):
-\begin{verbatim}
-\input estonian.sty
-\begindocument
+\end{document}
 \end{verbatim}
+\end{example}
 
-\begin{warning}
-  Not all languages provide a |sty| file and some of them are not
-  compatible with those formats. Please, refer to
-  \href{https://latex3.github.io/babel/guides/using-babel-with-plain.html}%
-   {Using babel with Plain} for further details.
-\end{warning}
-
-\subsection{Basic language selectors}
-
-This section describes the commands to be used in the document to
-switch the language in multilingual documents. In most cases, only the
-two basic macros |\selectlanguage| and |\foreignlanguage| are
-necessary. The environments |otherlanguage|, |otherlanguage*| and
-|hyphenrules| are auxiliary, and described in the next section.
-
-The main language is selected automatically when the |document|
-environment begins.
-
-\Describe{\selectlanguage}{\marg{language}}
-When a user wants to switch from one language to another he can
-do so using the macro |\selectlanguage|. This macro takes the
-language, defined previously by a language definition file, as
-its argument. It calls several macros that should be defined in
-the language definition files to activate the special definitions
-for the language chosen:
+\begin{example}
+  With \xetex{} and \luatex, the following bilingual, single script
+  document in UTF-8 encoding just prints a couple of ‘captions’ and
+  |\today| in Danish and Vietnamese. No additional packages are
+  required, because the default font supports both languages.
+\setengine{luatex/xetex}
 \begin{verbatim}
-\selectlanguage{german}
-\end{verbatim}
+\documentclass{article}
 
-This command can be used as environment, too, in case there are
-relatively short texts and you do not want to reset the language with a
-hardcode value.
+_\usepackage[vietnamese,danish]{babel}_
 
-\begin{note}
-  For ``historical reasons'', a macro name is converted to a language
-  name without the leading |\|; in other words,
-  |\selectlanguage{\german}| is equivalent to
-  |\selectlanguage{german}|. Using a macro instead of a ``real'' name
-  is deprecated. \New{3.43} However, if the macro name does not match
-  any language, it will get expanded as expected.
-\end{note}
+\begin{document}
 
-\begin{note}
-  Bear in mind |\selectlanguage| can be automatically executed, in some
-  cases, in the auxiliary files, at heads and foots, and after the
-  environment |otherlanguage*|.
-\end{note}
+Danish: \prefacename, \alsoname, \today.
 
-\begin{warning}
-  If used inside braces there might be some non-local changes, as this
-  would be roughly equivalent to:
-\begin{verbatim}
-{\selectlanguage{<inner-language>} ...}\selectlanguage{<outer-language>}
-\end{verbatim}
-  If you want a change which is really local, you must enclose this
-  code with an additional grouping level.
-\end{warning}
+\selectlanguage{vietnamese}
 
-\begin{warning}
-  There are a couple of issues related to the way the language
-  information is written to the auxiliary files:
-\begin{itemize}
-  \item |\selectlanguage| should not be used inside some boxed environments
-    (like floats or |minipage|) to switch the language if you need the
-    information written to the |aux| be correctly synchronized. This
-    rarely happens, but if it were the case, you must use
-    |otherlanguage| instead.
-  \item In addition, this macro inserts a |\write| in vertical mode,
-    which may break the vertical spacing in some cases (for example,
-    between lists or at the beginning of a table cell). \New{3.64} The
-    behavior can be adjusted with
-    |\babeladjust{select.write=<mode>}|, where \m{mode} is |shift|
-    (which shifts the skips down and adds a |\penalty|); |keep| (the
-    default -- with it the |\write| and the skips are kept in the order
-    they are written), and |omit| (which may seem a too drastic
-    solution, because nothing is written, but more often than not this
-    command is applied to more or less shorts texts with no sectioning
-    or similar commands, and therefore no language synchronization is
-    necessary). In a table cell, a |\leavevmode| just before the
-    selector may be enough.
-\end{itemize}
-\end{warning}
+Vietnamese: \prefacename, \alsoname, \today.
 
-\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), and since it is meant for phrases
-only the text direction (and not the paragraph one) is set.
-
-\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{document}
 \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.
+\end{example}
 
 \begin{note}
-  |\bibitem| is out of sync with |\selectlanguage| in the \file{.aux}
-  file. The reason is |\bibitem| uses |\immediate| (and others, in
-  fact), while |\selectlanguage| doesn't. There is a similar issue with
-  floats, too. There is no known workaround.
-\end{note}
-
-\subsection{Auxiliary language selectors}
-
-\Describe{\begin\menv{otherlanguage}}{\marg{language}\Eenv{otherlanguage}}
-
-The environment \Lenv{otherlanguage} does basically the same as
-|\selectlanguage|, except that language change is (mostly) local to
-the environment.
-
-Actually, there might be some non-local changes, as this environment
-is roughly equivalent to:
+  Although strongly discouraged, languages can be set as global and as
+  package option at the same time, but in such a case you should set
+  explicitly the main language with the package option |main|,
+  described below:
 \begin{verbatim}
-\begingroup
-\selectlanguage{<inner-language>}
-...
-\endgroup
-\selectlanguage{<outer-language>}
+\documentclass[_italian_]{book}
+\usepackage[ngerman,_main=italian_]{babel}
 \end{verbatim}
-If you want a change which is really local, you must enclose this
-environment with an additional grouping, like braces |{}|.
+\end{note}
 
-Spaces after the environment are ignored.\footnote{Very likely, and
-because of the limitations of many old editors with bidi text, the idea
-was \cs{end}\texttt{\{otherlanguage\}} had to be a line by itself.} If this
-behavior is not desired, you may use the environment
-\texttt{selectlanguage}.
-
-\begin{warning}
-  Being similar to |\selectlanguage|, the warning above about the
-  internal |\write| also applies here. The current mode (vertical or
-  horizontal) is also not changed.
-\end{warning}
-
-\Describe{\begin\menv{otherlanguage*}}%
-{\oarg{option-list}\marg{language}\Eenv{otherlanguage*}}
-
-Same as |\foreignlanguage| but as environment. Spaces after the
-environment are \textit{not} ignored.
-
-This environment was originally intended for intermixing left-to-right
-typesetting with right-to-left typesetting in engines not supporting a
-change in the writing direction inside a line. However, by default it
-never complied with the documented behavior and it is just a version as
-environment of |\foreignlanguage|, except when the option |bidi| is 
-set -- in this case, |\foreignlanguage| emits a |\leavevmode|, while 
-|otherlanguage*| does not.
-
-\subsection{More on selection}
-
-\Describe{\babeltags}{\char`\{\m{tag1} \texttt{=} \m{language1}, \m{tag2}
-\texttt{=} \m{language2}, \dots\char`\}}
-
-\New{3.9i} In multilingual documents with many language-switches the
-commands above can be cumbersome. With this tool shorter names can be
-defined. It adds nothing really new -- it is just syntactical sugar.
-
-It defines |\text<tag1>{<text>}| to be
-|\foreignlanguage{<language1>}{<text>}|, and |\begin{<tag1>}|
-to be |\begin{otherlanguage*}{<language1>}|, and so on. Note
-|\<tag1>| is also allowed, but remember to set it locally inside a
-group.
-
-\begin{warning}
-  There is a clear drawback to this feature, namely, the ‘prefix’
-  |\text...| is heavily overloaded in \LaTeX{} and conflicts with
-  existing macros may arise (|\textlatin|, |\textbar|, |\textit|,
-  |\textcolor| and many others). The same applies to environments,
-  because |arabic| conflicts with |\arabic|. Furthermore, and because of
-  this overloading, detecting the language of a chunk of text by
-  external tools can become unfeasible (is |\textga| the locale for the
-  African language Gã or something else?). Except if there is a reason for
-  this ‘syntactical sugar’, the best option is to stick to the default
-  selectors or even to define your own alternatives.
-\end{warning}
-
-\begin{example}
-With
-\begin{verbatim}
-\babeltags{de = german}
-\end{verbatim}
-you can write
-\begin{verbatim}
-text \textde{German text} text
-\end{verbatim}
-and
-\begin{verbatim}
-text
-\begin{de}
-  German text
-\end{de}
-text
-\end{verbatim}
-\end{example}
-
 \begin{note}
-  Something like \verb|\babeltags{finnish = finnish}| is legitimate --
-  it defines |\textfinnish| and |\finnish| (and, of course,
-  |\begin{finnish}|).
+  Once loaded a language, you can select it with the corresponding
+  BCP47 tag. See section \ref{bcp47} for further details.
 \end{note}
 
-\Describe{\babelensure}{|[include=|\m{commands}|,exclude=|\m{commands}%
-  |,fontenc=|\m{encoding}|]|\marg{language}}
-
-\New{3.9i} Except in a few languages, like \textsf{russian},
-captions and dates are just strings, and do not switch the
-language. That means you should set it explicitly if you want to use
-them, or hyphenation (and in some cases the text itself) will be
-wrong. For example:
+\begin{note}
+  Documents with several input encodings are not frequent, but
+  sometimes are useful. You can set different encodings for different
+  languages as the following example shows:
 \begin{verbatim}
-\foreignlanguage{russian}{text \foreignlanguage{polish}{\seename} text}
+\addto\extrasfrench{\inputencoding{latin1}}
+\addto\extrasrussian{\inputencoding{koi8-r}}
 \end{verbatim}
-
-Of course, \TeX{} can do it for you. To avoid switching the language
-all the while, |\babelensure| redefines the captions for a given
-language to wrap them with a selector:
-\begin{verbatim}
-\babelensure{polish}
-\end{verbatim}
-By default only the basic captions and |\today| are redefined, but you
-can add further macros with the key |include| in the optional argument
-(without commas). Macros not to be modified are listed in
-|exclude|. You can also enforce a font encoding with the option
-|fontenc|.\footnote{With it, encoded strings may not work as expected.}
-A couple of examples:
-\begin{verbatim}
-\babelensure[include=\Today]{spanish}
-\babelensure[fontenc=T5]{vietnamese}
-\end{verbatim}
-
-They are activated when the language is selected (at the |afterextras|
-event), and it makes some assumptions which could not be fulfilled in
-some languages. Note also you should include only macros defined by
-the language, not global macros (eg, |\TeX| of |\dag|).
-
-With |ini| files (see below), captions are ensured by default.
-
-\subsection{Shorthands}
-
-A \textit{shorthand} is a sequence of one or two characters that
-expands to arbitrary \TeX{} code.
-
-Shorthands can be used for different kinds of things; for example:
-(1) in some languages shorthands such as |"a| are defined to be able
-to hyphenate the word if the encoding is |OT1|; (2) in some languages
-shorthands such as |!| are used to insert the right amount of white
-space; (3) several kinds of discretionaries and breaks can be inserted
-easily with |"-|, |"=|, etc.
-
-The package \textsf{inputenc} as well as \xetex{} and \luatex{} have
-alleviated entering non-ASCII characters, but minority languages and
-some kinds of text can still require characters not directly available
-on the keyboards (and sometimes not even as separated or precomposed
-Unicode characters). As to the point 2, now \textsf{pdfTeX} provides
-|\knbccode|, and \luatex{} can manipulate the glyph list. Tools for
-point 3 can be still very useful in general.
-
-There are four levels of shorthands: \textit{user}, \textit{language},
-\textit{system}, and \textit{language user} (by order of precedence).
-In most cases, you will use only shorthands provided by languages.
-
-\begin{note} Keep in mind the following:
-\begin{enumerate}
-\item Activated chars used for two-char shorthands cannot be followed
-  by a closing brace |}| and the spaces following are gobbled.  With
-  one-char shorthands (eg,~|:|), they are preserved.
-\item If on a certain level (system, language, user, language user)
-  there is a one-char shorthand, two-char ones starting with that char
-  and on the same level are ignored.
-\item Since they are active, a shorthand cannot contain the same
-  character in its definition (except if deactivated with, eg,
-  |\string|).
-\end{enumerate}
 \end{note}
 
-\begin{troubleshooting}
-\trouble{Argument of \textbackslash language at active@arg"
-has an extra \textbraceright}
-A typical error when using shorthands is the following:
-\begin{verbatim}
-! Argument of \language at active@arg" has an extra }.
-\end{verbatim}
-It means there is a closing brace just after a shorthand, which is not
-allowed (eg,~|"}|). Just add |{}| after (eg,~|"{}}|).
-\end{troubleshooting}
+\subsection{Languages supported by \babel{} in the ‘classical’ mode}
 
-\Describe{\shorthandon}{\marg{shorthands-list}}
-\DescribeOther{\shorthandoff}{%
-\colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
-\marg{shorthands-list}}
-It is sometimes necessary to switch a shorthand
-character off temporarily, because it must be used in an
-entirely different way. For this purpose, the user commands
-|\shorthandoff| and |\shorthandon| are provided. They each take a
-list of characters as their arguments.
+(To be updated.) In the following table most of the languages supported
+by \babel{} with an |.ldf| file are listed, together with the names of
+the option which you can load \babel\ with for each language. Note this
+list is open and the current options may be different. It does not
+include |ini| files (see below). Except in a few cases (eg, |ngerman|,
+|serbianc|, |acadian|) names are those of the Unicode CLDR (or based on
+them).
 
-The command |\shorthandoff| sets the |\catcode| for each of the
-characters in its argument to other (12); the command |\shorthandon|
-sets the |\catcode| to active (13). Both commands only work on `known'
-shorthand characters, and an error will be raised otherwise. You can
-check if a character is a shorthand with |\ifbabelshorthand| (see
-below).
+Most of them work out of the box, but some may require extra fonts,
+encoding files, a preprocessor or even a complete framework (like
+\textsf{CJK} or \textsf{luatexja}). 
 
-\New{3.9a} However, |\shorthandoff| does not behave as
-you would expect with characters like |~| or |^|, because they
-usually are not ``other''. For them |\shorthandoff*| is provided,
-so that with
-\begin{verbatim}
-\shorthandoff*{~^}
-\end{verbatim}
-|~| is still active, very likely with the meaning of a non-breaking
-space, and |^| is the superscript character. The catcodes used are
-those when the shorthands are defined, usually when language files are
-loaded.
+\begingroup
 
-If you do not need shorthands, or prefer an alternative approach of
-your own, you may want to switch them off with the package option
-|shorthands=off|, as described below.
+\bigskip\hrule\nobreak
 
-\begin{warning}
-  It is worth emphasizing these macros are meant for temporary changes.
-  Whenever possible and if there are not conflicts with other packages,
-  shorthands must be always enabled (or disabled).
-\end{warning}
+\makeatletter
+\def\tag#1{\par\@hangfrom{\makebox[10em][l]{#1}}\ignorespaces}
+\def\tag#1#2{\par
+  \hspace{-2em}\textcolor{thered}{\texttt{#1}}#2\enspace}
+\def\subtag#1#2{\par
+  \hspace{-1em}\texttt{#1}#2\enspace}
+\def\subtagalt#1#2{\par
+  \hspace{-1em}\textcolor{thered}{\texttt{#1}}#2\enspace}
+\def\tagmin#1#2{\par
+  \hspace{-2em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace}
+\def\subtagmin#1#2{\par
+  \hspace{-1em}\textcolor[gray]{.4}{\texttt{#1}}#2\enspace}
+\def\note#1{\par{\footnotesize#1\par}}
+\small
 
-\Describe{\useshorthands}{%
-\colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
-\marg{char}}
+\bigskip
 
-The command |\useshorthands| initiates the definition of user-defined
-shorthand sequences. It has one argument, the character that starts
-these personal shorthands.
+\textit{This list is still under revision.}\\
+Recommended names are set in \textcolor{thered}{red}.\\
+Additional languages are set in \textcolor[gray]{.4}{gray}.\\
+Discouraged and deprecated names are not included.\\
+There are some notes in a few languages.
 
-\New{3.9a} User shorthands are not always alive, as they may
-be deactivated by languages (for example, if you use |"| for your user
-shorthands and switch from \textsf{german} to \textsf{french}, they
-stop working). Therefore, a starred version
-|\useshorthands*|\marg{char} is provided, which makes sure shorthands
-are always activated.
+\bigskip\hrule\nobreak
 
-If the package option |shorthands| is used, you must include any
-character to be activated with |\useshorthands|.
-
-\Describe\defineshorthand{\texttt{[}\langlist\texttt{]}%
-     \marg{shorthand}\marg{code}}
-
-The command |\defineshorthand| takes two arguments: the first is
-a one- or two-character shorthand sequence, and the second is the
-code the shorthand should expand to.
-
-\New{3.9a} An optional argument allows to (re)define language and
-system shorthands (some languages do not activate shorthands, so you
-may want to add |\languageshorthands|\marg{language} to the corresponding
-|\extras<language>|, as explained below). By default, user shorthands
-are (re)defined.
-
-User shorthands override language ones, which in turn override
-system shorthands. Language-dependent user shorthands (new in
-3.9) take precedence over ``normal'' user shorthands.
-
-\begin{example}
-  Let's assume you want a unified set of shorthand for discretionaries
-  (languages do not define shorthands consistently, and |"-|, |\-|,
-  |"=| have different meanings).  You can start with, say:
-\begin{verbatim}
-\useshorthands*{"}
-\defineshorthand{"*}{\babelhyphen{soft}}
-\defineshorthand{"-}{\babelhyphen{hard}}
-\end{verbatim}
-  However, the behavior of hyphens is language-dependent. For example, in
-  languages like Polish and Portuguese, a hard hyphen inside compound
-  words are repeated at the beginning of the next line. You can then
-  set:
-\begin{verbatim}
-\defineshorthand[*polish,*portuguese]{"-}{\babelhyphen{repeat}}
-\end{verbatim}
-  Here, options with |*| set a language-dependent user shorthand,
-  which means the generic one above only applies for the rest of
-  languages; without |*| they would (re)define the language shorthands
-  instead, which are overridden by user ones.
-
-  Now, you have a single unified shorthand (|"-|), with a
-  content-based meaning (`compound word hyphen') whose visual behavior
-  is that expected in each context.
-\end{example}
-
-\Describe{\languageshorthands}{\marg{language}} The command
-|\languageshorthands| can be used to switch the shorthands on the
-language level. It takes one argument, the name of a language or
-|none| (the latter does what its name suggests).\footnote{Actually,
-any name not corresponding to a language group does the same as
-\texttt{none}. However, follow this convention because it might be
-enforced in future releases of \babel{} to catch possible errors.}
-Note that for this to work the language should have been specified as
-an option when loading the \babel\ package.  For example, you can use
-in \textsf{english} the shorthands defined by \textsf{ngerman} with
-\begin{verbatim}
-\addto\extrasenglish{\languageshorthands{ngerman}}
-\end{verbatim}
-(You may also need to activate them as user shorthands in the preamble
-with, for example, |\useshorthands| or |\useshorthands*|.)
-
-\begin{example}
-  Very often, this is a more convenient way to deactivate shorthands
-  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}}
-\end{verbatim}
-\end{example}
-
-\Describe{\babelshorthand}{\marg{shorthand}}
-With this command you can use a shorthand even if (1) not activated in
-\texttt{shorthands} (in this case only shorthands for the current
-language are taken into account, ie, not user shorthands), (2) turned
-off with |\shorthandoff| or (3) deactivated with the internal
-|\bbl at deactivate|; for example, \verb|\babelshorthand{"u}| or
-\verb|\babelshorthand{:}|.  (You can conveniently define your own
-macros, or even your own user shorthands provided they do not overlap.)
-
-\begin{example}
-  Since by default shorthands are not activated until
-  |\begin{document}|, you may use this macro when defining the |\title|
-  in the preamble:
-\begin{verbatim}
-\title{Documento científico_\babelshorthand{"-}_técnico}
-\end{verbatim}
-\end{example}
-
+\begin{multicols}{2}
+\leftskip2em\parindent0pt
+\tag{afrikaans}{}
+\tag{albanian}{}
+\tag{arabic}{}
+\tag{azerbaijani}{}
+\tag{basque}{}
+\tag{belarusian}{}
+\tag{bosnian}{}
+\tag{breton}{}
+\tag{bulgarian}{}
+\tag{catalan}{}
+\tag{croatian}{}
+\tag{czech}{}
+\tag{danish}{}
+\tag{dutch}{}
+\tag{english}{}
+\subtagalt{american}{}
+\subtag{USenglish}{}{}
+\subtagalt{australian}{}
+\subtagalt{british}{}
+\subtag{UKenglish}{}
+\subtagalt{canadian}{}
+\subtagalt{newzealand}{}
+\tag{esperanto}{}
+\tag{estonian}{}
+\tagmin{ethiop}{} %%%%%%
+\tag{farsi}{}
+\tag{finnish}{}
+\tag{french}{}
+\subtagalt{acadian}{}
+\tag{friulian}{}
+\tag{galician}{}
+\tag{georgian}{}
+\tag{german}{}
+\note{This block refers to the old ortography. For the modern one, use
+the names in the block \textsf{ngerman}.}
+\subtagalt{austrian}{}
+\subtagalt{swissgerman}{}
+\note{Swiss High German}
+\tag{greek}{}
+% \subtagalt{polutonicogreek}{}
+\subtagmin{ibycus}{}
+\subtagmin{bgreek}{}
+\tag{hebrew}{}
+\tag{hindi}{}
+\tag{hungarian}{}
+\subtag{magyar}{}
+\tag{icelandic}{}
+\tag{indonesian}{}
+\tag{interlingua}{}
+\tag{irish}{}
+\tag{italian}{}
+\tag{japanese}{}
+\tag{kurmanji}{}
+\tag{latin}{}
+% \subtagalt{classiclatin}{}
+% \subtagalt{medievallatin}{}
+% \subtagalt{ecclesiasticlatin}{}
+\tag{latvian}{}
+\tag{lithuanian}{}
+\tag{lowersorbian}{}
+\tag{macedonian}{}
+\tag{malay}{}
+\tag{mongolian}{}
+\tag{ngerman}{}
+\note{This block refers to the new ortography.}
+\subtagalt{naustrian}{}
+\subtagalt{nswissgerman}{}
+\note{Swiss High German}
+\tag{northernsami}{}
+\tag{norwegian}{}
+\subtag{norsk}{}
+\tag{nynorsk}{}
+\tag{occitan}{}
+\tag{piedmontese}{}
+\tagmin{pinyin}{}
+\tag{polish}{}
+\tag{portuguese}{}
+\subtagalt{brazilian}{}
+\tag{romanian}{}
+\tag{romansh}{}
+\tag{russian}{}
+\tag{scottishgaelic}{}
+\note{Preferred to \texttt{scottish}}
+\tag{serbian}{}
+\note{Latin script}
+\subtagalt{serbianc}{}
+\note{Cyrillic script}
+\tag{slovak}{}
+\tag{slovene}{}
+\tag{slovenian}{}  %%%%%% <- and ini
+\tag{spanglish}{}
+\tag{spanish}{}
+\tag{swedish}{}
+\tag{thai}{}
+\subtagmin{thaicjk}{}
+\tag{turkish}{}
+\tag{turkmen}{}
+\tag{ukrainian}{}
+\tag{uppersorbian}{}
+\tag{vietnamese}{}
+\tag{welsh}{}
+\end{multicols}
+\endgroup
+\hrule
 \bigskip
 
-For your records, here is a list of shorthands, but you must double
-check them, as they may change:\footnote{Thanks to Enrico Gregorio}
+% \begin{note}
+%   There are also some deprecated names (a few has been even removed):
+%   \textsf{frenchb} or \textsf{francais}, as well as \textsf{canadien}
+%   (\textsf{french}), \textsf{germanb} (\textsf{german}),
+%   \textsf{bahasa}, \textsf{indon} or \textsf{bahasai}
+%   (\textsf{indonesian}), \textsf{lsorbian} (\textsf{lowersorbian}),
+%   \textsf{bahasam} (\textsf{malay}), \textsf{portuges}
+%   (\textsf{portuguese}), \textsf{brazil} (\textsf{brazilian}),
+%   \textsf{russianb} (\textsf{russian}), \textsf{usorbian}
+%   (\textsf{uppersorbian}), \textsf{vietnam} (\textsf{vietnamese}),
+%   \textsf{samin} (\textsf{northernsami}), \textsf{ukraineb}
+%   (\textsf{ukrainian}). Deprecated names come in many cases from the
+%   times when they had to be shortened to 8 characters. 
+% \end{note}
 
-\begin{description}
-\itemsep=-\parskip
-\item[Languages with no shorthands] Croatian, English (any variety),
-  Indonesian, Hebrew, Interlingua, Irish, Lower Sorbian, Malaysian,
-  North Sami, Romanian, Scottish, Welsh
-\item[Languages with only \texttt{"} as defined shorthand character]
-  Albanian, Bulgarian, Danish, Dutch, Finnish, German (old and new
-  orthography, also Austrian), Icelandic, Italian, Norwegian, Polish,
-  Portuguese (also Brazilian), Russian, Serbian (with Latin script),
-  Slovene, Swedish, Ukrainian, Upper Sorbian
-\item[Basque] |" ' ~|
-\item[Breton] |: ; ? !|
-\item[Catalan] |" ' `|
-\item[Czech] |" -|
-\item[Esperanto] |^|
-\item[Estonian] |" ~|
-\item[French] (all varieties) |: ; ? !|
-\item[Galician] |" . ' ~ < >|
-\item[Greek] (ancient, polutoniko, only 8-bit \TeX) |~|, (optional, see
-the manual for Greek) |;|
-\item[Hungarian] |`|
-\item[Kurmanji] |^|
-\item[Latin] |" ^ =|
-\item[Slovak] |" ^ ' -|
-\item[Spanish] |" . < > ' ~|
-\item[Turkish] |: ! =|
-\end{description}
-In addition, the \babel{} core declares |~| as a one-char shorthand
-which is let, like the standard |~|, to a non breaking
-space.\footnote{This declaration serves to nothing, but it is
-preserved for backward compatibility.}
-
-\Describe\ifbabelshorthand{\marg{character}\marg{true}\marg{false}}
-
-\New{3.23} Tests if a character has been made a shorthand.
-
-\begin{note}
-  \catcode`\|=12\relax Both \textsf{ltxdoc} and \textsf{babel} use
-  \verb|\AtBeginDocument| to change some catcodes, and \babel{} reloads
-  \textsf{hhline} to make sure \verb|:| has the right one, so if you
-  want to change the catcode of \verb/|/ it has to be done using the
-  same method at the proper place, with
-\begin{verbatim}
-\AtBeginDocument{\DeleteShortVerb{\|}}
-\end{verbatim}
-  \textit{before} loading \babel. This way, when the document begins
-  the sequence is (1) make \verb/|/ active (\textsf{ltxdoc}); (2) make
-  it inactive (your settings); (3) make \babel{} shorthands active
-  (\textsf{babel}); (4) reload \textsf{hhline} (\textsf{babel}, now
-  with the correct catcodes for \verb/|/ and
-  \verb|:|).\catcode`\|=\active
-\end{note}
-
-\subsection{Package options}
-
-\New{3.9a}
-These package options are processed before language options, so
-that they are taken into account irrespective of its order. The first
-three options have been available in previous versions.
-
-\Describe{KeepShorthandsActive}{}
-Tells \babel{} not to deactivate shorthands after loading a language
-file, so that they are also available in the preamble.
-
-\Describe{activeacute}{} For some languages \babel\ supports this
-options to set |'| as a shorthand in case it is not done by default.
-
-\Describe{activegrave}{}
-Same for |`|.
-
-\Describe{shorthands=}{\meta{char}\meta{char}...
-$\string|$ \texttt{off}}
-The only language shorthands activated
-are those given, like, eg:
-\begin{verbatim}
-\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
-\verb|~|) should be preceded by \verb|\string| (otherwise they will be
-expanded by \LaTeX{} before they are passed to the package and
-therefore they will not be recognized); however, |t| is provided for
-the common case of |~| (as well as |c| for not so common case of the
-comma).
-
-With |shorthands=off| no language shorthands are defined,
-As some languages use this mechanism for tools not available
-otherwise, a macro \verb|\babelshorthand| is defined, which allows
-using them; see above.
-
-\Describe{safe=}{\texttt{none} $\string|$ \texttt{ref} $\string|$
-\texttt{bib}} Some \LaTeX{} macros are redefined so that using
-shorthands is safe. With \texttt{safe=bib} only |\nocite|, |\bibcite|
-and |\bibitem| are redefined. With |safe=ref| only |\newlabel|, |\ref|
-and |\pageref| are redefined (as well as a few macros from
-\textsf{varioref} and \textsf{ifthen}).
-
-With |safe=none| no macro is redefined. This option is strongly
-recommended, because a good deal of incompatibilities and errors are
-related to these redefinitions. As of \New{3.34}, in $\epsilon$\TeX{}
-based engines (ie, almost every engine except the oldest ones)
-shorthands can be used in these macros (formerly you could not).
-
-\Describe{math=}{\texttt{active} $\string|$ \texttt{normal}}
-Shorthands are mainly intended for text, not for math. By setting this
-option with the value |normal| they are deactivated in math mode
-(default is |active|) and things like |${a'}$| (a closing brace after
-a shorthand) are not a source of trouble anymore.
-
-\Describe{config=}{\meta{file}} Load \meta{file}\texttt{.cfg} instead
-of the default config file |bblopts.cfg| (the file is loaded even
-with |noconfigs|).
-
-\Describe{main=}{\meta{language}} Sets the main language, as explained
-above, ie, this language is always loaded last. If it is not given as
-package or global option, it is added to the list of requested
-languages.
-
-\Describe{headfoot=}{\meta{language}} By default, headlines and
-footlines are not touched (only marks), and if they contain
-language-dependent macros (which is not usual) there may be unexpected
-results. With this option you may set the language in heads and foots.
-An alternative is to set the language explicitly when heads and foots
-are redefined.
-
-\Describe{noconfigs}{} Global and language default config files are
-not loaded, so you can make sure your document is not spoilt by an
-unexpected \texttt{.cfg} file. However, if the key |config| is set,
-this file is loaded.
-
-\Describe{showlanguages}{} Prints to the log the list of languages
-loaded when the format was created: number (remember dialects can
-share it), name, hyphenation file and exceptions file.
-
-% \Describe{nocase}{} \New{3.9l} Language settings for uppercase and
-% lowercase mapping (as set by |\SetCase|) are ignored. Use only if there
-% are incompatibilities with other packages.
-
-\Describe{silent}{} \New{3.9l} No warnings and no \textit{infos} are
-written to the log file.\footnote{You can use alternatively the
-package \textsf{silence}.}
-
-\Describe{hyphenmap=}{\texttt{off} $\string|$ \texttt{first}
-$\string|$ \texttt{select} $\string|$ \texttt{other} $\string|$
-\texttt{other*}}
-
-\New{3.9g} Sets the behavior of case mapping for hyphenation,
-provided the language defines it.\footnote{Turned off in plain.} It
-can take the following values:
-\begin{description}
-\renewcommand\makelabel[1]{%
-  \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
-\itemsep=-\parskip
-\item[off] deactivates this feature and no case mapping is applied;
-\item[first] sets it at the first switching commands in the
-  current or parent scope (typically, when the aux file is first read
-  and at |\begin{document}|, but also the first |\selectlanguage| in
-    the preamble), and it's the default if a single
-    language option has been stated;\footnote{Duplicated options count
-    as several ones.}
-\item[select] sets it only at |\selectlanguage|;
-\item[other] also sets it at |otherlanguage|;
-\item[other*] also sets it at |otherlanguage*| as well as in heads and
-  foots (if the option |headfoot| is used) and in auxiliary files (ie,
-  at |\select at language|), and it's the default if several language
-  options have been stated. The option |first| can be regarded as an
-  optimized version of \texttt{other*} for monolingual
-  documents.\footnote{Providing |foreign| is pointless, because the
-  case mapping applied is that at the end of the paragraph, but if either
-  \xetex{} or \luatex{} change this behavior it might be added. On
-  the other hand, |other| is provided even if I [JBL] think it isn't
-  really useful, but who knows.}
-\end{description}
-
-\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
-  $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
-  \texttt{bidi-r}}
-
-\New{3.14} Selects the bidi algorithm to be used in \luatex{} and
-\xetex{}. See sec.~\ref{bidi}.
-
-\Describe{layout=}{}
-
-\New{3.16} Selects which layout elements are adapted in bidi
-documents. See sec.~\ref{bidi}.
-
-\Describe{provide=}{\texttt{*}}
-\New{3.49} An alternative to |\babelprovide| for languages passed as
-options. See section~\ref{inifiles}, which describes also the variants
-|provide+=| and |provide*=|.
-
-\subsection{The \texttt{base} option}
-
-With this package option \babel{} just loads some basic macros (mainly
-the selectors), defines |\AfterBabelLanguage| and exits. It also
-selects the hyphenation patterns for the last language passed as option
-(by its name in |language.dat|). There are two main uses: classes and
-packages, and as a last resort in case there are, for some reason,
-incompatible languages. It can be used if you just want to select the
-hyphenation patterns of a single language, too.
-
-\Describe\AfterBabelLanguage{\marg{option-name}\marg{code}}
-
-This command is currently the only provided by |base|. Executes
-\meta{code} when the file loaded by the corresponding package option
-is finished (at |\ldf at finish|). The setting is global. So
-\begin{verbatim}
-\AfterBabelLanguage{french}{...}
-\end{verbatim}
-does ... at the end of |french.ldf|. It can be used in |ldf| files,
-too, but in such a case the code is executed only if
-\meta{option-name} is the same as |\CurrentOption| (which could not
-be the same as the option name as set in |\usepackage|!).
-
 \begin{example}
-  Consider two languages \textsf{foo} and \textsf{bar} defining the
-  same |\macro| with |\newcommand|. An error is raised if you attempt
-  to load both. Here is a way to overcome this problem:
+  An example of a language requiring a preprocessor and a separate
+  package is \texttt{hindi}. If you have got the
+  \textsf{velthuis/devnag} package, create a file with
+  extension |.dn|:
 \begin{verbatim}
-\usepackage[base]{babel}
-\AfterBabelLanguage{foo}{%
-  \let\macroFoo\macro
-  \let\macro\relax}
-\usepackage[foo,bar]{babel}
-\end{verbatim}
-\end{example}
-
-\begin{note}
-  With a recent version of \LaTeX, an alternative method to execute
-  some code just after an |ldf| file is loaded is with |\AddToHook| and
-  the hook |file/<language>.ldf/after|. \Babel{} does not predeclare
-  it, and you have to do it yourself with |\ActivateGenericHook|.
-\end{note}
-
-\begin{warning}
-  Currently this option is not compatible with languages loaded on the
-  fly.
-\end{warning}
-
-\subsection{\texttt{ini} files}
-\label{inifiles}
-
-An alternative approach to define a language (or, more precisely, a
-\textit{locale}) is by means of an \texttt{ini} file. Currently
-\babel{} provides about 380 of these files containing the basic data
-required for a locale, covering about 300 languages, plus basic
-templates for about 400 locales.
-
-|ini| files are not meant only for \babel, and they has been devised as
-a resource for other packages. To easy interoperability between \TeX{}
-and other systems, they are identified with the BCP 47 codes as
-preferred by the Unicode Common Locale Data Repository, which was
-used as source for most of the data provided by these files, too (the
-main exception being the |\...name| strings).
-
-Most of them set the date, and many also the captions (Unicode and
-LICR). They will be evolving with the time to add more features
-(something to keep in mind if backward compatibility is important). The
-following section shows how to make use of them by means of
-|\babelprovide|. In other words, |\babelprovide| is mainly meant as
-alternative when the |ldf| does not exists or does not work as
-expected, and for secondary tasks.
-
-\begin{example}
-  Although Georgian has its own \texttt{ldf} file, here is how to
-  declare this language with an |ini| file in Unicode engines.
-\setengine{luatex/xetex}
-\begin{verbatim}
-\documentclass{book}
-
-\usepackage{babel}
-_\babelprovide[import, main]{georgian}_
-
-\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans}
-
+\documentclass{article}
+\usepackage[hindi]{babel}
 \begin{document}
-
-\tableofcontents
-
-\chapter{სამზარეულო და სუფრის ტრადიციები}
-
-ქართული ტრადიციული სამზარეულო ერთ-ერთი უმდიდრესია მთელ მსოფლიოში.
-
+{\dn devaanaa.m priya.h}
 \end{document}
 \end{verbatim}
+  Then preprocess it with |devnag| \m{file}, which creates
+  \m{file}|.tex|; you can then typeset the latter with \LaTeX.
 \end{example}
 
-\begin{more}
-  There is an example of how to use an |ini| template file
-  \href{https://github.com/latex3/babel/issues/176#issuecomment-1080846575}{here},
-  for Phoenician (although currently this locale is bundled with
-  \babel).
-\end{more}
+\subsection{Languages supported by \babel{} in the ‘modern’ mode}
 
-\New{3.49} Alternatively, you can tell \babel{} to load all or some
-languages passed as options with |\babelprovide| and not from the |ldf|
-file in a few few typical cases. Thus, |provide=*| means ‘load the main
-language with the |\babelprovide| mechanism instead of the |ldf| file’
-applying the basic features, which in this case means |import,| |main|.
-There are (currently) three options:
-\begin{itemize}
-\item |provide=*| is the option just explained, for the main language;
-\item |provide+=*| is the same for additional languages (the main
-  language is still the |ldf| file);
-\item |provide*=*| is the same for all languages, ie, main and
-  additional.
-\end{itemize}
-
-\begin{example}
-  The preamble in the previous example can be more compactly written
-  as:
-\begin{verbatim}
-\documentclass{book}
-\usepackage[_georgian, provide=*_]{babel}
-\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans}
-\end{verbatim}
-Or also:
-\begin{verbatim}
-\documentclass[_georgian_]{book}
-\usepackage[_provide=*_]{babel}
-\babelfont{rm}[Renderer=Harfbuzz]{DejaVu Sans}
-\end{verbatim}
-\end{example}
-
-\begin{note}
-  The \texttt{ini} files just define and set some parameters, but the
-  corresponding behavior is not always implemented. Also, there are
-  some limitations in the engines. A few remarks follow (which could no
-  longer be valid when you read this manual, if the packages involved
-  have been updated). The Harfbuzz renderer still has some issues, so as
-  a rule of thumb prefer the default renderer, and resort to Harfbuzz
-  only if the former does not work for you. Fortunately, fonts can be
-  loaded twice with different renderers; for example:
-\begin{verbatim}
-\babelfont[spanish]{rm}{FreeSerif}
-\babelfont[hindi]{rm}[Renderer=Harfbuzz]{FreeSerif}
-\end{verbatim}
-\begin{description}
-\itemsep=-\parskip
-\item[Arabic] Monolingual documents mostly work in \luatex, but it must
-  be fine tuned, particularly math and graphical elements like
-  |picture|. In \xetex{} \babel{} resorts to the \textsf{bidi} package,
-  which seems to work.
-\item[Hebrew] Niqqud marks seem to work in both engines, but depending 
-  on the font cantillation marks might be misplaced (\xetex{} or
-  \luatex{} with Harfbuzz seems better).
-\item[Devanagari] In \luatex{} and the default renderer many fonts
-work, but some others do not, the main issue being the ‘ra’. You may
-need to set explicitly the script to either |deva| or |dev2|, eg:
-\begin{verbatim}
-\newfontscript{Devanagari}{deva}
-\end{verbatim}
-  Other Indic scripts are still under development in the default
-  \luatex{} renderer, but should work with |Renderer=Harfbuzz|. They
-  also work with \xetex{}, although unlike with \luatex{} fine tuning
-  the font behavior is not always possible.
-\item[Southeast scripts] Thai works in both \luatex{} and \xetex{}, but
-  line breaking differs (rules are hard-coded in \xetex, but they can
-  be modified in \luatex). Lao seems to work, too, but there are no
-  patterns for the latter in \luatex{}. Khemer clusters are rendered
-  wrongly with the default renderer. The comment about Indic scripts
-  and \textsf{lualatex} also applies here. Some quick patterns can
-  help, with something similar to:
-\begin{verbatim}
-\babelprovide[import, hyphenrules=+]{lao}
-\babelpatterns[lao]{1ດ 1ມ 1ອ 1ງ 1ກ 1າ} % Random
-\end{verbatim}
-\item[East Asia scripts] Settings for either Simplified of Traditional
-  should work out of the box, with basic line breaking with any
-  renderer. Although for a few words and shorts texts the |ini| files
-  should be fine, CJK texts are best set with a dedicated framework
-  (\textsf{CJK}, \textsf{luatexja}, \textsf{kotex}, \textsf{CTeX},
-  etc.). This is what the class |ltjbook| does with \luatex, which can
-  be used in conjunction with the |ldf| for |japanese|, because the
-  following piece of code loads \textsf{luatexja}:
-\begin{verbatim}
-\documentclass[japanese]{ltjbook}
-\usepackage{babel}
-\end{verbatim}
-\item[Latin, Greek, Cyrillic] Combining chars with the default
- \luatex{} font renderer might be wrong; on then other hand, with the
- Harfbuzz renderer diacritics are stacked correctly, but many
- hyphenations points are discarded (this bug is related to kerning,
- so it depends on the font). With \xetex{} both combining characters
- and hyphenation work as expected (not quite, but in most cases it
- works; the problem here are font clusters).
-\end{description}
-\end{note}
-
-\begin{note}
-  Wikipedia defines a \textit{locale} as follows: “In computing, a
-  locale is a set of parameters that defines the user’s language,
-  region and any special variant preferences that the user wants to see
-  in their user interface. Usually a locale identifier consists of at
-  least a language code and a country/region code.” \Babel{} is moving
-  gradually from the old and fuzzy concept of \textit{language} to the
-  more modern of \textit{locale}. Note each locale is by itself a
-  separate “language”, which explains why there are so many files. This
-  is on purpose, so that possible variants can be created and/or
-  redefined easily.
-\end{note}
-
-\textbf{Modifying and adding values to |ini| files}
-
-\nobreak 
-\New{3.39} There is a way to modify the values of |ini| files when they
-get loaded with |\babelprovide| and |import|. To set, say,
-|digits.native| in the |numbers| section, use something like
-|numbers/digits.native=abcdefghij|. Keys may be added, too. Without
-|import| you may modify the identification keys.
-
-This can be used to create private variants easily. All you need is to
-import the same |ini| file with a different locale name and different
-parameters. 
-
-% \begin{example}
-%   Let's assume you need only the basic features of `spanish`, so that
-%   the |ini| file is enough, and also a variant with your own
-%   hyphenation with
-% \end{example}
-
-\subsection{List of locales available in \cs{babelprovide}}
-
 Here is the list of the names currently supported with |ini| locale
 files, with |\babelprovide| (or |provide=|). With these languages,
 |\babelfont| loads (if not done before) the language and script names
@@ -1720,7 +988,7 @@
 \bigskip\hrule\nobreak
 
 \makeatletter
-\def\tag#1{\par\@hangfrom{\makebox[10em][l]{#1}}\ignorespaces}
+\def\tag#1{\par\@hangfrom{\makebox[1em][l]{#1}}\ignorespaces}
 \def\tag#1#2#3{\par
   \hspace{-2em}\textcolor{thered}{\texttt{#1}}#2\enspace
   \mbox{\footnotesize(#3)}}
@@ -1754,7 +1022,7 @@
 \bigskip\hrule\nobreak
 
 \begin{multicols}{2}
-\leftskip2em
+\leftskip2em\parindent0pt
 \tag{abkhazian}{}{ab}
 \tag{afar}{}{aa}
 \tag{afrikaans}{\hascapu\hascapl}{af}
@@ -2271,54 +1539,72 @@
 \hrule
 \bigskip
 
-\subsection{Selecting fonts}
+\subsection{Fonts in Unicode engines}
+\label{fonts}
 
-\New{3.15} Babel provides a high level interface on top of |fontspec|
-to select fonts. There is no need to load \textsf{fontspec} explicitly
--- \babel{} does it for you with the first |\babelfont|.\footnote{See
-also the package \textsf{combofont} for a complementary approach.}
+\begin{note}
+  For \textsf{pdflatex} and the standard \textsf{fontenc} mechanism,
+  refer to the \LaTeX{} manuals or \textit{The \LaTeX{} Companion},
+  vol.~I, ch.~9, and vol.~II, ch.~10.
+\end{note}
 
+\New{3.15} \Babel{} has native support for Unicode fonts (OpenType and
+TrueType) in \xetex{} and \luatex{} by means of a high level interface
+on top of |fontspec|. This makes it easier to handle a wide range of
+languages and scripts, and simplifies the process of typesetting
+multilingual documents. As described below, with \luatex{} the font can
+be switched automatically based on the script without explicit markup.
+
+There is no need to load \textsf{fontspec} explicitly – \babel{} does
+it for you with the first |\babelfont|. (See also the package
+\textsf{combofont} for a complementary approach.)
+
 \Describe\babelfont{\oarg{language-list}\marg{font-family}%
   \oarg{font-options}\marg{font-name}}
 
-\begin{note}
-  See the note in the previous section about some issues in
-  specific languages.
-\end{note}
+% \begin{note}
+%   See the note in the previous section about some issues in
+%   specific languages.
+% \end{note}
 
-The main purpose of |\babelfont| is to define at once in a multilingual
-document the fonts required by the different languages, with their
-corresponding language systems (script and language). So, if you load,
-say, 4 languages, |\babelfont{rm}{FreeSerif}| defines 4 fonts (with
-their variants, of course), which are switched with the language by
-\babel. It is a tool to make things easier and transparent to the user.
+The main purpose of |\babelfont| is to define at once the fonts
+required by the different languages, with their corresponding language
+systems (script and language). So, if you load, say, 4 languages,
+|\babelfont{rm}{FreeSerif}| defines 4 fonts (with their variants, of
+course), which are switched with the language by \babel. It is a tool
+to make things easier and transparent to the user.
 
 Here \textit{font-family} is |rm|, |sf| or |tt| (or newly defined
 ones, as explained below), and \textit{font-name} is the same as in
 \textsf{fontspec} and the like.
 
-If no language is given, then it is considered the default font for
-the family, activated when a language is selected.
+If no language is given, then it is considered the default font for the
+family. On the other hand, if there is one or more languages in the
+optional argument, the font will be assigned to all of them, overriding
+the default one. Alternatively, you may set a font for a script -- just
+precede its name (lowercase) with a star (eg, |*devanagari|).
 
-On the other hand, if there is one or more languages in the optional
-argument, the font will be assigned to them, overriding the default one.
-Alternatively, you may set a font for a script -- just precede its name
-(lowercase) with a star (eg, |*devanagari|). With this optional
-argument, the font is \textit{not} yet defined, but just predeclared.
-This means you may define as many fonts as you want ‘just in case’,
-because if the language is never selected, the corresponding
-|\babelfont| declaration is just ignored.
+With the optional argument, the font is \textit{not} yet loaded, but
+just predeclared. In other words, font loading is lazy, which means you
+may define as many fonts as you want ‘just in case’, because if the
+language is never selected, the corresponding |\babelfont| declaration
+is just ignored.
 
 \Babel{} takes care of the font language and the font script when
-languages are selected (as well as the writing direction); see the
-recognized languages above. In most cases, you will not need
-\textit{font-options}, which is the same as in \textsf{fontspec}, but
-you may add further key/value pairs if necessary.
+languages are selected (as well as the writing direction). In most
+cases, you will not need \textit{font-options}, which is the same as in
+\textsf{fontspec}, but you may add further key/value pairs if
+necessary.
 
+|\babelfont| can be used to implicitly define a new font family. Just
+write its name instead of |rm|, |sf| or |tt|. This is the preferred way
+to select fonts in addition to the three basic families.
+
 \begin{example}
   Usage in most cases is very simple. Let us assume you are setting up
   a document in Swedish, with some words in Hebrew, with a font suited
-  for both languages.
+  for both languages. Here the option |bidi=default| activates a simple
+  (or, rather, simplistic) bidirectional mode.
   \begingroup
 % If you are looking at the code to see how it has been written, you
 % will be disappointed :-). The following example is built ad hoc to
@@ -2355,15 +1641,27 @@
 \end{verbatim}
 \end{example}
 
-|\babelfont| can be used to implicitly define a new font family. Just
-write its name instead of |rm|, |sf| or |tt|. This is the preferred way
-to select fonts in addition to the three basic families.
+\begin{example}
+Thanks to this high level interface to |fontenc|, the roman fonts for
+all secondary languages in the Cyrillic and Greek scripts can be set
+at once with the following single line:
+\setengine{luatex/xetex}
+\begin{verbatim}
+\babelfont[_*cyrillic, *greek_]{rm}{NewComputerModern10}
+\end{verbatim}
+With some scripts, the \textsf{Harfbuzz} renderer is preferred:
+\begin{verbatim}
+  \babelfont[_*arabic, *devanagari_]{rm}[_Renderer=Harfbuzz_]{FreeSerif}
+\end{verbatim}
+\Babel{} does the rest for you, including setting the font language and
+script.
+\end{example}
 
 \begin{example}
-  Here is how to do it:
+  Here is how to declare a new family:
 \setengine{luatex/xetex}
 \begin{verbatim}
-\babelfont{kai}{FandolKai}
+\babelfont{_kai_}{FandolKai}
 \end{verbatim}
   Now, |\kaifamily| and |\kaidefault|, as well as |\textkai| are at
   your disposal.
@@ -2379,10 +1677,6 @@
 \end{verbatim}
   This makes sure the OpenType script for Devanagari is |deva| and not
   |dev2|, in case it is not detected correctly.
-%   You may also pass some
-%   options to \textsf{fontspec}: with |silent|, the warnings about
-%   unavailable scripts or languages are not shown (they are only really
-%   useful when the document format is being set up).
 \end{note}
 
 \begin{note}
@@ -2414,6 +1708,16 @@
   above for the reasons of this behavior.
 \end{note}
 
+\begin{note}
+  |\babelfont| is a high level interface to \textsf{fontspec}, and
+  therefore in \xetex{} you can apply |Mapping|s. For example, there is
+  a set of 
+  \href{https://github.com/davidmjones/brahmic-maps}{transliterations
+  for Brahmic scripts} by Davis M. Jones. After installing
+  them in you distribution, just set the map as you would do with
+  \textsf{fontspec}.
+\end{note}
+
 \begin{warning}
   Using |\set|\textit{xxxx}|font| and |\babelfont| at the same time is
   discouraged, but very often works as expected. However, be aware with
@@ -2465,23 +1769,762 @@
   be aware that this may lead to some problems.
 \end{troubleshooting}
 
+\subsection{Basic language selectors}
+\label{selectors}
+
+This section describes the commands to be used in the document to
+switch the language in multilingual documents. In most cases, only the
+two basic macros |\selectlanguage| and |\foreignlanguage| are
+necessary. The environments |otherlanguage|, |otherlanguage*| are
+auxiliary, and described in the next section.
+
+The main language is selected automatically when the |document|
+environment begins.
+
+\Describe{\selectlanguage}{\marg{language}}
+\DescribeOther{\begin\menv{selectlanguage}}%
+   {\marg{language}\Eenv{selectlanguage}}
+
+When a user wants to switch from one language to another he can do so
+using the macro |\selectlanguage|. It is meant for blocks of texts, and
+therefore should be used mainly in vertical mode, although it also
+works in horizontal mode.
+\begin{verbatim}
+\selectlanguage{german}
+\end{verbatim}
+
+This command can be used as environment, too, in case there are
+relatively short texts and you do not want to reset the language with a
+hardcode value.
+
 \begin{note}
-  |\babelfont| is a high level interface to \textsf{fontspec}, and
-  therefore in \xetex{} you can apply |Mapping|s. For example, there is
-  a set of 
-  \href{https://github.com/davidmjones/brahmic-maps}{transliterations
-  for Brahmic scripts} by Davis M. Jones. After installing
-  them in you distribution, just set the map as you would do with
-  \textsf{fontspec}.
+  Bear in mind |\selectlanguage| can be automatically executed, in some
+  cases, in the auxiliary files, at heads and foots, and after the
+  environment |otherlanguage*|.
 \end{note}
 
-\subsection{Modifying a language}
+\begin{warning}
+  If used inside braces or a group there might be some non-local
+  changes, as it would be roughly equivalent to:
+\begin{verbatim}
+\bgroup
+\selectlanguage{<inner-language>}
+...
+\egroup
+\selectlanguage{<outer-language>}
+\end{verbatim}
+  If you want a change which is really local, you must enclose this
+  code with an additional grouping level. The same applies to the
+  environment version.
+\end{warning}
 
+\begin{warning}
+  There are a couple of issues related to the way the language
+  information is written to the auxiliary files:
+\begin{itemize}
+  \item |\selectlanguage| should not be used inside some boxed environments
+    (like floats or |minipage|) to switch the language if you need the
+    information written to the |aux| be correctly synchronized. This
+    rarely happens, but if it were the case, you must use the
+    environment version or |otherlanguage| instead.
+  \item In addition, this macro inserts a |\write| in vertical mode,
+    which may break the vertical spacing in some cases (for example,
+    between lists or at the beginning of a table cell). \New{3.64} The
+    behavior can be adjusted with
+    |\babeladjust{select.write=<mode>}|, where \m{mode} is |shift|
+    (which shifts the skips down and adds a |\penalty|); |keep| (the
+    default -- with it the |\write| and the skips are kept in the order
+    they are written), and |omit| (which may seem a too drastic
+    solution, because nothing is written, but more often than not this
+    command is applied to more or less shorts texts with no sectioning
+    or similar commands, and therefore no language synchronization is
+    necessary). In a table cell, a |\leavevmode| just before the
+    selector may be enough.
+\end{itemize}
+\end{warning}
+
+\Describe{\foreignlanguage}{\oarg{option-list}\marg{language}\marg{text}}
+
+It takes two mandatory 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), and since it is meant for phrases
+only the text direction (and not the paragraph one) is set.
+
+\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.
+
+\begin{note}
+  |\bibitem| is out of sync with |\selectlanguage| in the \file{.aux}
+  file. The reason is |\bibitem| uses |\immediate| (and others, in
+  fact), while |\selectlanguage| doesn't. There is a similar issue with
+  floats, too. There is no known workaround, but it’s not usually a
+  real issue.
+\end{note}
+
+\subsection{Auxiliary language selectors}
+
+\Describe{\begin\menv{otherlanguage}}{\marg{language}\Eenv{otherlanguage}}
+
+Same as |selectlanguage| as environment, except spaces after the
+|\begin| and |\end| commands are ignored. (Very likely, and because of
+the limitations of many old editors with bidi text, the idea was
+\cs{end}\texttt{\{otherlanguage\}} had to be a line by itself.) The
+warning above about the internal |\write| also applies here. The
+current mode (vertical or horizontal) also remains unchanged.
+
+\Describe{\begin\menv{otherlanguage*}}%
+{\oarg{option-list}\marg{language}\Eenv{otherlanguage*}}
+
+Same as |\foreignlanguage| but as environment. Spaces are \textit{not}
+ignored.
+
+It was originally devised for intermixing left-to-right
+typesetting with right-to-left typesetting in engines not supporting a
+change in the writing direction inside a line. However, by default it
+never complied with the documented behavior and it is just a version as
+environment of |\foreignlanguage|, except when the package option
+|bidi| is set -- in this case, |\foreignlanguage| emits a
+|\leavevmode|, while |otherlanguage*| does not. Like |\foreignlanguage|
+it is a \textit{text} command, and therefore it doesn’t change the
+paragraph direction.
+
+\subsection{Plain}
+
+In e-Plain and pdf-Plain, load languages styles with |\input| and then use
+|\begindocument| (the latter is defined by \babel):
+\begin{verbatim}
+\input estonian.sty
+\begindocument
+\end{verbatim}
+
+\begin{warning}
+  Not all languages provide a |sty| file and some of them are not
+  compatible with those formats. Please, refer to
+  \href{https://latex3.github.io/babel/guides/using-babel-with-plain.html}%
+   {Using babel with Plain} for further details.
+\end{warning}
+
+\section{More on language loading and selection}
+
+\subsection{A couple of tools}
+
+% Also Plain
+\Describe{\babeltags}{\char`\{\m{tag1} \texttt{=} \m{language1}, \m{tag2}
+\texttt{=} \m{language2}, \dots\char`\}}
+
+\New{3.9i} In multilingual documents with many language-switches the
+commands above can be cumbersome. With this tool shorter names can be
+defined. It adds nothing really new -- it is just syntactical sugar.
+
+It defines |\text<tag1>{<text>}| to be
+|\foreignlanguage{<language1>}{<text>}|, and |\begin{<tag1>}|
+to be |\begin{otherlanguage*}{<language1>}|, and so on. Note
+|\<tag1>| is also allowed, but remember to set it locally inside a
+group.
+
+\begin{warning}
+  There is a clear drawback to this feature, namely, the ‘prefix’
+  |\text...| is heavily overloaded in \LaTeX{} and conflicts with
+  existing macros may arise (|\textlatin|, |\textbar|, |\textit|,
+  |\textcolor| and many others). The same applies to environments,
+  because |arabic| conflicts with |\arabic|. Furthermore, and because of
+  this overloading, detecting the language of a chunk of text by
+  external tools can become unfeasible (is |\textga| the locale for the
+  African language Gã or something else?). Except if there is a reason for
+  this ‘syntactical sugar’, the best option is to stick to the default
+  selectors or even to define your own alternatives.
+\end{warning}
+
+\begin{example}
+With
+\begin{verbatim}
+\babeltags{de = german}
+\end{verbatim}
+you can write
+\begin{verbatim}
+text \textde{German text} text
+\end{verbatim}
+and
+\begin{verbatim}
+text
+\begin{de}
+  German text
+\end{de}
+text
+\end{verbatim}
+\end{example}
+
+\begin{note}
+  Something like \verb|\babeltags{finnish = finnish}| is legitimate --
+  it defines |\textfinnish| and |\finnish| (and, of course,
+  |\begin{finnish}|).
+\end{note}
+
+% Also Plain
+\Describe{\babelensure}{|[include=|\m{commands}|,exclude=|\m{commands}%
+  |,fontenc=|\m{encoding}|]|\marg{language}}
+
+\New{3.9i} Except in a few languages, like \textsf{russian},
+captions and dates are just strings, and do not switch the
+language. That means you should set it explicitly if you want to use
+them, or hyphenation (and in some cases the text itself) will be
+wrong. For example:
+\begin{verbatim}
+\foreignlanguage{russian}{text \foreignlanguage{polish}{\seename} text}
+\end{verbatim}
+
+Of course, \TeX{} can do it for you. To avoid switching the language
+all the while, |\babelensure| redefines the captions for a given
+language to wrap them with a selector:
+\begin{verbatim}
+\babelensure{polish}
+\end{verbatim}
+By default only the basic captions and |\today| are redefined, but you
+can add further macros with the key |include| in the optional argument
+(without commas). Macros not to be modified are listed in
+|exclude|. You can also enforce a font encoding with the option
+|fontenc|.\footnote{With it, encoded strings may not work as expected.}
+A couple of examples:
+\begin{verbatim}
+\babelensure[include=\Today]{spanish}
+\babelensure[fontenc=T5]{vietnamese}
+\end{verbatim}
+
+They are activated when the language is selected (at the |afterextras|
+event), and it makes some assumptions which could not be fulfilled in
+some languages. Note also you should include only macros defined by
+the language, not global macros (eg, |\TeX| of |\dag|).
+
+With |ini| files (see below), captions are ensured by default.
+
+\subsection{Accessing language info}
+
+% Also Plain
+\Describe{\localename}{}
+\DescribeOther{\mainlocalename}{}
+\DescribeOther{\languagename}{}
+
+\New{24.10} The control sequence |\localename| contains the name of the current
+locale. This is now the recommended way to retrieve the current
+language. In addtion, |\mainlocalename| contains the main language.
+
+|\languagename| is still used internally, but it is now discouraged at
+the user level.
+
+\begin{warning}
+  Due to a bug, which lead to some internal inconsistencies in
+  catcodes, |\languagename| should \textit{not} be used to test which
+  is the current language. Rely on |\localename| or, if you still need
+  |\languagename| for some reason, on \textsf{iflang}, by Heiko Oberdiek.
+\end{warning}
+
+\Describe{\iflanguage}{\marg{language}\marg{true}\marg{false}}
+
+Here ``language'' is used in the \TeX{} sense, as a set of hyphenation
+patterns, and \textit{not} as its \textsf{babel} name. The first
+argument is the name of a language.
+
+\Describe{\localeinfo}{\optstar{\marg{field}}}
+
+\New{3.38} If an |ini| file has been loaded for the current language,
+you may access the information stored in it. Note with the ‘classical’
+|ldf| files the corresponding |ini| ones are also loaded, but only some
+basic data required for fonts, casing and a few more. 
+
+This macro is fully expandable, but raises an error if the info doesn’t
+exist. \New{3.75} Sometimes, it comes in handy to be able to use
+|\localeinfo| in an quite fully expandable way even if something went
+wrong (for example, the locale currently active is undefined). For
+these cases, |localeinfo*| just returns an empty string instead of
+raising an error.
+
+The available fields are:
+\begin{description}
+\itemsep=-\parskip
+\item[|name.english|] as provided by the Unicode CLDR.
+\item[|tag.ini|] is the tag of the |ini| file (the way this
+  file is identified in its name).
+\item[|tag.bcp47|] is the full BCP 47 tag (see the warning below). This
+  is the value to be used for the ‘real' provided tag (\babel{} may
+  fill other fields if they are considered necessary).
+\item[|language.tag.bcp47|] is the BCP 47 language tag.
+\item[|tag.opentype|] is the tag used by OpenType (usually, but not
+  always, the same as BCP 47).
+\item[|script.name|], as provided by the Unicode CLDR.
+\item[|script.tag.bcp47|] is the BCP 47 tag of the script
+  used by this locale. This is a required field for the fonts to be
+  correctly set up, and therefore it should be always defined.
+\item[|script.tag.opentype|] is the tag used by OpenType (usually,
+  but not always, the same as BCP 47).
+\item[|region.tag.bcp47|] is the BCP 47 tag of the region or territory.
+  Defined only if the locale loaded actually contains it (eg, |es-MX|
+  does, but |es| doesn’t), which is how locales behave in the CLDR.
+  \New{3.75}
+\item[|variant.tag.bcp47|] is the BCP 47 tag of the variant (in the BCP 47
+  sense, like |1901| for German). \New{3.75}
+\item[|extension.|\m{s}|.tag.bcp47|] is the BCP 47 value of the
+  extension whose singleton is \m{s} (currently the recognized
+  singletons are |x|, |t| and |u|). The internal syntax can be somewhat
+  complex, and this feature is still somewhat tentative. An example is
+  \textsf{classicallatin} which sets |extension.x.tag.bcp47| to |classic|.
+  \New{3.75}
+\end{description}
+
+% All of these keys can be preceded by |main.| (eg, |main.tag.ini|),
+% which retrieves the values of the main locale.
+
+\begin{note}
+  Currently, |x| is used for two separate functions, namely,
+  identifying a \babel{} locale without a BCP47 tag and setting an
+  alternative set of rules for casing.
+\end{note}
+
+\begin{note}
+  Bear in mind that \babel{}, following the CLDR, may leave the region
+  unset, which means |\getlocaleproperty*|, described below, is the
+  preferred command, so that the existence of a field can be checked
+  before. This also means building a string with the language and the
+  region with something like
+  |\localeinfo*{language.tab.bcp47}|\allowbreak |-|\allowbreak
+  |\localeinfo*{region.tab.bcp47}| is not usually a good idea (because
+  of the hyphen).
+\end{note}
+
+\begin{warning}
+  \New{3.46} As of version 3.46 |tag.bcp47| returns the full BCP 47
+  tag. Formerly it returned just the language subtag, which was clearly
+  counterintuitive.
+\end{warning}
+
+\Describe{\getlocaleproperty}{%
+  \optstar\marg{macro}\marg{locale}\marg{property}}
+
+\New{3.42} The value of any locale property as set by the |ini| files
+(or added/modified with |\babelprovide|) can be retrieved and stored in
+a macro with this command. For example, after:
+\begin{verbatim}
+  \getlocaleproperty\hechap{hebrew}{captions/chapter}
+\end{verbatim}
+the macro |\hechap| will contain the string
+{\fontspec[Scale=.87,Script=Hebrew]{Liberation Mono}\textdir TRT פרק}.
+
+If the key does not exist, the macro is set to |\relax| and an error is
+raised. \New{3.47} With the starred version no error is raised, so that
+you can take your own actions with undefined properties.
+
+\Describe{\localeid}{}
+Each language in the \babel{} sense has its own unique numeric
+identifier, which can be retrieved with |\localeid|.
+
+The |\localeid| is not the same as the |\language| identifier, which
+refers to a set of hyphenation patterns (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
+(when it makes sense) as an attribute, too.
+
+\Describe{\ShowLocaleProperties}{\marg{language}}
+\New{3.98} Prints to the |log| file all the loaded key/value pairs from
+the |ini| locale file for \meta{language}. 
+
+\Describe{\LocaleForEach}{\marg{code}}
+\Babel{} remembers which |ini| files have been loaded. There is a loop
+named |\LocaleForEach| to traverse the list, where |#1| is the name of
+the current item, so that |\LocaleForEach{\message{ **#1** }}| just
+shows the loaded |ini|’s. 
+
+\subsection{Package options}
+
+\New{3.9a}
+These package options are processed before language options, so
+that they are taken into account irrespective of its order. The first
+three options have been available in previous versions.
+
+\Describe{KeepShorthandsActive}{}
+Tells \babel{} not to deactivate shorthands after loading a language
+file, so that they are also available in the preamble.
+
+\Describe{headfoot=}{\meta{language}} By default, headlines and
+footlines are not touched (only marks), and if they contain
+language-dependent macros (which is not usual) there may be unexpected
+results. With this option you may set the language in heads and foots.
+An alternative is to set the language explicitly when heads and foots
+are redefined.
+
+\Describe{noconfigs}{} Global and language default config files are
+not loaded, so you can make sure your document is not spoilt by an
+unexpected \texttt{.cfg} file. However, if the key |config| is set,
+this file is loaded.
+
+\Describe{config=}{\meta{file}} Load \meta{file}\texttt{.cfg} instead
+of the default config file |bblopts.cfg| (forced even with
+|noconfigs|).
+
+\Describe{showlanguages}{} Prints to the log the list of languages
+loaded when the format was created: number (remember dialects can
+share it), name, hyphenation file and exceptions file.
+
+\Describe{silent}{} \New{3.9l} No warnings and no \textit{infos} are
+written to the log file.\footnote{You can use alternatively the
+package \textsf{silence}.}
+
+\Describe{hyphenmap=}{\texttt{off} $\string|$ \texttt{first}
+$\string|$ \texttt{select} $\string|$ \texttt{other} $\string|$
+\texttt{other*}}
+
+\New{3.9g} Sets the behavior of case mapping for hyphenation,
+provided the language defines it.\footnote{Turned off in plain.} It
+can take the following values:
+\begin{description}
+\renewcommand\makelabel[1]{%
+  \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
+\itemsep=-\parskip
+\item[off] deactivates this feature and no case mapping is applied;
+\item[first] sets it at the first switching commands in the
+  current or parent scope (typically, when the aux file is first read
+  and at |\begin{document}|, but also the first |\selectlanguage| in
+    the preamble), and it's the default if a single
+    language option has been stated;\footnote{Duplicated options count
+    as several ones.}
+\item[select] sets it only at |\selectlanguage|;
+\item[other] also sets it at |otherlanguage|;
+\item[other*] also sets it at |otherlanguage*| as well as in heads and
+  foots (if the option |headfoot| is used) and in auxiliary files (ie,
+  at |\select at language|), and it's the default if several language
+  options have been stated. The option |first| can be regarded as an
+  optimized version of \texttt{other*} for monolingual
+  documents.\footnote{Providing |foreign| is pointless, because the
+  case mapping applied is that at the end of the paragraph, but if either
+  \xetex{} or \luatex{} change this behavior it might be added. On
+  the other hand, |other| is provided even if I [JBL] think it isn't
+  really useful, but who knows.}
+\end{description}
+
+\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
+  $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
+  \texttt{bidi-r}}
+
+\New{3.14} Selects the bidi algorithm to be used in \luatex{} and
+\xetex{}. See sec.~\ref{bidi}.
+
+\Describe{layout=}{}
+
+\New{3.16} Selects which layout elements are adapted in bidi
+documents. See sec.~\ref{bidi}.
+
+\Describe{provide=}{\texttt{*} $\string|$ \meta{option-list}}
+\New{3.49} An alternative to |\babelprovide| for languages passed as
+options. See section~\ref{inifiles}, which describes also the variants
+|provide+=| and |provide*=|.
+
+\Describe{main=}{\meta{language}} Forces the main language, but this
+option should not be used except if there a need to do it. If the
+language is not given as such as package or global option, it is added
+to the list of requested languages. For example:
+\begin{verbatim}
+\documentclass{article}
+\usepackage[_main=english_,dutch]{babel}
+\end{verbatim}
+Some classes load \babel{} with a hardcoded language option. Sometimes,
+the main language can be overridden with something like that before
+|\documentclass|:
+\begin{verbatim}
+\PassOptionsToPackage{main=english}{babel}
+\end{verbatim}
+
+\subsection{The \texttt{base} option}
+
+With this package option \babel{} just loads some basic macros (mainly
+the selectors), defines |\AfterBabelLanguage| and exits. It also
+selects the hyphenation patterns for the last language passed as option
+(by its name in |language.dat|). There are two main uses: classes and
+packages, and as a last resort in case there are, for some reason,
+incompatible languages. It can be used if you just want to select the
+hyphenation patterns of a single language, too.
+
+\Describe\AfterBabelLanguage{\marg{option-name}\marg{code}}
+
+This command is currently the only provided by |base|. Executes
+\meta{code} when the file loaded by the corresponding package option
+is finished (at |\ldf at finish|). The setting is global. So
+\begin{verbatim}
+\AfterBabelLanguage{french}{...}
+\end{verbatim}
+does ... at the end of |french.ldf|. It can be used in |ldf| files,
+too, but in such a case the code is executed only if
+\meta{option-name} is the same as |\CurrentOption| (which could not
+be the same as the option name as set in |\usepackage|!).
+
+\begin{example}
+  Consider two languages \textsf{foo} and \textsf{bar} defining the
+  same |\macro| with |\newcommand|. An error is raised if you attempt
+  to load both. Here is a way to overcome this problem:
+\begin{verbatim}
+\usepackage[base]{babel}
+\AfterBabelLanguage{foo}{%
+  \let\macroFoo\macro
+  \let\macro\relax}
+\usepackage[foo,bar]{babel}
+\end{verbatim}
+\end{example}
+
+\begin{note}
+  With a recent version of \LaTeX, an alternative method to execute
+  some code just after an |ldf| file is loaded is with |\AddToHook| and
+  the hook |file/<language>.ldf/after|. \Babel{} does not predeclare
+  it, and you have to do it yourself with |\ActivateGenericHook|.
+\end{note}
+
+\begin{warning}
+  Currently this option is not compatible with languages loaded on the
+  fly.
+\end{warning}
+
+\subsection{\texttt{provide} and \cs{babelprovide} – \texttt{ini} files}
+\label{inifiles}
+
+An alternative approach to define a language (or, more precisely, a
+\textit{locale}) is by means of an \texttt{ini} file. Currently
+\babel{} provides about 380 of these files containing the basic data
+required for a locale, covering about 300 languages and 40 scripts,
+plus basic templates for about 400 locales. 
+
+|ini| files are not meant only for \babel, and they has been devised as
+a resource for other packages. To easy interoperability between \TeX{}
+and other systems, they are identified with the BCP 47 codes as
+preferred by the Unicode Common Locale Data Repository, which was
+used as source for most of the data provided by these files, where
+available.
+
+Most of them set the date, and many also the captions (Unicode and
+LICR). They will be evolving with the time to add more features
+(something to keep in mind if backward compatibility is important). The
+following section shows how to make use of them by means of
+|\babelprovide|.
+
+Not all languages in the CLDR are complete, and therefore neither are
+the |ini| files. A few languages may show a warning about the current
+lack of suitability of some features.
+
+\begin{example}
+  There is an example of how to use an |ini| template file
+  \href{https://github.com/latex3/babel/issues/176#issuecomment-1080846575}{here},
+  for Phoenician (although currently this locale is bundled with
+  \babel).
+\end{example}
+
+\New{3.49} Alternatively, you can tell \babel{} to load all or some
+languages passed as options with |\babelprovide| and not from the |ldf|
+file in a few few typical cases. Thus, |provide=*| means ‘load the main
+language with the |\babelprovide| mechanism instead of the |ldf| file’
+applying the basic features, which in this case means |import| and |main|.
+There are (currently) three options:
+\begin{itemize}
+\item |provide=*| is the option just explained, for the main language;
+\item |provide+=*| is the same for additional languages (the main
+  language is still the |ldf| file);
+\item |provide*=*| is the same for all languages, ie, main and
+  additional.
+\end{itemize}
+
+\begin{note}
+  The \texttt{ini} files just define and set some parameters, but the
+  corresponding behavior is not always implemented. Also, there are
+  some limitations in the engines. A few remarks follow (which could no
+  longer be valid when you read this manual, if the packages involved
+  have been updated). The Harfbuzz renderer still has some issues, so as
+  a rule of thumb prefer the default renderer, and resort to Harfbuzz
+  only if the former does not work for you. Fortunately, fonts can be
+  loaded twice with different renderers; for example:
+\begin{verbatim}
+\babelfont[spanish]{rm}{FreeSerif}
+\babelfont[hindi]{rm}[Renderer=Harfbuzz]{FreeSerif}
+\end{verbatim}
+\begin{description}
+\itemsep=-\parskip
+\item[Arabic] Monolingual documents mostly work in \luatex, but it must
+  be fine tuned, particularly math and graphical elements like
+  |picture|. In \xetex{} \babel{} resorts to the \textsf{bidi} package,
+  which seems to work.
+\item[Hebrew] Niqqud marks seem to work in both engines, but depending 
+  on the font cantillation marks might be misplaced (\xetex{} or
+  \luatex{} with Harfbuzz seems better).
+\item[Devanagari] In \luatex{} and the default renderer many fonts
+work, but some others do not, the main issue being the ‘ra’. You may
+need to set explicitly the script to either |deva| or |dev2|, eg:
+\begin{verbatim}
+\newfontscript{Devanagari}{deva}
+\end{verbatim}
+  Other Indic scripts are still under development in the default
+  \luatex{} renderer, but should work with |Renderer=Harfbuzz|. They
+  also work with \xetex{}, although unlike with \luatex{} fine tuning
+  the font behavior is not always possible.
+\item[Southeast scripts] Thai works in both \luatex{} and \xetex{}, but
+  line breaking differs (rules are hard-coded in \xetex, but they can
+  be modified in \luatex). Lao seems to work, too, but there are no
+  patterns for the latter in \luatex{}. Khemer clusters are rendered
+  wrongly with the default renderer. The comment about Indic scripts
+  and \textsf{lualatex} also applies here. Some quick patterns can
+  help, with something similar to:
+\begin{verbatim}
+\babelprovide[import, hyphenrules=+]{lao}
+\babelpatterns[lao]{1ດ 1ມ 1ອ 1ງ 1ກ 1າ} % Random
+\end{verbatim}
+\item[East Asia scripts] Settings for either Simplified of Traditional
+  should work out of the box, with basic line breaking with any
+  renderer. Although for a few words and shorts texts the |ini| files
+  should be fine, CJK texts are best set with a dedicated framework
+  (\textsf{CJK}, \textsf{luatexja}, \textsf{kotex}, \textsf{CTeX},
+  etc.). This is what the class |ltjbook| does with \luatex, which can
+  be used in conjunction with the |ldf| for |japanese|, because the
+  following piece of code loads \textsf{luatexja}:
+\begin{verbatim}
+\documentclass[japanese]{ltjbook}
+\usepackage{babel}
+\end{verbatim}
+\item[Latin, Greek, Cyrillic] Combining chars with the default
+ \luatex{} font renderer might be wrong; on then other hand, with the
+ Harfbuzz renderer diacritics are stacked correctly, but many
+ hyphenations points are discarded (this bug is related to kerning,
+ so it depends on the font). With \xetex{} both combining characters
+ and hyphenation work as expected (not quite, but in most cases it
+ works; the problem here are font clusters).
+\end{description}
+\end{note}
+
+\begin{note}
+  Wikipedia defines a \textit{locale} as follows: “In computing, a
+  locale is a set of parameters that defines the user’s language,
+  region and any special variant preferences that the user wants to see
+  in their user interface. Usually a locale identifier consists of at
+  least a language code and a country/region code.” \Babel{} is moving
+  gradually from the old and fuzzy concept of \textit{language} to the
+  more modern of \textit{locale}. Note each locale is by itself a
+  separate “language”, which explains why there are so many files. This
+  is on purpose, so that possible variants can be created and/or
+  redefined easily.
+\end{note}
+
+% \begin{example}
+%   Let's assume you need only the basic features of `spanish`, so that
+%   the |ini| file is enough, and also a variant with your own
+%   hyphenation with
+% \end{example}
+
+\subsection{Selection based on BCP 47 tags}
+\label{bcp47}
+
+\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 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
+of locales as described in this section. In these contexts autoloading
+is particularly important because we may not know on beforehand which
+languages will be requested.
+
+It must be activated explicitly, because it is primarily meant for
+special tasks. Mapping from BCP 47 codes to locale names are not
+hardcoded in \babel. Instead the data is taken from the \texttt{ini}
+files, which means currently about 350 tags are already recognized.
+\Babel{} performs a simple lookup in the following way: |fr-Latn-FR| $\to$
+|fr-Latn| $\to$ |fr-FR| $\to$ |fr|. Languages with the same resolved
+name are considered the same. Case is normalized before, so that
+|fr-latn-fr| $\to$ |fr-Latn-FR|. If a tag and a name overlap, the tag
+takes precedence.
+
+Here is a minimal example:
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[danish]{babel}
+
+_\babeladjust{_
+_  autoload.bcp47 = on,_
+_  autoload.bcp47.options = import_
+_}_
+
+\begin{document}
+
+Chapter in Danish: \chaptername.
+
+_\selectlanguage{de-AT}_
+
+\localedate{2020}{1}{30}
+
+\end{document}
+\end{verbatim}
+
+Currently the locales loaded are based on the \texttt{ini} files and
+decoupled from the main \texttt{ldf} files. This is by design, to
+ensure code generated externally produces the same result regardless of
+the languages requested in the document, but an option to use the
+\texttt{ldf} instead will be added in a future release, because both
+options make sense depending on the particular needs of each document
+(there will be some restrictions, however).
+
+The behavior is adjusted with |\babeladjust| with the following parameters:
+\begin{description}
+\item \texttt{autoload.bcp47} with values |on| and |off|.
+\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
+  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
+  \texttt{bcp47-}. You may change it with this key.
+\end{description}
+
+\New{3.46} If an |ldf| file has been loaded, you can enable the
+corresponding language tags as selector names with:
+\begin{verbatim}
+\babeladjust{ bcp47.toname = on }
+\end{verbatim}
+(You can deactivate it with |off|.) So, if |dutch| is one of the
+package (or class) options, you can write |\selectlanguage{nl}|. Note
+the language name does not change (in this example is still |dutch|),
+but you can get it with |\localeinfo| or |\getlocaleproperty|. It
+must be turned on explicitly for similar reasons to those explained
+above.
+
+\section{Tailoring, customizing and modifying a language}
+
 Modifying the behavior of a language (say, the chapter
-“caption”), is sometimes necessary, but not always trivial. In the case
-of caption names a specific macro is provided, because this is perhaps
-the most frequent change:
+“caption”) is sometimes necessary.
 
+Several language definition files use their own methods to set
+options. For example, \textsf{french} uses |\frenchsetup|,
+\textsf{magyar} (1.5) uses |\magyarOptions|; modifiers provided by
+|spanish| have no attribute counterparts. Macros setting
+options are also used (eg, |\ProsodicMarksOn| in \textsf{latin}).
+
+This section describes the general tools provided by the \babel{} core.
+
+\subsection{Captions}
+
+In the case of caption names a specific macro is provided,
+because this is perhaps the most frequent change.
+
 \Describe{\setlocalecaption}{%
   \marg{language-name}\marg{caption-name}\marg{string}}
 
@@ -2500,7 +2543,7 @@
   There are a few alternative methods:
   \begin{itemize}
 \item With data |import|’ed from |ini| files, you can modify the values
-  of specific keys, like:
+  of specific keys when loaded, like:
 \begin{verbatim}
 \babelprovide[import, _captions/listtable = Lista de tablas_]{spanish}
 \end{verbatim}
@@ -2507,8 +2550,8 @@
   (In this particular case, instead of the |captions| group you may need
   to modify the |captions.licr| one.)
 
-\item The ‘old way’, still valid for many languages, to redefine a
-    caption is the following:
+\item The ‘old way’ to redefine a caption, still valid for many
+languages but discouraged in general, is the following:
 \begin{verbatim}
 \addto\captionsenglish{%
   \renewcommand\contentsname{Foo}%
@@ -2556,14 +2599,55 @@
 something like:
 \begin{verbatim}
 \usepackage[danish]{babel}
-\babelprovide[captions=da, hyphenrules=nohyphenation]{danish}
+\babelprovide[_hyphenrules=nohyphenation_]{danish}
 \end{verbatim}
-first loads |danish.ldf|, and then redefines the captions for
-\texttt{danish} (as provided by the |ini| file) and prevents
-hyphenation. The rest of the language definitions are not touched.
-Without the optional argument it just loads some additional tools if
-provided by the |ini| file, like extra counters.
+first loads |danish.ldf|, and then prevents hyphenation for this
+locale. The rest of the language definitions are not touched. Without
+the optional argument it just loads some additional tools if provided
+by the |ini| file, like extra counters.
 
+\subsection{Modifiers}
+
+\New{3.9c} The basic behavior of some languages can be modified when
+loading \babel{} by means of \textit{modifiers}. They are set after
+the language name, and are prefixed with a dot (only when the language
+is set as package option -- neither global options nor the |main| key
+accepts them). An example is (spaces are not significant and they can
+be added or removed):\footnote{No predefined ``axis'' for modifiers
+are provided because languages and their scripts have quite different
+needs.}
+\begin{verbatim}
+\usepackage[latin_.medieval_, spanish_.notilde.lcroman_, danish]{babel}
+\end{verbatim}
+
+Attributes (described below) are considered modifiers, ie, you can
+set an attribute by including it in the list of modifiers.
+
+\New{3.89} Alternatively, modifiers can be set with a separate option,
+with the keyword |modifiers| followed by a dot and the language name
+(note the language is not selected or loaded with this option). It is
+useful to activate some feature when the language is declared as a
+class option:
+\begin{verbatim}
+\documentclass[spanish]{report}
+\usepackage[_modifiers.spanish = notilde.lcroman_]{babel}
+\end{verbatim}
+
+\subsection{Language attributes}
+
+\Describe{\languageattribute}{\marg{language}}
+
+This is a user-level command, to be used in the preamble of a
+document (after |\usepackage[...]{babel}|), that declares which
+attributes are to be used for a given language. It takes two
+arguments: the first is the name of the language; the second,
+a (list of) attribute(s) to be used. Attributes must be set in the
+preamble and only once -- they cannot be turned on and off.
+The command checks whether the language is known in this document
+and whether the attribute(s) are known for this language.
+
+\subsection{Casing}
+
 \Describe{\BabelUppercaseMapping}
   {\marg{locale-name}\marg{codepoint}\marg{output}}
 \DescribeOther{\BabelLowercaseMapping}
@@ -2594,8 +2678,221 @@
   tag. These issues are expected be sorted out in future releases.
 \end{note}
 
-\subsection{Creating a language}
+\subsection{Modifying and adding values to \texttt{ini} files}
 
+\New{3.39} There is a way to modify or even add values of |ini| files
+when they are imported with |\babelprovide| or |provide=|. This can be
+used to create private variants easily. All you need is to import the
+same |ini| file with a different locale name and different parameters.
+Without |import| you may still modify the identification keys.
+
+Examples of the fine-grained control you have at your disposal are the
+following. All of them assume |\usepackage[english]{babel}|.
+
+\begin{example}
+  Here is how to change the hyphenation rules because there are several
+  criteria, or you must follow and editorial style. The following
+  example just uses the default Spanish rules in English:
+\begin{verbatim}
+\babelprovide[hyphenrules=spanish]{english}
+\end{verbatim}
+\end{example}
+
+\begin{example}
+  The required native digits are already defined in the corresponding
+  |ini| files, but they can be modified and even added as shown:
+\begin{verbatim}
+\babelprovide[numbers/digits.native=abcdefghij]{english}
+\end{verbatim}
+This example is somewhat absurd, but now |\englishdigits{264}| will
+print ‘cge’. (It doesn't work with \pdftex.)
+\end{example}
+
+\begin{example}
+  Currently date format they can be changed only with imported data, but
+  with its high level interface it’s quite straightforward:
+\begin{verbatim}
+\babelprovide[
+    import,
+    date.gregorian/date.long = {[d] ([MMMM]) [y]}]
+  {english}
+\end{verbatim}
+  Here |[d]| is the day number, |[MMMM]| the month name and |[y]| the
+  years. It will print something like ‘5 (October) 2024’.
+\end{example}
+
+\begin{example}
+  To set the hyphen to ‘none’ (only \luatex).
+\begin{verbatim}
+\babelprovide[typography/prehyphenchar = 0]{english}
+\end{verbatim}
+This setting \textit{may} work with `xetex`, but getting rid of the
+hyphen char in this engine is not trivial, because you must rely on the
+font, and not all fonts behave the same.
+\end{example}
+
+\begin{example}
+You can define new counters freely, and assign them to |\alph|: 
+\begin{verbatim}
+\babelprovide[
+    counters/acute = á é í ó ú, % Define a counter named `acute`
+    alph = acute                % Assign it to \alph
+  ]{english}
+\end{verbatim}
+You can choose the name, and instead of `alphabetic` it can be another one.
+\end{example}
+
+\subsection{Hooks}
+
+\New{3.9a} A hook is a piece of code to be executed at certain
+events. Some hooks are predefined when \luatex{} and \xetex{} are
+used.
+
+\New{3.64} This is not the only way to inject code at those points. The
+events listed below can be used as a hook name in |\AddToHook| in the
+form |babel/<language-name>/<event-name>| (with |*| it’s applied to
+all languages), but there is a limitation, because the parameters
+passed with the \babel{} mechanism are not allowed. The |\AddToHook|
+mechanism does \textit{not} replace the current one in `babel`. Its
+main advantage is you can reconfigure `babel` even before loading it.
+See the example below.
+
+\Describe{\AddBabelHook}{\oarg{language}\marg{name}\marg{event}\marg{code}}
+
+The same name can be applied to several events. Hooks with a certain
+\marg{name} may be enabled and disabled for all defined events with
+|\EnableBabelHook|\marg{name}, |\DisableBabelHook|\marg{name}. Names
+containing the string |babel| are reserved (they are used, for example,
+by |\useshortands*| to add a hook for the event |afterextras|).
+\New{3.33} They may be also applied to a specific language with the
+optional argument; language-specific settings are executed after global
+ones.
+
+Current events are the following; in some of them you can use one to
+three \TeX{} parameters (|#1|, |#2|, |#3|), with the meaning given:
+\begin{description}
+\renewcommand\makelabel[1]{%
+  \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
+\itemsep=-\parskip
+\item[adddialect] (language name, dialect name) Used by
+  \file{luababel.def} to load the patterns if not preloaded.
+\item[patterns] (language name, language with encoding) Executed just
+  after the |\language| has been set. The second argument has the
+  patterns name actually selected (in the form of either |lang:ENC| or
+  |lang|).
+\item[hyphenation] (language name, language with encoding) Executed
+  locally just before exceptions given in |\babelhyphenation| are
+  actually set.
+\item[defaultcommands] Used (locally) in |\StartBabelCommands|.
+\item[encodedcommands] (input, font encodings) Used (locally) in
+  |\StartBabelCommands|. Both \xetex{} and \luatex{} make sure the
+  encoded text is read correctly.
+\item[stopcommands] Used to reset the above, if necessary.
+\item[write] This event comes just after the switching commands are
+  written to the |aux| file.
+\item[beforeextras] Just before executing |\extras<language>|. This
+  event and the next one should not contain language-dependent code
+  (for that, add it to |\extras<language>|).
+\item[afterextras] Just after executing |\extras<language>|. For
+  example, the following deactivates shorthands in all languages:
+\begin{verbatim}
+\AddBabelHook{noshort}{afterextras}{\languageshorthands{none}}
+\end{verbatim}
+\item[stringprocess] Instead of a parameter, you can manipulate the
+  macro |\BabelString| containing the string to be defined with
+  |\SetString|. For example, to use an expanded version of the string
+  in the definition, write:
+\begin{verbatim}
+\AddBabelHook{myhook}{stringprocess}{%
+  \protected at edef\BabelString{\BabelString}}
+\end{verbatim}
+\item[initiateactive] (char as active, char as other, original char)
+  \New{3.9i} Executed just after a shorthand has been `initiated'. The three
+  parameters are the same character with different catcodes: active,
+  other (|\string|'ed) and the original one.
+\item[afterreset] \New{3.9i} Executed when selecting a language just after
+  |\originalTeX| is run and reset to its base value, before executing
+  |\captions<language>| and |\date<language>|.
+\item[begindocument] \New{3.88} Executed before the code written by
+  |ldf| files with |\AtBeginDocument|. The optional argument with the
+  language in this particular case is the language that wrote the code.
+  The special value |/| means ‘return to the core \babel{} definitions’
+  (in other words, what follows hasn’t been written by any language).
+\item[foreign] \New{24.8} Executed by |\foreignlanguage| after the
+  language has been set up and just before typesetting the text from the
+  second argument. Its main purpose it to wrap the text with some
+  code, with the help of |\BabelWrapText|. For example, with:
+\begin{verbatim}
+\AddBabelHook{one}{foreign}{\BabelWrapText{\textit{##1}}
+\AddBabelHook{two}{foreign}{\BabelWrapText{\parse{##1}}
+\end{verbatim}
+the text becomes |\textit{\parse{<text>}}|. 
+
+\end{description}
+
+Four events are used in \file{hyphen.cfg}, which are handled in a
+quite different way for efficiency reasons -- unlike the precedent
+ones, they only have a single hook and replace a default definition.
+\begin{description}
+\renewcommand\makelabel[1]{%
+  \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
+\itemsep=-\parskip
+\item[everylanguage] (language) Executed before every language patterns
+  are loaded.
+\item[loadkernel] (file) By default just defines a few basic commands.
+  It can be used to define different versions of them or to load a file.
+\item[loadpatterns] (patterns file) Loads the patterns file. Used by
+  \file{luababel.def}.
+\item[loadexceptions] (exceptions file) Loads the exceptions
+  file. Used by \file{luababel.def}.
+\end{description}
+
+\begin{example}
+The generic unlocalized \LaTeX{} hooks are predefined, so that you can
+write:
+\begin{verbatim}
+\AddToHook{babel/*/afterextras}{\frenchspacing} 
+\end{verbatim}
+which is executed always after the extras for the language being
+selected (and just before the non-localized hooks defined with
+|\AddBabelHook|).
+
+In addition, locale-specific hooks in the form
+|babel/<language-name>/<event-name>| are \textit{recognized}
+(executed just before the localized \babel{} hooks), but they are
+\textit{not predefined}. You have to do it yourself. For example, to
+set |\frenchspacing| only in |bengali|:
+\begin{verbatim}
+\ActivateGenericHook{babel/bengali/afterextras}
+\AddToHook{babel/bengali/afterextras}{\frenchspacing}
+\end{verbatim}
+\end{example}
+
+\subsection{Manage auxiliary files}
+
+\Describe{\BabelContentsFiles}{}
+\New{3.9a} This macro contains a list of ``toc'' types
+requiring a command to switch the language. Its default value is
+|toc,lof,lot|, but you may redefine it with |\renewcommand| (it's up
+to you to make sure no toc type is duplicated).
+
+\subsection{Code based on the selector}
+
+\Describe{\IfBabelSelectorTF}{\marg{selectors}\marg{true}\marg{false}}
+
+\New{3.67} Sometimes a different setup is desired depending on the
+selector used. Values allowed in \m{selectors} are |select|, |other|,
+|foreign|, |other*| (and also |foreign*| for the tentative starred
+version), and it can consist of a comma-separated list. For example:
+\begin{verbatim}
+\IfBabelSelectorTF{other, other*}{A}{B}
+\end{verbatim}
+is true with any of these two environment selectors.
+
+Its natural place of use is in hooks or in |\extras<language>|.
+
+\section{Creating a language}
+
 \New{3.10} And what if there is no style for your language or none fits
 your needs? You may then define quickly a language with the help of the
 following macro in the preamble (which may be used to modify an
@@ -2652,7 +2949,8 @@
 Blah \foreignlanguage{ipa}{ɔːlˈðəʊ} Blah.
 \end{document}
 \end{verbatim}
-  Then you can define shorthands, transforms (with \luatex), and so on. 
+  Then you can define shorthands, transforms (with \luatex), interchars
+  (with \xetex) and so on, specific to this new ‘language’.
 \end{example}
 
 \begin{example}
@@ -2659,7 +2957,7 @@
   Locales with names based on BCP 47 codes can be created with
   something like:
 \begin{verbatim}
-  \babelprovide[import=en-US]{enUS}
+  \babelprovide[import=en-US]{en-US}
 \end{verbatim}
   Note, however, mixing ways to identify locales can lead to problems.
   For example, is \verb|yi| the name of the language spoken by the Yi
@@ -2673,43 +2971,32 @@
 If the language has been loaded as an argument in |\documentclass| or
 |\usepackage|, then |\babelprovide| redefines the requested data.
 
-\Describe{import=}{\meta{language-tag}}
-\New{3.13} Imports data from an |ini| file, including captions and date
-(also line breaking rules in newly defined languages). For example:
-\begin{verbatim}
-\babelprovide[_import=hu_]{hungarian}
-\end{verbatim}
-Unicode engines load the UTF-8 variants, while 8-bit engines load the
-LICR (ie, with macros like |\'| or |\ss|) ones.
+\Describe{import=}{\meta{locale-tag}} The |<language-tag>| is optional.
+Imports the full data from the |ini| file corresponding to the locale
+being loaded, as set in |babel-<locale>.tex| (where |<locale>| is the
+last argument in |\babelprovide|), including captions and date (and
+also line breaking rules in newly defined languages). Unicode engines
+load the UTF-8 variants, while 8-bit engines load the LICR (ie, with
+macros like |\'| or |\ss|) ones.
 
-\New{3.23} It may be used without a value, and that is often the
-recommended option. In such a case, the |ini| file set in the
-corresponding |babel-<language>.tex| (where |<language>| is the last
-argument in |\babelprovide|) is imported. See the list of recognized
-languages above. So, the previous example is best written as:
+However, in some cases you may want to load a different |ini| file. In
+such a case, you can set its value.
+
+\begin{example} 
+  For example, the locale |ar-DZ| is named |arabic-algeria|. You may
+  prefer the shorter name |arabic| if there are no conflicts:
 \begin{verbatim}
-\babelprovide[_import_]{hungarian}
+\babelprovide[_import=ar-DZ_]{arabic}
 \end{verbatim}
+\end{example}
 
-There are 380 |ini| files for about 300 languages, with data taken from
-the |ldf| files and the CLDR provided by Unicode. Not all languages in
-the latter are complete, and therefore neither are the |ini| files. A
-few languages may show a warning about the current lack of suitability
-of some features.
-
 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}|. \New{3.44}
-More convenient is usually |\localedate|, with prints the date for the
+More convenient is usually |\localedate|, which prints the date for the
 current locale.
 
-\Describe{captions=}{\meta{language-tag}}
-Loads only the strings. For example:
-\begin{verbatim}
-\babelprovide[_captions=hu_]{hungarian}
-\end{verbatim}
-
 \Describe{hyphenrules=}{\meta{language-list}} With this option, with a
 space-separated list of hyphenation rules, \babel{} assigns to the
 language the first valid hyphenation rules in the list. For example:
@@ -2737,8 +3024,7 @@
 alternative to |justification=unhyphenated|.
 
 \Describe{main}{} This valueless option makes the language the main one
-(thus overriding that set when \babel\ is loaded). Only in newly defined
-languages.
+(thus overriding that set when \babel\ is loaded).
 \begin{example}
   Let's assume your document (\xetex{} or \luatex{}) is mainly in
   Polytonic Greek with but with some sections in Italian. Then, the
@@ -2779,7 +3065,7 @@
 
 \Describe{Alph=}{\meta{counter-name}} Same for |\Alph|.
 
-\Describe{casing}{\meta{rules}} \New{3.90} Selects the casing rules in a few
+\Describe{casing=}{\meta{rules}} \New{3.90} Selects the casing rules in a few
 languages. The first ones are predefined by \LaTeX{} (see
 \textsf{interface3.pdf}), while the following are defined by \babel:
 \begin{description}
@@ -2790,9 +3076,10 @@
   \item[Greek] |iota| converts the \textit{ypogegrammeni} (subscript muted
     iota) to capital iota when uppercasing.
   \item[Latin] |nouv| in |classicallatin| and |medievallatin| reverts
-    the default rules, which maps u ↔ V; |uv| in |ecclesianticallatin|
-    and the basic |latin| locale applies the map u ↔ V (by default it’s
-    u ↔ U and v ↔ V).
+    the default rules, which maps u $\leftrightarrow$ V; |uv| in
+    |ecclesianticallatin| and the basic |latin| locale applies the map
+    u $\leftrightarrow$ V (by default it’s u $\leftrightarrow$ U and v
+    $\leftrightarrow$ V).
 \end{description}
 
 \begin{example} For the latter:
@@ -2851,21 +3138,252 @@
   be still necessary.
 \end{note}
 
-\Describe{intraspace=}{\meta{base} \meta{shrink} \meta{stretch}}
-Sets the interword space for the writing system of the language, in em
-units (so, |0 .1 0| is |0em plus .1em|). Like |\spaceskip|, the em unit
-applied is that of the current text (more precisely, the previous 
-glyph). Currently used only in Southeast Asian scripts, like Thai, and
-CJK.
-
-\Describe{intrapenalty=}{\meta{penalty}}
-Sets the interword penalty for the writing system of this language.
-Currently used only in Southeast Asian scripts, like Thai. Ignored if 0
-(which is the default value).
-
 \Describe{transforms=}{\meta{transform-list}}
 See section~\ref{transforms}.
 
+\Describe{interchar=}{\meta{interchar-list}}
+See section~\ref{interchar}.
+
+\begin{note}
+  (1) If you need shorthands, you can define them with |\useshorthands|
+  and |\defineshorthand| as described above. (2) Captions and |\today|
+  are ``ensured'' with |\babelensure| (this is the default in
+  |ini|-based languages).
+\end{note}
+
+\begin{example} When creating a locale from another locale, you may want
+to reset some properties, like the BCP-47 tags. Here is an example of
+how to do it:
+\begin{verbatim}
+\babelprovide{spanish}      % import=es by default
+\babelprovide[
+    import=es,
+    _identification/tag.bcp47 = es-x-medieval_,
+    _identification/extension.x.tag.bcp47 = medieval_]
+  {medievalspanish}
+\end{verbatim}
+\end{example}
+
+\section{Locale features}
+
+\subsection{Hyphenation and line breaking – 1. Commands}
+
+\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 (although in a limited way),
+while \luatex{} provides basic rules for the latter, too. With \luatex{}
+there are also tools for non-standard hyphenation rules, explained in
+the next section.
+
+\Describe{\babelhyphenation}{\texttt{[}\langlist\texttt{]}%
+    \marg{exceptions}}
+
+\New{3.9a} Sets hyphenation exceptions for the languages given
+or, without the optional argument, for \textit{all} languages (eg,
+proper nouns or common loan words, and of course monolingual
+documents). Multiple declarations work much like |\hyphenation| (last
+wins), but language exceptions take precedence over global ones.
+
+It can be used only in the preamble, and exceptions are set when the
+language is first selected, thus taking into account changes of
+|\lccodes|'s done in |\extras<language>| as well as the language-specific
+encoding (not set in the preamble by default). Multiple
+|\babelhyphenation|'s are allowed. For example:
+\begin{verbatim}
+\babelhyphenation{Wal-hal-la Dar-bhan-ga}
+\end{verbatim}
+
+Listed words are saved expanded and therefore it relies on the
+LICR. Of course, it also works without the LICR if the input and the
+font encodings are the same, like in Unicode based engines.
+
+\begin{note}
+  Using |\babelhyphenation| with Southeast Asian scripts is mostly
+  pointless. But with |\babelpatterns| (below) you may fine-tune line
+  breaking (only \luatex). For example:
+\begingroup
+\catcode`@=13
+\def@#1@{{\fontspec{Loma}#1}}
+\begin{verbatim}
+\babelpatterns[thai]{@ศึก@2@ษา@}
+\end{verbatim}
+\endgroup
+  Even if there are no patterns for the language, you can add at least
+  some typical cases.
+\end{note}
+
+\begin{note}
+  Use |\babelhyphenation| instead of |\hyphenation| to set hyphenation
+  exceptions in the preamble before any language is explicitly set with
+  a selector. In the preamble the hyphenation rules are not always
+  fully set up and an error can be raised.
+\end{note}
+
+\Describe{\babelpatterns}{\texttt{[}\langlist\texttt{]}%
+    \marg{patterns}}
+
+\New{3.9m} \textit{In \textsf{luatex} only},\footnote{With
+\textsf{luatex} exceptions and patterns can be modified almost
+freely. However, this is very likely a task for a separate package
+and \texttt{babel} only provides the most basic tools.} adds or
+replaces patterns for the languages given or, without the optional
+argument, for \textit{all} languages. If a pattern for a certain
+combination already exists, it gets replaced by the new one.
+
+It can be used only in the preamble, and patterns are added when the
+language is first selected, thus taking into account changes of
+|\lccodes|'s done in |\extras<language>| as well as the language-specific
+encoding (not set in the preamble by default). Multiple
+|\babelpatterns|'s are allowed.
+
+Listed patterns are saved expanded and therefore it relies on the
+LICR. Of course, it also works without the LICR if the input and the
+font encodings are the same, like in Unicode based engines.
+
+\New{3.31} (Only \luatex.) With |\babelprovide| and |import|ed CJK
+languages, a simple generic line breaking algorithm (push-out-first) is
+applied, based on a selection of the Unicode rules (\New{3.32} it is
+disabled in verbatim mode, or more precisely when the hyphenrules
+are set to |nohyphenation|). It can be activated alternatively by
+setting explicitly the |intraspace|.
+
+\New{3.27} Interword spacing for Thai, Lao and Khemer is activated
+automatically if a language with one of those scripts are loaded with
+|\babelprovide|. See the sample on the \babel{} repository. With both
+Unicode engines, spacing is based on the ``current'' em unit (the size
+of the previous char in \luatex, and the font size set by the last
+|\selectfont| in \xetex).
+
+\begin{note}
+  With Unicode engines, a line break can happen just before an explicit
+  combining char (eg, \textit{\~{g}}, used in Guarani and Filipino, is
+  not included as a combined char and it’s represented in Unicode as
+  |U+0067|~|U+0303|. This issue is not directly related to \babel, but
+  to the hyphenation patterns and/or the font renderer. However, at
+  least with \luatex{} there is a workaround (change the language name
+  to what you are using):
+\begin{verbatim}
+\babelposthyphenation{guarani}{ | [{0300}-{036F}] }{ remove, {} }
+\end{verbatim}
+The Lua pattern means ‘a discretionary followed by a character in the
+range |U+0300|--|U+0367| (which contains combining chars)’. An
+alternative to a transform is |\babelpatterns|.
+\end{note}
+
+\Describe{\babelhyphenmins}{%
+  \optstar\texttt{[}\langlist\texttt{]}%
+  \marg{left}\marg{right}\oarg{hyphenationmin}}
+
+\New{24.10} See the news page for the rationale for this commands. It
+sets the corresponding values for the given languages (all languages
+without the optional argument). With the star, the values are also
+applied immediately (the optional argument and the star are currently
+incompatible). The optional argument is available only in \luatex.
+\begin{example}
+You are typesetting a book with wide lines and want to limit the
+number of hyphens in all languages:
+\begin{verbatim}
+  \babelhyphenmins{3}{4}
+\end{verbatim}
+But there are also some 3-column text and you want to be more flexible:
+\begin{verbatim}
+  \begin{multicols}{3}
+  \babelhyphenmins*{2}{3}
+  ...
+  \end{multicols}
+\end{verbatim}
+\end{example}
+
+\Describe{\babelhyphen}{\optstar\marg{type}}
+\DescribeOther{\babelhyphen}{\optstar\marg{text}}
+
+\New{3.9a} It is customary to classify hyphens in two types: (1)
+\textit{explicit} or \textit{hard hyphens}, which in \TeX\ are
+entered as \verb|-|, and (2) \textit{optional} or \textit{soft
+hyphens}, which are entered as \verb|\-|. Strictly, a \textit{soft
+hyphen} is not a hyphen, but just a breaking opportunity or, in
+\TeX\ terms, a ``discretionary''; a \textit{hard hyphen} is a hyphen
+with a breaking opportunity after it. A further type is a
+\textit{non-breaking hyphen}, a hyphen without a breaking
+opportunity.
+
+In \TeX, \verb|-| and \verb|\-| forbid further breaking opportunities
+in the word. This is the desired behavior very often, but not always,
+and therefore many languages provide shorthands for these
+cases. Unfortunately, this has not been done consistently: for
+example, \verb|"-| in Dutch, Portuguese, Catalan or Danish is a hard
+hyphen, while in German, Spanish, Norwegian, Slovak or Russian is a
+soft hyphen. Furthermore, some of them even redefine |\-|, so that you
+cannot insert a soft hyphen without breaking opportunities in the rest
+of the word.
+
+Therefore, some macros are provided with a set of basic ``hyphens''
+which can be used by themselves, to define a user shorthand, or even
+in language files.
+\begin{itemize}
+\item |\babelhyphen{soft}| and |\babelhyphen{hard}| are self
+  explanatory.
+\item |\babelhyphen{repeat}| inserts a hard hyphen which is repeated
+  at the beginning of the next line, as done in languages like
+  Polish, Portuguese and Spanish.
+\item |\babelhyphen{nobreak}| inserts a hard hyphen without a break
+  after it (even if a space follows).
+\item |\babelhyphen{empty}| inserts a break opportunity without
+  a hyphen at all.
+\item |\babelhyphen|\marg{text} is a hard ``hyphen'' using \m{text}
+  instead. A typical case is |\babelhyphen{/}|.
+\end{itemize}
+With all of them, hyphenation in the rest of the word is enabled. If
+you don't want to enable it, there is a starred counterpart:
+|\babelhyphen*{soft}| (which in most cases is equivalent to the
+original |\-|), |\babelhyphen*{hard}|, etc.
+
+Note |hard| is also good for isolated prefixes (eg, \textit{anti-})
+and |nobreak| for isolated suffixes (eg, \textit{-ism}), but in both
+cases |\babelhyphen*{nobreak}| is usually better.
+
+There are also some differences with \LaTeX: (1) the character used is
+that set for the current font, while in \LaTeX{} it is hardwired to
+|-| (a typical value); (2) the hyphen to be used in fonts with a
+negative |\hyphenchar| is  |-|, like in \LaTeX, but it can be changed to
+another value by redefining |\babelnullhyphen|; (3) a break after the
+hyphen is forbidden if preceded by a glue ${>}0$~pt (at the beginning
+of a word, provided it is not immediately preceded by, say, a
+parenthesis).
+
+\Describe{\begin\menv{hyphenrules}}{\marg{language}\Eenv{hyphenrules}}
+
+The environment \Lenv{hyphenrules} can be used to select \emph{only} the
+hyphenation rules to be used (it can be used as command, too). This can
+for instance be used to select ‘nohyphenation’, provided that in
+\file{language.dat} the ‘language’ \textsf{nohyphenation} is defined by
+loading \file{zerohyph.tex}. It deactivates language shorthands, too
+(but not user shorthands).
+
+Except for these simple uses, |hyphenrules| is deprecated and
+|otherlanguage*| (the starred version) is preferred, because the former
+does not take into account possible changes in encodings of characters
+like, say, |'| done by some languages (eg, \textsf{italian},
+\textsf{french}, \textsf{ukrainian}).
+
+\begin{note}
+  For the hyphenation to work correctly, lccodes cannot change, because
+  \TeX{} only takes into account the values when the paragraph is
+  hyphenated, i.e., when it has been finished.\footnote{This explains
+  why \LaTeX{} assumes the lowercase mapping of T1 and does not provide
+  a tool for multiple mappings. Unfortunately, \cs{savinghyphcodes} is
+  not a solution either, because lccodes for hyphenation are frozen in
+  the format and cannot be changed.} So, if you write a chunk of French
+  text with |\foreignlanguage|, the apostrophes might not be taken into
+  account. This is a limitation of \TeX, not of \babel. Alternatively,
+  you may use |\useshorthands| to activate |'| and |\defineshorthand|,
+  or redefine |\textquoteright| (the latter is called by the non-ASCII
+  right quote).
+\end{note}
+
+\subsection{Hyphenation and line breaking – 2. ‘Provide’ options}
+
 \Describe{justification=}{\texttt{unhyphenated} $\string|$
 \texttt{kashida} $\string|$ \texttt{elongated} $\string|$
 \texttt{padding}}
@@ -2873,14 +3391,14 @@
 dependent, so that they will not be applied to other languages.
 
 The first one (|unhyphenated|) activates a line breaking mode that
-allows spaces to be stretched to arbitrary amounts. Although for
-European standards the result may look odd, in some writing systems,
-like Malayalam and other Indic scripts, this has been the customary
-(although not always the desired) practice. Because of that, no locale
-sets currently this mode by default (Amharic is an exception). Unlike
-|\sloppy|, the |\hfuzz| and the |\vfuzz| are not changed, because this
-line breaking mode is not really ‘sloppy’ (in other words, overfull
-boxes are reported as usual).
+allows breaks only at spaces, which can be stretched to arbitrary
+amounts. Although for European standards the result may look odd, in
+some writing systems, like Malayalam and other Indic scripts, this has
+been the customary (although not always the desired) practice. Because
+of that, no locale sets currently this mode by default (Amharic is an
+exception). Unlike |\sloppy|, the |\hfuzz| and the |\vfuzz| are not
+changed, because this line breaking mode is not really ‘sloppy’ (in
+other words, overfull boxes are reported as usual).
 
 The second and the third are for the Arabic script. It sets the
 linebreaking and justification method, which can be based on the
@@ -2899,13 +3417,316 @@
 \New{3.59} Just a synonymous for \texttt{justification}. Depending on
 the language, this name can make more sense.
 
+\Describe{intraspace=}{\meta{base} \meta{shrink} \meta{stretch}}
+Sets the interword space for the writing system of the language, in em
+units (so, |0 .1 0| is |0em plus .1em|). Like |\spaceskip|, the em unit
+applied is that of the current text (more precisely, the previous 
+glyph). Currently used only in Southeast Asian scripts, like Thai, and
+CJK.
+
+\Describe{intrapenalty=}{\meta{penalty}}
+Sets the interword penalty for the writing system of this language.
+Currently used only in Southeast Asian scripts, like Thai. If 0, which
+is the default value, no penalty is inserted.
+
+\subsection{Shorthands – 1. Commands}
+
+A \textit{shorthand} is a sequence of one or two characters that
+expands to arbitrary \TeX{} code.
+
+Shorthands can be used for different kinds of things; for example:
+(1) in some languages shorthands such as |"a| are defined to be able
+to hyphenate the word if the encoding is |OT1|; (2) in some languages
+shorthands such as |!| are used to insert the right amount of white
+space; (3) several kinds of discretionaries and breaks can be inserted
+easily with |"-|, |"=|, etc.
+
+The package \textsf{inputenc} as well as \xetex{} and \luatex{} have
+alleviated entering non-ASCII characters, but minority languages and
+some kinds of text can still require characters not directly available
+on the keyboards (and sometimes not even as separated or precomposed
+Unicode characters). As to the point 2, now \textsf{pdfTeX} provides
+|\knbccode|, and \luatex{} can manipulate the glyph list. Tools for
+point 3 can be still very useful in general.
+
+There are four levels of shorthands: \textit{user}, \textit{language},
+\textit{system}, and \textit{language user} (by order of precedence).
+In most cases, you will use only shorthands provided by languages.
+
+\begin{note} Keep in mind the following:
+\begin{enumerate}
+\item Activated chars used for two-char shorthands cannot be followed
+  by a closing brace |}| and the spaces following are gobbled.  With
+  one-char shorthands (eg,~|:|), they are preserved.
+\item If on a certain level (system, language, user, language user)
+  there is a one-char shorthand, two-char ones starting with that char
+  and on the same level are ignored.
+\item Since they are active, a shorthand cannot contain the same
+  character in its definition (except if deactivated with, eg,
+  |\string|).
+\end{enumerate}
+\end{note}
+
+\begin{troubleshooting}
+\trouble{Argument of \textbackslash language at active@arg"
+has an extra \textbraceright}
+A typical error when using shorthands is the following:
+\begin{verbatim}
+! Argument of \language at active@arg" has an extra }.
+\end{verbatim}
+It means there is a closing brace just after a shorthand, which is not
+allowed (eg,~|"}|). Just add |{}| after (eg,~|"{}}|).
+\end{troubleshooting}
+
+\Describe{\shorthandon}{\marg{shorthands-list}}
+\DescribeOther{\shorthandoff}{\optstar\marg{shorthands-list}}
+It is sometimes necessary to switch a shorthand
+character off temporarily, because it must be used in an
+entirely different way. For this purpose, the user commands
+|\shorthandoff| and |\shorthandon| are provided. They each take a
+list of characters as their arguments.
+
+The command |\shorthandoff| sets the |\catcode| for each of the
+characters in its argument to other (12); the command |\shorthandon|
+sets the |\catcode| to active (13). Both commands only work on `known'
+shorthand characters, and an error will be raised otherwise. You can
+check if a character is a shorthand with |\ifbabelshorthand| (see
+below).
+
+\New{3.9a} However, |\shorthandoff| does not behave as
+you would expect with characters like |~| or |^|, because they
+usually are not ``other''. For them |\shorthandoff*| is provided,
+so that with
+\begin{verbatim}
+\shorthandoff*{~^}
+\end{verbatim}
+|~| is still active, very likely with the meaning of a non-breaking
+space, and |^| is the superscript character. The catcodes used are
+those when the shorthands are defined, usually when language files are
+loaded.
+
+If you do not need shorthands, or prefer an alternative approach of
+your own, you may want to switch them off with the package option
+|shorthands=off|, as described below.
+
+\begin{warning}
+  It is worth emphasizing these macros are meant for temporary changes.
+  Whenever possible shorthands must be always enabled or disabled.
+\end{warning}
+
+\Describe{\useshorthands}{\optstar\marg{char}}
+
+It initiates the definition of user-defined
+shorthand sequences. It has one argument, the character that starts
+these personal shorthands.
+
+\New{3.9a} User shorthands are not always alive, as they may
+be deactivated by languages (for example, if you use |"| for your user
+shorthands and switch from \textsf{german} to \textsf{french}, they
+stop working). Therefore, a starred version
+|\useshorthands*|\marg{char} is provided, which makes sure shorthands
+are always activated.
+
+If the package option |shorthands| is used, you must include any
+character to be activated with |\useshorthands|.
+
+\Describe\defineshorthand{\texttt{[}\langlist\texttt{]}%
+     \marg{shorthand}\marg{code}}
+
+It takes two arguments: the first is a one- or two-character shorthand
+sequence, and the second is the code the shorthand should expand to.
+
+\New{3.9a} An optional argument allows to (re)define language and
+system shorthands (some languages do not activate shorthands, so you
+may want to add |\languageshorthands|\marg{language} to the corresponding
+|\extras<language>|, as explained below). By default, user shorthands
+are (re)defined.
+
+User shorthands override language ones, which in turn override system
+shorthands. Language-dependent user shorthands take precedence over
+``normal'' user shorthands.
+
+\begin{example}
+  Let's assume you want a unified set of shorthand for discretionaries
+  (languages do not define shorthands consistently, and |"-|, |\-|,
+  |"=| have different meanings).  You can start with, say:
+\begin{verbatim}
+\useshorthands*{"}
+\defineshorthand{"*}{\babelhyphen{soft}}
+\defineshorthand{"-}{\babelhyphen{hard}}
+\end{verbatim}
+  However, the behavior of hyphens is language-dependent. For example, in
+  languages like Polish and Portuguese, a hard hyphen inside compound
+  words are repeated at the beginning of the next line. You can then
+  set:
+\begin{verbatim}
+\defineshorthand[*polish,*portuguese]{"-}{\babelhyphen{repeat}}
+\end{verbatim}
+  Here, options with |*| set a language-dependent user shorthand,
+  which means the generic one above only applies for the rest of
+  languages; without |*| they would (re)define the language shorthands
+  instead, which are overridden by user ones.
+
+  Now, you have a single unified shorthand (|"-|), with a
+  content-based meaning (`compound word hyphen') whose visual behavior
+  is that expected in each context.
+\end{example}
+
+\Describe{\languageshorthands}{\marg{language}}
+
+Used to switch the shorthands on the
+language level. It takes one argument, the name of a language or
+|none| (the latter does what its name suggests).\footnote{Actually,
+any name not corresponding to a language group does the same as
+\texttt{none}. However, follow this convention because it might be
+enforced in future releases of \babel{} to catch possible errors.}
+Note that for this to work the language should have been specified as
+an option when loading the \babel\ package.  For example, you can use
+in \textsf{english} the shorthands defined by \textsf{ngerman} with
+\begin{verbatim}
+\addto\extrasenglish{\languageshorthands{ngerman}}
+\end{verbatim}
+(You may also need to activate them as user shorthands in the preamble
+with, for example, |\useshorthands| or |\useshorthands*|.)
+
+\begin{example}
+  Very often, this is a more convenient way to deactivate shorthands
+  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}}
+\end{verbatim}
+\end{example}
+
+\Describe{\babelshorthand}{\marg{shorthand}}
+With this command you can use a shorthand even if (1) not activated in
+\texttt{shorthands} (in this case only shorthands for the current
+language are taken into account, ie, not user shorthands), (2) turned
+off with |\shorthandoff| or (3) deactivated with the internal
+|\bbl at deactivate|; for example, \verb|\babelshorthand{"u}| or
+\verb|\babelshorthand{:}|.  (You can conveniently define your own
+macros, or even your own user shorthands provided they do not overlap.)
+
+\begin{example}
+  Since by default shorthands are not activated until
+  |\begin{document}|, you may use this macro when defining the |\title|
+  in the preamble:
+\begin{verbatim}
+\title{Documento científico_\babelshorthand{"-}_técnico}
+\end{verbatim}
+\end{example}
+
+\bigskip
+
+For your records, here is a list of shorthands, but you must double
+check them, as they may change:\footnote{Thanks to Enrico Gregorio}
+
+\begin{description}
+\itemsep=-\parskip
+\item[Languages with no shorthands] Croatian, English (any variety),
+  Indonesian, Hebrew, Interlingua, Irish, Lower Sorbian, Malaysian,
+  North Sami, Romanian, Scottish, Welsh
+\item[Languages with only \texttt{"} as defined shorthand character]
+  Albanian, Bulgarian, Danish, Dutch, Finnish, German (old and new
+  orthography, also Austrian), Icelandic, Italian, Norwegian, Polish,
+  Portuguese (also Brazilian), Russian, Serbian (with Latin script),
+  Slovene, Swedish, Ukrainian, Upper Sorbian
+\item[Basque] |" ' ~|
+\item[Breton] |: ; ? !|
+\item[Catalan] |" ' `|
+\item[Czech] |" -|
+\item[Esperanto] |^|
+\item[Estonian] |" ~|
+\item[French] (all varieties) |: ; ? !|
+\item[Galician] |" . ' ~ < >|
+\item[Greek] (ancient, polutoniko, only 8-bit \TeX) |~|, (optional, see
+the manual for Greek) |;|
+\item[Hungarian] |`|
+\item[Kurmanji] |^|
+\item[Latin] |" ^ =|
+\item[Slovak] |" ^ ' -|
+\item[Spanish] |" . < > ' ~|
+\item[Turkish] |: ! =|
+\end{description}
+In addition, the \babel{} core declares |~| as a one-char shorthand
+which is let, like the standard |~|, to a non breaking
+space.\footnote{This declaration serves to nothing, but it is
+preserved for backward compatibility.}
+
+\Describe\ifbabelshorthand{\marg{character}\marg{true}\marg{false}}
+
+\New{3.23} Tests if a character has been made a shorthand.
+
 \begin{note}
-  (1) If you need shorthands, you can define them with |\useshorthands|
-  and |\defineshorthand| as described above. (2) Captions and |\today|
-  are ``ensured'' with |\babelensure| (this is the default in
-  |ini|-based languages).
+  \catcode`\|=12\relax Both \textsf{ltxdoc} and \textsf{babel} use
+  \verb|\AtBeginDocument| to change some catcodes, and \babel{} reloads
+  \textsf{hhline} to make sure \verb|:| has the right one, so if you
+  want to change the catcode of \verb/|/ it has to be done using the
+  same method at the proper place, with
+\begin{verbatim}
+\AtBeginDocument{\DeleteShortVerb{\|}}
+\end{verbatim}
+  \textit{before} loading \babel. This way, when the document begins
+  the sequence is (1) make \verb/|/ active (\textsf{ltxdoc}); (2) make
+  it inactive (your settings); (3) make \babel{} shorthands active
+  (\textsf{babel}); (4) reload \textsf{hhline} (\textsf{babel}, now
+  with the correct catcodes for \verb/|/ and
+  \verb|:|).\catcode`\|=\active
 \end{note}
 
+\begin{note}
+Using a character mathematically active (ie, with math code |"8000|) as
+a shorthand can make \TeX{} enter in an infinite loop in some rare
+cases. (There is a partial solution.)
+\end{note}
+
+\subsection{Shorthands – 2. Package options}
+
+\Describe{activeacute}{}
+\DescribeOther{activegrave}{}
+
+For some languages \babel\ supports these options to set |'| and |`|,
+respectively, as a shorthand in case it is not done by default.
+
+\Describe{shorthands=}{\meta{char}\meta{char}...
+$\string|$ \texttt{off}}
+The only language shorthands activated
+are those given, like, eg:
+\begin{verbatim}
+\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
+\verb|~|) should be preceded by \verb|\string| (otherwise they will be
+expanded by \LaTeX{} before they are passed to the package and
+therefore they will not be recognized); however, |t| is provided for
+the common case of |~| (as well as |c| for not so common case of the
+comma).
+
+With |shorthands=off| no language shorthands are defined,
+As some languages use this mechanism for tools not available
+otherwise, a macro \verb|\babelshorthand| is defined, which allows
+using them; see above.
+
+\Describe{safe=}{\texttt{none} $\string|$ \texttt{ref} $\string|$
+\texttt{bib}} Some \LaTeX{} macros are redefined so that using
+shorthands is safe. With \texttt{safe=bib} only |\nocite|, |\bibcite|
+and |\bibitem| are redefined. With |safe=ref| only |\newlabel|, |\ref|
+and |\pageref| are redefined (as well as a few macros from
+\textsf{varioref} and \textsf{ifthen}).
+
+With |safe=none| no macro is redefined. This option is strongly
+recommended, because a good deal of incompatibilities and errors are
+related to these redefinitions. As of \New{3.34}, in $\epsilon$\TeX{}
+based engines (ie, almost every engine except the oldest ones)
+shorthands can be used in these macros (formerly you could not).
+
+\Describe{math=}{\texttt{active} $\string|$ \texttt{normal}}
+Shorthands are mainly intended for text, not for math. By setting this
+option with the value |normal| they are deactivated in math mode
+(default is |active|) and things like |${a'}$| (a closing brace after
+a shorthand) are not a source of trouble anymore.
+
 \subsection{Digits and counters}
 
 \New{3.20} About thirty |ini| files define a field named
@@ -2920,9 +3741,9 @@
 
 For example:
 \begin{verbatim}
-\babelprovide[import]{telugu}
-  % Or also, if you want:
-  % \babelprovide[import, maparabic]{telugu}
+\usepackage[telugu, provide=*]{babel}
+  % Or also, if you want, with:
+  % provide={ maparabic }
 \babelfont{rm}{Gautami} % With luatex, better with Harfbuzz
 \begin{document}
 _\telugudigits{1234}_
@@ -2932,6 +3753,7 @@
 
 Languages providing native digits in all or some variants are:
 \begin{multicols}{5}
+\parindent0pt
 Arabic\\ 
 Assamese\\
 Bangla\\ 
@@ -2985,7 +3807,7 @@
 bidi and fonts are processed (ie, to the node list as generated by the
 \TeX{} code). This means the local digits have the correct
 bidirectional behavior (unlike |Numbers=Arabic| in \textsf{fontspec},
-which is deprecated).
+which is deprecated). Another option is the transform |digits.native|.
 
 \begin{note}
   With \xetex{} you can use the option |Mapping| when defining a
@@ -3012,7 +3834,7 @@
 \item In |\babelprovide|, as an argument to the keys |alph| and |Alph|,
 which redefine what |\alph| and |\Alph| print. For example:
 \begin{verbatim}
-\babelprovide[alph=alphabetic]{thai}
+\babelprovide[_alph=alphabetic_]{thai}
 \end{verbatim}
 \end{itemize}
 
@@ -3164,346 +3986,6 @@
 calendars accept only a restricted range of years. Please, refer to the
 page on the news for 3.76 in the \babel{} site for further details.
 
-\subsection{Accessing language info}
-
-\Describe{\localename}{}
-\DescribeOther{\mainlocalename}
-\DescribeOther{\languagename}
-\New{29.10} The control sequence |\localename| contains the name of the current
-locale. This is now the recommended way to retrieve the current
-language. In addtion, |\mainlocalename| contains the main language.
-
-|\languagename| is still used internally, but it is now discouraged at
-the user level.
-
-\begin{warning}
-  Due to a bug, which lead to some internal inconsistencies in
-  catcodes, |\languagename| should \textit{not} be used to test which
-  is the current language. Rely on |\localename| or, if you still need
-  |\languagename| for some reason, on \textsf{iflang}, by Heiko Oberdiek.
-\end{warning}
-
-\Describe{\iflanguage}{\marg{language}\marg{true}\marg{false}}
-
-Here ``language'' is used in the \TeX{} sense, as a set of hyphenation
-patterns, and \textit{not} as its \textsf{babel} name. The first
-argument is the name of a language.
-
-\Describe{\localeinfo}{%
- \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}{\marg{field}}}
-
-\New{3.38} If an |ini| file has been loaded for the current language,
-you may access the information stored in it. This macro is fully
-expandable, and the available fields are:
-\begin{description}
-\itemsep=-\parskip
-\item[|name.english|] as provided by the Unicode CLDR.
-\item[|tag.ini|] is the tag of the |ini| file (the way this
-  file is identified in its name).
-\item[|tag.bcp47|] is the full BCP 47 tag (see the warning below). This
-  is the value to be used for the ‘real' provided tag (\babel{} may
-  fill other fields if they are considered necessary).
-\item[|language.tag.bcp47|] is the BCP 47 language tag.
-\item[|tag.opentype|] is the tag used by OpenType (usually, but not
-  always, the same as BCP 47).
-\item[|script.name|], as provided by the Unicode CLDR.
-\item[|script.tag.bcp47|] is the BCP 47 tag of the script
-  used by this locale. This is a required field for the fonts to be
-  correctly set up, and therefore it should be always defined.
-\item[|script.tag.opentype|] is the tag used by OpenType (usually,
-  but not always, the same as BCP 47).
-\item[|region.tag.bcp47|] is the BCP 47 tag of the region or territory.
-  Defined only if the locale loaded actually contains it (eg, |es-MX|
-  does, but |es| doesn’t), which is how locales behave in the CLDR.
-  \New{3.75}
-\item[|variant.tag.bcp47|] is the BCP 47 tag of the variant (in the BCP 47
-  sense, like |1901| for German). \New{3.75}
-\item[|extension.|\m{s}|.tag.bcp47|] is the BCP 47 value of the
-  extension whose singleton is \m{s} (currently the recognized
-  singletons are |x|, |t| and |u|). The internal syntax can be somewhat
-  complex, and this feature is still somewhat tentative. An example is
-  \textsf{classicallatin} which sets |extension.x.tag.bcp47| to |classic|.
-  \New{3.75}
-\end{description}
-
-\begin{note}
-  Currently, |x| is used for two separate functions, namely,
-  identifying a \babel{} locale without a BCP47 tag and setting an
-  alternative set of rules for casing.
-\end{note}
-
-\begin{warning}
-  \New{3.46} As of version 3.46 |tag.bcp47| returns the full BCP 47
-  tag. Formerly it returned just the language subtag, which was clearly
-  counterintuitive.
-\end{warning}
-
-\New{3.75} Sometimes, it comes in handy to be able to use |\localeinfo|
-in an expandable way even if something went wrong (for example, the
-locale currently active is undefined). For these cases, |localeinfo*|
-just returns an empty string instead of raising an error. Bear in mind
-that \babel{}, following the CLDR, may leave the region unset, which
-means |\getlocaleproperty*|, described below, is the preferred
-command, so that the existence of a field can be checked before. This
-also means building a string with the language and the region with
-|\localeinfo*{language.tab.bcp47}|\allowbreak |-|\allowbreak
-|\localeinfo*{region.tab.bcp47}| is not usually a good idea (because of
-the hyphen).
-
-\Describe{\getlocaleproperty}{%
-  \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
-  \marg{macro}\marg{locale}\marg{property}}
-
-\New{3.42} The value of any locale property as set by the |ini| files
-(or added/modified with |\babelprovide|) can be retrieved and stored in
-a macro with this command. For example, after:
-\begin{verbatim}
-  \getlocaleproperty\hechap{hebrew}{captions/chapter}
-\end{verbatim}
-the macro |\hechap| will contain the string
-{\fontspec[Scale=.87,Script=Hebrew]{Liberation Mono}\textdir TRT פרק}.
-
-If the key does not exist, the macro is set to |\relax| and an error is
-raised. \New{3.47} With the starred version no error is raised, so that
-you can take your own actions with undefined properties.
-
-\Describe{\localeid}{}
-Each language in the \babel{} sense has its own unique numeric
-identifier, which can be retrieved with |\localeid|.
-
-The |\localeid| is not the same as the |\language| identifier, which
-refers to a set of hyphenation patterns (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
-(when it makes sense) as an attribute, too.
-
-\Describe{\ShowLocaleProperties}{\marg{language}}
-\New{3.98} Prints to the |log| file all the loaded key/value pairs from
-the |ini| locale file for \meta{language}. 
-
-\Describe{\LocaleForEach}{\marg{code}}
-\Babel{} remembers which |ini| files have been loaded. There is a loop
-named |\LocaleForEach| to traverse the list, where |#1| is the name of
-the current item, so that |\LocaleForEach{\message{ **#1** }}| just
-shows the loaded |ini|’s. 
-
-\Describe{ensureinfo=off}{}
-\New{3.75} Previously, |ini| files were loaded only with |\babelprovide|
-and also when languages are selected if there is a |\babelfont| or they
-have not been explicitly declared. Now the |ini| files are loaded (and
-therefore the corresponding data) even if these two conditions are not
-met (in previous versions you had to enable it with |\BabelEnsureInfo|
-in the preamble). Because of the way this feature works, problems are
-very unlikely, but there is switch as a package option to turn the new
-behavior off (|ensureinfo=off|).
-
-\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 (although in a limited way),
-while \luatex{} provides basic rules for the latter, too. With \luatex{}
-there are also tools for non-standard hyphenation rules, explained in
-the next section.
-
-\Describe{\babelhyphen}{%
-  \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{type}}
-\DescribeOther\babelhyphen{%
-  \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{text}}
-
-\New{3.9a} It is customary to classify hyphens in two types: (1)
-\textit{explicit} or \textit{hard hyphens}, which in \TeX\ are
-entered as \verb|-|, and (2) \textit{optional} or \textit{soft
-hyphens}, which are entered as \verb|\-|. Strictly, a \textit{soft
-hyphen} is not a hyphen, but just a breaking opportunity or, in
-\TeX\ terms, a ``discretionary''; a \textit{hard hyphen} is a hyphen
-with a breaking opportunity after it. A further type is a
-\textit{non-breaking hyphen}, a hyphen without a breaking
-opportunity.
-
-In \TeX, \verb|-| and \verb|\-| forbid further breaking opportunities
-in the word. This is the desired behavior very often, but not always,
-and therefore many languages provide shorthands for these
-cases. Unfortunately, this has not been done consistently: for
-example, \verb|"-| in Dutch, Portuguese, Catalan or Danish is a hard
-hyphen, while in German, Spanish, Norwegian, Slovak or Russian is a
-soft hyphen. Furthermore, some of them even redefine |\-|, so that you
-cannot insert a soft hyphen without breaking opportunities in the rest
-of the word.
-
-Therefore, some macros are provided with a set of basic ``hyphens''
-which can be used by themselves, to define a user shorthand, or even
-in language files.
-\begin{itemize}
-\item |\babelhyphen{soft}| and |\babelhyphen{hard}| are self
-  explanatory.
-\item |\babelhyphen{repeat}| inserts a hard hyphen which is repeated
-  at the beginning of the next line, as done in languages like
-  Polish, Portuguese and Spanish.
-\item |\babelhyphen{nobreak}| inserts a hard hyphen without a break
-  after it (even if a space follows).
-\item |\babelhyphen{empty}| inserts a break opportunity without
-  a hyphen at all.
-\item |\babelhyphen|\marg{text} is a hard ``hyphen'' using \m{text}
-  instead. A typical case is |\babelhyphen{/}|.
-\end{itemize}
-With all of them, hyphenation in the rest of the word is enabled. If
-you don't want to enable it, there is a starred counterpart:
-|\babelhyphen*{soft}| (which in most cases is equivalent to the
-original |\-|), |\babelhyphen*{hard}|, etc.
-
-Note |hard| is also good for isolated prefixes (eg, \textit{anti-})
-and |nobreak| for isolated suffixes (eg, \textit{-ism}), but in both
-cases |\babelhyphen*{nobreak}| is usually better.
-
-There are also some differences with \LaTeX: (1) the character used is
-that set for the current font, while in \LaTeX{} it is hardwired to
-|-| (a typical value); (2) the hyphen to be used in fonts with a
-negative |\hyphenchar| is  |-|, like in \LaTeX, but it can be changed to
-another value by redefining |\babelnullhyphen|; (3) a break after the
-hyphen is forbidden if preceded by a glue ${>}0$~pt (at the beginning
-of a word, provided it is not immediately preceded by, say, a
-parenthesis).
-
-\Describe\babelhyphenation{\texttt{[}\langlist\texttt{]}%
-    \marg{exceptions}}
-
-\New{3.9a} Sets hyphenation exceptions for the languages given
-or, without the optional argument, for \textit{all} languages (eg,
-proper nouns or common loan words, and of course monolingual
-documents). Multiple declarations work much like |\hyphenation| (last
-wins), but language exceptions take precedence over global ones.
-
-It can be used only in the preamble, and exceptions are set when the
-language is first selected, thus taking into account changes of
-|\lccodes|'s done in |\extras<language>| as well as the language-specific
-encoding (not set in the preamble by default). Multiple
-|\babelhyphenation|'s are allowed. For example:
-\begin{verbatim}
-\babelhyphenation{Wal-hal-la Dar-bhan-ga}
-\end{verbatim}
-
-Listed words are saved expanded and therefore it relies on the
-LICR. Of course, it also works without the LICR if the input and the
-font encodings are the same, like in Unicode based engines.
-
-\begin{note}
-  Using |\babelhyphenation| with Southeast Asian scripts is mostly
-  pointless. But with |\babelpatterns| (below) you may fine-tune line
-  breaking (only \luatex). For example:
-\begingroup
-\catcode`@=13
-\def@#1@{{\fontspec{Loma}#1}}
-\begin{verbatim}
-\babelpatterns[thai]{@ศึก@2@ษา@}
-\end{verbatim}
-\endgroup
-  Even if there are no patterns for the language, you can add at least
-  some typical cases.
-\end{note}
-
-\begin{note}
-  Use |\babelhyphenation| instead of |\hyphenation| to set hyphenation
-  exceptions in the preamble before any language is explicitly set with
-  a selector. In the preamble the hyphenation rules are not always
-  fully set up and an error can be raised.
-\end{note}
-
-\Describe{\babelpatterns}{\texttt{[}\langlist\texttt{]}%
-    \marg{patterns}}
-
-\New{3.9m} \textit{In \textsf{luatex} only},\footnote{With
-\textsf{luatex} exceptions and patterns can be modified almost
-freely. However, this is very likely a task for a separate package
-and \texttt{babel} only provides the most basic tools.} adds or
-replaces patterns for the languages given or, without the optional
-argument, for \textit{all} languages. If a pattern for a certain
-combination already exists, it gets replaced by the new one.
-
-It can be used only in the preamble, and patterns are added when the
-language is first selected, thus taking into account changes of
-|\lccodes|'s done in |\extras<language>| as well as the language-specific
-encoding (not set in the preamble by default). Multiple
-|\babelpatterns|'s are allowed.
-
-Listed patterns are saved expanded and therefore it relies on the
-LICR. Of course, it also works without the LICR if the input and the
-font encodings are the same, like in Unicode based engines.
-
-\New{3.31} (Only \luatex.) With |\babelprovide| and |import|ed CJK
-languages, a simple generic line breaking algorithm (push-out-first) is
-applied, based on a selection of the Unicode rules (\New{3.32} it is
-disabled in verbatim mode, or more precisely when the hyphenrules
-are set to |nohyphenation|). It can be activated alternatively by
-setting explicitly the |intraspace|.
-
-\New{3.27} Interword spacing for Thai, Lao and Khemer is activated
-automatically if a language with one of those scripts are loaded with
-|\babelprovide|. See the sample on the \babel{} repository. With both
-Unicode engines, spacing is based on the ``current'' em unit (the size
-of the previous char in \luatex, and the font size set by the last
-|\selectfont| in \xetex).
-
-\begin{note}
-  With Unicode engines, a line break can happen just before an explicit
-  combining char (eg, \textit{\~{g}}, used in Guarani and Filipino, is
-  not included as a combined char and it’s represented in Unicode as
-  |U+0067|~|U+0303|. This issue is not directly related to \babel, but
-  to the hyphenation patterns and/or the font renderer. However, at
-  least with \luatex{} there is a workaround (change the language name
-  to what you are using):
-\begin{verbatim}
-\babelposthyphenation{guarani}{ | [{0300}-{036F}] }{ remove, {} }
-\end{verbatim}
-The Lua pattern means ‘a discretionary followed by a character in the
-range |U+0300|--|U+0367| (which contains combining chars)’. An
-alternative to a transform is |\babelpatterns|.
-\end{note}
-
-\Describe{\babelhyphenmins}{%
-  \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
-  \texttt{[}\langlist\texttt{]}%
-  \marg{left}\marg{right}\oarg{hyphenationmin}}
-
-\New{24.10} See the news page for the rationale for this commands. It
-sets the corresponding values for the given languages (all languages
-without the optional argument). With the star, the values are also
-applied immediately (the optional argument and the star are currently
-incompatible). The optional argument is available only in \luatex.
-\begin{example}
-You are typesetting a book with wide lines and want to limit the
-number of hyphens in all languages:
-\begin{verbatim}
-  \babelhyphenmins{3}{4}
-\end{verbatim}
-But there are also some 3-column text and you want to be more flexible:
-\begin{verbatim}
-  \begin{multicols}{3}
-  \babelhyphenmins*{2}{3}
-  ...
-  \end{multicols}
-\end{verbatim}
-\end{example}
-
-\Describe{\begin\menv{hyphenrules}}{\marg{language}\Eenv{hyphenrules}}
-
-The environment \Lenv{hyphenrules} can be used to select \emph{only} the
-hyphenation rules to be used (it can be used as command, too). This can
-for instance be used to select ‘nohyphenation’, provided that in
-\file{language.dat} the ‘language’ \textsf{nohyphenation} is defined by
-loading \file{zerohyph.tex}. It deactivates language shorthands, too
-(but not user shorthands).
-
-Except for these simple uses, |hyphenrules| is deprecated and
-|otherlanguage*| (the starred version) is preferred, because the former
-does not take into account possible changes in encodings of characters
-like, say, |'| done by some languages (eg, \textsf{italian},
-\textsf{french}, \textsf{ukrainian}).
-
 \subsection{Transforms}
 \label{transforms}
 
@@ -3548,7 +4030,7 @@
   \parbox[t]{4.0cm}{\strut\ttfamily#2}%
   \hspace{2mm}%
   \parbox[t]{6.6cm}{\strut#3}\par}
-\bigskip\hrule\nobreak\vspace{.5mm}
+\bigskip\hrule\nobreak\vspace{.5mm}\parindent0pt
 
 \trans{}{digits.native}{\New{24.9} An alternative to |mapdigits|,
 available in the same locales. This transform is applied before the
@@ -3788,6 +4270,7 @@
 the current language.
 
 \subsection{Support for \xetex{} interchar}
+\label{interchar}
 
 \New{3.97} A few macros are provided to deal with locale dependent
 inter-character rules (aka ‘interchar’).
@@ -3866,7 +4349,7 @@
   \parbox[t]{4.0cm}{\strut\ttfamily#2}%
   \hspace{2mm}%
   \parbox[t]{6.6cm}{\strut#3}\par}
-\bigskip\hrule\nobreak\vspace{.5mm}
+\bigskip\hrule\nobreak\vspace{.5mm}\parindent0pt
 
 \trans{Cantonese, Chinese, Japanese,
 Korean}{linebreak.basic}{\New{24.4} Basic settings for CJK
@@ -3887,86 +4370,8 @@
   relevant key for the current engine is taken into account.
 \end{note}
 
-\subsection{Selection based on BCP 47 tags}
-\label{bcp47}
+\subsection{Scripts}
 
-\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 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
-of locales as described in this section. In these contexts autoloading
-is particularly important because we may not know on beforehand which
-languages will be requested.
-
-It must be activated explicitly, because it is primarily meant for
-special tasks. Mapping from BCP 47 codes to locale names are not
-hardcoded in \babel. Instead the data is taken from the \texttt{ini}
-files, which means currently about 250 tags are already recognized.
-\Babel{} performs a simple lookup in the following way: |fr-Latn-FR| $\to$
-|fr-Latn| $\to$ |fr-FR| $\to$ |fr|. Languages with the same resolved
-name are considered the same. Case is normalized before, so that
-|fr-latn-fr| $\to$ |fr-Latn-FR|. If a tag and a name overlap, the tag
-takes precedence.
-
-Here is a minimal example:
-\begin{verbatim}
-\documentclass{article}
-
-\usepackage[danish]{babel}
-
-_\babeladjust{_
-_  autoload.bcp47 = on,_
-_  autoload.bcp47.options = import_
-_}_
-
-\begin{document}
-
-Chapter in Danish: \chaptername.
-
-_\selectlanguage{de-AT}_
-
-\localedate{2020}{1}{30}
-
-\end{document}
-\end{verbatim}
-
-Currently the locales loaded are based on the \texttt{ini} files and
-decoupled from the main \texttt{ldf} files. This is by design, to
-ensure code generated externally produces the same result regardless of
-the languages requested in the document, but an option to use the
-\texttt{ldf} instead will be added in a future release, because both
-options make sense depending on the particular needs of each document
-(there will be some restrictions, however).
-
-The behaviour is adjusted with |\babeladjust| with the following parameters:
-\begin{description}
-\item \texttt{autoload.bcp47} with values |on| and |off|.
-\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
-  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
-  \texttt{bcp47-}. You may change it with this key.
-\end{description}
-
-\New{3.46} If an |ldf| file has been loaded, you can enable the
-corresponding language tags as selector names with:
-\begin{verbatim}
-\babeladjust{ bcp47.toname = on }
-\end{verbatim}
-(You can deactivate it with |off|.) So, if |dutch| is one of the
-package (or class) options, you can write |\selectlanguage{nl}|. Note
-the language name does not change (in this example is still |dutch|),
-but you can get it with |\localeinfo| or |\getlocaleproperty|. It
-must be turned on explicitly for similar reasons to those explained
-above.
-
-\subsection{Selecting scripts}
-
 Currently \babel{} provides no standard interface to select
 scripts, because they are best selected with either |\fontencoding|
 (low-level) or a language name (high-level). Even the Latin script may
@@ -3986,6 +4391,60 @@
 therefore it has been deprecated.\footnote{But still defined for
 backwards compatibility.}
 
+The locales currently available cover the following scripts:
+\begin{multicols}{4}
+\parindent-.5em
+\leftskip.5em
+Arabic\\   
+Armenian\\  
+Bangla\\
+Bengali\\   
+Cherokee\\  
+Coptic\\
+Cyrillic\\  
+Devanagari\\
+Egyptian hieroglyphs\\ 
+Ethiopic\\  
+Georgian\\  
+Glagolitic\\
+Gothic\\
+Greek\\
+Gujarati\\  
+Gurmukhi\\  
+Han\\ 
+Hebrew\\
+Japanese\\
+Kannada\\ 
+Khmer\\
+Khojki\\
+Khudawadi\\
+Korean\\
+Lao\\
+Latin\\
+Malayalam\\
+Myanmar\\   
+Nyiakeng Puachue Hmong\\
+N’Ko\\
+Ol Chiki\\  
+Old Church Slavonic Cyrillic\\ 
+Oriya\\
+Phoenician\\
+Runic\\
+Simplified\\
+Sinhala\\   
+Sumero-Akkadian Cuneiform\\
+Tamil\\
+Telugu\\
+Thaana\\
+Thai\\
+Tibetan\\   
+Tifinagh\\  
+Traditional\\
+Unified Canadian Aboriginal Syllabics\\
+Vai\\ 
+Yi
+\end{multicols}
+
 \Describe{\ensureascii}{\marg{text}}
 
 \New{3.9i} This macro makes sure \m{text} is typeset with a
@@ -4011,7 +4470,7 @@
 127, which may not follow the LICR conventions -- the goal is just
 to ensure most of the ASCII letters and symbols are the right ones.
 
-\subsection{Selecting directions}
+\subsection{Bidirectional and right-to-left text}
 \label{bidi}
 
 No macros to select the writing direction are provided, either --
@@ -4096,13 +4555,12 @@
 \catcode`@=13
 \def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else
 \bgroup\textdir TRT \pardir TRT \fi}
+\setengine{luatex}
 \begin{verbatim}
-\documentclass{article}
+\documentclass[arabic]{article}
 
-\usepackage[_bidi=basic_]{babel}
+\usepackage[_bidi=basic_, provide=*]{babel}
 
-_\babelprovide[import, main]{arabic}_
-
 \babelfont{rm}{FreeSerif}
 
 \begin{document}
@@ -4271,10 +4729,17 @@
 
 \begin{example}
   Typically, in an Arabic document you would need:
+\setengine{luatex}
 \begin{verbatim}
 \usepackage[bidi=basic,
             layout=counters tabular]{babel}
 \end{verbatim}
+or
+\setengine{xetex}
+\begin{verbatim}
+\usepackage[bidi=bidi,
+            layout=counters tabular]{babel}
+\end{verbatim}
 \end{example}
 
 \Describe{\babelsublr}{\marg{lr-text}}
@@ -4331,18 +4796,18 @@
 
 \New{3.17} Something like:
 \begin{verbatim}
-\BabelFootnote{\parsfootnote}{\languagename}{(}{)}
+\BabelFootnote{\parsfootnote}{\localename}{(}{)}
 \end{verbatim}
 defines |\parsfootnote| so that |\parsfootnote{note}| is equivalent to:
 \begin{verbatim}
-\footnote{(\foreignlanguage{\languagename}{note})}
+\footnote{(\foreignlanguage{\localename}{note})}
 \end{verbatim}
 but the footnote itself is typeset in the main language (to unify its
 direction). In addition, |\parsfootnotetext| is defined. The option
 |footnotes| just does the following:
 \begin{verbatim}
-\BabelFootnote{\footnote}{\languagename}{}{}%
-\BabelFootnote{\localfootnote}{\languagename}{}{}%
+\BabelFootnote{\footnote}{\localename}{}{}%
+\BabelFootnote{\localfootnote}{\localename}{}{}%
 \BabelFootnote{\mainfootnote}{}{}{}
 \end{verbatim}
 (which also redefine |\footnotetext| and define |\localfootnotetext|
@@ -4362,159 +4827,6 @@
   footnote text should be omitted.
 \end{example}
 
-\subsection{Language attributes}
-
-\DescribeMacro{\languageattribute}
-
-This is a user-level command, to be used in the preamble of a
-document (after |\usepackage[...]{babel}|), that declares which
-attributes are to be used for a given language. It takes two
-arguments: the first is the name of the language; the second,
-a (list of) attribute(s) to be used. Attributes must be set in the
-preamble and only once -- they cannot be turned on and off.
-The command checks whether the language is known in this document
-and whether the attribute(s) are known for this language.
-
-Very often, using a \textit{modifier} in a package option is better.
-
-Several language definition files use their own methods to set
-options. For example, \textsf{french} uses |\frenchsetup|,
-\textsf{magyar} (1.5) uses |\magyarOptions|; modifiers provided by
-|spanish| have no attribute counterparts. Macros setting
-options are also used (eg, |\ProsodicMarksOn| in \textsf{latin}).
-
-\subsection{Hooks}
-
-\New{3.9a} A hook is a piece of code to be executed at certain
-events. Some hooks are predefined when \luatex{} and \xetex{} are
-used.
-
-\New{3.64} This is not the only way to inject code at those points. The
-events listed below can be used as a hook name in |\AddToHook| in the
-form |babel/<language-name>/<event-name>| (with |*| it’s applied to
-all languages), but there is a limitation, because the parameters
-passed with the \babel{} mechanism are not allowed. The |\AddToHook|
-mechanism does \textit{not} replace the current one in `babel`. Its
-main advantage is you can reconfigure `babel` even before loading it.
-See the example below.
-
-\Describe{\AddBabelHook}{\oarg{language}\marg{name}\marg{event}\marg{code}}
-
-The same name can be applied to several events. Hooks with a certain
-\marg{name} may be enabled and disabled for all defined events with
-|\EnableBabelHook|\marg{name}, |\DisableBabelHook|\marg{name}. Names
-containing the string |babel| are reserved (they are used, for example,
-by |\useshortands*| to add a hook for the event |afterextras|).
-\New{3.33} They may be also applied to a specific language with the
-optional argument; language-specific settings are executed after global
-ones.
-
-Current events are the following; in some of them you can use one to
-three \TeX{} parameters (|#1|, |#2|, |#3|), with the meaning given:
-\begin{description}
-\renewcommand\makelabel[1]{%
-  \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
-\itemsep=-\parskip
-\item[adddialect] (language name, dialect name) Used by
-  \file{luababel.def} to load the patterns if not preloaded.
-\item[patterns] (language name, language with encoding) Executed just
-  after the |\language| has been set. The second argument has the
-  patterns name actually selected (in the form of either |lang:ENC| or
-  |lang|).
-\item[hyphenation] (language name, language with encoding) Executed
-  locally just before exceptions given in |\babelhyphenation| are
-  actually set.
-\item[defaultcommands] Used (locally) in |\StartBabelCommands|.
-\item[encodedcommands] (input, font encodings) Used (locally) in
-  |\StartBabelCommands|. Both \xetex{} and \luatex{} make sure the
-  encoded text is read correctly.
-\item[stopcommands] Used to reset the above, if necessary.
-\item[write] This event comes just after the switching commands are
-  written to the |aux| file.
-\item[beforeextras] Just before executing |\extras<language>|. This
-  event and the next one should not contain language-dependent code
-  (for that, add it to |\extras<language>|).
-\item[afterextras] Just after executing |\extras<language>|. For
-  example, the following deactivates shorthands in all languages:
-\begin{verbatim}
-\AddBabelHook{noshort}{afterextras}{\languageshorthands{none}}
-\end{verbatim}
-\item[stringprocess] Instead of a parameter, you can manipulate the
-  macro |\BabelString| containing the string to be defined with
-  |\SetString|. For example, to use an expanded version of the string
-  in the definition, write:
-\begin{verbatim}
-\AddBabelHook{myhook}{stringprocess}{%
-  \protected at edef\BabelString{\BabelString}}
-\end{verbatim}
-\item[initiateactive] (char as active, char as other, original char)
-  \New{3.9i} Executed just after a shorthand has been `initiated'. The three
-  parameters are the same character with different catcodes: active,
-  other (|\string|'ed) and the original one.
-\item[afterreset] \New{3.9i} Executed when selecting a language just after
-  |\originalTeX| is run and reset to its base value, before executing
-  |\captions<language>| and |\date<language>|.
-\item[begindocument] \New{3.88} Executed before the code written by
-  |ldf| files with |\AtBeginDocument|. The optional argument with the
-  language in this particular case is the language that wrote the code.
-  The special value |/| means ‘return to the core \babel{} definitions’
-  (in other words, what follows hasn’t been written by any language).
-\item[foreign] \New{24.8} Executed by |\foreignlanguage| after the
-  language has been set up and just before typesetting the text from the
-  second argument. Its main purpose it to wrap the text with some
-  code, with the help of |\BabelWrapText|. For example, with:
-\begin{verbatim}
-\AddBabelHook{one}{foreign}{\BabelWrapText{\textit{##1}}
-\AddBabelHook{two}{foreign}{\BabelWrapText{\parse{##1}}
-\end{verbatim}
-the text becomes |\textit{\parse{<text>}}|. 
-
-\end{description}
-
-Four events are used in \file{hyphen.cfg}, which are handled in a
-quite different way for efficiency reasons -- unlike the precedent
-ones, they only have a single hook and replace a default definition.
-\begin{description}
-\renewcommand\makelabel[1]{%
-  \hspace\labelsep\normalfont\ttfamily\color{thered}#1}
-\itemsep=-\parskip
-\item[everylanguage] (language) Executed before every language patterns
-  are loaded.
-\item[loadkernel] (file) By default just defines a few basic commands.
-  It can be used to define different versions of them or to load a file.
-\item[loadpatterns] (patterns file) Loads the patterns file. Used by
-  \file{luababel.def}.
-\item[loadexceptions] (exceptions file) Loads the exceptions
-  file. Used by \file{luababel.def}.
-\end{description}
-
-\begin{example}
-The generic unlocalized \LaTeX{} hooks are predefined, so that you can
-write:
-\begin{verbatim}
-\AddToHook{babel/*/afterextras}{\frenchspacing} 
-\end{verbatim}
-which is executed always after the extras for the language being
-selected (and just before the non-localized hooks defined with
-|\AddBabelHook|).
-
-In addition, locale-specific hooks in the form
-|babel/<language-name>/<event-name>| are \textit{recognized}
-(executed just before the localized \babel{} hooks), but they are
-\textit{not predefined}. You have to do it yourself. For example, to
-set |\frenchspacing| only in |bengali|:
-\begin{verbatim}
-\ActivateGenericHook{babel/bengali/afterextras}
-\AddToHook{babel/bengali/afterextras}{\frenchspacing}
-\end{verbatim}
-\end{example}
-
-\Describe{\BabelContentsFiles}{}
-\New{3.9a} This macro contains a list of ``toc'' types
-requiring a command to switch the language. Its default value is
-|toc,lof,lot|, but you may redefine it with |\renewcommand| (it's up
-to you to make sure no toc type is duplicated).
-
 \subsection{Unicode character properties in \luatex}
 
 \New{3.32} Part of the \babel{} job is to apply Unicode rules to some
@@ -4552,7 +4864,7 @@
 \babelcharproperty{`,}{locale}{english}
 \end{verbatim}
 
-\subsection{Tweaking some features}
+\subsection{Tweaking some \babel{} features}
 
 \Describe{\babeladjust}{\marg{key-value-list}}
 
@@ -4604,34 +4916,36 @@
 with care, because these options do not deactivate other related
 options (like paragraph direction with |bidi.text|).
 
-\subsection{Tips, workarounds, known issues and notes}
+\section{Relation with other packages}
 
-\begin{itemize}
- \item For the hyphenation to work correctly, lccodes cannot change,
-   because \TeX{} only takes into account the values when the
-   paragraph is hyphenated, i.e., when it has been
-   finished.\footnote{This explains why \LaTeX{} assumes the lowercase
-   mapping of T1 and does not provide a tool for multiple
-   mappings. Unfortunately, \cs{savinghyphcodes} is not a solution
-   either, because lccodes for hyphenation are frozen in the format
-   and cannot be changed.} So, if you write a chunk of French text
-   with |\foreignlanguage|, the apostrophes might not be taken into
-   account. This is a limitation of \TeX, not of
-   \babel. Alternatively, you may use |\useshorthands| to activate |'|
-   and |\defineshorthand|, or redefine |\textquoteright| (the latter
-   is called by the non-ASCII right quote).
-\item Babel does not take into account |\normalsfcodes| and
-  (non-)French spacing is not always properly (un)set by
-  languages. However, problems are unlikely to happen and therefore
-  this part remains untouched (but it is in the `to do' list).
-\item Using a character mathematically active (ie, with math code
-  |"8000|) as a shorthand can make \TeX{} enter in an infinite loop in
-  some rare cases. (Another issue in the ‘to do’ list, although there
-  is a partial solution.)
-\end{itemize}
+There are compatibility issues with the following packages.
 
-The following packages can be useful, too (the list is still
-far from complete):
+\begingroup
+\parindent0pt
+\def\trans#1#2{%
+  \vspace{1.5mm}%
+  \parbox[t]{3.0cm}{\strut\sffamily#1}%
+  \hspace{2mm}%
+  \parbox[t]{10cm}{\strut#2}\par}
+\bigskip\hrule\nobreak\vspace{.5mm}
+
+\trans{polyglossia}{This package is not compatible at all with \babel.
+They should never be used together, because macros are different, and
+even those with the same name doesn’t behave in the same way. Also,
+languages are organized quite differently (\babel{} treats all locales
+on an equal footing).}
+
+\trans{tikz/pgf}{There are some issues with shorthands, which are
+usually solved with \texttt{\string\usetikzlibrary\{babel\}}.}
+
+\trans{cleveref}{Because of a long standing bug in this package, some
+languages can raise and error (particularly |spanish| and |greek|).}
+
+\vspace{2mm}\hrule\nobreak\bigskip
+\endgroup
+
+The following packages can be useful in multilingual contexts (the list
+is far from complete):
 \begin{description}
 \itemsep=-\parskip
 \item[csquotes] Logical markup for quotes.
@@ -4653,12 +4967,14 @@
 \item[zhspacing] Spacing for CJK documents in \xetex.
 \end{description}
 
-\subsection{Tentative and experimental code}
+For multilingual indexing, see \textsf{upmendex} and \textsf{xindex}.
 
+\section{Tentative and experimental code}
+
 See the code section for |\foreignlanguage*| (a new starred
 version of |\foreignlanguage|).
 
-For old an deprecated functions, see the \babel{} site.
+For old and deprecated functions, see the \babel{} site.
 
 \medskip
 \textbf{Options for locales loaded on the fly}
@@ -4678,12 +4994,12 @@
 because it is far from trivial -- see the \babel{} site for further
 details.
 
-\section{Loading languages with \file{language.dat}}
+\section{Loading language hyphenation rules with \file{language.dat}}
 
 \TeX{} and most engines based on it (pdf\TeX, \xetex, $\epsilon$-\TeX,
 the main exception being \luatex) require hyphenation patterns to be
-preloaded when a format is created (eg, \LaTeX, Xe\LaTeX,
-pdf\LaTeX). \babel{} provides a tool which has become standard in many
+preloaded when a format is created (eg, \LaTeX, Xe\LaTeX, pdf\LaTeX).
+\babel{} provides a tool which has become standard in many
 distributions and based on a ``configuration file'' named
 \file{language.dat}. The exact way this file is used depends on the
 distribution, so please, read the documentation for the latter (note
@@ -4691,19 +5007,11 @@
 
 \New{3.9q} With \luatex, however, patterns are loaded on the fly when
 requested by the language (except the ``0th'' language, typically
-\textsf{english}, which is preloaded always).\footnote{This feature
-was added to 3.9o, but it was buggy. Both 3.9o and 3.9p are
-deprecated.} Until 3.9n, this task was delegated to the package
-\textsf{luatex-hyphen}, by Khaled Hosny, \'Elie Roux, and Manuel
-P\'egouri\'e-Gonnard, and required an extra file named
-|language.dat.lua|, but now a new mechanism has been devised based
-solely on |language.dat|. \textbf{You must rebuild the formats} if
-upgrading from a previous version.  You may want to have a local
-|language.dat| for a particular project (for example, a book on
-Chemistry).\footnote{The loader for lua(e)tex is slightly different as
-it's not based on \babel{} but on \texttt{etex.src}. Until 3.9p it
-just didn't work, but thanks to the new code it works by reloading the
-data in the \babel{} way, i.e., with \texttt{language.dat}.}
+\textsf{english}, which is preloaded always). You may want to have a
+local |language.dat| for a particular project (for example, a book on
+Chemistry). The loader for lua(e)tex is slightly different as it's not
+based on \babel{}, but on \texttt{etex.src}; however, \babel{} reloads
+the data so that it works as expected.
 
 \subsection{Format}
 
@@ -4742,17 +5050,6 @@
 used, but otherwise use those in \file{hyphen.ger} (note the encoding
 can be set in |\extras<language>|).
 
-A typical error when using \babel{} is the following:
-\begin{verbatim}
-No hyphenation patterns were preloaded for
-the language `<lang>' into the format.
-Please, configure your TeX system to add them and
-rebuild the format. Now I will use the patterns
-preloaded for english instead}}
-\end{verbatim}
-It simply means you must reconfigure \file{language.dat}, either by
-hand or with the tools provided by your distribution.
-
 \section{The interface between the core of \babel{} and the language
 definition files}
 
@@ -5055,7 +5352,7 @@
 introduced. To facilitate this, some support macros are provided.
 
 \DescribeMacro{\initiate at active@char}
-The internal macro |\initiate at active@char| is used in language
+Used in language
 definition files to instruct \LaTeX\ to give a character the category
 code `active'. When a character has been made active it will remain
 that way until the end of the document. Its definition may vary.
@@ -5062,13 +5359,13 @@
 
 \DescribeMacro{\bbl at activate}
 \DescribeMacro{\bbl at deactivate}
-The command |\bbl at activate| is used to change the way an active
+Used to change the way an active
 character expands. |\bbl at activate| `switches on' the active behavior
 of the character. |\bbl at deactivate| lets the active character expand
 to its former (mostly) non-active self.
 
 \DescribeMacro{\declare at shorthand}
-The macro |\declare at shorthand| is used to define the various
+Used to define the various
 shorthands. It takes three arguments: the name for the collection of
 shorthands this definition belongs to; the character (sequence) that
 makes up the shorthand, i.e.\ |~| or |"a|; and the code to be executed
@@ -5075,18 +5372,15 @@
 when the shorthand is encountered. (It does \textit{not} raise an
 error if the shorthand character has not been ``initiated''.)
 
-\DescribeMacro{\bbl at add@special}
-\DescribeMacro{\bbl at remove@special}
-The \TeX book states: ``Plain \TeX\ includes a macro called
-|\dospecials| that is essentially a set macro, representing the set of
-all characters that have a special category code.'' \cite[p.~380]{DEK}
-It is used to set text `verbatim'.  To make this work if more
-characters get a special category code, you have to add this character
-to the macro |\dospecials|.  \LaTeX\ adds another macro called
-|\@sanitize| representing the same character set, but without the
-curly braces.  The macros |\bbl at add@special|\meta{char} and
-|\bbl at remove@special|\meta{char} add and remove the character
-\meta{char} to these two sets.
+\DescribeMacro{\bbl at add@special} The \TeX book states: ``Plain \TeX\
+includes a macro called |\dospecials| that is essentially a set macro,
+representing the set of all characters that have a special category
+code.'' \cite[p.~380]{DEK} It is used to set text `verbatim'. To make
+this work if more characters get a special category code, you have to
+add this character to the macro |\dospecials|. \LaTeX\ adds another
+macro called |\@sanitize| representing the same character set, but
+without the curly braces. The macros |\bbl at add@special|\meta{char} add
+the character \meta{char} to these two sets.
 
 \DescribeMacro{\@safe at activestrue}
 \DescribeMacro{\@safe at activesfalse}
@@ -5165,9 +5459,16 @@
 
 \DescribeMacro{\bbl at frenchspacing}
 \DescribeMacro{\bbl at nonfrenchspacing}
-The commands |\bbl at frenchspacing| and |\bbl at nonfrenchspacing| can be
+Those commands can be
 used to properly switch French spacing on and off.
 
+\begin{note}
+ With |lfd| files, \babel does not take into account |\normalsfcodes|
+ and (non-)French spacing is not always properly (un)set by languages
+ However, problems are unlikely to happen and therefore this part
+ remains untouched. With |ini| files, this issue has been addressed.
+\end{note}
+
 \subsection{Encoding-dependent strings}
 \label{s:strings}
 
@@ -5303,8 +5604,7 @@
   with the help of these macros.
 \end{note}
 
-\Describe\StartBabelCommands{%
-  \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}%
+\Describe\StartBabelCommands{\optstar
   \marg{language-list}\marg{category}\oarg{selector}}
 The starred version just forces |strings| to take a value -- if not set
 as package option (which is now deprecated), then the default for the
@@ -5373,21 +5673,6 @@
   assignment is wrong, fix it directly.
 \end{note}
 
-\subsection{Executing code based on the selector}
-
-\Describe{\IfBabelSelectorTF}{\marg{selectors}\marg{true}\marg{false}}
-
-\New{3.67} Sometimes a different setup is desired depending on the
-selector used. Values allowed in \m{selectors} are |select|, |other|,
-|foreign|, |other*| (and also |foreign*| for the tentative starred
-version), and it can consist of a comma-separated list. For example:
-\begin{verbatim}
-\IfBabelSelectorTF{other, other*}{A}{B}
-\end{verbatim}
-is true with any of these two environment selectors.
-
-Its natural place of use is in hooks or in |\extras<language>|.
-
 \else
 
 \DocInput{babel.dtx}
@@ -5403,7 +5688,7 @@
 Spit helped find and repair bugs.
 
 More recently, there are significant contributions by Salim Bou, Ulrike
-Fischer and Udi Fogiel.
+Fischer, Loren Davis and Udi Fogiel.
 
 There are also many contributors for specific languages, which are
 mentioned in the respective files. Without them, \babel{} just
@@ -5450,8 +5735,9 @@
 %</filedriver>
 % \fi
 %
-% \addtolength{\oddsidemargin}{-15pt}
+% \addtolength{\oddsidemargin}{-5pt}
 % \addtolength{\textwidth}{50pt}
+% \reversemarginpar
 %
 % \small
 %
@@ -5463,8 +5749,6 @@
 %
 % \section{Identification and loading of required files}
 %
-% \textit{Code documentation is still under revision.}
-%
 % The \babel{} package after unpacking consists of the following files:
 % \begin{description}
 % \itemsep=-\parskip
@@ -5512,8 +5796,8 @@
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=24.10>>
-%<<date=2024/09/18>>
+%<<version=24.11>>
+%<<date=2024/10/05>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -5553,7 +5837,7 @@
 \def\bbl at for#1#2#3{\bbl at loopx#1{#2}{\ifx#1\@empty\else#3\fi}}
 %    \end{macrocode}
 %
-% \begin{macro}{\bbl at add@list}
+% \macro{\bbl at add@list}
 % This internal macro adds its second argument to a comma separated
 % list in its first argument. When the list is not defined yet (or
 % empty), it will be initiated. It presumes expandable character
@@ -5568,10 +5852,8 @@
     #2}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at afterelse}
-% \begin{macro}{\bbl at afterfi}
+% \macro{\bbl at afterelse}
+% \macro{\bbl at afterfi}
 % Because the code that is used in the handling of active characters
 % may need to look ahead, we take extra care to `throw' it over the
 % |\else| and |\fi| parts of an |\if|-statement\footnote{This code is
@@ -5585,11 +5867,8 @@
 \long\def\bbl at afterfi#1\fi{\fi#1}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \macro{\bbl at exp}
 %
-% \begin{macro}{\bbl at exp}
-%
 % Now, just syntactical sugar, but it makes partial expansion of some
 % code a lot more simple and readable. Here |\\| stands for
 % |\noexpand|, |\<..>| for |\noexpand| applied to a built macro name
@@ -5610,9 +5889,8 @@
 \def\bbl at exp@ue#1]{%
   \unexpanded\expandafter\expandafter\expandafter{\csname#1\endcsname}}%
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\bbl at trim}
+% \macro{\bbl at trim}
 % The following piece of code is stolen (with some changes) from
 % \textsf{keyval}, by David Carlisle. It defines two macros:
 % |\bbl at trim| and |\bbl at trim@def|. The first one strips the leading and
@@ -5636,9 +5914,8 @@
 \long\def\bbl at trim@i#1\@nil#2\relax#3{#3{#1}}
 \long\def\bbl at trim@def#1{\bbl at trim{\def#1}}
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\bbl at ifunset}
+% \macro{\bbl at ifunset}
 % To check if a macro is defined, we create a new macro, which does the
 % same as |\@ifundefined|. However, in an $\epsilon$-tex engine, it is
 % based on |\ifcsname|, which is more efficient, and does not waste
@@ -5667,9 +5944,8 @@
        \fi}}
 \endgroup
 %    \end{macrocode}
-% \end{macro}
 %
-% \begin{macro}{\bbl at ifblank}
+% \macro{\bbl at ifblank}
 % A tool from \textsf{url}, by Donald Arseneau, which tests if a string
 % is empty or space. The companion macros tests if a macro is defined
 % with some `real' value, ie, not |\relax| and not empty,
@@ -5681,7 +5957,6 @@
 \def\bbl at ifset#1#2#3{%
   \bbl at ifunset{#1}{#3}{\bbl at exp{\\\bbl at ifblank{\@nameuse{#1}}}{#3}{#2}}}
 %    \end{macrocode}
-% \end{macro}
 %
 % For each element in the comma separated <key>|=|<value> list,
 % execute <code> with |#1| and |#2| as the key and the value of
@@ -5719,7 +5994,7 @@
 \def\bbl at foreach#1{\expandafter\bbl at vforeach\expandafter{#1}}
 %    \end{macrocode}
 %
-% \begin{macro}{\bbl at replace}
+% \macro{\bbl at replace}
 %
 % Returns implicitly |\toks@| with the modified string. 
 %
@@ -5777,7 +6052,6 @@
       \bbl at tempc}}  % empty or expand to set #1 with changes 
 \fi
 %    \end{macrocode}
-% \end{macro}
 %
 % Two further tools.  |\bbl at ifsamestring| first expand its arguments and
 % then compare their expansion (sanitized, so that the catcodes do not
@@ -5875,16 +6149,11 @@
 %<</Make sure ProvidesFile is defined>>
 %    \end{macrocode}
 %
-% \subsection{Multiple languages}
+% \subsection{A few core definitions}
 %
-% \begin{macro}{\language}
+% \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.
+% Just for compatibility, for not to touch |hyphen.cfg|.
 %
 %    \begin{macrocode}
 %<<*Define core switching macros>>
@@ -5894,14 +6163,12 @@
 %<</Define core switching macros>>
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\last at language}
 %
-% \begin{macro}{\last at language}
-%
 % Another counter is used to keep track of the allocated languages.
 % \TeX{} and \LaTeX{} reserves for this purpose the count 19.
 %
-% \begin{macro}{\addlanguage}
+% \macro{\addlanguage}
 %
 % This macro was introduced for \TeX{} $<$ 2. Preserved for
 % compatibility.
@@ -5913,9 +6180,6 @@
 %<</Define core switching macros>>
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % Now we make sure all required files are loaded. When the command
 % |\AtBeginDocument| doesn't exist we assume that we are dealing with a
 % plain-based format. In that case the file \file{plain.def} is needed
@@ -5929,8 +6193,11 @@
 % load |babel.def| here because we first need to declare and process
 % the package options.
 %
-% \subsection{The Package File (\LaTeX, \texttt{babel.sty})}
+% \subsection{\LaTeX: \texttt{babel.sty} (start)}
 %
+% Here starts the style file for \LaTeX. It also takes care of a number
+% of compatibility issues with other packages.
+%
 %    \begin{macrocode}
 %<*package>
 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
@@ -5937,8 +6204,9 @@
 \ProvidesPackage{babel}[<@date@> v<@version@> The Babel package]
 %    \end{macrocode}
 %
-% Start with some “private” debugging tool, and then define macros for
-% errors.
+% Start with some “private” debugging tools, and then define macros for
+% errors. The global lua ‘space’ |Babel| is declared here, too (inside
+% the test for |debug|).
 %
 %    \begin{macrocode}
 \@ifpackagewith{babel}{debug}
@@ -5945,7 +6213,8 @@
   {\providecommand\bbl at trace[1]{\message{^^J[ #1 ]}}%
    \let\bbl at debug\@firstofone
    \ifx\directlua\@undefined\else
-     \directlua{ Babel = Babel or {}
+     \directlua{
+       Babel = Babel or {}
        Babel.debug = true }%
      \input{babel-debug.tex}%
    \fi}
@@ -5952,9 +6221,16 @@
   {\providecommand\bbl at trace[1]{}%
    \let\bbl at debug\@gobble
    \ifx\directlua\@undefined\else
-     \directlua{ Babel = Babel or {}
+     \directlua{
+       Babel = Babel or {}
        Babel.debug = false }%
    \fi}
+%    \end{macrocode}
+%
+% Macros to deal with errors, warnings, etc. Errors are stored in a
+% separate file.
+%      
+%    \begin{macrocode}
 \def\bbl at error#1{% Implicit #2#3#4
   \begingroup
     \catcode`\\=0 \catcode`\==12 \catcode`\`=12
@@ -5978,11 +6254,6 @@
   \endgroup}
 %    \end{macrocode}
 %
-% This file also takes care of a number of compatibility issues with
-% other packages an defines a few additional package options. Apart from
-% all the language options below we also have a few options that
-% influence the behavior of language definition files.
-%
 % Many of the following options don’t do anything themselves, they are
 % just defined in order to make it possible for \babel{} and language
 % definition files to check if one of them was specified by the user.
@@ -6182,6 +6453,8 @@
 \ProcessOptions*
 %    \end{macrocode}
 %
+% \subsection{Post-process some options}
+%
 %    \begin{macrocode}
 \ifx\bbl at opt@provide\@nnil
   \let\bbl at opt@provide\@empty  % %%% MOVE above
@@ -6191,14 +6464,11 @@
     \in@{,provide,}{,#1,}%
     \ifin@
       \def\bbl at opt@provide{#2}%
-      \bbl at replace\bbl at opt@provide{;}{,}%
     \fi}
 \fi
 %
 %    \end{macrocode}
 %
-% \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.
@@ -6305,10 +6575,9 @@
     \fi}
 \fi
 %</package>
-%<*core>
 %    \end{macrocode}
 %
-% \subsection{Interlude for Plain}
+% \subsection{Plain: \texttt{babel.def} (start)}
 %
 % Because of the way \pkg{docstrip} works, we need to insert some code
 % for Plain here. However, the tools provided by the \babel{}
@@ -6317,6 +6586,7 @@
 % \textit{Emulate LaTeX}.
 %
 %    \begin{macrocode}
+%<*core>
 \ifx\ldf at quit\@undefined\else
 \endinput\fi % Same line!
 <@Make sure ProvidesFile is defined@>
@@ -6332,25 +6602,18 @@
 %
 %    \begin{macrocode}
 %</core>
-%<*package|core>
 %    \end{macrocode}
 %
-% \section{Multiple languages}
+% \section{\texttt{babel.sty} and \texttt{babel.def} (common)}
 %
-% This is not a separate file (\texttt{switch.def}) anymore.
-%
-% 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.
-%
 %    \begin{macrocode}
+%<*package|core>
 \def\bbl at version{<@version@>}
 \def\bbl at date{<@date@>}
 <@Define core switching macros@>
 %    \end{macrocode}
 %
-% \begin{macro}{\adddialect}
+% \macro{\adddialect}
 % The macro |\adddialect| can be used to add the name of a dialect
 % or variant language, for which an already defined hyphenation
 % table can be used.
@@ -6373,8 +6636,6 @@
   \endgroup}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % |\bbl at iflanguage| executes code only if the language |l@| exists.
 % Otherwise raises an error.
 %
@@ -6493,7 +6754,7 @@
 %<*package|core>
 %    \end{macrocode}
 %
-% \begin{macro}{\iflanguage}
+% \macro{\iflanguage}
 % Users might want to test (in a private package for instance)
 % which language is currently active. For this we provide a test
 % macro, |\iflanguage|, that has three arguments.  It checks
@@ -6512,13 +6773,11 @@
     \fi}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Selecting the language}
 %
-% \begin{macro}{\selectlanguage}
+% \macro{\selectlanguage}
 %
-% The macro |\selectlanguage| checks whether the language is
+% It checks whether the language is
 % already defined before it performs its actual task, which is to
 % update |\language| and activate language-specific definitions.
 %
@@ -6546,13 +6805,11 @@
 \let\xstring\string
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % Since version 3.5 \babel\ writes entries to the auxiliary files in
 % order to typeset table of contents etc. in the correct language
 % environment.
 %
-% \begin{macro}{\bbl at pop@language}
+% \macro{\bbl at pop@language}
 %
 % \emph{But} when the language change happens \emph{inside} a group
 % the end of the group doesn't write anything to the auxiliary
@@ -6563,7 +6820,7 @@
 % executed at the end of the group. It calls |\bbl at set@language|
 % with the name of the current language as its argument.
 %
-% \begin{macro}{\bbl at language@stack}
+% \macro{\bbl at language@stack}
 % The previous solution works for one level of nesting groups, but
 % as soon as more levels are used it is no longer adequate. For
 % that case we need to keep track of the nested languages using a
@@ -6577,8 +6834,8 @@
 % When using a stack we need a mechanism to push an element on the
 % stack and to retrieve the information afterwards.
 %
-% \begin{macro}{\bbl at push@language}
-% \begin{macro}{\bbl at pop@language}
+% \macro{\bbl at push@language}
+% \macro{\bbl at pop@language}
 % The stack is simply a list of languagenames, separated with a `+'
 % sign; the push function can be simple:
 %
@@ -6601,7 +6858,7 @@
 % we need to remove the element from the stack while storing it in the
 % macro |\languagename|. For this we first define a helper function.
 %
-% \begin{macro}{\bbl at pop@lang}
+% \macro{\bbl at pop@lang}
 % This macro stores its first element (which is delimited by the
 % `+'-sign) in |\languagename| and stores the rest of the string in
 % |\bbl at language@stack|.
@@ -6612,7 +6869,6 @@
   \xdef\bbl at language@stack{#2}}
 %    \end{macrocode}
 %
-% \end{macro}
 % The reason for the somewhat weird arrangement of arguments to the
 % helper function is the fact it is called in the following way.
 % This means that before |\bbl at pop@lang| is executed \TeX\ first
@@ -6634,9 +6890,6 @@
 % Once the name of the previous language is retrieved from the stack,
 % it is fed to |\bbl at set@language| to do the actual work of
 % switching everything that needs switching.
-% \end{macro}
-% \end{macro}
-% \end{macro}
 %
 % An alternative way to identify languages (in the \babel{} sense)
 % with a numerical value is introduced in 3.30. This is one of the
@@ -6656,10 +6909,9 @@
      \edef\bbl at id@last{\the\count@}%
      \ifcase\bbl at engine\or
        \directlua{
-         Babel = Babel or {}
-         Babel.locale_props = Babel.locale_props or {}
          Babel.locale_props[\bbl at id@last] = {}
          Babel.locale_props[\bbl at id@last].name = '\languagename'
+         Babel.locale_props[\bbl at id@last].vars = {}
         }%
       \fi}%
     {}%
@@ -6678,10 +6930,8 @@
 \let\endselectlanguage\relax
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\bbl at set@language}
 %
-% \begin{macro}{\bbl at set@language}
-%
 % The macro |\bbl at set@language| takes care of switching the language
 % environment \emph{and} of writing entries on the auxiliary files.
 % For historical reasons, language names can be either |language| of
@@ -6755,8 +7005,6 @@
   \select at language{#1}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % First, check if the user asks for a known language. If so,
 % update the value of |\language| and call |\originalTeX|
 % to bring \TeX\ in a certain pre-defined state.
@@ -6885,8 +7133,8 @@
   \let\bbl at selectorname\@empty}
 %    \end{macrocode}
 %
-% \begin{environment}{otherlanguage}
-% The \Lenv{otherlanguage} environment can be used as an alternative to
+% \environment{otherlanguage}
+% It can be used as an alternative to
 % using the |\selectlanguage| declarative command. The |\ignorespaces|
 % command is necessary to hide the environment when it is entered in
 % horizontal mode.
@@ -6906,13 +7154,11 @@
 \long\def\endotherlanguage{\@ignoretrue\ignorespaces}
 %    \end{macrocode}
 %
-%  \end{environment}
-%
-% \begin{environment}{otherlanguage*}
-% The \Lenv{otherlanguage} environment is meant to be used when a
+% \environment{otherlanguage*}
+% It is meant to be used when a
 % large part of text from a different language needs to be typeset,
 % but without changing the translation of words such as `figure'.
-% This environment makes use of |\foreign at language|.
+% It makes use of |\foreign at language|.
 %
 %    \begin{macrocode}
 \expandafter\def\csname otherlanguage*\endcsname{%
@@ -6932,15 +7178,12 @@
 \expandafter\let\csname endotherlanguage*\endcsname\relax
 %    \end{macrocode}
 %
-%  \end{environment}
+% \macro{\foreignlanguage}
 %
-% \begin{macro}{\foreignlanguage}
+% This command takes two arguments, the first argument is the name of
+% the language to use for typesetting the text specified in the second
+% argument.
 %
-% The |\foreignlanguage| command is another substitute for the
-% |\selectlanguage| command. This command takes two arguments, the
-% first argument is the name of the language to use for typesetting
-% the text specified in the second argument.
-%
 % Unlike |\selectlanguage| this command doesn't switch
 % \emph{everything}, it only switches the hyphenation rules and the
 % extra definitions for the language specified. It does this within
@@ -7007,10 +7250,8 @@
    \expandafter\bbl at tempa\expandafter{\BabelText{#1}}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\foreign at language}
 %
-% \begin{macro}{\foreign at language}
-%
 % This macro does the work for |\foreignlanguage| and the
 % \Lenv{otherlanguage*} environment. First we need to store the name
 % of the language and check that it is a known language. Then it
@@ -7033,8 +7274,6 @@
     \expandafter\bbl at switch\expandafter{\languagename}}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % The following macro executes conditionally some code based on the
 % selector being used.
 %
@@ -7048,7 +7287,7 @@
   \fi}
 %    \end{macrocode}
 %
-% \begin{macro}{\bbl at patterns}
+% \macro{\bbl at patterns}
 %
 % This macro selects the hyphenation patterns by changing the
 % \cs{language} register.  If special hyphenation patterns
@@ -7095,12 +7334,10 @@
     \endgroup}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \environment{hyphenrules}
 %
-% \begin{environment}{hyphenrules}
-%
-% The environment \Lenv{hyphenrules} can be used to select
-% \emph{just} the hyphenation rules. This environment does
+% It can be used to select
+% \emph{just} the hyphenation rules. It does
 % \emph{not} change |\languagename| and when the hyphenation rules
 % specified were not loaded it has no effect. Note however,
 % |\lccode|'s and font encodings are not set at all, so in most
@@ -7124,9 +7361,7 @@
 \let\endhyphenrules\@empty
 %    \end{macrocode}
 %
-%  \end{environment}
-%
-% \begin{macro}{\providehyphenmins}
+% \macro{\providehyphenmins}
 % The macro |\providehyphenmins| should be used in the language
 % definition files to provide a \emph{default} setting for the
 % hyphenation parameters |\lefthyphenmin| and |\righthyphenmin|. If
@@ -7140,9 +7375,7 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\set at hyphenmins}
+% \macro{\set at hyphenmins}
 % This macro sets the values of |\lefthyphenmin| and |\righthyphenmin|.
 % It expects two values as its argument.
 %
@@ -7152,9 +7385,7 @@
   \righthyphenmin#2\relax}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\ProvidesLanguage}
+% \macro{\ProvidesLanguage}
 % The identification code for each file is something that was
 % introduced in \LaTeXe. When the command |\ProvidesFile| does not
 % exist, a dummy definition is provided temporarily. For use in the
@@ -7183,9 +7414,7 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\originalTeX}
+% \macro{\originalTeX}
 % The macro|\originalTeX| should be known to \TeX\ at this moment. As
 % it has to be expandable we |\let| it to |\@empty| instead of
 % |\relax|.
@@ -7202,8 +7431,6 @@
 \ifx\babel at beginsave\@undefined\let\babel at beginsave\relax\fi
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % A few macro names are reserved for future releases of \babel, which
 % will use the concept of `locale':
 %
@@ -7219,8 +7446,8 @@
 %
 % \subsection{Errors}
 %
-% \begin{macro}{\@nolanerr}
-% \begin{macro}{\@nopatterns}
+% \macro{\@nolanerr}
+% \macro{\@nopatterns}
 %
 % The \babel\ package will signal an error when a documents tries
 % to select a language that hasn't been defined earlier. When a
@@ -7230,7 +7457,7 @@
 % In most formats that will be (US)english, but it might also be
 % empty.
 %
-% \begin{macro}{\@noopterr}
+% \macro{\@noopterr}
 % When the package was loaded without options not everything will
 % work as expected. An error message is issued in that case.
 %
@@ -7310,7 +7537,7 @@
 \fi
 %    \end{macrocode}
 %
-% \begin{macro}{\addto}
+% \macro{\addto}
 % It takes two arguments, a \meta{control sequence} and \TeX-code to
 % be added to the \meta{control sequence}.
 %
@@ -7334,8 +7561,6 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % The macro |\initiate at active@char| below takes all the necessary
 % actions to make its argument a shorthand character. The real work
 % is performed once for each character. But first we define a little
@@ -7348,7 +7573,7 @@
     \lowercase{\endgroup#1~}}
 %    \end{macrocode}
 %
-% \begin{macro}{\bbl at redefine}
+% \macro{\bbl at redefine}
 %
 % To redefine a command, we save the old meaning of the macro. Then
 % we redefine it to call the original macro with the `sanitized'
@@ -7365,9 +7590,7 @@
 \@onlypreamble\bbl at redefine
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at redefine@long}
+% \macro{\bbl at redefine@long}
 % This version of |\babel at redefine| can be used to redefine |\long|
 % commands such as |\ifthenelse|.
 %
@@ -7379,9 +7602,7 @@
 \@onlypreamble\bbl at redefine@long
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at redefinerobust}
+% \macro{\bbl at redefinerobust}
 % For commands that are redefined, but which \textit{might} be
 % robust we need a slightly more intelligent macro. A robust
 % command |foo| is defined to expand to |\protect|\verb*|\foo |. So
@@ -7400,8 +7621,6 @@
 \@onlypreamble\bbl at redefinerobust
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Hooks}
 %
 % Admittedly, the current implementation is a somewhat simplistic and
@@ -7454,7 +7673,7 @@
 \fi
 %    \end{macrocode}
 %
-% \begin{macro}{\babelensure}
+% \macro{\babelensure}
 %
 % The user command just parses the optional argument and creates a
 % new macro named |\bbl at e@<language>|. We register a hook at the
@@ -7540,11 +7759,9 @@
   \alsoname\proofname\glossaryname}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Setting up language files}
 %
-% \begin{macro}{\LdfInit}
+% \macro{\LdfInit}
 %
 % |\LdfInit| macro takes two arguments. The first
 % argument is the name of the language that will be defined in the
@@ -7609,9 +7826,7 @@
   \bbl at ldfinit}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\ldf at quit}
+% \macro{\ldf at quit}
 % This macro interrupts the processing of a language definition file.
 %
 %    \begin{macrocode}
@@ -7622,9 +7837,7 @@
   \endinput}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\ldf at finish}
+% \macro{\ldf at finish}
 % This macro takes one argument. It is the name of the language that
 % was defined in the language definition file.
 %
@@ -7647,8 +7860,6 @@
   \catcode`\==\eqcatcode \let\eqcatcode\relax}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % After the preamble of the document the commands |\LdfInit|,
 % |\ldf at quit| and |\ldf at finish| are no longer needed. Therefore they
 % are turned into warning messages in \LaTeX.
@@ -7659,8 +7870,8 @@
 \@onlypreamble\ldf at finish
 %    \end{macrocode}
 %
-% \begin{macro}{\main at language}
-% \begin{macro}{\bbl at main@language}
+% \macro{\main at language}
+% \macro{\bbl at main@language}
 % This command should be used in the various language definition files.
 % It stores its argument in |\bbl at main@language|; to be used to switch
 % to the correct language at the beginning of the document.
@@ -7730,9 +7941,6 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % A bit of optimization. Select in heads/foots the language only if
 % necessary.
 %
@@ -7747,7 +7955,7 @@
 %
 % \subsection{Shorthands}
 %
-% \begin{macro}{\bbl at add@special}
+% \macro{\bbl at add@special}
 % The macro |\bbl at add@special| is used to add a new character (or
 % single character control sequence) to the macro |\dospecials| (and
 % |\@sanitize| if \LaTeX\ is used). It is used only at one place,
@@ -7777,32 +7985,7 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at remove@special}
-%
-% The companion of the former macro is |\bbl at remove@special|. It
-% removes a character from the set macros |\dospecials| and
-% |\@sanitize|, but it is not used at all in the \babel{} core.
-%
-%    \begin{macrocode}
-\def\bbl at remove@special#1{%
-  \begingroup
-    \def\x##1##2{\ifnum`#1=`##2\noexpand\@empty
-                 \else\noexpand##1\noexpand##2\fi}%
-    \def\do{\x\do}%
-    \def\@makeother{\x\@makeother}%
-  \edef\x{\endgroup
-    \def\noexpand\dospecials{\dospecials}%
-    \expandafter\ifx\csname @sanitize\endcsname\relax\else
-      \def\noexpand\@sanitize{\@sanitize}%
-    \fi}%
-  \x}
-%    \end{macrocode}
-%
-% \end{macro}
-%
-% \begin{macro}{\initiate at active@char}
+% \macro{\initiate at active@char}
 % A language definition file can call this macro to make a character
 % active. This macro takes one argument, the character that is to be
 % made active. When the character was already active this macro does
@@ -8049,9 +8232,7 @@
    \AtEndOfPackage{\let\bbl at restoreactive\@gobble}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at sh@select}
+% \macro{\bbl at sh@select}
 % This command helps the shorthand supporting macros to select how to
 % proceed. Note that this macro needs to be expandable as do all the
 % shorthand macros in order for them to work in expansion-only
@@ -8071,10 +8252,8 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\active at prefix}
-% The command |\active at prefix| which is used in the expansion of active
+% \macro{\active at prefix}
+% Used in the expansion of active
 % characters has a function similar to |\OT1-cmd| in that it
 % |\protect|s the active character whenever |\protect| is \emph{not}
 % |\@typeset at protect|. The |\@gobble| is needed to remove a token such
@@ -8113,9 +8292,8 @@
 \endgroup
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{if at safe@actives}
 %
-% \begin{macro}{\if at safe@actives}
 % In some circumstances it is necessary to be able to reset the
 % shorthand to its ‘normal’ value (usually the character with catcode
 % ‘other’) on the fly. For this purpose the switch |@safe at actives| is
@@ -8133,9 +8311,7 @@
 \@safe at activesfalse
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at restore@actives}
+% \macro{\bbl at restore@actives}
 % When the output routine kicks in while the active characters were
 % made ``safe'' this must be undone in the headers to prevent
 % unexpected typeset results. For this situation we define a command to
@@ -8145,11 +8321,9 @@
 \def\bbl at restore@actives{\if at safe@actives\@safe at activesfalse\fi}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\bbl at activate}
+% \macro{\bbl at deactivate}
 %
-% \begin{macro}{\bbl at activate}
-% \begin{macro}{\bbl at deactivate}
-%
 % Both macros take one argument, like |\initiate at active@char|. The
 % macro is used to change the definition of an active character to
 % expand to |\active at char<char>| in the case of |\bbl at activate|,
@@ -8167,12 +8341,9 @@
     \csname bbl at normal@\string#1\endcsname}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \macro{\bbl at firstcs}
+% \macro{\bbl at scndcs}
 %
-% \begin{macro}{\bbl at firstcs}
-% \begin{macro}{\bbl at scndcs}
-%
 % These macros are used only as a trick when declaring shorthands.
 %
 %    \begin{macrocode}
@@ -8180,11 +8351,8 @@
 \def\bbl at scndcs#1#2{\csname#2\endcsname}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\declare at shorthand}
-% The command |\declare at shorthand| is used to declare a shorthand
+% \macro{\declare at shorthand}
+% Used to declare a shorthand
 % on a certain level. It takes three arguments:
 % \begin{enumerate}
 % \item a name for the collection of shorthands, i.e. `system', or
@@ -8201,7 +8369,7 @@
 % string in math mode, like a minus sign instead of an hyphen
 % (currently \textsf{hyperref} doesn't discriminate the mode). This
 % macro may be used in |ldf| files.
-
+%
 %    \begin{macrocode}
 \def\babel at texpdf#1#2#3#4{%
   \ifx\texorpdfstring\@undefined
@@ -8239,9 +8407,7 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\textormath}
+% \macro{\textormath}
 % Some of the shorthands that will be declared by the language
 % definition files have to be usable in both text and mathmode. To
 % achieve this the helper macro |\textormath| is provided.
@@ -8255,11 +8421,9 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\user at group}
-% \begin{macro}{\language at group}
-% \begin{macro}{\system at group}
+% \macro{\user at group}
+% \macro{\language at group}
+% \macro{\system at group}
 % The current concept of `shorthands' supports three levels or groups
 % of shorthands. For each level the name of the level or group is
 % stored in a macro. The default is to have a user group; use language
@@ -8271,12 +8435,8 @@
 \def\system at group{system}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-% \end{macro}
+% \macro{\useshorthands}
 %
-% \begin{macro}{\useshorthands}
-%
 % This is the user level macro. It initializes and activates the
 % character for use as a shorthand character (ie, it's active in the
 % preamble). Languages can deactivate shorthands, so a starred version
@@ -8299,10 +8459,8 @@
     {\bbl at error{shorthand-is-off}{}{#2}{}}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\defineshorthand}
 %
-% \begin{macro}{\defineshorthand}
-%
 % Currently we only support two groups of user level shorthands,
 % named internally |user| and |user@<language>| (language-dependent
 % user shorthands). By default, only the first one is taken into
@@ -8334,10 +8492,8 @@
     \declare at shorthand{\bbl at tempb}{#2}{#3}}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\languageshorthands}
 %
-% \begin{macro}{\languageshorthands}
-%
 % A user level command to change the language from which shorthands are
 % used. Unfortunately, \babel{} currently does not keep track of
 % defined groups, and therefore there is no way to catch a possible
@@ -8347,10 +8503,8 @@
 \def\languageshorthands#1{\def\language at group{#1}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\aliasshorthand}
 %
-% \begin{macro}{\aliasshorthand}
-%
 % \textit{Deprecated}. First the new shorthand needs to be
 % initialized. Then, we define the new shorthand in terms of the
 % original one, but note with |\aliasshorthands{"}{/}| is
@@ -8373,19 +8527,15 @@
     {\bbl at error{shorthand-is-off}{}{#2}{}}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\@notshorthand}
 %
-% \begin{macro}{\@notshorthand}
-%
 %    \begin{macrocode}
 \def\@notshorthand#1{\bbl at error{not-a-shorthand}{#1}{}{}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\shorthandon}
+% \macro{\shorthandoff}
 %
-% \begin{macro}{\shorthandon}
-% \begin{macro}{\shorthandoff}
-%
 % The first level definition of these macros just passes the
 % argument on to |\bbl at switch@sh|, adding |\@nil| at the end to
 % denote the end of the list of characters.
@@ -8397,7 +8547,7 @@
 \def\bbl at shorthandoff#1#2{\bbl at switch@sh#1#2\@nnil}
 %    \end{macrocode}
 %
-% \begin{macro}{\bbl at switch@sh}
+% \macro{\bbl at switch@sh}
 %
 % The macro |\bbl at switch@sh| takes the list of characters apart one
 % by one and subsequently switches the category code of the
@@ -8443,10 +8593,6 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
 % Note the value is that at the expansion time; eg, in the preamble
 % shorthands are usually deactivated.
 %
@@ -8486,8 +8632,8 @@
 \newcommand\ifbabelshorthand[3]{\bbl at ifunset{bbl at active@\string#1}{#3}{#2}}
 %    \end{macrocode}
 %
-% \begin{macro}{\bbl at prim@s}
-% \begin{macro}{\bbl at pr@m at s}
+% \macro{\bbl at prim@s}
+% \macro{\bbl at pr@m at s}
 %
 % One of the internal macros that are involved in substituting |\prime|
 % for each right quote in mathmode is |\prim at s|. This checks if the
@@ -8517,9 +8663,6 @@
 \endgroup
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % Usually the |~| is active and expands to \verb*=\penalty\@M\ =.
 % When it is written to the \file{.aux} file it is written
 % expanded. To prevent that and to be able to use the character |~|
@@ -8536,8 +8679,8 @@
 \bbl at activate{~}
 %    \end{macrocode}
 %
-% \begin{macro}{\OT1dqpos}
-% \begin{macro}{\T1dqpos}
+% \macro{\OT1dqpos}
+% \macro{\T1dqpos}
 % The position of the double quote character is different for the OT1
 % and T1 encodings. It will later be selected using the |\f at encoding|
 % macro. Therefore we define two macros here to store the position of
@@ -8557,15 +8700,12 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % \subsection{Language attributes}
 %
 % Language attributes provide a means to give the user control over
 % which features of the language definition files he wants to enable.
 %
-% \begin{macro}{\languageattribute}
+% \macro{\languageattribute}
 %
 % The macro |\languageattribute| checks whether its arguments are valid
 % and then activates the selected language attribute. First check
@@ -8621,9 +8761,7 @@
   \bbl at error{unknown-attribute}{#1}{#2}{}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at declare@ttribute}
+% \macro{\bbl at declare@ttribute}
 % This command adds the new language/attribute combination to the list
 % of known attributes.
 %
@@ -8643,9 +8781,8 @@
   \expandafter\def\csname#1 at attr@#2\endcsname{#3}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\bbl at ifattributeset}
 %
-% \begin{macro}{\bbl at ifattributeset}
 % This internal macro has 4 arguments. It can be used to interpret
 % \TeX\ code based on whether a certain attribute was set. This command
 % should appear inside the argument to |\AtBeginDocument| because the
@@ -8670,9 +8807,7 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at ifknown@ttrib}
+% \macro{\bbl at ifknown@ttrib}
 % An internal macro to check whether a given language/attribute is
 % known. The macro takes 4 arguments, the language/attribute, the
 % attribute list, the \TeX-code to be executed when the attribute is
@@ -8693,9 +8828,7 @@
   \bbl at tempa}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at clear@ttribs}
+% \macro{\bbl at clear@ttribs}
 % This macro removes all the attribute code from \LaTeX's memory at
 % |\begin{document}| time (if any is present).
 %
@@ -8711,8 +8844,6 @@
 \AtBeginDocument{\bbl at clear@ttribs}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Support for saving macro definitions}
 %
 % To save the meaning of control sequences using |\babel at save|, we use
@@ -8725,8 +8856,8 @@
 % |\selectlanguage| and |\originalTeX|). Note undefined macros are not
 % undefined any more when saved -- they are |\relax|'ed.
 %
-% \begin{macro}{\babel at savecnt}
-% \begin{macro}{\babel at beginsave}
+% \macro{\babel at savecnt}
+% \macro{\babel at beginsave}
 % The initialization of a new save cycle: reset the counter to zero.
 %
 %    \begin{macrocode}
@@ -8741,12 +8872,9 @@
 \babel at beginsave
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \macro{\babel at save}
+% \macro{\babel at savevariable}
 %
-% \begin{macro}{\babel at save}
-% \begin{macro}{\babel at savevariable}
-%
 % The macro |\babel at save|\meta{csname} saves the current meaning of the
 % control sequence \meta{csname} to
 % |\originalTeX|\footnote{\cs{originalTeX} has to be expandable,
@@ -8777,11 +8905,8 @@
   \bbl at exp{\def\\\originalTeX{\the\toks@\the#1\relax}}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\bbl at frenchspacing}
-% \begin{macro}{\bbl at nonfrenchspacing}
+% \macro{\bbl at frenchspacing}
+% \macro{\bbl at nonfrenchspacing}
 % Some languages need to have |\frenchspacing| in effect. Others
 % don't want that. The command |\bbl at frenchspacing| switches it on
 % when it isn't already in effect and |\bbl at nonfrenchspacing|
@@ -8829,12 +8954,9 @@
   \fi\fi\fi}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % \subsection{Short tags}
 %
-% \begin{macro}{\babeltags}
+% \macro{\babeltags}
 % This macro is straightforward. After zapping spaces, we
 % loop over the list and define the macros |\text<tag>| and
 % |\<tag>|. Definitions are first expanded so that they don't
@@ -8858,15 +8980,13 @@
     \expandafter\bbl at tempb\bbl at tempa\@@}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Hyphens}
 %
-% \begin{macro}{\babelhyphenation}
+% \macro{\babelhyphenation}
 %
 % This macro saves hyphenation exceptions. Two macros are used to
 % store them: |\bbl at hyphenation@| for the global ones and
-% |\bbl at hyphenation<language>| for language ones. See |\bbl at patterns|
+% |\bbl at hyphenation@<language>| for language ones. See |\bbl at patterns|
 % above for further details. We make sure there is a space between
 % words when multiple commands are used.
 %
@@ -8899,12 +9019,10 @@
     \fi}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\babelhyphenmins}
 %
-% \begin{macro}{\babelhyphenmins}
+% Only \LaTeX{} (basically because it’s defined with a \LaTeX{} tool).
 %
-% Only \LaTeX (basically because it’s defined with a \LaTeX{} tool).
-%
 %    \begin{macrocode}
 \ifx\NewDocumentCommand\@undefined\else
   \NewDocumentCommand\babelhyphenmins{sommo}{%
@@ -8925,10 +9043,8 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\bbl at allowhyphens}
 %
-% \begin{macro}{\bbl at allowhyphens}
-%
 % This macro makes hyphenation possible. Basically its definition
 % is nothing more than |\nobreak| |\hskip| \texttt{0pt plus
 % 0pt}\footnote{\TeX\ begins and ends a word for hyphenation at a
@@ -8940,10 +9056,8 @@
 \def\allowhyphens{\ifx\cf at encoding\bbl at t@one\else\bbl at allowhyphens\fi}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\babelhyphen}
 %
-% \begin{macro}{\babelhyphen}
-%
 % Macros to insert common hyphens. Note the space before |@| in
 % |\babelhyphen|. Instead of protecting it with
 % |\DeclareRobustCommand|, which could insert a |\relax|, we use
@@ -9014,9 +9128,7 @@
 \def\bbl at hy@@empty{\discretionary{}{}{}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\bbl at disc}
+% \macro{\bbl at disc}
 % For some languages the macro |\bbl at disc| is used to ease the
 % insertion of discretionaries for letters that behave `abnormally' at
 % a breakpoint.
@@ -9025,8 +9137,6 @@
 \def\bbl at disc#1#2{\nobreak\discretionary{#2-}{}{#1}\bbl at allowhyphens}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Multiencoding strings}
 %
 % The aim following commands is to provide a common interface for
@@ -9386,7 +9496,9 @@
   \fi}
 %    \end{macrocode}
 %
-% This sections ends with a general tool for resetting the caption
+% \subsection{Tailor captions}
+%
+% A general tool for resetting the caption
 % names with a unique interface. With the old way, which mixes the
 % switcher and the string, we convert it to the new one, which
 % separates these two steps.
@@ -9448,10 +9560,14 @@
   \fi}
 %    \end{macrocode}
 %
-% \subsection{Macros common to a number of languages}
+% \subsection{Making glyphs available}
 %
-% \begin{macro}{\set at low@box}
+% This section makes a number of glyphs available that either do not
+% exist in the \texttt{OT1} encoding and have to be `faked', or
+% that are not accessible through \file{T1enc.def}.
 %
+% \macro{\set at low@box}
+%
 % The following macro is used to lower quotes to the same level as
 % the comma.  It prepares its argument in box register~0.
 %
@@ -9462,9 +9578,7 @@
     \setbox\z@\hbox{\lower\dimen\z@ \box\z@}\ht\z@\ht\tw@ \dp\z@\dp\tw@}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\save at sf@q}
+% \macro{\save at sf@q}
 % The macro |\save at sf@q| is used to save and reset the current space
 % factor.
 %
@@ -9475,17 +9589,9 @@
   \endgroup}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \subsection{Making glyphs available}
-%
-% This section makes a number of glyphs available that either do not
-% exist in the \texttt{OT1} encoding and have to be `faked', or
-% that are not accessible through \file{T1enc.def}.
-%
 % \subsubsection{Quotation marks}
 %
-% \begin{macro}{\quotedblbase}
+% \macro{\quotedblbase}
 % In the \texttt{T1} encoding the opening double quote at the
 % baseline is available as a separate character, accessible via
 % |\quotedblbase|. In the \texttt{OT1} encoding it is not
@@ -9506,9 +9612,7 @@
   \UseTextSymbol{OT1}{\quotedblbase}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\quotesinglbase}
+% \macro{\quotesinglbase}
 % We also need the single quote character at the baseline.
 %
 %    \begin{macrocode}
@@ -9525,10 +9629,8 @@
   \UseTextSymbol{OT1}{\quotesinglbase}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\guillemetleft}
-% \begin{macro}{\guillemetright}
+% \macro{\guillemetleft}
+% \macro{\guillemetright}
 % The guillemet characters are not available in \texttt{OT1}
 % encoding. They are faked. (Wrong names with o preserved for
 % compatibility.)
@@ -9578,11 +9680,8 @@
   \UseTextSymbol{OT1}{\guillemotright}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\guilsinglleft}
-% \begin{macro}{\guilsinglright}
+% \macro{\guilsinglleft}
+% \macro{\guilsinglright}
 % The single guillemets are not available in \texttt{OT1} encoding.
 % They are faked.
 %
@@ -9613,13 +9712,10 @@
   \UseTextSymbol{OT1}{\guilsinglright}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % \subsubsection{Letters}
 %
-% \begin{macro}{\ij}
-% \begin{macro}{\IJ}
+% \macro{\ij}
+% \macro{\IJ}
 % The dutch language uses the letter `ij'. It is available in
 % \texttt{T1} encoded fonts, but not in the \texttt{OT1} encoded
 % fonts. Therefore we fake it for the \texttt{OT1} encoding.
@@ -9643,11 +9739,8 @@
   \UseTextSymbol{OT1}{\IJ}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\dj}
-% \begin{macro}{\DJ}
+% \macro{\dj}
+% \macro{\DJ}
 % The croatian language needs the letters |\dj| and |\DJ|; they are
 % available in the \texttt{T1} encoding, but not in the
 % \texttt{OT1} encoding by default.
@@ -9688,10 +9781,7 @@
   \UseTextSymbol{OT1}{\DJ}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\SS}
+% \macro{\SS}
 % For the \texttt{T1} encoding |\SS| is defined and selects a specific
 % glyph from the font, but for other encodings it is not available.
 % Therefore we make it available here.
@@ -9701,8 +9791,6 @@
 \ProvideTextCommandDefault{\SS}{\UseTextSymbol{OT1}{\SS}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsubsection{Shorthands for quotation marks}
 %
 % Shorthands are provided for a number of different quotation marks,
@@ -9711,8 +9799,8 @@
 % not required because their definitions are based on
 % encoding-dependent macros.
 %
-% \begin{macro}{\glq}
-% \begin{macro}{\grq}
+% \macro{\glq}
+% \macro{\grq}
 %
 % The `german' single quotes.
 %
@@ -9736,12 +9824,9 @@
 \ProvideTextCommandDefault{\grq}{\UseTextSymbol{OT1}\grq}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \macro{\glqq}
+% \macro{\grqq}
 %
-% \begin{macro}{\glqq}
-% \begin{macro}{\grqq}
-%
 % The `german' double quotes.
 %
 %    \begin{macrocode}
@@ -9764,12 +9849,9 @@
 \ProvideTextCommandDefault{\grqq}{\UseTextSymbol{OT1}\grqq}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \macro{\flq}
+% \macro{\frq}
 %
-% \begin{macro}{\flq}
-% \begin{macro}{\frq}
-%
 % The `french' single guillemets.
 %
 %    \begin{macrocode}
@@ -9779,12 +9861,9 @@
   \textormath{\guilsinglright}{\mbox{\guilsinglright}}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \macro{\flqq}
+% \macro{\frqq}
 %
-% \begin{macro}{\flqq}
-% \begin{macro}{\frqq}
-%
 % The `french' double guillemets.
 %
 %    \begin{macrocode}
@@ -9794,9 +9873,6 @@
   \textormath{\guillemetright}{\mbox{\guillemetright}}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % \subsubsection{Umlauts and tremas}
 %
 % The command |\"| needs to have a different effect for different
@@ -9806,9 +9882,9 @@
 % normal position. For Dutch the same glyph is always placed in the
 % lower position.
 %
-% \begin{macro}{\umlauthigh}
+% \macro{\umlauthigh}
 %
-% \begin{macro}{\umlautlow}
+% \macro{\umlautlow}
 % To be able to provide both positions of |\"| we provide two commands
 % to switch the positioning, the default will be |\umlauthigh| (the
 % normal positioning).
@@ -9826,11 +9902,8 @@
 \umlauthigh
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
-% \begin{macro}{\lower at umlaut}
-% The command |\lower at umlaut| is used to position the |\"| closer to
+% \macro{\lower at umlaut}
+% Used to position the |\"| closer to
 % the letter. We want the umlaut character lowered, nearer to the
 % letter. To do this we need an extra \meta{dimen} register.
 %
@@ -9867,8 +9940,6 @@
   \egroup}
 %    \end{macrocode}
 %
-% \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
@@ -9978,6 +10049,7 @@
   \let\babelpatterns\babelprehyphenation
   \let\babelcharproperty\babelprehyphenation
 \fi
+%</package|core>
 %    \end{macrocode}
 %
 % \subsection{Creating and modifying languages}
@@ -9990,7 +10062,6 @@
 % loaded |ldf| files.
 %
 %    \begin{macrocode}
-%</package|core>
 %<*package>
 \bbl at trace{Creating languages and reading ini files}
 \let\bbl at extend@ini\@gobble
@@ -10534,7 +10605,7 @@
 %    \end{macrocode}
 %
 % The reader of |babel-...tex| files. We reset temporarily some
-% catcodes.
+% catcodes (and make sure no space is accidentally inserted).
 %
 %    \begin{macrocode}
 \def\bbl at input@texini#1{%
@@ -10582,6 +10653,8 @@
   \fi}
 %    \end{macrocode}
 %
+% \subsection{Main loop in ‘provide’}
+%
 % Now, the ‘main loop’, which \textbf{**must be executed inside a
 % group**}. At this point, |\bbl at inidata| may contain data declared in
 % |\babelprovide|, with ‘slashed’ keys. There are 3 steps: first read
@@ -10721,7 +10794,6 @@
 % file is read, just skip the corresponding key and reset the macro (in
 % |\bbl at inistore| above).
 %
-%
 %    \begin{macrocode}
 \def\bbl at renewinikey#1/#2\@@#3{%
   \edef\bbl at tempa{\zap at space #1 \@empty}%   section
@@ -10830,6 +10902,8 @@
   \fi}
 %    \end{macrocode}
 %
+% \subsection{Processing keys in \texttt{ini}}
+%
 % A shared handler for key=val lines to be stored in
 % |\bbl@@kv@<section>.<key>|.
 %
@@ -11258,6 +11332,8 @@
 \endgroup
 %    \end{macrocode}
 %
+% \subsection{Handle language system}
+%
 % Language and Script values to be used when defining a font or
 % setting the direction are set with the following macros.
 %
@@ -11327,6 +11403,8 @@
   {\bbl at input@texini{#1}}}
 %    \end{macrocode}
 %
+% \subsection{Numerals}
+%
 % 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. Non-digits characters are kept. The
@@ -11420,6 +11498,58 @@
   \bbl at error{alphabetic-too-large}{#1}{}{}}
 %    \end{macrocode}
 %
+% \subsection{Casing}
+%
+%    \begin{macrocode}
+\newcommand\BabelUppercaseMapping[3]{%
+  \DeclareUppercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
+\newcommand\BabelTitlecaseMapping[3]{%
+  \DeclareTitlecaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
+\newcommand\BabelLowercaseMapping[3]{%
+  \DeclareLowercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
+%    \end{macrocode}
+%
+% The parser for |casing| and |casing.|\meta{variant}. 
+%
+%    \begin{macrocode}
+\def\bbl at casemapping#1#2#3{% 1:variant
+  \def\bbl at tempa##1 ##2{% Loop
+    \bbl at casemapping@i{##1}%
+    \ifx\@empty##2\else\bbl at afterfi\bbl at tempa##2\fi}%
+  \edef\bbl at templ{\@nameuse{bbl at casing@#2}#1}%  Language code
+  \def\bbl at tempe{0}%   Mode (upper/lower...)
+  \def\bbl at tempc{#3 }% Casing list
+  \expandafter\bbl at tempa\bbl at tempc\@empty}
+\def\bbl at casemapping@i#1{%
+  \def\bbl at tempb{#1}%
+  \ifcase\bbl at engine % Handle utf8 in pdftex, by surrounding chars with {}
+    \@nameuse{regex_replace_all:nnN}%
+      {[\x{c0}-\x{ff}][\x{80}-\x{bf}]*}{{\0}}\bbl at tempb
+  \else
+    \@nameuse{regex_replace_all:nnN}{.}{{\0}}\bbl at tempb % TODO. needed?
+  \fi
+  \expandafter\bbl at casemapping@ii\bbl at tempb\@@}
+\def\bbl at casemapping@ii#1#2#3\@@{%
+  \in@{#1#3}{<>}% ie, if <u>, <l>, <t>
+  \ifin@
+    \edef\bbl at tempe{%
+      \if#2u1 \else\if#2l2 \else\if#2t3 \fi\fi\fi}%
+  \else
+    \ifcase\bbl at tempe\relax
+      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#2}}{#1}%
+    \or
+      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+    \or
+      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+    \or
+      \DeclareTitlecaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+    \fi
+  \fi}
+%    \end{macrocode}
+%
+% \subsection{Getting info}
+%
 % The information in the identification section can be useful, so the
 % following macro just exposes it with a user command.
 %
@@ -11466,7 +11596,8 @@
   \def\bbl at utftocode#1{\expandafter`\string#1}
 \fi
 % Still somewhat hackish. WIP. Note |\str_if_eq:nnTF| is fully
-% expandable (|\bbl at ifsamestring| isn’t).
+% expandable (|\bbl at ifsamestring| isn’t). The argument is the prefix to
+% tag.bcp47. Can be prece
 \providecommand\BCPdata{}
 \ifx\renewcommand\@undefined\else % For plain. TODO. It’s a quick fix
   \renewcommand\BCPdata[1]{\bbl at bcpdata@i#1\@empty}
@@ -11481,53 +11612,8 @@
         {\bbl at cs{\csname bbl at info@#1.tag.bcp47\endcsname @#2}}}}
 \fi
 \@namedef{bbl at info@casing.tag.bcp47}{casing}
-\newcommand\BabelUppercaseMapping[3]{%
-  \DeclareUppercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
-\newcommand\BabelTitlecaseMapping[3]{%
-  \DeclareTitlecaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
-\newcommand\BabelLowercaseMapping[3]{%
-  \DeclareLowercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
 %    \end{macrocode}
 %
-% The parser for |casing| and |casing.|\meta{variant}. 
-%
-%    \begin{macrocode}
-\def\bbl at casemapping#1#2#3{% 1:variant
-  \def\bbl at tempa##1 ##2{% Loop
-    \bbl at casemapping@i{##1}%
-    \ifx\@empty##2\else\bbl at afterfi\bbl at tempa##2\fi}%
-  \edef\bbl at templ{\@nameuse{bbl at casing@#2}#1}%  Language code
-  \def\bbl at tempe{0}%   Mode (upper/lower...)
-  \def\bbl at tempc{#3 }% Casing list
-  \expandafter\bbl at tempa\bbl at tempc\@empty}
-\def\bbl at casemapping@i#1{%
-  \def\bbl at tempb{#1}%
-  \ifcase\bbl at engine % Handle utf8 in pdftex, by surrounding chars with {}
-    \@nameuse{regex_replace_all:nnN}%
-      {[\x{c0}-\x{ff}][\x{80}-\x{bf}]*}{{\0}}\bbl at tempb
-  \else
-    \@nameuse{regex_replace_all:nnN}{.}{{\0}}\bbl at tempb % TODO. needed?
-  \fi
-  \expandafter\bbl at casemapping@ii\bbl at tempb\@@}
-\def\bbl at casemapping@ii#1#2#3\@@{%
-  \in@{#1#3}{<>}% ie, if <u>, <l>, <t>
-  \ifin@
-    \edef\bbl at tempe{%
-      \if#2u1 \else\if#2l2 \else\if#2t3 \fi\fi\fi}%
-  \else
-    \ifcase\bbl at tempe\relax
-      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#2}}{#1}%
-    \or
-      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-    \or
-      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-    \or
-      \DeclareTitlecaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-    \fi
-  \fi}
-%    \end{macrocode}
-%
 % With version 3.75 |\BabelEnsureInfo| is executed always, but there is
 % an option to disable it.
 %
@@ -11746,7 +11832,7 @@
 %<</More package options>>
 %    \end{macrocode}
 %
-% \begin{macro}{\@newl at bel}
+% \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
@@ -11766,10 +11852,8 @@
     \global\@namedef{#1@#2}{#3}}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\@testdef}
 %
-% \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.
@@ -11809,11 +11893,9 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\ref}
+% \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
@@ -11846,11 +11928,8 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \macro{\@citex}
 %
-% \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),
@@ -11904,10 +11983,8 @@
       }{}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\nocite}
 %
-% \begin{macro}{\nocite}
-%
 % The macro |\nocite| which is used to instruct BiB\TeX\ to
 % extract uncited references from the database.
 %
@@ -11916,10 +11993,8 @@
     \@safe at activestrue\org at nocite{#1}\@safe at activesfalse}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\bibcite}
 %
-% \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
@@ -11939,10 +12014,8 @@
     \bibcite}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\bbl at bibcite}
 %
-% \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.
 %
@@ -11951,10 +12024,8 @@
     \org at bibcite{#1}{\@safe at activesfalse#2}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\bbl at cite@choice}
 %
-% \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.
@@ -11975,10 +12046,8 @@
   \AtBeginDocument{\bbl at cite@choice}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\@bibitem}
 %
-% \begin{macro}{\@bibitem}
-%
 % One of the two internal \LaTeX\ macros called by |\bibitem|
 % that write the citation label on the |.aux| file.
 %
@@ -11993,11 +12062,9 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Marks}
 %
-% \begin{macro}{\markright}
+% \macro{\markright}
 % Because the output routine is asynchronous, we must pass the
 % current language attribute to the head lines. To achieve this we
 % need to adapt the definition of |\markright| and |\markboth|
@@ -12033,10 +12100,8 @@
               {\\\protect\\\bbl at restore@actives\the\toks@}}}}}%
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\markboth}
-% \begin{macro}{\@mkboth}
+% \macro{\markboth}
+% \macro{\@mkboth}
 % The definition of |\markboth| is equivalent to that of |\markright|,
 % except that we need two token registers. The documentclasses
 % \cls{report} and \cls{book} define and set the headings for the page.
@@ -12069,14 +12134,11 @@
      \fi}  % end ifbbl at single, end \IfBabelLayout
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
+% \subsection{Other packages}
 %
-% \subsection{Preventing clashes with other packages}
-%
 % \subsubsection{\pkg{ifthen}}
 %
-% \begin{macro}{\ifthenelse}
+% \macro{\ifthenelse}
 %
 % Sometimes a document writer wants to create a special effect
 % depending on the page a certain fragment of text appears on. This
@@ -12129,13 +12191,11 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsubsection{\pkg{varioref}}
 %
-% \begin{macro}{\@@vpageref}
-% \begin{macro}{\vrefpagenum}
-% \begin{macro}{\Ref}
+% \macro{\@@vpageref}
+% \macro{\vrefpagenum}
+% \macro{\Ref}
 %
 % When the package \pkg{varioref} is in use we need to modify its
 % internal command |\@@vpageref| in order to prevent problems when
@@ -12172,13 +12232,9 @@
 \fi
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
 % \subsubsection{\pkg{hhline}}
 %
-% \begin{macro}{\hhline}
+% \macro{\hhline}
 %
 % Delaying the activation of the shorthand characters has introduced
 % a problem with the \pkg{hhline} package. The reason is that it
@@ -12200,15 +12256,12 @@
       {}}}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\substitutefontfamily}
 %
-% \begin{macro}{\substitutefontfamily}
-%
-% \textit{Deprecated.} Use the tools provided by \LaTeX\ 
-% (|\DeclareFontFamilySubstitution|). The command
-% |\substitutefontfamily| creates an \file{.fd} file on the fly. The
+% \textit{Deprecated.} It creates an \file{.fd} file on the fly. The
 % first argument is an encoding mnemonic, the second and third
-% arguments are font family names.
+% arguments are font family names. Use the tools provided by \LaTeX\ 
+% (|\DeclareFontFamilySubstitution|). 
 %
 %    \begin{macrocode}
 \def\substitutefontfamily#1#2#3{%
@@ -12232,8 +12285,6 @@
 \@onlypreamble\substitutefontfamily
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Encoding and fonts}
 %
 % Because documents may use non-ASCII font encodings, we make sure
@@ -12245,7 +12296,7 @@
 % too (in reverse order): the ``main'' encoding (when the document
 % begins), the last loaded, or |OT1|.
 %
-% \begin{macro}{\ensureascii}
+% \macro{\ensureascii}
 %
 %    \begin{macrocode}
 \bbl at trace{Encoding and fonts}
@@ -12285,13 +12336,11 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % Now comes the old deprecated stuff (with a little change in 3.9l, for
 % \textsf{fontspec}). The first thing we need to do is to determine, at
 % |\begin{document}|, which latin fontencoding to use.
 %
-% \begin{macro}{\latinencoding}
+% \macro{\latinencoding}
 % When text is being typeset in an encoding other than `latin'
 % (\texttt{OT1} or \texttt{T1}), it would be nice to still have Roman
 % numerals come out in the Latin encoding. So we first assume that the
@@ -12332,9 +12381,7 @@
      \fi}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\latintext}
+% \macro{\latintext}
 % Then we can define the command |\latintext| which is a declarative
 % switch to a latin font-encoding. Usage of this macro is deprecated.
 %
@@ -12344,9 +12391,7 @@
   \def\encodingdefault{\latinencoding}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
-% \begin{macro}{\textlatin}
+% \macro{\textlatin}
 % This command takes an argument which is then typeset using the
 % requested font encoding. In order to avoid many encoding switches it
 % operates in a local scope.
@@ -12367,11 +12412,9 @@
 \def\bbl at patchfont#1{\AddToHook{selectfont}{#1}}
 %    \end{macrocode}
 %
-% \end{macro}
-%
 % \subsection{Basic bidi support}
 %
-% \textbf{Work in progress.} This code is currently placed here for
+% This code is currently placed here for
 % practical reasons. It will be moved to the correct place soon, I
 % hope.
 %
@@ -12465,12 +12508,12 @@
 \bbl at trace{Macros to switch the text direction}
 \def\bbl at alscripts{,Arabic,Syriac,Thaana,}
 \def\bbl at rscripts{% 
-  ,Imperial Aramaic,Avestan,Cypriot,Hatran,Hebrew,%
-  Old Hungarian,Lydian,Mandaean,Manichaean,%
-  Meroitic Cursive,Meroitic,Old North Arabian,%
-  Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,%
-  Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,%
-  Old South Arabian,}%
+  ,Garay,Todhri,Imperial Aramaic,Avestan,Cypriot,Elymaic,Hatran,Hebrew,%
+  Old Hungarian,Kharoshthi,Lydian,Mandaean,Manichaean,Mende Kikakui,%
+  Meroitic Cursive,Meroitic,Old North Arabian,Nabataean,N'Ko,%
+  Old Turkic,Orkhon,Palmyrene,Inscriptional Pahlavi,Psalter Pahlavi,%
+  Phoenician,Inscriptional Parthian,Hanifi,Samaritan,Old Sogdian,%
+  Old South Arabian,Yezidi,}%
 \def\bbl at provide@dirs#1{%
   \bbl at xin@{\csname bbl at sname@#1\endcsname}{\bbl at alscripts\bbl at rscripts}%
   \ifin@
@@ -12604,7 +12647,7 @@
 %
 % \subsection{Local Language Configuration}
 %
-% \begin{macro}{\loadlocalcfg}
+% \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
@@ -12629,8 +12672,6 @@
         \@empty}}
 \fi
 %    \end{macrocode}%
-% \end{macro}
-%
 % \subsection{Language options}
 %
 % Languages are loaded when processing the corresponding option
@@ -12674,6 +12715,7 @@
     {\bbl at load@language{\CurrentOption}}%
     {#1\bbl at load@language{#2}#3}}
 %
+\DeclareOption{friulian}{\bbl at try@load at lang{}{friulan}{}}
 \DeclareOption{hebrew}{%
   \ifcase\bbl at engine\or
     \bbl at error{only-pdftex-lang}{hebrew}{luatex}{}%
@@ -12883,7 +12925,7 @@
 %</package>
 %    \end{macrocode}
 %
-% \section{The kernel of Babel (\texttt{babel.def}, common)}
+% \section{The kernel of Babel}
 %
 % The kernel of the \babel\ system is currently stored in
 % \file{babel.def}. The file \file{babel.def} contains most of the
@@ -12911,6 +12953,7 @@
 \input babel.def
 \let\bbl at onlyswitch\@undefined
 %</kernel>
+%    \end{macrocode}
 %
 % \section{Error messages}
 %
@@ -12920,6 +12963,7 @@
 % catcodes have the right value, although those for |\|, |`|, |^^M|,
 % |%| and |=| are reset before loading the file.
 %
+%    \begin{macrocode}
 %<*errors>
 \catcode`\{=1  \catcode`\}=2  \catcode`\#=6
 \catcode`\:=12 \catcode`\,=12 \catcode`\.=12 \catcode`\-=12
@@ -13115,10 +13159,6 @@
 %<*patterns>
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
 % \section{Loading hyphenation patterns}
 %
 % The following code is meant to be read by ini\TeX\ because it
@@ -13139,7 +13179,7 @@
 <@Define core switching macros@>
 %    \end{macrocode}
 %
-% \begin{macro}{\process at line}
+% \macro{\process at line}
 % Each line in the file \file{language.dat} is processed by
 % |\process at line| after it is read. The first thing this macro does is
 % to check whether the line starts with \texttt{=}. When the first
@@ -13156,10 +13196,8 @@
   \ignorespaces}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\process at synonym}
 %
-% \begin{macro}{\process at synonym}
-%
 % This macro takes care of the lines which start with an
 % \texttt{=}. It needs an empty token register to begin with.
 % |\bbl at languages| is also set to empty.
@@ -13193,10 +13231,8 @@
   \fi}
 %    \end{macrocode}
 %
-% \end{macro}
+% \macro{\process at language}
 %
-% \begin{macro}{\process at language}
-%
 % The macro |\process at language| is used to process a non-empty line
 % from the `configuration file'. It has three arguments, each
 % delimited by white space. The first argument is the `name' of a
@@ -13284,9 +13320,9 @@
   \fi}
 %    \end{macrocode}
 %
-% \begin{macro}{\bbl at get@enc}
+% \macro{\bbl at get@enc}
 %
-% \begin{macro}{\bbl at hyph@enc}
+% \macro{\bbl at hyph@enc}
 % The macro |\bbl at get@enc| extracts the font encoding from the
 % language name and stores it in |\bbl at hyph@enc|. It uses delimited
 % arguments to achieve this.
@@ -13295,10 +13331,6 @@
 \def\bbl at get@enc#1:#2:#3\@@@{\def\bbl at hyph@enc{#2}}
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
 % Now, hooks are defined. For efficiency reasons, they are dealt
 % here in a special way. Besides \luatex, format-specific
 % configuration files are taken into account. |loadkernel| currently
@@ -13372,7 +13404,7 @@
 \bbl at hook@loadkernel{switch.def}
 %    \end{macrocode}
 %
-% \begin{macro}{\readconfigfile}
+% \macro{\readconfigfile}
 % The configuration file can now be opened for reading.
 %
 %    \begin{macrocode}
@@ -13477,9 +13509,8 @@
 %    \end{macrocode}
 %
 % Here the code for ini\TeX\ ends.
-% \end{macro}
 %
-% \section{Font handling with fontspec}
+% \section{\xetex{} + \luatex{}: common stuff}
 %
 % Add the bidi handler just before luaoftload, which is loaded by default
 % by LaTeX. Just in case, consider the possibility it has not been
@@ -13497,6 +13528,8 @@
 %<</More package options>>
 %    \end{macrocode}
 %
+% \macro{\babelfont}
+%
 % With explicit languages, we could define the font at once, but we
 % don't. Just wait and see if the language is actually activated.
 % |bbl at font| replaces hardcoded font names inside |\..family| by the
@@ -13726,14 +13759,10 @@
 %<</Font selection>>
 %    \end{macrocode}
 %
-% \section{Hooks for XeTeX and LuaTeX}
+% \macro{\BabelFootnote}
 %
-% \subsection{XeTeX}
+% Footnotes
 %
-% Unfortunately, the current encoding cannot be retrieved and
-% therefore it is reset always to |utf8|, which seems a sensible
-% default.
-%
 %    \begin{macrocode}
 %<<*Footnote changes>>
 \bbl at trace{Bidi footnotes}
@@ -13784,6 +13813,14 @@
 %<</Footnote changes>>
 %    \end{macrocode}
 %
+% \section{Hooks for XeTeX and LuaTeX}
+%
+% \subsection{XeTeX}
+%
+% Unfortunately, the current encoding cannot be retrieved and
+% therefore it is reset always to |utf8|, which seems a sensible
+% default.
+%
 % Now, the code.
 %
 %    \begin{macrocode}
@@ -14216,6 +14253,7 @@
 %
 %    \begin{macrocode}
 %<*luatex>
+\directlua{ Babel = Babel or {} } % DL2
 \ifx\AddBabelHook\@undefined % When plain.def, babel.sty starts
 \bbl at trace{Read language.dat}
 \ifx\bbl at readstream\@undefined
@@ -14384,17 +14422,17 @@
 \endinput\fi
 %    \end{macrocode}
 %
-% Here stops reading code for \textsc{hyphen.cfg}. The following is read the 2nd
-% time it's loaded. First, global declarations for lua.
+% Here stops reading code for \textsc{hyphen.cfg}. The following is
+% read the 2nd time it's loaded. First, global declarations for lua.
 %
 %    \begin{macrocode}
-\begingroup  % TODO - to a lua file
+\begingroup  % TODO - to a lua file % DL3
 \catcode`\%=12
 \catcode`\'=12
 \catcode`\"=12
 \catcode`\:=12
 \directlua{
-  Babel = Babel or {}
+  Babel.locale_props = Babel.locale_props or {}
   function Babel.lua_error(e, a)
     tex.print([[\noexpand\csname bbl at error\endcsname{]] .. 
       e .. '}{' .. (a or '') .. '}{}{}')
@@ -14491,7 +14529,7 @@
 }
 \endgroup
 \ifx\newattribute\@undefined\else % Test for plain
-  \newattribute\bbl at attr@locale
+  \newattribute\bbl at attr@locale % DL4
   \directlua{ Babel.attr_locale = luatexbase.registernumber'bbl at attr@locale' }
   \AddBabelHook{luatex}{beforeextras}{%
     \setattribute\bbl at attr@locale\localeid}
@@ -14546,7 +14584,7 @@
         {\prehyphenchar=\bbl at cl{prehc}\relax}}}}
 %    \end{macrocode}
 %
-% \begin{macro}{\babelpatterns}
+% \macro{\babelpatterns}
 %
 % This macro adds patterns. Two macros are used to store them:
 % |\bbl at patterns@| for the global ones and |\bbl at patterns@<language>| for
@@ -14580,7 +14618,6 @@
             #2}}}%
     \fi}}
 %    \end{macrocode}
-% \end{macro}
 %
 % \subsection{Southeast Asian scripts}
 %
@@ -14594,8 +14631,7 @@
 %
 %    \begin{macrocode}
 % TODO - to a lua file -- or a logical place
-\directlua{
-  Babel = Babel or {}
+\directlua{% DL5
   Babel.linebreaking = Babel.linebreaking or {}
   Babel.linebreaking.before = {}
   Babel.linebreaking.after = {}
@@ -14615,7 +14651,6 @@
 }
 \def\bbl at intraspace#1 #2 #3\@@{%
   \directlua{
-    Babel = Babel or {}
     Babel.intraspaces = Babel.intraspaces or {}
     Babel.intraspaces['\csname bbl at sbcp@\languagename\endcsname'] = %
        {b = #1, p = #2, m = #3}
@@ -14624,7 +14659,6 @@
   }}
 \def\bbl at intrapenalty#1\@@{%
   \directlua{
-    Babel = Babel or {}
     Babel.intrapenalties = Babel.intrapenalties or {}
     Babel.intrapenalties['\csname bbl at sbcp@\languagename\endcsname'] = #1
     Babel.locale_props[\the\localeid].intrapenalty = #1
@@ -14637,7 +14671,6 @@
 \gdef\bbl at seaintraspace{&
   \let\bbl at seaintraspace\relax
   \directlua{
-    Babel = Babel or {}
     Babel.sea_enabled = true
     Babel.sea_ranges = Babel.sea_ranges or {}
     function Babel.set_chranges (script, chrng) 
@@ -14702,7 +14735,6 @@
 \gdef\bbl at cjkintraspace{%
   \let\bbl at cjkintraspace\relax
   \directlua{
-    Babel = Babel or {}
     require('babel-data-cjk.lua')
     Babel.cjk_enabled = true
     function Babel.cjk_linebreak(head)
@@ -14801,7 +14833,6 @@
        \ifin@           % cjk
          \bbl at cjkintraspace
          \directlua{
-             Babel = Babel or {}
              Babel.locale_props = Babel.locale_props or {}
              Babel.locale_props[\the\localeid].linebreak = 'c'
          }%
@@ -14813,7 +14844,6 @@
          \bbl at seaintraspace
          \bbl at exp{\\\bbl at intraspace\bbl at cl{intsp}\\\@@}%
          \directlua{
-            Babel = Babel or {}
             Babel.sea_ranges = Babel.sea_ranges or {}
             Babel.set_chranges('\bbl at cl{sbcp}', 
                                '\bbl at cl{chrng}')
@@ -15129,7 +15159,7 @@
 %
 %    \begin{macrocode}
 % TODO - to a lua file
-\directlua{
+\directlua{% DL6
 Babel.script_blocks = {
   ['dflt'] = {},
   ['Arab'] = {{0x0600, 0x06FF}, {0x08A0, 0x08FF}, {0x0750, 0x077F},
@@ -15310,7 +15340,7 @@
 % still slow). The Lua code is below.
 %
 %    \begin{macrocode}
-\directlua{
+\directlua{% DL7
   Babel.nohyphenation = \the\l at nohyphenation
 }
 %    \end{macrocode}
@@ -15355,23 +15385,26 @@
         {\bbl at add@list\babeltempb{nil}}&%
         {\directlua{
            local rep = [=[##1]=]
+           local three_args = '%s*=%s*([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)'
+           &% Numeric passes directly: kern, penalty...
            rep = rep:gsub('^%s*(remove)%s*$', 'remove = true')
            rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ')
            rep = rep:gsub('^%s*(after)%s*,', 'after = true, ')
            rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func)
            rep = rep:gsub('node%s*=%s*(%a+)%s*(%a*)', Babel.capture_node)
-           rep = rep:gsub(&%
-             '(norule)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
-             'norule = {' .. '%2, %3, %4' .. '}')
+           rep = rep:gsub( '(norule)' .. three_args,
+               'norule = {' .. '%2, %3, %4' .. '}')
            if #1 == 0 or #1 == 2 then
-             rep = rep:gsub(&%
-               '(space)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
+             rep = rep:gsub( '(space)' .. three_args,
                'space = {' .. '%2, %3, %4' .. '}')
-             rep = rep:gsub(&%
-               '(spacefactor)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
-               'spacefactor = {' .. '%2, %3, %4' .. '}')
+             rep = rep:gsub( '(spacefactor)' .. three_args,
+               'spacefactor = {' .. '%2, %3, %4' .. '}')           
              rep = rep:gsub('(kashida)%s*=%s*([^%s,]*)', Babel.capture_kashida)
-           else
+             &% Transform values
+             rep, n = rep:gsub( '{([%a%-]+)|([%-%d%.]+)}',
+              '{\the\csname bbl at id@@#3\endcsname,"%1",%2}')
+           end
+           if #1 == 1 then
              rep = rep:gsub(    '(no)%s*=%s*([^%s,]*)', Babel.capture_func)
              rep = rep:gsub(   '(pre)%s*=%s*([^%s,]*)', Babel.capture_func)
              rep = rep:gsub(  '(post)%s*=%s*([^%s,]*)', Babel.capture_func)
@@ -15507,6 +15540,10 @@
     require('babel-transforms.lua')
     Babel.linebreaking.add_before(Babel.pre_hyphenate_replace)
   }}
+\newcommand\SetTransformValue[3]{%
+  \directlua{
+    Babel.locale_props[\the\csname bbl at id@@#1\endcsname].vars["#2"] = #3
+  }}
 %    \end{macrocode}
 %
 % The following experimental (and unfinished) macro applies the
@@ -15533,8 +15570,6 @@
 \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)
@@ -15592,7 +15627,7 @@
       table.insert(Babel.ranges, {0xF0000,  0xFFFFD, 'on'})
       table.insert(Babel.ranges, {0x100000, 0x10FFFD, 'on'})
     \fi}
-  \newattribute\bbl at attr@dir
+  \newattribute\bbl at attr@dir 
   \directlua{ Babel.attr_dir = luatexbase.registernumber'bbl at attr@dir' }
   \bbl at exp{\output{\bodydir\pagedir\the\output}}
 \fi
@@ -15873,7 +15908,6 @@
       {\RequirePackage{luatexbase}%
        \bbl at activate@preotf
        \directlua{
-         Babel = Babel or {}  %%% -> presets in luababel
          Babel.digits_mapped = true
          Babel.digits = Babel.digits or {}
          Babel.digits[\the\localeid] =
@@ -16239,8 +16273,8 @@
 Babel.linebreaking.replacements[1] = {}  -- post
 
 function Babel.tovalue(v)
-  if type(v) == 'string' then
-    return loadstring('return ' .. v)()
+  if type(v) == 'table' then
+    return Babel.locale_props[v[1]].vars[v[2]] or v[3]
   else
     return v
   end
@@ -16396,6 +16430,7 @@
 function Babel.hyphenate_replace(head, mode)
   local u = unicode.utf8
   local lbkr = Babel.linebreaking.replacements[mode]
+  local tovalue = Babel.tovalue
 
   local word_head = head
 
@@ -16599,9 +16634,9 @@
             d.replace = Babel.str_to_nodes(crep.no, matches, item_base)
             d.attr = item_base.attr
             if crep.pre == nil then  -- TeXbook p96
-              d.penalty = crep.penalty or tex.hyphenpenalty
+              d.penalty = tovalue(crep.penalty) or tex.hyphenpenalty
             else
-              d.penalty = crep.penalty or tex.exhyphenpenalty
+              d.penalty = tovalue(crep.penalty) or tex.exhyphenpenalty
             end
             placeholder = '|'
             head, new = node.insert_before(head, item, d)
@@ -16612,7 +16647,7 @@
           elseif crep and crep.penalty then
             d = node.new(14, 0)   -- (penalty, userpenalty)
             d.attr = item_base.attr
-            d.penalty = crep.penalty
+            d.penalty = tovalue(crep.penalty)
             head, new = node.insert_before(head, item, d)
 
           elseif crep and crep.space then
@@ -16619,9 +16654,9 @@
             -- 655360 = 10 pt = 10 * 65536 sp
             d = node.new(12, 13)      -- (glue, spaceskip)
             local quad = font.getfont(item_base.font).size or 655360
-            node.setglue(d, crep.space[1] * quad,
-                            crep.space[2] * quad,
-                            crep.space[3] * quad)
+            node.setglue(d, tovalue(crep.space[1]) * quad,
+                            tovalue(crep.space[2]) * quad,
+                            tovalue(crep.space[3]) * quad)
             if mode == 0 then
               placeholder = ' '
             end
@@ -16631,9 +16666,9 @@
             -- 655360 = 10 pt = 10 * 65536 sp
             d = node.new(2, 3)      -- (rule, empty) = \no*rule
             local quad = font.getfont(item_base.font).size or 655360
-            d.width   = crep.norule[1] * quad
-            d.height  = crep.norule[2] * quad
-            d.depth   = crep.norule[3] * quad
+            d.width   = tovalue(crep.norule[1]) * quad
+            d.height  = tovalue(crep.norule[2]) * quad
+            d.depth   = tovalue(crep.norule[3]) * quad
             head, new = node.insert_before(head, item, d)
 
           elseif crep and crep.spacefactor then
@@ -16640,9 +16675,9 @@
             d = node.new(12, 13)      -- (glue, spaceskip)
             local base_font = font.getfont(item_base.font)
             node.setglue(d,
-              crep.spacefactor[1] * base_font.parameters['space'],
-              crep.spacefactor[2] * base_font.parameters['space_stretch'],
-              crep.spacefactor[3] * base_font.parameters['space_shrink'])
+              tovalue(crep.spacefactor[1]) * base_font.parameters['space'],
+              tovalue(crep.spacefactor[2]) * base_font.parameters['space_stretch'],
+              tovalue(crep.spacefactor[3]) * base_font.parameters['space_shrink'])
             if mode == 0 then
               placeholder = ' '
             end
@@ -16655,7 +16690,7 @@
             d = node.new(13, 1)      -- (kern, user)
             local quad = font.getfont(item_base.font).size or 655360
             d.attr = item_base.attr
-            d.kern = crep.kern * quad
+            d.kern = tovalue(crep.kern) * quad
             head, new = node.insert_before(head, item, d)
 
           elseif crep and crep.node then
@@ -16836,8 +16871,6 @@
 %<*bididata>
 -- Data from Unicode and ConTeXt
 
-Babel = Babel or {}
-
 Babel.ranges = {
  {0x0590, 0x05FF, 'r'},
  {0x0600, 0x07BF, 'al'},
@@ -22960,8 +22993,6 @@
 %
 %    \begin{macrocode}
 %<*basic-r>
-Babel = Babel or {}
-
 Babel.bidi_enabled = true
 
 require('babel-data-bidi.lua')
@@ -23226,8 +23257,6 @@
 %
 %    \begin{macrocode}
 %<*basic>
-Babel = Babel or {}
-
 -- eg, Babel.fontmap[1][<prefontid>]=<dirfontid>
 
 Babel.fontmap = Babel.fontmap or {}
@@ -23700,8 +23729,6 @@
 %\iffalse
 %    \begin{macrocode}
 %<*cjkdata>
-Babel = Babel or {}
-
 Babel.cjk_characters = {
   [0x0021]={c='ex'},
   [0x0022]={c='qu'},
@@ -24061,8 +24088,8 @@
 %
 % The next step consists of defining commands to switch to (and from)
 % the `nil' language.
-% \begin{macro}{\captionnil}
-% \begin{macro}{\datenil}
+% \macro{\captionnil}
+% \macro{\datenil}
 %
 %    \begin{macrocode}
 \let\captionsnil\@empty
@@ -24069,9 +24096,6 @@
 \let\datenil\@empty
 %    \end{macrocode}
 %
-% \end{macro}
-% \end{macro}
-%
 % There is no locale file for this pseudo-language, so the
 % corresponding fields are defined here.
 %

Modified: trunk/Master/texmf-dist/source/latex/babel/babel.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/babel.ins	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.ins	2024-10-05 19:35:50 UTC (rev 72469)
@@ -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{2024/09/18}
+\def\filedate{2024/10/05}
 \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	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx	2024-10-05 19:35:50 UTC (rev 72469)
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2024/09/18 v24.]
+\ProvidesFile{bbcompat.dtx}[2024/10/05 v24.]
 %</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-bidi-basic-r.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua	2024-10-05 19:35:50 UTC (rev 72469)
@@ -32,8 +32,6 @@
 -- and covered by LPPL is defined by the unpacking scripts (with
 -- extension |.ins|) which are part of the distribution.
 --
-Babel = Babel or {}
-
 Babel.bidi_enabled = true
 
 require('babel-data-bidi.lua')

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua	2024-10-05 19:35:50 UTC (rev 72469)
@@ -32,8 +32,6 @@
 -- and covered by LPPL is defined by the unpacking scripts (with
 -- extension |.ins|) which are part of the distribution.
 --
-Babel = Babel or {}
-
 -- eg, Babel.fontmap[1][<prefontid>]=<dirfontid>
 
 Babel.fontmap = Babel.fontmap or {}

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel-data-bidi.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-data-bidi.lua	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-data-bidi.lua	2024-10-05 19:35:50 UTC (rev 72469)
@@ -34,8 +34,6 @@
 --
 -- Data from Unicode and ConTeXt
 
-Babel = Babel or {}
-
 Babel.ranges = {
  {0x0590, 0x05FF, 'r'},
  {0x0600, 0x07BF, 'al'},

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel-data-cjk.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-data-cjk.lua	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-data-cjk.lua	2024-10-05 19:35:50 UTC (rev 72469)
@@ -32,8 +32,6 @@
 -- and covered by LPPL is defined by the unpacking scripts (with
 -- extension |.ins|) which are part of the distribution.
 --
-Babel = Babel or {}
-
 Babel.cjk_characters = {
   [0x0021]={c='ex'},
   [0x0022]={c='qu'},

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel-transforms.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-transforms.lua	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-transforms.lua	2024-10-05 19:35:50 UTC (rev 72469)
@@ -37,8 +37,8 @@
 Babel.linebreaking.replacements[1] = {}  -- post
 
 function Babel.tovalue(v)
-  if type(v) == 'string' then
-    return loadstring('return ' .. v)()
+  if type(v) == 'table' then
+    return Babel.locale_props[v[1]].vars[v[2]] or v[3]
   else
     return v
   end
@@ -194,6 +194,7 @@
 function Babel.hyphenate_replace(head, mode)
   local u = unicode.utf8
   local lbkr = Babel.linebreaking.replacements[mode]
+  local tovalue = Babel.tovalue
 
   local word_head = head
 
@@ -397,9 +398,9 @@
             d.replace = Babel.str_to_nodes(crep.no, matches, item_base)
             d.attr = item_base.attr
             if crep.pre == nil then  -- TeXbook p96
-              d.penalty = crep.penalty or tex.hyphenpenalty
+              d.penalty = tovalue(crep.penalty) or tex.hyphenpenalty
             else
-              d.penalty = crep.penalty or tex.exhyphenpenalty
+              d.penalty = tovalue(crep.penalty) or tex.exhyphenpenalty
             end
             placeholder = '|'
             head, new = node.insert_before(head, item, d)
@@ -410,7 +411,7 @@
           elseif crep and crep.penalty then
             d = node.new(14, 0)   -- (penalty, userpenalty)
             d.attr = item_base.attr
-            d.penalty = crep.penalty
+            d.penalty = tovalue(crep.penalty)
             head, new = node.insert_before(head, item, d)
 
           elseif crep and crep.space then
@@ -417,9 +418,9 @@
             -- 655360 = 10 pt = 10 * 65536 sp
             d = node.new(12, 13)      -- (glue, spaceskip)
             local quad = font.getfont(item_base.font).size or 655360
-            node.setglue(d, crep.space[1] * quad,
-                            crep.space[2] * quad,
-                            crep.space[3] * quad)
+            node.setglue(d, tovalue(crep.space[1]) * quad,
+                            tovalue(crep.space[2]) * quad,
+                            tovalue(crep.space[3]) * quad)
             if mode == 0 then
               placeholder = ' '
             end
@@ -429,9 +430,9 @@
             -- 655360 = 10 pt = 10 * 65536 sp
             d = node.new(2, 3)      -- (rule, empty) = \no*rule
             local quad = font.getfont(item_base.font).size or 655360
-            d.width   = crep.norule[1] * quad
-            d.height  = crep.norule[2] * quad
-            d.depth   = crep.norule[3] * quad
+            d.width   = tovalue(crep.norule[1]) * quad
+            d.height  = tovalue(crep.norule[2]) * quad
+            d.depth   = tovalue(crep.norule[3]) * quad
             head, new = node.insert_before(head, item, d)
 
           elseif crep and crep.spacefactor then
@@ -438,9 +439,9 @@
             d = node.new(12, 13)      -- (glue, spaceskip)
             local base_font = font.getfont(item_base.font)
             node.setglue(d,
-              crep.spacefactor[1] * base_font.parameters['space'],
-              crep.spacefactor[2] * base_font.parameters['space_stretch'],
-              crep.spacefactor[3] * base_font.parameters['space_shrink'])
+              tovalue(crep.spacefactor[1]) * base_font.parameters['space'],
+              tovalue(crep.spacefactor[2]) * base_font.parameters['space_stretch'],
+              tovalue(crep.spacefactor[3]) * base_font.parameters['space_shrink'])
             if mode == 0 then
               placeholder = ' '
             end
@@ -453,7 +454,7 @@
             d = node.new(13, 1)      -- (kern, user)
             local quad = font.getfont(item_base.font).size or 655360
             d.attr = item_base.attr
-            d.kern = crep.kern * quad
+            d.kern = tovalue(crep.kern) * quad
             head, new = node.insert_before(head, item, d)
 
           elseif crep and crep.node then

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.def	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.def	2024-10-05 19:35:50 UTC (rev 72469)
@@ -39,7 +39,7 @@
     \wlog{File: #1 #4 #3 <#2>}%
     \let\ProvidesFile\@undefined}
 \fi
-\ProvidesFile{babel.def}[2024/09/18 v24.10 Babel common definitions]
+\ProvidesFile{babel.def}[2024/10/05 v24.11 Babel common definitions]
 \ifx\AtBeginDocument\@undefined
   \def\@empty{}
 \def\loadlocalcfg#1{%
@@ -595,8 +595,8 @@
     \toks@\expandafter{\bbl at tempc#3}%
     \expandafter\edef\csname extras\languagename\endcsname{\the\toks@}%
   \fi}
-\def\bbl at version{24.10}
-\def\bbl at date{2024/09/18}
+\def\bbl at version{24.11}
+\def\bbl at date{2024/10/05}
 \ifx\language\@undefined
   \csname newcount\endcsname\language
 \fi
@@ -721,10 +721,9 @@
      \edef\bbl at id@last{\the\count@}%
      \ifcase\bbl at engine\or
        \directlua{
-         Babel = Babel or {}
-         Babel.locale_props = Babel.locale_props or {}
          Babel.locale_props[\bbl at id@last] = {}
          Babel.locale_props[\bbl at id@last].name = '\languagename'
+         Babel.locale_props[\bbl at id@last].vars = {}
         }%
       \fi}%
     {}%
@@ -1303,18 +1302,6 @@
         \endgroup
       \fi
   \fi}
-\def\bbl at remove@special#1{%
-  \begingroup
-    \def\x##1##2{\ifnum`#1=`##2\noexpand\@empty
-                 \else\noexpand##1\noexpand##2\fi}%
-    \def\do{\x\do}%
-    \def\@makeother{\x\@makeother}%
-  \edef\x{\endgroup
-    \def\noexpand\dospecials{\dospecials}%
-    \expandafter\ifx\csname @sanitize\endcsname\relax\else
-      \def\noexpand\@sanitize{\@sanitize}%
-    \fi}%
-  \x}
 \def\bbl at active@def#1#2#3#4{%
   \@namedef{#3#1}{%
     \expandafter\ifx\csname#2 at sh@#1@\endcsname\relax
@@ -1458,7 +1445,6 @@
     \csname bbl at normal@\string#1\endcsname}
 \def\bbl at firstcs#1#2{\csname#1\endcsname}
 \def\bbl at scndcs#1#2{\csname#2\endcsname}
-
 \def\babel at texpdf#1#2#3#4{%
   \ifx\texorpdfstring\@undefined
     \textormath{#1}{#3}%

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.sty	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.sty	2024-10-05 19:35:50 UTC (rev 72469)
@@ -33,12 +33,13 @@
 %% extension |.ins|) which are part of the distribution.
 %%
 \NeedsTeXFormat{LaTeX2e}[2005/12/01]
-\ProvidesPackage{babel}[2024/09/18 v24.10 The Babel package]
+\ProvidesPackage{babel}[2024/10/05 v24.11 The Babel package]
 \@ifpackagewith{babel}{debug}
   {\providecommand\bbl at trace[1]{\message{^^J[ #1 ]}}%
    \let\bbl at debug\@firstofone
    \ifx\directlua\@undefined\else
-     \directlua{ Babel = Babel or {}
+     \directlua{
+       Babel = Babel or {}
        Babel.debug = true }%
      \input{babel-debug.tex}%
    \fi}
@@ -45,7 +46,8 @@
   {\providecommand\bbl at trace[1]{}%
    \let\bbl at debug\@gobble
    \ifx\directlua\@undefined\else
-     \directlua{ Babel = Babel or {}
+     \directlua{
+       Babel = Babel or {}
        Babel.debug = false }%
    \fi}
 \def\bbl at error#1{% Implicit #2#3#4
@@ -406,7 +408,6 @@
     \in@{,provide,}{,#1,}%
     \ifin@
       \def\bbl at opt@provide{#2}%
-      \bbl at replace\bbl at opt@provide{;}{,}%
     \fi}
 \fi
 \bbl at trace{Conditional loading of shorthands}
@@ -465,8 +466,8 @@
       \expandafter\@secondoftwo
     \fi}
 \fi
-\def\bbl at version{24.10}
-\def\bbl at date{2024/09/18}
+\def\bbl at version{24.11}
+\def\bbl at date{2024/10/05}
 \ifx\language\@undefined
   \csname newcount\endcsname\language
 \fi
@@ -619,10 +620,9 @@
      \edef\bbl at id@last{\the\count@}%
      \ifcase\bbl at engine\or
        \directlua{
-         Babel = Babel or {}
-         Babel.locale_props = Babel.locale_props or {}
          Babel.locale_props[\bbl at id@last] = {}
          Babel.locale_props[\bbl at id@last].name = '\languagename'
+         Babel.locale_props[\bbl at id@last].vars = {}
         }%
       \fi}%
     {}%
@@ -1213,18 +1213,6 @@
         \endgroup
       \fi
   \fi}
-\def\bbl at remove@special#1{%
-  \begingroup
-    \def\x##1##2{\ifnum`#1=`##2\noexpand\@empty
-                 \else\noexpand##1\noexpand##2\fi}%
-    \def\do{\x\do}%
-    \def\@makeother{\x\@makeother}%
-  \edef\x{\endgroup
-    \def\noexpand\dospecials{\dospecials}%
-    \expandafter\ifx\csname @sanitize\endcsname\relax\else
-      \def\noexpand\@sanitize{\@sanitize}%
-    \fi}%
-  \x}
 \def\bbl at active@def#1#2#3#4{%
   \@namedef{#3#1}{%
     \expandafter\ifx\csname#2 at sh@#1@\endcsname\relax
@@ -1368,7 +1356,6 @@
     \csname bbl at normal@\string#1\endcsname}
 \def\bbl at firstcs#1#2{\csname#1\endcsname}
 \def\bbl at scndcs#1#2{\csname#2\endcsname}
-
 \def\babel at texpdf#1#2#3#4{%
   \ifx\texorpdfstring\@undefined
     \textormath{#1}{#3}%
@@ -3434,6 +3421,46 @@
     {\bbl at cs{cntr@#1.F.\number#5#6#7#8@\languagename}}}
 \def\bbl at alphnum@invalid#1{%
   \bbl at error{alphabetic-too-large}{#1}{}{}}
+\newcommand\BabelUppercaseMapping[3]{%
+  \DeclareUppercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
+\newcommand\BabelTitlecaseMapping[3]{%
+  \DeclareTitlecaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
+\newcommand\BabelLowercaseMapping[3]{%
+  \DeclareLowercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
+\def\bbl at casemapping#1#2#3{% 1:variant
+  \def\bbl at tempa##1 ##2{% Loop
+    \bbl at casemapping@i{##1}%
+    \ifx\@empty##2\else\bbl at afterfi\bbl at tempa##2\fi}%
+  \edef\bbl at templ{\@nameuse{bbl at casing@#2}#1}%  Language code
+  \def\bbl at tempe{0}%   Mode (upper/lower...)
+  \def\bbl at tempc{#3 }% Casing list
+  \expandafter\bbl at tempa\bbl at tempc\@empty}
+\def\bbl at casemapping@i#1{%
+  \def\bbl at tempb{#1}%
+  \ifcase\bbl at engine % Handle utf8 in pdftex, by surrounding chars with {}
+    \@nameuse{regex_replace_all:nnN}%
+      {[\x{c0}-\x{ff}][\x{80}-\x{bf}]*}{{\0}}\bbl at tempb
+  \else
+    \@nameuse{regex_replace_all:nnN}{.}{{\0}}\bbl at tempb % TODO. needed?
+  \fi
+  \expandafter\bbl at casemapping@ii\bbl at tempb\@@}
+\def\bbl at casemapping@ii#1#2#3\@@{%
+  \in@{#1#3}{<>}% ie, if <u>, <l>, <t>
+  \ifin@
+    \edef\bbl at tempe{%
+      \if#2u1 \else\if#2l2 \else\if#2t3 \fi\fi\fi}%
+  \else
+    \ifcase\bbl at tempe\relax
+      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#2}}{#1}%
+    \or
+      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+    \or
+      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+    \or
+      \DeclareTitlecaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
+    \fi
+  \fi}
 \def\bbl at localeinfo#1#2{%
   \bbl at ifunset{bbl at info@#2}{#1}%
     {\bbl at ifunset{bbl@\csname bbl at info@#2\endcsname @\languagename}{#1}%
@@ -3480,46 +3507,6 @@
         {\bbl at cs{\csname bbl at info@#1.tag.bcp47\endcsname @#2}}}}
 \fi
 \@namedef{bbl at info@casing.tag.bcp47}{casing}
-\newcommand\BabelUppercaseMapping[3]{%
-  \DeclareUppercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
-\newcommand\BabelTitlecaseMapping[3]{%
-  \DeclareTitlecaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
-\newcommand\BabelLowercaseMapping[3]{%
-  \DeclareLowercaseMapping[\@nameuse{bbl at casing@#1}]{#2}{#3}}
-\def\bbl at casemapping#1#2#3{% 1:variant
-  \def\bbl at tempa##1 ##2{% Loop
-    \bbl at casemapping@i{##1}%
-    \ifx\@empty##2\else\bbl at afterfi\bbl at tempa##2\fi}%
-  \edef\bbl at templ{\@nameuse{bbl at casing@#2}#1}%  Language code
-  \def\bbl at tempe{0}%   Mode (upper/lower...)
-  \def\bbl at tempc{#3 }% Casing list
-  \expandafter\bbl at tempa\bbl at tempc\@empty}
-\def\bbl at casemapping@i#1{%
-  \def\bbl at tempb{#1}%
-  \ifcase\bbl at engine % Handle utf8 in pdftex, by surrounding chars with {}
-    \@nameuse{regex_replace_all:nnN}%
-      {[\x{c0}-\x{ff}][\x{80}-\x{bf}]*}{{\0}}\bbl at tempb
-  \else
-    \@nameuse{regex_replace_all:nnN}{.}{{\0}}\bbl at tempb % TODO. needed?
-  \fi
-  \expandafter\bbl at casemapping@ii\bbl at tempb\@@}
-\def\bbl at casemapping@ii#1#2#3\@@{%
-  \in@{#1#3}{<>}% ie, if <u>, <l>, <t>
-  \ifin@
-    \edef\bbl at tempe{%
-      \if#2u1 \else\if#2l2 \else\if#2t3 \fi\fi\fi}%
-  \else
-    \ifcase\bbl at tempe\relax
-      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#2}}{#1}%
-    \or
-      \DeclareUppercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-    \or
-      \DeclareLowercaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-    \or
-      \DeclareTitlecaseMapping[\bbl at templ]{\bbl at utftocode{#1}}{#2}%
-    \fi
-  \fi}
 \let\bbl at ensureinfo\@gobble
 \newcommand\BabelEnsureInfo{%
   \ifx\InputIfFileExists\@undefined\else
@@ -3994,12 +3981,12 @@
 \bbl at trace{Macros to switch the text direction}
 \def\bbl at alscripts{,Arabic,Syriac,Thaana,}
 \def\bbl at rscripts{%
-  ,Imperial Aramaic,Avestan,Cypriot,Hatran,Hebrew,%
-  Old Hungarian,Lydian,Mandaean,Manichaean,%
-  Meroitic Cursive,Meroitic,Old North Arabian,%
-  Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,%
-  Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,%
-  Old South Arabian,}%
+  ,Garay,Todhri,Imperial Aramaic,Avestan,Cypriot,Elymaic,Hatran,Hebrew,%
+  Old Hungarian,Kharoshthi,Lydian,Mandaean,Manichaean,Mende Kikakui,%
+  Meroitic Cursive,Meroitic,Old North Arabian,Nabataean,N'Ko,%
+  Old Turkic,Orkhon,Palmyrene,Inscriptional Pahlavi,Psalter Pahlavi,%
+  Phoenician,Inscriptional Parthian,Hanifi,Samaritan,Old Sogdian,%
+  Old South Arabian,Yezidi,}%
 \def\bbl at provide@dirs#1{%
   \bbl at xin@{\csname bbl at sname@#1\endcsname}{\bbl at alscripts\bbl at rscripts}%
   \ifin@
@@ -4145,6 +4132,7 @@
   \IfFileExists{\CurrentOption.ldf}%
     {\bbl at load@language{\CurrentOption}}%
     {#1\bbl at load@language{#2}#3}}
+\DeclareOption{friulian}{\bbl at try@load at lang{}{friulan}{}}
 \DeclareOption{hebrew}{%
   \ifcase\bbl at engine\or
     \bbl at error{only-pdftex-lang}{hebrew}{luatex}{}%

Modified: trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg	2024-10-05 19:35:50 UTC (rev 72469)
@@ -37,10 +37,10 @@
     \wlog{File: #1 #4 #3 <#2>}%
     \let\ProvidesFile\@undefined}
 \fi
-\ProvidesFile{hyphen.cfg}[2024/09/18 v24.10 Babel hyphens]
+\ProvidesFile{hyphen.cfg}[2024/10/05 v24.11 Babel hyphens]
 \xdef\bbl at format{\jobname}
-\def\bbl at version{24.10}
-\def\bbl at date{2024/09/18}
+\def\bbl at version{24.11}
+\def\bbl at date{2024/10/05}
 \ifx\AtBeginDocument\@undefined
   \def\@empty{}
 \fi

Modified: trunk/Master/texmf-dist/tex/generic/babel/locale/zh/babel-zh.ini
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/locale/zh/babel-zh.ini	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/locale/zh/babel-zh.ini	2024-10-05 19:35:50 UTC (rev 72469)
@@ -256,6 +256,7 @@
 spacing.basic.3.2 =   {}
 ;
 spacing.basic.4.0 = { [、。,.・:;!?)]}〉》」』】〕〗〙〛”〞] ()[{a}]() }
+spacing.basic.4.1 =   { insert, space = {cjknormal|0} {cjkplus|.1} 0 }
 spacing.basic.4.1 =   { insert, kern = -.5, step = -1 }
 spacing.basic.4.2 =   { insert, penalty = 0 }
 spacing.basic.4.3 =   { insert, kern = .5 }

Modified: trunk/Master/texmf-dist/tex/generic/babel/luababel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/luababel.def	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/luababel.def	2024-10-05 19:35:50 UTC (rev 72469)
@@ -32,6 +32,7 @@
 %% and covered by LPPL is defined by the unpacking scripts (with
 %% extension |.ins|) which are part of the distribution.
 %%
+\directlua{ Babel = Babel or {} } % DL2
 \ifx\AddBabelHook\@undefined % When plain.def, babel.sty starts
 \bbl at trace{Read language.dat}
 \ifx\bbl at readstream\@undefined
@@ -192,13 +193,13 @@
        {\expandafter\expandafter\expandafter\bbl at tempb
         \csname bbl at hyphendata@\the\language\endcsname}}
 \endinput\fi
-\begingroup  % TODO - to a lua file
+\begingroup  % TODO - to a lua file % DL3
 \catcode`\%=12
 \catcode`\'=12
 \catcode`\"=12
 \catcode`\:=12
 \directlua{
-  Babel = Babel or {}
+  Babel.locale_props = Babel.locale_props or {}
   function Babel.lua_error(e, a)
     tex.print([[\noexpand\csname bbl at error\endcsname{]] ..
       e .. '}{' .. (a or '') .. '}{}{}')
@@ -295,7 +296,7 @@
 }
 \endgroup
 \ifx\newattribute\@undefined\else % Test for plain
-  \newattribute\bbl at attr@locale
+  \newattribute\bbl at attr@locale % DL4
   \directlua{ Babel.attr_locale = luatexbase.registernumber'bbl at attr@locale' }
   \AddBabelHook{luatex}{beforeextras}{%
     \setattribute\bbl at attr@locale\localeid}
@@ -373,8 +374,7 @@
               {\csname bbl at patterns@\bbl at tempa\endcsname\space}%
             #2}}}%
     \fi}}
-\directlua{
-  Babel = Babel or {}
+\directlua{% DL5
   Babel.linebreaking = Babel.linebreaking or {}
   Babel.linebreaking.before = {}
   Babel.linebreaking.after = {}
@@ -394,7 +394,6 @@
 }
 \def\bbl at intraspace#1 #2 #3\@@{%
   \directlua{
-    Babel = Babel or {}
     Babel.intraspaces = Babel.intraspaces or {}
     Babel.intraspaces['\csname bbl at sbcp@\languagename\endcsname'] = %
        {b = #1, p = #2, m = #3}
@@ -403,7 +402,6 @@
   }}
 \def\bbl at intrapenalty#1\@@{%
   \directlua{
-    Babel = Babel or {}
     Babel.intrapenalties = Babel.intrapenalties or {}
     Babel.intrapenalties['\csname bbl at sbcp@\languagename\endcsname'] = #1
     Babel.locale_props[\the\localeid].intrapenalty = #1
@@ -416,7 +414,6 @@
 \gdef\bbl at seaintraspace{&
   \let\bbl at seaintraspace\relax
   \directlua{
-    Babel = Babel or {}
     Babel.sea_enabled = true
     Babel.sea_ranges = Babel.sea_ranges or {}
     function Babel.set_chranges (script, chrng)
@@ -465,7 +462,6 @@
 \gdef\bbl at cjkintraspace{%
   \let\bbl at cjkintraspace\relax
   \directlua{
-    Babel = Babel or {}
     require('babel-data-cjk.lua')
     Babel.cjk_enabled = true
     function Babel.cjk_linebreak(head)
@@ -564,7 +560,6 @@
        \ifin@           % cjk
          \bbl at cjkintraspace
          \directlua{
-             Babel = Babel or {}
              Babel.locale_props = Babel.locale_props or {}
              Babel.locale_props[\the\localeid].linebreak = 'c'
          }%
@@ -576,7 +571,6 @@
          \bbl at seaintraspace
          \bbl at exp{\\\bbl at intraspace\bbl at cl{intsp}\\\@@}%
          \directlua{
-            Babel = Babel or {}
             Babel.sea_ranges = Babel.sea_ranges or {}
             Babel.set_chranges('\bbl at cl{sbcp}',
                                '\bbl at cl{chrng}')
@@ -1005,7 +999,7 @@
 \def\bbl at font@rst#1#2#3#4{%
   \bbl at csarg\def{famrst@#4}{\bbl at font@set{#1}#2#3}}
 \def\bbl at font@fams{rm,sf,tt}
-\directlua{
+\directlua{% DL6
 Babel.script_blocks = {
   ['dflt'] = {},
   ['Arab'] = {{0x0600, 0x06FF}, {0x08A0, 0x08FF}, {0x0750, 0x077F},
@@ -1173,7 +1167,7 @@
     Babel.chr_to_loc[\the\count@] =
       \bbl at ifblank{#1}{-1000}{\the\bbl at cs{id@@#1}}\space
   }}
-\directlua{
+\directlua{% DL7
   Babel.nohyphenation = \the\l at nohyphenation
 }
 \begingroup
@@ -1201,23 +1195,26 @@
         {\bbl at add@list\babeltempb{nil}}&%
         {\directlua{
            local rep = [=[##1]=]
+           local three_args = '%s*=%s*([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)'
+           &% Numeric passes directly: kern, penalty...
            rep = rep:gsub('^%s*(remove)%s*$', 'remove = true')
            rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ')
            rep = rep:gsub('^%s*(after)%s*,', 'after = true, ')
            rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func)
            rep = rep:gsub('node%s*=%s*(%a+)%s*(%a*)', Babel.capture_node)
-           rep = rep:gsub(&%
-             '(norule)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
-             'norule = {' .. '%2, %3, %4' .. '}')
+           rep = rep:gsub( '(norule)' .. three_args,
+               'norule = {' .. '%2, %3, %4' .. '}')
            if #1 == 0 or #1 == 2 then
-             rep = rep:gsub(&%
-               '(space)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
+             rep = rep:gsub( '(space)' .. three_args,
                'space = {' .. '%2, %3, %4' .. '}')
-             rep = rep:gsub(&%
-               '(spacefactor)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
+             rep = rep:gsub( '(spacefactor)' .. three_args,
                'spacefactor = {' .. '%2, %3, %4' .. '}')
              rep = rep:gsub('(kashida)%s*=%s*([^%s,]*)', Babel.capture_kashida)
-           else
+             &% Transform values
+             rep, n = rep:gsub( '{([%a%-]+)|([%-%d%.]+)}',
+              '{\the\csname bbl at id@@#3\endcsname,"%1",%2}')
+           end
+           if #1 == 1 then
              rep = rep:gsub(    '(no)%s*=%s*([^%s,]*)', Babel.capture_func)
              rep = rep:gsub(   '(pre)%s*=%s*([^%s,]*)', Babel.capture_func)
              rep = rep:gsub(  '(post)%s*=%s*([^%s,]*)', Babel.capture_func)
@@ -1353,13 +1350,15 @@
     require('babel-transforms.lua')
     Babel.linebreaking.add_before(Babel.pre_hyphenate_replace)
   }}
+\newcommand\SetTransformValue[3]{%
+  \directlua{
+    Babel.locale_props[\the\csname bbl at id@@#1\endcsname].vars["#2"] = #3
+  }}
 \newcommand\localeprehyphenation[1]{%
   \directlua{ Babel.string_prehyphenation([==[#1]==], \the\localeid) }}
 \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)
@@ -1632,7 +1631,6 @@
       {\RequirePackage{luatexbase}%
        \bbl at activate@preotf
        \directlua{
-         Babel = Babel or {}  %%% -> presets in luababel
          Babel.digits_mapped = true
          Babel.digits = Babel.digits or {}
          Babel.digits[\the\localeid] =

Modified: trunk/Master/texmf-dist/tex/generic/babel/nil.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/nil.ldf	2024-10-05 19:34:50 UTC (rev 72468)
+++ trunk/Master/texmf-dist/tex/generic/babel/nil.ldf	2024-10-05 19:35:50 UTC (rev 72469)
@@ -32,7 +32,7 @@
 %% and covered by LPPL is defined by the unpacking scripts (with
 %% extension |.ins|) which are part of the distribution.
 %%
-\ProvidesLanguage{nil}[2024/09/18 v24.10 Nil language]
+\ProvidesLanguage{nil}[2024/10/05 v24.11 Nil language]
 \LdfInit{nil}{datenil}
 \ifx\l at nil\@undefined
   \newlanguage\l at nil



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