# What is the most appropriate way to configure biblatex for use with an unsupported language?

From time to time, I need to typeset Welsh. Sometimes, I need to typeset citations and bibliographies in Welsh. I think that last time I did this, I may still have been using BibTeX although I am honestly not sure. In any case, my entire work-flow now uses biber and biblatex...

I found lockstep's excellent answer on changing the names of things, including the names of things used by biblatex. However, that cannot deal with the case of an unsupported language.

Suppose that I want to typeset a document in Welsh:

\documentclass[a4paper,welsh]{article}

\usepackage{babel}
\usepackage[utf8]{inputenc}% welsh needs utf8x but biblatex doesn't like it
\usepackage[T1]{fontenc}% not great for Welsh but the best pdfTeX can do
\usepackage{csquotes}% doesn't like Welsh though biblatex likes csquotes on account of babel...
\usepackage[backend=biber]{biblatex}
\bibliography{biblatex-examples}

\title{Fy Nogfen}
\author{Rhywun}

\begin{document}
\maketitle
\tableofcontents
\section{Cyntaf}
\autocite{westfahl:space}

\printbibliography

\end{document}


There are multiple problems in such a case. (One is that I need utf8x but can't use it on account of biblatex. Another is that I need utf8x at all. Another is that biblatex likes csquotes but csquotes doesn't do Welsh. But these are irrelevant to this question.)

The output is as follows:

Note that the use of the English citation is just so this is easy to reproduce. Obviously, the content of the reference might well be in Welsh. (Though it might be in English, too.)

As can be seen, while elements of the document controlled by babel are handled correctly, those under the control of biblatex are not. However, I cannot simply modify the solution offered by lockstep for changing strings to customised English variants. That is, I can't just use a Welsh version of

\DefineBibliographyStrings{english}{%
bibliography = {Works Cited},
references = {Works Cited},
}


because biblatex has never heard of it.

What is the most appropriate way to configure biblatex for use with an unsupported language?

• Since the comment about utf8x is just an aside: It seems to be regarded as the best option to use \usepackage[utf8]{inputenc} instead. For the problems with csquotes, \DeclareQuoteStyle is needed (see quotation mark (quotation sign) xelatex + polyglossia + csquotes, for example), having read Wikipedia on the subject though, I'd just go with \DeclareQuoteAlias[british]{english}{welsh}. – moewe Sep 15 '14 at 15:21
• @moewe Thanks. That's helpful about the quotes. I know you can avoid utf8x and if I end up having to define the lot using utf8 to get a document to compile then I will but I'm too lazy to do so until I have to ;) since it basically means adding support for all relevant accents on two more vowels in two cases. However, if I could solve the biblatex problem, then it would definitely be worth doing that properly since that would allow me to avoid the utf8x/biblatex conflict. That is, the biblatex issue is the really the one I'm concerned with and not sure how to tackle. – cfr Sep 15 '14 at 16:05
• Mhh, I was just getting the minor questions out of the way to concentrate on the big biblatex question. – moewe Sep 15 '14 at 16:13
• i had assumed that you were using utf8x for the extra accented vowels (e.g., \^w) -- which is in row 3 in my (ancient) copy of iso/iec 10646-1. is this not the case -- i.e., does the utf8 encoding definition cope with such letters? – wasteofspace Sep 19 '14 at 11:05
• @wasteofspace No. utf8 does not support circumflexes on either 'w' or 'y'. However, utf8x cannot be used with biblatex as far as I can tell. There are ways around this, though, since you can tell utf8 about the additional characters. – cfr Sep 19 '14 at 20:56

First of all, you might want to have a look at Checklist for submitting a new .lbx file on the GitHub Wiki for biblatex and a real-world example of the process; the relevant part of the biblatex documentation is §4.9 Localization Modules, pp. 215-225.

The process of adding support for a language supported by babel to biblatex is pretty much straight-forward.

One just needs to create an .lbx file (named <language>.lbx where <language> is babel's language identifier, so in our case that's welsh.lbx), place it somewhere it can be found and put the translations of the bibstrings there.

There are two sections/parts in an .lbx file (1) BibliographyExtras and (2) BibliographyStrings.

The BibliographyExtras control things like date format, Oxford comma, name delimiters, use of dashes (--- vs -- etc. pp.), while BibliographyStrings are for the translations proper.

My stub for welsh.lbx looks like this (it inherits the extras from the british style; the translations are just what I picked up in a quick internet research - I doubt they are correct)

\ProvidesFile{welsh.lbx}[2014/09/15 Welsh language stub]

\InheritBibliographyExtras{british}

\DeclareBibliographyStrings{%
bibliography     = {{Llyfryddiaeth}{Llyfryddiaeth}},
in               = {{yn}{yn}},
}

\endinput


