[Tex/LaTex] How do we get Polyglossia language variants to work with Biblatex bibliographies

biblatexlanguagespolyglossiaxetex

Intro

I'm testing development versions of the biblatex package (3.5) with the biber (Date modified 2016-08-03 18:31) backend. These versions add various kinds of date support (e.g. approximate dates, BCE/BC dates, datetimes).

I'm trying to get biblatex to work with polyglossia (Version 1.42.1; packaged on 2016-03-29). Specifically for the dates in bibliographic entries to be affected by the polyglossia language variant setting. Chiefly – for the day, month, and year sequence; and month names – to be language dependent.

I'm using the xetex engine.

My minimal working example (MWE) is:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
  @article{barker_2016_swiss,
    author = {Barker, Anne},
    title = {Swiss voters say no to guaranteed free money},
    date = {2016-06-06},
    journaltitle = {ABC News},
  }
\end{filecontents}

\usepackage{fontspec}

%\usepackage[british]{babel}

\usepackage{polyglossia}
\setdefaultlanguage[variant=british]{english}

\usepackage[%
  style=authoryear,%
  alldates=long,%
  language=auto,%
  autolang=langname,%
  backend=biber]{biblatex}

\addbibresource{\jobname.bib}

\begin{document}
  Current language: \currentlang. \autocite{barker_2016_swiss}
  \printbibliography
\end{document}

Result

I get:

Current language: english. (Barker 2016)
References
Barker, Anne (June 6, 2016). “Swiss voters say no to guaranteed free money”.
In: ABC News.

That is, the output seems to format the date as american english (which is the default in biblatex for later versions).

Expected

I expected, however, "Current language: british" and the date to be formatted as "6th June 2016". And indeed I get that if I change my MWE to use babel

\usepackage[british]{babel}

%\usepackage{polyglossia}
%\setdefaultlanguage[variant=british]{english}

… that is, the result is (as I would expect) …

Current language: british. (Barker 2016)
References
Barker, Anne (6th June 2016). “Swiss voters say no to guaranteed free money”.
In: ABC News.

Testing polyglossia with main language

Also if I use polyglossia with a main language setting, rather than a variant, then I get expected results. I.e. If in my MWE I have

%\usepackage[british]{babel}

\usepackage{polyglossia}
\setdefaultlanguage{french}

… then I get …

Current language : french. (Barker 2016)
Références
Barker, Anne (6 juin 2016). “Swiss voters say no to guaranteed free money”.
In : ABC News.

Problem summary

In summary, with my MWE, babel and polyglossia work as expected with biblatex when using \usepackage[*mainlanguage*]{babel} and \setdefaultlanguage{*mainlanguage*} respectively. But polyglossia doesn't work when using \setdefaultlanguage[variant=*somevariantlanguage*]{english}.

Other considerations

I've ran this past the biblatex developer (of date support), @PLK, and they wrote

I think there are some issues with Polyglossia still – there has been a release pending for some time to fix some of these issues I think.

I've tried using the LuaTex engine, with no joy.

Setting \usepackage[ ... language=british ....]{biblatex} doesn't help.

At this point it feels like a bug in Polyglossia. But before raising an issue at the Polyglossia github I'd appreciate if anyone can identify anything wrong that I'm doing. Also if anyone can reproduce this issue with a production version of biblatex/biber that'd save me the rigmarole of downgrading.

Updates:

2016-08-16 07:39: From the comments this appears to be a Polylossia issue. And so I've posted Github > Polyglossia > Exposing Polyglossia language variants to other packages like Biblatex. #154. (Edit: 2016-08-16 08:00 corrected link)

2016-08-17 19:31 My workaround will be to use babel (with thanks to @UlrikeFischer for clearing the way to it).

Best Answer

Update All multilingual features of biblatex should work as intended with biblatex v3.14 (or above) and polyglossia v1.46 (or above).

The MWE gives the expected (babel-equivalent) output now.

If you are facing any problems with polyglossia and biblatex, update your system so that you have at least biblatex 3.14 (and a matching Biber version) and polyglossia 1.46. If that does not help, please open a bug report at https://github.com/plk/biblatex/issues.

The rest of this answer below is kept for historic interest.

Just so this gets an answer.

The documentation of csquotes, which was devised by the same author as biblatex and uses similar techniques, states on p. 2

Note that polyglossia support is currently in a preliminary state because polyglossia is lacking a proper interface for other packages. In practice, this means that csquotes can detect the language (e.g., english) but not the language variant (e.g., british).

The same considerations hold for biblatex. Since polyglossia does not offer an interface to detect the language variant used, biblatex always uses only the main language. In your example that means that no matter which variant you selected, only english.lbx is loaded, so you can not get british.lbx with polyglossia.

A viable work-around for some languages is to switch to babel instead of polyglossia. For british this is certainly an option. But it might not be that easy for other languages.

Starting from biblatex 3.11 you can use \DeclareLanguageMapping{english}{british} as a workaround. This is not the intended use of \DeclareLanguageMapping, but works currently as a workaround as long as you don't use english in your document. (There is no guarantee this will continue to work as misusing the language mapping for different dialects or languages instead of stylistic versions is explicitly discouraged in the documentation.)


I have covered the difficulties with polyglossia in my answer to \DeclareLanguageMappingSuffix, inheritance, and polyglossia in biblatex from a more technical side. I won't repeat the entire explanation, but in short the problem arises as follows.

babel treats language dialects/variants basically as languages in their own right with an .ldf file and a separate identifier. polyglossia on the other hand has the concept of a main language that can be modified with attributes/options. One of the most prominent options is the variant, which as it so happens corresponds for English pretty much to the babel dialects. For German variant and spelling are needed. There is neither a binding convention as to what attributes should be used for language variants, nor is there a uniform implementation of the attributes across language modules. This makes it extremely hard for packages to detect the language variant used by polglossia and translate it into a babel language name (or vice versa).

Related Question