reutenauer / polyglossia

An alternative to Babel for XeLaTeX and LuaLaTeX
http://www.ctan.org/pkg/polyglossia
MIT License
185 stars 52 forks source link

Reuse babelshorthands from other languages #604

Closed skurzinz closed 4 months ago

skurzinz commented 9 months ago

Babel offers a nifty feature that allows one to use shorthands defined for other languages, such as

\addto\extrasenglish{\languageshorthands{ngerman}}%a babel feature as described in babel.pdf page 14.

Is it possible to provide something similar to polyglossia?

jspitz commented 9 months ago

There is no officially supported way currently. In fact, \languageshorthands is defined in babelsh.def, so it is probably just a matter of sitting down and trying to get it to work in the context of polyglossia.

It is possible to do it generally with some more clumsy definition, e.g. for the above:

% !TeX TS-program = xelatex
\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{german}
\makeatletter
\addto\blockextras@english{\german@shorthands}
\addto\inlineextras@english{\german@shorthands}
\addto\noextras@english{\nogerman@shorthands}
\makeatother
\begin{document}
    Test test"=test
\end{document}
jspitz commented 6 months ago

The next release will introduce a dedicated macro \inheritbabelshorthands{<source language>}{<target language>} for the purpose described here.

jspitz commented 6 months ago

FWIW I have also added a companion command \usebabelshorthands{<language>} that allows to activate the shorthands of a loaded language inline (or deactivate shorthands via \usebabelshorthands{none}). This more or less mimics what \languageshorthands does in babel.

Edit: \startbabelshorthands has been renamed to \usebabelshorthands