2

I am using BiblaTeX and I have a question: As I see in nearly all types of sources in my .bib file I can use the entry language.

However all I put in their is literary displayed in my references. So can't I e.g. also use a ISO-639-1 or another ISO code?

E.g.:

@online{SOTexBibLangIso,
    author = {Stackoverflow Tex Community},
    title = {Can I use a shortened "language" entry (language code) in my .bib file?},
    url = {https://tex.stackexchange.com/questions/294703/can-i-use-a-shortened-language-entry-language-code-in-my-bib-file},
    language = {en},
    urldate = {2016-02-18},
}
  • 1
    I am not familiar with styles that print the name of the language in the bibliography (though I suppose there must be some). The field I find more useful is langid, which sets the language for hyphenation purposes. In any event, my suggestion would be the same: either use a programming tool like sed (or awk or, etc.) or do it dynamically (but with more initial effort) with \DeclareSourcemap. – jon Feb 18 '16 at 20:44
  • I suspect you mean langid, not language and if you are using biber, you can indeed use standard BCP47 codes. – PLK Feb 18 '16 at 20:48
  • No there is indeed language. So I tried to change it to langid = {en}, but in this way it is not shown in my references whereas it was shown when using language. I use numeric as my style. – rugk Feb 18 '16 at 21:15
  • Now it gets worse: When I add both langid = {en} and language Biber tells me: "WARN - The field 'language' in entry '/.../' cannot be null, deleting it" And therefore the language is still not show in the references. So basically it currently only works when I only use 'language'. – rugk Feb 18 '16 at 21:22
  • 1
    Sorry I didn't mean to imply language doesn't exist, it's just that it's rarely what people want, but it seems you do ... – PLK Feb 19 '16 at 10:00
11

biblatex distinguishes two language fields: (1) language and (2) langid. According to the biblatex documentation, p. 20,

[the language field holds the] language(s) of the work. Languages may be specified literally or as localization keys. If localization keys are used, the prefix lang is omissible.

on p. 25 we have

[langid] The language id of the bibliography entry. [...] The identifier must be a language name known to the babel/polyglossia packages. This information may be used to switch hyphenation patterns and localize strings in the bibliography. Note that the language names are case sensitive.

So the language field is what is printed in the bibliography as the language of the work, while langid is used internally for biblatex's language switching behaviour (it can be used to switch hyphenation in the bibliography, so words are hyphenated properly, or it might change the language-dependent strings as well; this is controlled with the autolang option). Note that by default the language information is not printed if the language given there coincides with the main language of the document; this is controlled by the clearlang option and \DeclareRedundantLanguages.

You might for example have

@online{elk,
  author   = {Anne Elk},
  title    = {Über die Anatomie der Donnerechse},
  url      = {http://www.example.edu/~elk/bronto.pdf},
  date     = {2016-01-01},
  language = {german},
  langid   = {ngerman},
}

for a German text (language is german, langgerman would also be OK) following the new rules of orthography (langid is ngerman).


The langid field can only work with language identifiers known to babel/polyglossia, but per PLK's comment above Biber can deal with BCP47 language codes as well and maps them to their respective counterparts. In fact Biber will happily accept nonsense input such as langid = {flobbel}, but that will lead to problems with babel or polyglossia if you use anything other than autolang=none and the language package tries to load the unknown language flobbel.


The language field accepts any input, but language identifiers that biblatex knows are treated differently, they are translated. To be a bit more precise this works for languages defined in the currently used .lbx file as lang<language>, you can give them as <language> or lang<language>. If the bibstring is not defined in the .lbx, the content of the language field is printed as is. You can see the languages supported by english.lbx here, for Dutch the list is here). You can give the language identifier either with the prefix lang or without, langgreek and greek yield the same results. If you use

language = {english},

in a Dutch document, you get the output "Engels" and if the document language is English we get "English".

The string en is not on the list of recognised language identifiers and is printed as is.

You can emulate what Biber does with the langid field using a sourcemap

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=language,
            match=\regexp{\Aen\Z},
            replace=\regexp{english}]
      \step[fieldsource=language,
            match=\regexp{\Ade\Z},
            replace=\regexp{german}]
    }
  }
}
  • Okay, but this dos not really seem to work. With language = {english} I get the following errors: WARN - BibTeX subsystem: D:\Users\%username%\AppData\Local\Temp\snSCccnz83\referenzen.bib_4224.utf8, line 6, warning: undefined macro "[english" and later WARN - The field 'language' in entry '/.../' cannot be null, deleting it – rugk Feb 20 '16 at 9:35
  • @rugk Please post an MWE with that problem. It should really work. – moewe Feb 20 '16 at 9:37
  • @rugk It might be nothing, but your error message says "[english" with [ maybe that is the problem. – moewe Feb 20 '16 at 9:45
  • Oh, yes, indeed. Stupid... Thanks for your help. Now it works. – rugk Feb 20 '16 at 10:48
  • 2
    Someone a while ago on the github tracker proposed some interesting changes to standardise everything into BCP47 codes, which would be better. However, it's a bit messy until babel/polyglossia also standardise or at least support some ISO standard language identifiers. – PLK Feb 21 '16 at 16:58

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.