plk / biblatex

biblatex is a sophisticated bibliography system for LaTeX users. It has considerably more features than traditional bibtex and supports UTF-8
518 stars 118 forks source link

hyphenation warning with language variants and polyglossia #1381

Open jspitz opened 2 months ago

jspitz commented 2 months ago

From https://github.com/reutenauer/polyglossia/issues/663:

I have a issue with a document, using the austrian language. Here is a minimal example file:

\documentclass{scrreprt}

\usepackage{polyglossia}
\setdefaultlanguage[variant=austrian]{german}
\usepackage[backend=biber]{biblatex}

\begin{document}
Hier steht Inhalt. Welcher jährlich mehr wird.
\end{document}

The run of lualatex gives the following warnings:

(/usr/share/texmf-dist/tex/latex/biblatex/lbx/german.lbx
Module polyglossia Warning: Language naustrian not found in language.dat.lua on
 input line 580

Package biblatex Warning: No hyphenation patterns for 'naustrian' on input line
 580.

) (/usr/share/texmf-dist/tex/latex/biblatex/lbx/german.lbx
Module polyglossia Warning: Language naustrian not found in language.dat.lua on
 input line 580

Package biblatex Warning: No hyphenation patterns for 'naustrian' on input line
 580.

)
Module polyglossia Warning: Language naustrian not found in language.dat.lua on
 input line 20

Package biblatex Warning: No hyphenation patterns for 'naustrian' on input line
 20.

)

The same file without austrian variant \setdefaultlanguage{german} gives no warnings. Versions are LuaHBTeX 1.18.0, polyglossia 2024/03/07 v2.1, biblatex 2023/03/05 v 3.19


AFAICS this is due \DeclareHyphenationExceptions. Interestingly, replacing them with \DefineHyphenationExceptions{ngerman} does not seem to fix it.

(These exceptions themselves are disputable in the lbx files; but I think these go back to plehmann)

jspitz commented 4 days ago

A fix for this would be to use polyglossia's own hyphenation exception macro which takes care for aliases:

diff --git a/tex/latex/biblatex/biblatex.sty b/tex/latex/biblatex/biblatex.sty
index 6495db6b..1e37447d 100644
--- a/tex/latex/biblatex/biblatex.sty
+++ b/tex/latex/biblatex/biblatex.sty
@@ -562,6 +562,9 @@
     {\ifundef\xpg@ifdefined
        {}
        {\def\blx@ifhyphenationundef#1#2#3{\xpg@ifdefined{#1}{#3}{#2}}}%
+     \ifundef\pghyphenation
+       {}
+       {\def\blx@hyphexcept#1#2{\pghyphenation{#1}{#2}}}%
      % This is required for languages which are never explicitly selected
      % \xpg@bloaded is not defined in polyglossia < v1.45
      \ifundef\xpg@bloaded

Also, duplicate \DeclareHyphenationExceptions in language variant *.ldf files can go if the files they inherit have the same exceptions (such as in the austrian case). The exceptions are already set from the inherited files.

I could take care about that once #1392 is resolved and I can make new PRs.