[latex3-commits] [git/LaTeX3-latex3-latex2e] gh1035: Add \BCPdata and adapt \Make<thing>case (#1035) (9fa24571)
Joseph Wright
joseph.wright at morningstar2.co.uk
Tue Apr 11 13:51:58 CEST 2023
Repository : https://github.com/latex3/latex2e
On branch : gh1035
Link : https://github.com/latex3/latex2e/commit/9fa24571e9c5ed639686b722c4cc2bcdd6bf595c
>---------------------------------------------------------------
commit 9fa24571e9c5ed639686b722c4cc2bcdd6bf595c
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Tue Apr 11 11:51:20 2023 +0100
Add \BCPdata and adapt \Make<thing>case (#1035)
>---------------------------------------------------------------
9fa24571e9c5ed639686b722c4cc2bcdd6bf595c
base/changes.txt | 6 ++++++
base/doc/clsguide.tex | 34 ++++++++++++++++++++++++++++++++++
base/doc/ltnews37.tex | 14 ++++++++++++++
base/ltfinal.dtx | 36 ++++++++++++++++++------------------
4 files changed, 72 insertions(+), 18 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 5f912fee..00151c0c 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,12 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2023-04-11 Joseph Wright <Joseph.Wright at latex-project.org>
+
+ * ltfinal.dtx:
+ Add \BCPdata (gh/1035)
+ Adapt \Make<thing>case to use \BCPdata for locale info
+
2023-04-01 David Carlisle <David.Carlisle at latex-project.org>
* ltfssbas.dtx: locally reset frozen mathversions when the math
diff --git a/base/doc/clsguide.tex b/base/doc/clsguide.tex
index 1431678b..9f1c86a3 100644
--- a/base/doc/clsguide.tex
+++ b/base/doc/clsguide.tex
@@ -1138,6 +1138,40 @@ It is normally given the correct definition automatically in |\begin{document}|
and so need not be explicitly set; however, if it is explicitly made non-empty
in a class file then automatic default setting will be over-ridden.
+\subsection{Querying localisation}
+
+Localisation information is needed to customise a range of outputs. The
+\LaTeX{} kernel does not itself manage localisation, which is well-served
+by the bundles \pkg{babel} and \pkg{polyglossia}. To allow the kernel and
+other packages to access the current localisation information provided
+by \pkg{babel} or \pkg{polyglossia}, the command \cs{BCPdata} is defined
+by the kernel. The initial kernel definition absorbs one argument and
+expands to an empty value, as the kernel does not track localisation.
+However, if \pkg{babel} or \pkg{polyglossia} are loaded, it is redefined
+to takes one argument and expands to the BCP-47 information matching this
+argument. The supported arguments are the BCP-47 tag breakdowns:
+\begin{itemize}
+ \item \texttt{language} (e.g.,~\texttt{de})
+ \item \texttt{region} (e.g.,~\texttt{AT})
+ \item \texttt{scriipt} (e.g.,~\texttt{Latn})
+ \item \texttt{variant} (e.g.,~\texttt{1901})
+ \item \texttt{extension.t} (transformation, e.g.,~\texttt{en-t-ja})
+ \item \texttt{extension.u} (additional locale
+ information, e.g.,~\texttt{ar-u-nu-latn})
+ \item \texttt{extension.x} (private use area, e.g.,~\texttt{la-x-classic})
+\end{itemize}
+The information for the \emph{main} language for a document is be provided
+if these are prefixed by \texttt{main.}, e.g.~\texttt{main.language} will
+expand to the main language even if another language is currently active.
+
+In addition to the tag breakdown, the following semantic arguments are
+supported
+\begin{itemize}
+ \item \texttt{casing} The tag for case changing, e.g.~\texttt{el-x-iota}
+ could be selected rather than \texttt{el} to select a capital adscript
+ iota on uppercasing an \emph{ypogegrammeni}
+\end{itemize}
+
\section{Commands superseded for new material}
A small number of commands were introduced as part of \LaTeXe{} in the
diff --git a/base/doc/ltnews37.tex b/base/doc/ltnews37.tex
index da473763..8cc0cfb4 100644
--- a/base/doc/ltnews37.tex
+++ b/base/doc/ltnews37.tex
@@ -289,6 +289,20 @@ line.
%
\githubissue{1015}
+\subsection{\cs{BCPdata}}
+
+Improvements in the Unicode handling for case changing have highlight that
+the kernel has not to-date been locale-aware. The packages \pkg{babel} and
+\pkg{polyglossia} provide comprehensive locale support, but did not have
+an agreed unified interface to pass that information back to other code.
+Following discussion with the maintainers of those two bundles, the kernel
+now defines \cs{BCPdata} as a stub (so it is always defined), and \pkg{babel}
+and \pkg{polyglossia} will redefine it to provide the locale data. An agreed
+set of keywords mean that \cs{BCPdata} can be queried in a structured way
+by both the kernel and any other \enquote{consumer} packages.
+%
+\githubissue{1035}
+
\subsection{Improve \cs{samepage}}
The \cs{samepage} declaration sets various parameters to
diff --git a/base/ltfinal.dtx b/base/ltfinal.dtx
index 6e9209b5..bf78eb38 100644
--- a/base/ltfinal.dtx
+++ b/base/ltfinal.dtx
@@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfinal.dtx}
- [2023/03/28 v2.2z LaTeX Kernel (Final Settings)]
+ [2023/04/11 v2.3a LaTeX Kernel (Final Settings)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfinal.dtx}
@@ -1062,6 +1062,14 @@
\fi % End of reset block for 8-bit engines
% \end{macrocode}
%
+% \begin{macro}{\BCPdata}
+% \changes{v2.3a}{2023/04/11}{Command added}
+% A stub for use by \pkg{babel}, \pkg{polyglossia}, etc.
+% \begin{macrocode}
+\newcommand*\BCPdata[1]{}
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\MakeUppercase}
% \begin{macro}{\MakeLowercase}
% \begin{macro}{\MakeTitlecase}
@@ -1088,6 +1096,7 @@
% \changes{v2.2x}{2022/10/26}{Introduce optional argument for case-changing commands}
% \changes{v2.2x}{2022/10/26}{Make case changing commands language-aware}
% \changes{v2.2x}{2022/10/26}{Auto-detect \pkg{babel} locale}
+% \changes{v2.3a}{2023/04/11}{Use new generic mechanism to detect locale}
% Wrappers around the L3 case changing functions.
% |\protected| to make them mostly safe as replacements for |uppercase|
% and |\lowercase|.
@@ -1121,33 +1130,24 @@
{
\cs_set_nopar:Npn \reserved at a { }
\tl_if_blank:nTF {#2}
- { \@@text at case@aux@ }
- { \keys_set:nn { __kernel } {#2} }
- \use:c { text_ #1 case:Vn } \reserved at a {#3}
- }
-\cs_new_protected:Npn \@@text at case@aux@ { }
-\tl_gput_right:Nn \@kernel at after@begindocument
- {
- \@ifpackageloaded { babel }
{
- \@ifpackagelater { babel } { 2020-01-15 }
+ \str_set:Nx \reserved at a
+ { \BCPdata { casing } }
+ \str_if_empty:NT \reserved at a
{
- \cs_gset_protected:Npn \@@text at case@aux@
- {
- \str_set:Nx \reserved at a
- { \localeinfo* { tag.bcp47 } }
- }
+ \str_set:Nx \reserved at a
+ { \BCPdata { language } }
}
- { }
}
- { }
+ { \keys_set:nn { __kernel } {#2} }
+ \use:c { text_ #1 case:Vn } \reserved at a {#3}
}
-\exp_args_generate:n { cnx }
% \end{macrocode}
% The odd use of \emph{three} spaces here is needed as \pkg{ltcmd} uses the
% name with one and two spaces to give a `friendly' error message for a runaway
% argument: that means we can't use it here.
% \begin{macrocode}
+\exp_args_generate:n { cnx }
\cs_set_protected:Npn \reserved at a #1
{
\cs_generate_variant:cn { text_ \str_lowercase:n {#1} case:nn } { V }
More information about the latex3-commits
mailing list.