Biblatex warning on unsupported language in segment without citations

babelbiblatexlanguages

I have a document in English using biblatex to which I need to add an abstract in another language that is supported by babel, but not by biblatex. I thought that this would not be an issue because the abstract does not contain any citations, but I am still getting a warning when I change the language. How can I resolve this?

PS: This happens also when I pass the language=english to biblatex, but I don't want to do that anyway because I do have some non-English bibliography entries whose language is supported by biblatex.

A working example

\documentclass{article}

\usepackage[english]{babel}
% Not including 'csquotes' fires an unrelated warning.
\usepackage{csquotes}
\usepackage{biblatex}

\begin{filecontents}{bibliography.bib}
@misc{SampleEntry,
  author = {Author, Sample},
  title = {Sample Title}
}
\end{filecontents}
\addbibresource{bibliography.bib}

\begin{document}

\selectlanguage{esperanto}
Saluton!
\selectlanguage{english}

Let us cite \cite{SampleEntry}.

\printbibliography
\end{document}

The warnings

Package biblatex Warning: Language 'esperanto' not supported.

LaTeX Warning: There were undefined references.

Package biblatex Warning: Please rerun LaTeX.

Best Answer

biblatex's language support is implemented in way that

  • requires all used languages to be "known" beforehand (for babel this means, all languages you are going to use need to be announced as options to babel),
  • tries to load biblatex localisations for all announced languages even if there are no citations/bibliographies in the portion of your document typeset in that language.

That means that your document compiles with fewer warnings as soon as you make it read

\documentclass{article}
\usepackage[esperanto, english]{babel}
\usepackage{csquotes}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}

\selectlanguage{esperanto}
Saluton!
\selectlanguage{english}
Let us cite \cite{sigfridsson}.

\printbibliography
\end{document}

You still get a warning that esperanto is unsupported in biblatex, because biblatex does not have an esperanto.lbx.

You may choose to ignore this warning or you may want to look into writing a suitable esperanto.lbx (cf. What is the most appropriate way to configure biblatex for use with an unsupported language?).

There are ways to "silence" this warning, but I would not recommend that, since silencing the warning could come back to bite you if you really want Esperanto citations/bibliography entries at some point.

gusbrs suggested a simple way to make biblatex shut up in the comments: Map Esperanto to English

\DeclareLanguageMapping{esperanto}{english}

Or you can issue

\makeatletter
\protected\def\blx@langsetup#1{%
  \blx@lbxinput{#1}
    {\edef\blx@languagename{#1}}
    {}}
\makeatother

in the preamble to remove the code that generates the relevant warning.


While babel does not error if you don't pass esperanto as option and later use \selectlanguage{esperanto}, the result might be a bit off.

\documentclass{article}
\usepackage[english]{babel}

\begin{document}
\selectlanguage{esperanto}
\tableofcontents
\section{Foo}
Saluton!
\selectlanguage{english}
\tableofcontents
\section{Bar}
Lorem
\end{document}

gives

? contentsname ?

and the warning

Package babel Warning: \contentsname not set for 'esperanto'. Please,
(babel)                define it after the language has been loaded
(babel)                (typically in the preamble) with:
(babel)                \setlocalecaption{esperanto}{contents}{..}
(babel)                Reported on input line 6.

With

\documentclass{article}
\usepackage[esperanto, english]{babel}

\begin{document}
\selectlanguage{esperanto}
\tableofcontents
\section{Foo}
Saluton!
\selectlanguage{english}
\tableofcontents
\section{Bar}
Lorem
\end{document}

I get

Enhavo

I can't tell you if other more important features like hyphenation work in both settings, but this behaviour seems to suggest to me that at least at the moment, you should still announce all languages to babel as package/class options.