I've been trying to solve a bug with a custom style. It relates to .lbx
files, and specifically how they interact with babel
and polyglossia
.
Here's what I have in MWE terms:
A simple
.lbx
file, calledenglish-rev.lbx
. All it does is redefine the date macros, simply for testing purposes.A test file which contains the lines
\DeclareLanguageMapping{english}{english-rev}
and\DeclareLanguageMapping{british}{english-rev}
which as I understand it should tellbiblatex
that it should find the language-specific definitions inenglish-rev.lbx
rather than its default files.
If I compile that test the requisite number of times without any explicit use of babel
, I get what I expected: my default language (I guess) is English, and biblatex
duly loads english-rev.lbx
and we are good: the revised date macro is used.
Similarly, if I load babel
with an explicit choice of english
, it seems to work.
But what I really want is to deal with british
. Now if I \DeclareLanguageMapping{british}{english-rev}
and load babel
with a chosen language of british
, it doesn't work. My log file shows that english-rev
is duly being loaded:
(./english-rev.lbx
Package biblatex Info: Trying to load language 'english' -> 'english-rev'...
Package biblatex Info: ... file 'english-rev.lbx' found.
(./english-rev.lbx
Package biblatex Info: Trying to load language 'english'...
Package biblatex Info: ... file 'english.lbx' found.
(/usr/local/texlive/2016/texmf-dist/tex/latex/biblatex/lbx/english.lbx
File: english.lbx 2016/05/14 v3.4 biblatex localization (PK/JW/AB)
)))
That I think is all as I would hope: english-rev.lbx
should load some definitions from english.lbx
.
But then it goes back and loads the (default) british.lbx
again:
Package biblatex Info: Trying to load language 'british'...
Package biblatex Info: ... file 'british.lbx' found.
(/usr/local/texlive/2016/texmf-dist/tex/latex/biblatex/lbx/british.lbx
File: british.lbx 2016/05/14 v3.4 biblatex localization (PK/JW/AB)
)
And in doing so (I'm assuming) it "clobbers" the revised definitions from the revised file.
Does anyone know what's happening or what I'm doing wrong. I'm obviously missing something simple, but I don't know what it is. I get the same results with polyglossia
.
The example below includes filecontents
to generate a sample .bib
file and the revised .lbx
file. What it should do is show "(LONG DATE)" instead of 2008 in the bibliography, not any actual date. Obviously that is simply for testing purposes: what I really want is a different date format -- but my concern right now is simply to induce biblatex
to use the .lbx
file I want it to.
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{testbib.bib}
@article{booky,
author = "A N Author",
title = "A Title",
journaltitle = "Some Journal",
date = "2008-11-11",
}
\end{filecontents}
\begin{filecontents}{english-rev.lbx}
\InheritBibliographyExtras{english}
\DeclareBibliographyExtras{%
\protected\def\mkbibdatelong#1#2#3{% %
LONG-DATE}
\protected\def\mkbibdateshort#1#2#3{%
SHORT DATE}
}
\InheritBibliographyStrings{english}
\endinput
\end{filecontents}
%\usepackage[british]{babel} <-- If this is uncommented, it breaks
\usepackage{csquotes}
\usepackage[style=authortitle]{biblatex}
\DeclareLanguageMapping{english}{english-rev}
\DeclareLanguageMapping{british}{english-rev}
\addbibresource{testbib.bib}
\begin{document}
\cite{booky}
\printbibliography
\end{document}
biblatex
cares about the inheritance or the name of the file, or both, or why! I'd love someone to explain why it works, but I'll happily take working without comprehension. If you'd like to make it an answer ....lbx
loading, the planned changes should resolve the weird behaviour here, I hope. See github.com/plk/biblatex/issues/677. Testing and comments are very much appreciated since the changes are to a critical part ofbiblatex
's infrastructure.