diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/babel/babel.dtx | 160 |
1 files changed, 126 insertions, 34 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index b21384f6a02..745cf114068 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -31,7 +31,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2021/04/07 v3.57 The Babel package] +\ProvidesFile{babel.dtx}[2021/04/26 v3.58 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -80,6 +80,13 @@ \usepackage{multicol} \usepackage{color,colortbl} \usepackage[linkcolor=blue,urlcolor=blue,colorlinks=true]{hyperref} +\hypersetup{% + pdfsubject={LaTeX Multilingual documents and localization for pdfTeX, LuaTex and + XeTeX.}, + pdfauthor={Johannes Braams, Javier Bezos}, + pdftitle={Babel}, + pdfkeywords={TeX, LaTeX, pdfTeX, LuaTeX, XeTeX, internationalization, + localization}} \newcommand\New[1]{% \colorbox[rgb]{.92, .86, .73}{New #1}\enspace\ignorespaces} \definecolor{thered} {rgb}{0.65,0.04,0.07} @@ -89,6 +96,7 @@ \makeatletter \def\@begintheorem#1#2{% \list{}{}% + \small \global\advance\@listdepth\m@ne \item[{\sffamily\bfseries\color{messages}\hspace*{1.3em}% \MakeUppercase{#1}}]}% @@ -238,9 +246,9 @@ Xe\largetex \begin{description} \item[\sffamily\color{messages}What is this document about?] This user guide focuses on internationalization and localization with \LaTeX{} -and \pdftex, \xetex{} and \luatex{} with the \babel{} package. There are -also some notes on its use with Plain \TeX. Part II describes the code, -and usually it can be ignored. +and \pdftex, \xetex{} and \luatex{} with the \babel{} package. There +are also some notes on its use with e-Plain and pdf-Plain \TeX . Part II +describes the code, and usually it can be ignored. \item[\sffamily\color{messages}What if I’m interested only in the latest changes?] Changes and new features with relation to version 3.8 @@ -631,7 +639,7 @@ modifiers are a more general mechanism. \subsection{Plain} -In Plain, load languages styles with |\input| and then use +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 @@ -640,9 +648,10 @@ In Plain, load languages styles with |\input| and then use \begin{warning} Not all languages provide a |sty| file and some of them are not - compatible with Plain.\footnote{Even in the \babel{} kernel there - were some macros not compatible with plain. Hopefully these issues - have been fixed.} + compatible with those formats. Please, refer to + \href{https://github.com/latex3/babel/blob/% + master/news-guides/guides/using-babel-with-plain.md}{Using babel with + Plain} for further details. \end{warning} \subsection{Basic language selectors} @@ -1298,7 +1307,7 @@ required for a locale. |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 Language Data Repository, which was +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). @@ -1408,7 +1417,7 @@ need to set explicitly the script to either |deva| or |dev2|, eg: \begingroup \setmonofont[Script=Lao,Scale=MatchLowercase]{DejaVu Sans Mono} \begin{verbatim} -\babelprovide[import,hyphenrules=+]{lao} +\babelprovide[import, hyphenrules=+]{lao} \babelpatterns[lao]{1ດ 1ມ 1ອ 1ງ 1ກ 1າ} % Random \end{verbatim} \endgroup @@ -2490,6 +2499,9 @@ for example: In other engines it just suppresses hyphenation (because the pattern list is empty). +\New{3.58} Another special value is |unhyphenated|, which activates a +line breking mode that allows spaces to be stretched to arbitrary amounts. + \Describe{main}{} This valueless option makes the language the main one (thus overriding that set when \babel\ is loaded). Only in newly defined languages. @@ -3034,11 +3046,13 @@ in future releases.) \begingroup \def\trans#1#2#3{% - \vspace{1mm}% - \parbox[t]{2.4cm}{\strut#1}% - \parbox[t]{4.2cm}{\strut\ttfamily#2}% + \vspace{1.5mm}% + \parbox[t]{2.2cm}{\raggedright\strut#1}% + \hspace{2mm}% + \parbox[t]{4.0cm}{\strut\ttfamily#2}% + \hspace{2mm}% \parbox[t]{6.6cm}{\strut#3}\par} -\bigskip\hrule\nobreak\vspace{1mm} +\bigskip\hrule\nobreak\vspace{.5mm} % \strut\hfil Transforms % \medskip\hrule\nobreak @@ -3052,18 +3066,37 @@ devised by Yannis Haralambous for \textsf{dad} (simple and recommended way to make these transformations (the best way is with OTF features), but it can get you out of a hurry.} +\trans{Czech, Polish, Portuguese, Slovak, +Spanish}{hyphen.repeat}{Explicit hyphens behave like +|\string\babelhyphen|\allowbreak|\{repeat\}|.} + +\trans{Czech, Polish, Slovak}{oneletter.nobreak}{Converts a space after +a non-syllabic preposition or conjunction into a non-breaking space.} + \trans{Greek}{diaeresis.hyphen}{Removes the diaeresis above iota and upsilon if hyphenated just before. It works with the three variants.} -\trans{Hindi}{transliteration.hk}{The Harvard-Kyoto system to romanize -Devanagari.} +\trans{Hindi, Sanskrit}{transliteration.hk}{The Harvard-Kyoto system to +romanize Devanagari.} + +\trans{}{punctuation.space}{Inserts a space before the following +four characters: \textit{!?:;}\,.} \trans{Hungarian}{digraphs.hyphen}{Hyphenates the long digraphs \textit{ccs}, \textit{ddz}, \textit{ggy}, \textit{lly}, \textit{nny}, \textit{ssz}, \textit{tty} and \textit{zzs} as \textit{cs-cs}, \textit{dz-dz}, etc.} +\trans{Norsk}{doubleletter.hyphen}{Hyphenates the doble-letter groups +\textit{bb}, \textit{dd}, \textit{ff}, \textit{gg}, \textit{ll}, +\textit{mm}, \textit{nn}, \textit{pp}, \textit{rr}, \textit{ss}, +\textit{tt} as \textit{bb-b}, \textit{dd-d}, etc.} + +\trans{Serbian}{transliteration.gajica}{(Note |serbian| with |ini| +files refers to the Cyrillic script, which is here the target.) The +standard system devised by Ljudevit Gaj.} + \vspace{2mm}\hrule\nobreak \endgroup @@ -3147,6 +3180,21 @@ This feature is activated with the first |\babelposthyphenation| or \end{verbatim} \end{example} +\begin{note} + With \luatex{} there is another approach to make text + transformations, with the function |fonts.handlers.otf.addfeature|, + which adds new features to an OTF font (substitution and + positioning). These features can be made language-dependent, and + \babel{} by default recognizes this setting if the font has been + declared with |\babelfont|. The \textit{transforms} mechanism + supplements rather than replaces OTF features. + + With \xetex{}, where \textit{transforms} are not available, there is + still another approach, with font mappings, mainly meant to perform + encoding conversions and transliterations. Mappings, however, are + linked to fonts, not to languages. +\end{note} + \subsection{Selection based on BCP 47 tags} \label{bcp47} @@ -4910,8 +4958,8 @@ help from Bernd Raichle, for which I am grateful. % \section{Tools} % % \begin{macrocode} -%<<version=3.57>> -%<<date=2021/04/07>> +%<<version=3.58>> +%<<date=2021/04/26>> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They @@ -7104,8 +7152,10 @@ help from Bernd Raichle, for which I am grateful. \count@#1\relax \def\bbl@elt##1##2##3##4{% \ifnum\count@=##2\relax - \bbl@info{\string#1 = using hyphenrules for ##1\\% - (\string\language\the\count@)}% + \edef\bbl@tempa{\expandafter\@gobbletwo\string#1}% + \bbl@info{Hyphen rules for '\expandafter\@gobble\bbl@tempa' + set to \expandafter\string\csname l@##1\endcsname\\% + (\string\language\the\count@). Reported}% \def\bbl@elt####1####2####3####4{}% \fi}% \bbl@cs{languages}% @@ -7597,14 +7647,23 @@ help from Bernd Raichle, for which I am grateful. \fi \fi \let\bbl@hymapsel\@cclv - % hyphenation - select patterns - \bbl@patterns{#1}% - % hyphenation - allow stretching with babelnohyphens - \ifnum\language=\l@babelnohyphens + % hyphenation - select rules + \ifnum\csname l@\languagename\endcsname=\l@unhyphenated + \edef\bbl@tempa{u}% + \else + \edef\bbl@tempa{\bbl@cl{lnbrk}}% + \fi + \bbl@xin@{/u}{/\bbl@tempa}% + \ifin@ + % 'unhyphenated' = allow stretching + \language\l@unhyphenated \babel@savevariable\emergencystretch \emergencystretch\maxdimen \babel@savevariable\hbadness \hbadness\@M + \else + % other = select patterns + \bbl@patterns{#1}% \fi % hyphenation - mins \babel@savevariable\lefthyphenmin @@ -8877,10 +8936,13 @@ help from Bernd Raichle, for which I am grateful. % or |\normal@char|\m{char} in the case of |\bbl@deactivate|. % % \begin{macrocode} +\chardef\bbl@activated\z@ \def\bbl@activate#1{% + \chardef\bbl@activated\@ne \bbl@withactive{\expandafter\let\expandafter}#1% \csname bbl@active@\string#1\endcsname} \def\bbl@deactivate#1{% + \chardef\bbl@activated\tw@ \bbl@withactive{\expandafter\let\expandafter}#1% \csname bbl@normal@\string#1\endcsname} % \end{macrocode} @@ -9152,12 +9214,25 @@ help from Bernd Raichle, for which I am grateful. {\bbl@error {I cannot switch `\string#2' on or off--not a shorthand}% {This character is not a shorthand. Maybe you made\\% - a typing mistake? I will ignore your instruction}}% - {\ifcase#1% + a typing mistake? I will ignore your instruction.}}% + {\ifcase#1% off, on, off* \catcode`#212\relax \or \catcode`#2\active + \bbl@ifunset{bbl@shdef@\string#2}% + {}% + {\bbl@withactive{\expandafter\let\expandafter}#2% + \csname bbl@shdef@\string#2\endcsname + \bbl@csarg\let{shdef@\string#2}\relax}% + \ifcase\bbl@activated\or + \bbl@activate{#2}% + \else + \bbl@deactivate{#2}% + \fi \or + \bbl@ifunset{bbl@shdef@\string#2}% + {\bbl@withactive{\bbl@csarg\let{shdef@\string#2}}#2}% + {}% \csname bbl@oricat@\string#2\endcsname \csname bbl@oridef@\string#2\endcsname \fi}% @@ -10628,8 +10703,8 @@ help from Bernd Raichle, for which I am grateful. \chardef\l@english\z@ \fi % The following is used to cancel rules in ini files (see Amharic). -\ifx\l@babelnohyhens\@undefined - \newlanguage\l@babelnohyphens +\ifx\l@unhyphenated\@undefined + \newlanguage\l@unhyphenated \fi % \end{macrocode} % @@ -10712,6 +10787,7 @@ help from Bernd Raichle, for which I am grateful. \let\bbl@KVP@script\@nil \let\bbl@KVP@language\@nil \let\bbl@KVP@hyphenrules\@nil + \let\bbl@KVP@linebreaking\@nil \let\bbl@KVP@mapfont\@nil \let\bbl@KVP@maparabic\@nil \let\bbl@KVP@mapdigits\@nil @@ -11112,7 +11188,7 @@ help from Bernd Raichle, for which I am grateful. % Load the basic parameters (ids, typography, counters, and a few % more), while captions and dates are left out. But it may happen some % data has been loaded before automatically, so we first discard the -% saved values. +% saved values. (TODO. But preserving previous values would be useful.) % % \begin{macrocode} \def\bbl@load@basic#1{% @@ -12089,6 +12165,14 @@ help from Bernd Raichle, for which I am grateful. \BabelEnsureInfo} \@namedef{bbl@ADJ@bcp47.toname@off}{% \bbl@bcptonamefalse} +\@namedef{bbl@ADJ@prehyphenation.disable@nohyphenation}{% + \directlua{ Babel.ignore_pre_char = function(node) + return (node.lang == \the\csname l@nohyphenation\endcsname) + end }} +\@namedef{bbl@ADJ@prehyphenation.disable@off}{% + \directlua{ Babel.ignore_pre_char = function(node) + return false + end }} % TODO: use babel name, override % % As the final task, load the code for lua. @@ -12875,8 +12959,8 @@ help from Bernd Raichle, for which I am grateful. \bbl@csarg\gdef{xeipn@\languagename}% {\XeTeXlinebreakpenalty #1\relax}} \def\bbl@provide@intraspace{% - \bbl@xin@{\bbl@cl{lnbrk}}{s}% - \ifin@\else\bbl@xin@{\bbl@cl{lnbrk}}{c}\fi + \bbl@xin@{/s}{/\bbl@cl{lnbrk}}% + \ifin@\else\bbl@xin@{/c}{/\bbl@cl{lnbrk}}\fi \ifin@ \bbl@ifunset{bbl@intsp@\languagename}{}% {\expandafter\ifx\csname bbl@intsp@\languagename\endcsname\@empty\else @@ -13581,7 +13665,7 @@ help from Bernd Raichle, for which I am grateful. \def\bbl@provide@intraspace{% \bbl@ifunset{bbl@intsp@\languagename}{}% {\expandafter\ifx\csname bbl@intsp@\languagename\endcsname\@empty\else - \bbl@xin@{\bbl@cl{lnbrk}}{c}% + \bbl@xin@{/c}{/\bbl@cl{lnbrk}}% \ifin@ % cjk \bbl@cjkintraspace \directlua{ @@ -13867,7 +13951,11 @@ end end Babel.fetch_subtext = {} - + + Babel.ignore_pre_char = function(node) + return (node.lang == \the\l@nohyphenation) + end + &% Merging both functions doesn't seen feasible, because there are too &% many differences. Babel.fetch_subtext[0] = function(head) @@ -13891,7 +13979,11 @@ end if lang == locale or lang == nil then lang = lang or locale - word_string = word_string .. unicode.utf8.char(item.char) + if Babel.ignore_pre_char(item) then + word_string = word_string .. Babel.us_char + else + word_string = word_string .. unicode.utf8.char(item.char) + end word_nodes[#word_nodes+1] = item else break |