The easiest way to make create a new .lbx file is probably by taking one in a language you know (so english.lbx might be a good start - note that the wiki linked to above picks out english.lbx and german.lbx as 'reference files') and just start translating (taking into account the explanations and additions in §4.9.2 Localization Keys, pp. 206-217). You can check the output of your .lbx with the file biblatex/doc/examples/03-localization-keys.tex. Just put your .lbx into the same directory as 03-localization-keys.tex, load your language in babel and compile 03-localization-keys.tex. This file contains all of biblatex's default bibstrings and shows the long and short for as well as the English explanation of all strings, missing strings will generate warnings.

Some languages have features that need extra support by biblatex. In Welsh, I seem to have gathered, 'and' is either 'a' or 'ac' depending the following word (more or less like the English 'a'/'an' thing) - to handle this properly, there would need to be a command similar to spanish.lbx's \smartand (see §3.11.2 Language-specific Notes: Spanish, p. 104) - you'll notice that I backed off from dealing with that, hence the bold 'and' in the example below. For issues such as this, it is best to get in touch with the developers. While we're at it, if you plan to make an .lbx file and intend to make a comprehensive one, you might want to think about contributing to the project by submitting the file to the maintainers.

Self-contained MWE

\documentclass[a4paper,welsh]{article}
\usepackage{babel}
\usepackage[utf8]{inputenc}% welsh needs utf8x but biblatex doesn't like it
\usepackage[T1]{fontenc}% not great for Welsh but the best pdfTeX can do
\usepackage{csquotes}% doesn't like Welsh though biblatex likes csquotes on account of babel...
\usepackage[backend=biber]{biblatex}

\title{Fy Nogfen}
\author{Rhywun}

\DeclareQuoteAlias[british]{english}{welsh}

\begin{filecontents*}{welsh.lbx}
\ProvidesFile{welsh.lbx}[2014/09/15 Welsh language stub]

\InheritBibliographyExtras{british}

\DeclareBibliographyStrings{%
bibliography     = {{Llyfryddiaeth}{Llyfryddiaeth}},
in               = {{yn}{yn}},
}

\endinput

\end{filecontents*}

\begin{document}
\maketitle
\tableofcontents
\section{Cyntaf}
\autocite{westfahl:space}

\printbibliography
\end{document}


• Brilliant! Thank you. I don't suppose you have any idea how to deal with mutations? The a/ac thing is likely to be the least of it. For example, a causes the first letter of the next word to change if it is t, p or c (-> th, ph or ch). Separately, something like a y would become a'r (usually). But maybe this is a question for the maintainers? – cfr Sep 15 '14 at 17:12
• @cfr I'm afraid that sound like it's way above my paygrade. You could try and describe exactly what macro you need in a separate question (and hope some of the experts around here has an idea how to deal with it properly), but (especially) if you intend to submit the Welsh language definition to the maintainers for inclusion in the project, they will be very much inclined to help you with that. If you feel confident, you could examine \smartand in spanish.lbx for starters. – moewe Sep 15 '14 at 18:26
• Sorry. Forgot to accept this earlier and ended up only up-voting it. Corrected now! – cfr Sep 15 '14 at 19:23
• In fact, it should be 'Fy Nogfen'. I forgot the mutation... – cfr Sep 15 '14 at 19:25

This is too long for a comment but picks up on your question about mutation. I've had to handle a similar effect in another language and did so via text composites. Specifically, pick an accent that you don't need for your article. Let's say the overdot \. will do.

You then define the bibliographic and to an a\. but add to the preamble of your document, for vowels:

\DeclareTextCompositeCommand{\.}{T1}{a}{c a}
\DeclareTextCompositeCommand{\.}{T1}{e}{c e}


for nonmutating consonants:

\DeclareTextCompositeCommand{\.}{T1}{m}{ m}
\DeclareTextCompositeCommand{\.}{T1}{f}{ f}


and, for mutating consonants:

\DeclareTextCompositeCommand{\.}{T1}{c}{ ch}
\DeclareTextCompositeCommand{\.}{T1}{t}{ th}


You should then find that and + a = ac a, that and + m = a m, and that and + c = a ch.

Two things that you may have to watch for in implementing this idea:

1. Biblatex (or similar systems) may want to force a space after and. If this is a normal space, then latex may ignore it (\.c = \. c). Otherwise, maybe \ignorespaces might help (not sure though).

2. From some of the code in moeve's answer, it looks biblatex may want to embed and in brackets (compare to references = {{Cyfeiriadau}{Cyfeiriadau}}). If a\. is so embedded, it may interfere with \. having its argument passed on (it may try to interpret the closing bracket } as its argument, which will lead to an error in compiling). If that's the case, you'll need someone clueyer than me to fix the problem.

• (+1) Thanks. This looks really useful, too. (If I could accept your answer as a supplement as well, I would do so.) – cfr Sep 19 '14 at 12:41