# How do we get Polyglossia language variants to work with Biblatex bibliographies?

## 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}

\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.

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).

• I see the problem in a current biblatex too. I'm not sure if I would call it a bug in polyglossia, it is more missing (a lot) code. Polyglossias gloss-english.ldf changes \today for british but beside this it doesn't seem to do anything to adapt date formats or to offer a sensible interface for packages like biblatex. Why are you using it instead of the (working) babel? – Ulrike Fischer Aug 15 '16 at 9:11
• Indeed, it "just" seems to be the problem that language variant detection with polyglossia does not really work in biblatex. (The csquotes package, which was devised by the same author as biblatex, has a footnote: "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).") – moewe Aug 15 '16 at 13:35
• I think I submitted a patch for polyglossia to make it report the variant but I don't think it ever made it into a new release. It was a while ago. – PLK Aug 15 '16 at 16:25
• @UlrikeFischer I've updated the post to link to a github polyglossia issue I've created. Thanks for the test. I'm using polyglossia over the working babel only because polyglossia is made out, both in the babel and polyglossia documentation, to supercede babel for the Xetex and LuaTex engines (and I like the unicode support of either engine). I'm open to have that understanding challenged. In any case it looks like I will have to use babel until the polyglossia variant language issue is addressed. – John Bentley Aug 15 '16 at 21:54
• The core of babel is nowadays "luatex and xelatex ready." There are imho still a number of language files which won't work and some languages are missing. But english (and french and german) works fine and here I would currently prefer babel over polyglossia -- also as bugs are corrected faster in babel. – Ulrike Fischer Aug 15 '16 at 22:04

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).

I ended up creating, as the easiest solution, a Polyglossia gloss-australian.ldf file (see SE question 166739), which is just gloss-english.ldf with a few minor tweaks, so that the language australian would flow into Biblatex and the dates come out in Australian format.

Decoupling the administrative processing (what is the default setting for a language/dialect cluster?) from the operational processing (what are the specific settings for each variant/dialect?) could be the way to go, for easier maintenance and usage, and so on.

Similar, as I see it, topologically speaking, to how the Strafgesetzbuch is organized into a General part and a Special or Specific part, compared with how higgledy-piggledy the statutes are here in Australia. Keeping the relationship between objects separate from the objects themselves, is another way of phrasing it.

There's not enough code in gloss-english.ldf at the moment to deal with processing half a dozen sets of (really independent) settings (variants), and setting up the default processing as well, all in, in effect, one if statement. Valiant attempt, though. And a good start.

Next step on the Australian side is being able to do all three date formats in the same document/bibliography, and further, keeping original formatting when quoting/citing from other jurisdictions and/or styles.