4

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:

  1. A simple .lbx file, called english-rev.lbx. All it does is redefine the date macros, simply for testing purposes.

  2. A test file which contains the lines \DeclareLanguageMapping{english}{english-rev} and \DeclareLanguageMapping{british}{english-rev} which as I understand it should tell biblatex that it should find the language-specific definitions in english-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}
3
  • 3
    Imho you will have to create a "british-rev" (and an "american-rev") which inherit their strings from british, at least this is how biblatex-apa does it. Mar 11 '17 at 18:00
  • Ulrike, that seems to work! I have to admit that's a huge surprise; I cannot for the life of me understand why it should, and it's not clear to me whether 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 ... Mar 11 '17 at 20:40
  • 1
    We are currently trying to overhaul .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 of biblatex's infrastructure.
    – moewe
    Jan 30 '18 at 12:02
1

biblatex 3.11 has overhauled the .lbx loading (https://github.com/plk/biblatex/pull/702) so that the example in your question now gives the expected results.

In earlier versions biblatex would not follow up on language mapping aliases when loading nested .lbx files and in other weird situations when an alias had been resolved before. The .lbx loading should hopefully be more robust now.

The changes have been tested as extensively as possible with the resources available and calls for testing before the release on comp.text.tex have not unearthed any new problems. In case you happen to stumble upon a problem related to language loading, do not hesitate to report the issue at https://github.com/plk/biblatex/issues

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.