Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Biblatex fails to detect languages loaded with \babelprovide #1362

Open
Mycroft-47 opened this issue Jun 9, 2024 · 9 comments
Open

Biblatex fails to detect languages loaded with \babelprovide #1362

Mycroft-47 opened this issue Jun 9, 2024 · 9 comments
Labels
localisation concerns lbx files or localisation in general

Comments

@Mycroft-47
Copy link

As suggested by @u-fischer on stackexchange, I'm opening this issue to report a problem with biblatex failing to detect languages loaded using \babelprovide from the babel package.

Description
I'm experiencing a persistent warning Please rerun LaTeX when using biblatex in a multilingual document with babel (check this .log file). The warning only appears when I use a macro or environment that requires switching to a non-main language, specifically when using the otherlanguage environment with a non-main language as an option.

Here's a minimal example that reproduces the warning:

\documentclass{report}

\usepackage{babel}
\babelprovide[import=fr, main]{french}
\babelprovide[import=en]{english}

\usepackage{csquotes}
\usepackage{biblatex}

\addbibresource{biblatex-examples.bib}

\begin{document}

Donec varius orci eget risus.\cite{bertram}

\begin{otherlanguage}{english}
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
\end{otherlanguage}

\printbibliography

\end{document}
@moewew
Copy link
Collaborator

moewew commented Jun 9, 2024

Oh, this is going to be a bigger project.

I haven't yet looked at \babelprovide, which is a completely different way of loading languages than previously in babel (it doesn't use .ldf files, instead it uses .ini files), in depth. Unfortunately, a quick look suggests that none of our existing code can be used since one can do shenanigans of the following sort (where we load the Dutch language to define a language called english).

\listfiles
\documentclass{article}

\usepackage{babel}
\babelprovide[import=fr, main]{french}
\babelprovide[import=nl]{english}

\usepackage{csquotes}
\usepackage{biblatex}

\addbibresource{biblatex-examples.bib}

\begin{document}

Donec varius orci eget risus.\cite{bertram} \today

\begin{otherlanguage}{english}
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \today
\end{otherlanguage}

\today

\printbibliography

\end{document}

@u-fischer
Copy link

one can do shenanigans of the following sort

We discussed and agreed with the maintainer of the language package to provide data about the languages in bcp format. latex3/latex2e#1035. The support is not fully complete (e.g. babel currently errors on the tag keyword), but the command is in the current LaTeX and the language key word is reliable and you can use it to detect languages:

\documentclass{article}

\usepackage{babel}
\babelprovide[import=fr, main]{quack}
\babelprovide[import=nl]{english}

\begin{document}
\today 

\languagename, \BCPdata{language}, \BCPdata{region}, \BCPdata{script}, 
%\BCPdata{tag} (errors in babel)

\begin{otherlanguage}{english}
\today

\languagename, \BCPdata{language}, \BCPdata{region}, \BCPdata{script}, 

\BCPdata{main.language}, \BCPdata{main.region}, \BCPdata{main.script}

\end{otherlanguage}

\end{document}

gives

image

If you miss something (e.g. a list of loaded languages) I would suggest to discuss that with the package maintainers so that they provide that in a uniform way.

@moewew
Copy link
Collaborator

moewew commented Jun 10, 2024

Thanks, that looks like a good start. I think our problem though is that at the moment we build everything upon babel (classic babel that is) language identifiers. At the moment I can't see a way to obtain this name for .ini files (I can see name.babel in some of them, but it's not documented in the manual and \localeinfo{name.babel} errors).

polyglossia has \babelname and \mainbabelname to access the babel name of languages used etc.

But maybe we should be moving away from babl identifiers and go for BC47. See also #961, #160, but of course that requires careful consideration...

@jbezos
Copy link

jbezos commented Jun 14, 2024

Why not to use the basic syntax, namely,

\documentclass[english,french]{report}
\usepackage{babel}

(Or, if you want ini files, \usepackage[provide*=*]{babel}.)
That way, languages can be detected by other packages.

It's a real question, to know if I can improve something.

@pauloney
Copy link
Collaborator

pauloney commented Jun 14, 2024 via email

@jbezos
Copy link

jbezos commented Jun 14, 2024

\babelprovide is not a general alternative to be used in any context and in any circumstance. From the manual: “In other words, \babelprovide is mainly meant as alternative when the ldf does not exists or does not work as expected, and for secondary tasks.” Particularly in French, the ldf is much preferred (https://latex3.github.io/babel/guides/locale-french.html). But my experience tells me users tend to use packages in quite ‘creative’ ways, which is great, but I’d like to know why, to improve them.

@u-fischer
Copy link

@jbezos

Why not to use the basic syntax, namely,

biblatex can not control what user do, and user use all syntax variants as they are examples of all of them everywhere (some of them e.g. using ini-files as intended to avoid problems with old ldf like the ones for arabic or hebrew).

So from the biblatex view they need reliable interface to detect the main and the current language for all these variants. And they need reliable interfaces to detect how to select a language, e.g. if the bib-file contains langid=french biblatex must know what do even if the user does something like \babelprovide[import=fr, main]{quack}

@pauloney
Copy link
Collaborator

pauloney commented Jun 15, 2024 via email

@cfr42
Copy link

cfr42 commented Jun 18, 2024

\babelprovide is not a general alternative to be used in any context and in any circumstance. From the manual: “In other words, \babelprovide is mainly meant as alternative when the ldf does not exists or does not work as expected, and for secondary tasks.”

Judging by questions on SE, I do not think this is how users are treating this facility. And the manual is not clear enough on this point that I've felt confident telling somebody to prefer the old interface, even though I was well aware of that description. If you mean, 'do not use unless ...', it would be better to say so, imho. (Still people will use it, of course. Whatever you do, people will still do that.)

@moewew moewew added the localisation concerns lbx files or localisation in general label Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
localisation concerns lbx files or localisation in general
Projects
None yet
Development

No branches or pull requests

6 participants