View on GitHub

Babel

The multilingual framework to localize LaTeX, LuaLaTeX, XeLaTeX

What’s new in babel 3.43

2020-04-28

Autoloading based on BCP 47 codes

The most relevant new feature is the loading on the fly based on BCP 47 codes. It must be activated explicitly with \babeladjust, because it is meant for special tasks (most document are mainly monolingual). Mapping from BCP 47 codes to locale names are not hardcoded in babel. Instead the data is taken from the ini files, which means currently about 250 275 tags are already recognized

\documentclass{article}

\usepackage[danish]{babel}

\babeladjust{ autoload.bcp47 = on }

\begin{document}

\today

\selectlanguage{fr-CA}

\today

\end{document}

Babel performs a simple lookup in the following way: fr-Latn-FRfr-Latnfr-FRfr. Languages with the same resolved name are considered the same. Case is normalized before, so that fr-latn-frfr-Latn-FR. If a tag and a name overlap, the tag takes precedence (for example, lu is considered lubakatanga).

Currently the locales loaded are based on the ini files and decoupled from the main 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 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:

Fixes

Changes in ini locale files

Macros in \selectlanguage

Since its beginnings, an alternative syntax was allowed in the argument of \selectlanguage, so that, say, \selectlanguage{\dutch} is the same as \selectlanguage{dutch}. Now, if the passed macro doesn’t match a loaded language, it’s treated as expected, that is, the string contained in the macro will be the name of the language to be selected. For example, the following piece of code will select dutch

\newcommand{\mylang}{dutch}
\selectlanguage{\mylang}

The alternative syntax is deprecated. not recommended (there will be an ‘info’ about this).

Reorganization of the internal code

This change may affect a few packages.