Localizing Place Names in Bibliographies

If you need to create bibliographies for different purposes, in different languages and styles, one problem is that sometimes you want the place of publication (or, if applicable, the venue) to include the country (e.g., “Lausanne, Switzerland”), and sometimes you don’t. APA style1 requires the country only for places outside the US: “Chicago, IL” but “Frankfurt, Germany.” Other bibliography styles are less explicit in this respect, but it seems at least at a little bit silly to give the country for major European cities in a German-language bibliography. In this case you probably want “Frankfurt am Main” (or some abbreviation thereof) to distinguish it from “Frankfurt an der Oder.” And for a bibliography in French you want “Francfort-sur-le-Main,” and so on.

It turns out that a solution is relatively easy when you’re using LaTeX with the biblatex package (which is intended as a replacement for the venerable BibTeX). The biblatex package supports localization out of the box, i.e., terms like “editor,” “pages,” etc. are not hard-coded but depend on the language of the bibliography (or the individual item). What is important for us is that biblatex also supports the use of bibliography strings in the database, which specified using a key, which is replaced with the corresponding text in the current language when formatting the bibliography. For example, in language = {italian}, italian is actually a key, which is replaced by “Italian,” “italien,” etc.

So, instead of directly entering something like Frankfurt, Germany into the database one could imagine entering some key, which is then rendered as necessary in the particular circumstances. There are just two problems: the documentation of biblatex is not very helpful, and there are many possible solutions. I first used a different approach using a separate country field in the database before I came up with the approach described here; both approaches have their advantages and disadvantages, but this one seems to be more straightforward.

All of this can be done in the preamble of a document, so we don’t need to create files all over the place, we can adapt the mappings depending on the requirements of a particular document, but it is also possible to have a standard set of definitions in a central location. The only thing that needs to be in a separate file are the \DeclareDatamodelFields declarations; for testing, one can use the filecontents package, so we can also include it in the preamble.

What we need to do:

First, even though apparently not strictly necessary, it seems to be a good idea to declare (using \DeclareDatamodelFields) the location and venue fields to have the datatype key rather than literal; using the filecontents package, we can say:

\begin{filecontents}{biblatex-dm.cfg}
  \DeclareDatamodelFields[type=field, datatype=key, skipout=false]{venue}
  \DeclareDatamodelFields[type=list, datatype=key, skipout=false]{location}
\end{filecontents}

Second, we need to declare the possible keys using \NewBibliographyString. Luckily we don’t need to come up with codes ourselves, but we can use UN/LOCODE2 identifiers (we just need to write them in a way that’s acceptable to LaTeX). Note that if we use something that is not defined as a bibliography string, biblatex will simply output it. Here’s just a short list for testing. I’m using the locode prefix just to make sure that the keys don’t match a regular word.

\NewBibliographyString{locodeatvie, locodeczprg, locodedelej, locodeusnyc, locodeussrf}

Third, we define the language-specific mappings for the keys using \DefineBibliographyStrings. Here are just mappings for American and German, which also illustrate that countries can be mentioned as desired:

\DefineBibliographyStrings{american}{%
  locodeatvie = {Vienna, Austria},
  locodeczprg = {Prague, Czech Republic},
  locodedelej = {Leipzig, Germany},
  locodeusnyc = {New York, NY},
  locodeussrf = {San Rafael, CA},
}
\DefineBibliographyStrings{german}{%
  locodeatvie = {Wien},
  locodeczprg = {Prag},
  locodedelej = {Leipzig},
  locodeusnyc = {New York, NY, USA},
  locodeussrf = {San Rafael, CA, USA},
}

Finally, we need to redefine the rendering of the location and venue fields, so they pick up the bibliography strings. Note that like in the standard definition, venue is a field and location is a list, i.e., you can specify multiple places of publication. I’ve simply copied and adapted the default format for location, which concatenates multiple entries with commas:

\DeclareFieldFormat{venue}{\ifbibstring{#1}{\bibstring{#1}}{#1}}
\DeclareListFormat{location}{%
  \ifbibstring{#1}{\bibstring{#1}}{#1}%
  \ifthenelse{\value{listcount}<\value{liststop}}
    {\addcomma\space}
    {}}

Here’s a complete minimal working example, which also contains a small database with two entries. Try switching the order of american and ngerman in \usepackage[…]{babel} to see the different results for English and German.

For production use, you can put the \DeclareDatamodelFields declarations into a file called biblatex-dm.cfg in a path searched by biblatex. You can also store the various string definitions in .lbx files; note that you’d need to use \DeclareBibliographyStrings to inherit from the default language definitions (see Section 3.9 of the biblatex manual). You could then select the desired mapping in the document like this, for example:

\DeclareLanguageMapping{american}{american-locode}

Is this overkill? Maybe, but if you need to create bibliographies for different purposes, in different languages and styles, it can help you to ensure consistency and to conform to the required bibliography style.


  1. https://irsc.libguides.com/apa/placeofpublicationreferencecitation

  2. http://www.unece.org/cefact/locode/welcome.html


Author: Michael Piotrowski

Computational linguist, computer scientist, professor of digital humanities at the University of Lausanne.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.