2

I'm in a situation where my bibtex database keeps getting

   language={EN},

I know that it should be language={english}, but these entries are automatically generated and I can't edit my bibtex database.

So, my question is, how can I make EN "work" without disabling the language field? Some of the entries include correct language fields such as language="japanese". Here is a self-contained example:

\documentclass{article}
\begin{filecontents}[overwrite]{tmp.bib}
@book{Entry-EN,
  language = {EN},
  title = {Title},
  editor = {Abramowitz, Milton and Stegun, Irene A.},
  date = {1965},
  pages = {1060},
  publisher = {Dover}
}
@book{Entry-english,
  language = {english},
  title = {Title},
  editor = {Abramowitz, Milton and Stegun, Irene A.},
  date = {1965},
  pages = {1060},
  publisher = {Dover}
}
@book{Entry-japanese,
  language = {japanese},
  title = {Title},
  editor = {Abramowitz, Milton and Stegun, Irene A.},
  date = {1965},
  pages = {1060},
  publisher = {Dover}
}
\end{filecontents}
\usepackage{biblatex}
\addbibresource{tmp.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

As you can see, the first bib entry gives "EN" in the reference list, which I need to avoid.

Edit: After confirming that @moewe's answer works (thanks!), I realized that I also have language={en}. So I modified the regular expression to

   \A[Ee][Nn]\Z

and confirmed that it also converts "en" to "english". It should also work for "En" and "eN".

1 Answer 1

6

You can use a sourcemap to turn language = {EN}, into the correct language = {english},, but this should really be fixed on the .bib export side of things.

\documentclass{article}
\usepackage{biblatex}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
       \step[fieldsource=language,
            match=\regexp{\AEN\Z},
            replace={english}]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@book{Entry-EN,
  language = {EN},
  title = {Title},
  editor = {Abramowitz, Milton and Stegun, Irene A.},
  date = {1965},
  pages = {1060},
  publisher = {Dover}
}
@book{Entry-english,
  language = {english},
  title = {Title},
  editor = {Abramowitz, Milton and Stegun, Irene A.},
  date = {1965},
  pages = {1060},
  publisher = {Dover}
}
@book{Entry-japanese,
  language = {japanese},
  title = {Title},
  editor = {Abramowitz, Milton and Stegun, Irene A.},
  date = {1965},
  pages = {1060},
  publisher = {Dover}
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

[1] Milton Abramowitz and Irene A. Stegun, eds. Title. Dover, 1965, p. 1060.
[2] Milton Abramowitz and Irene A. Stegun, eds. Title. Dover, 1965, p. 1060.
[3] Milton Abramowitz and Irene A. Stegun, eds. Title. Japanese. Dover, 1965, p. 1060.

You can use matchi=\regexp{\AEN\Z}, instead of match=\regexp{\AEN\Z}, for case-insensitive regexp matching, so that also en, eN and En are matched.

1
  • "this should really be fixed on the .bib export side of things"---Yes, I've just submitted a request to fix this problem. This is the Zotero -> biblatex exporter. Your answer is nevertheless helpful because it shows a general way to "fix" data.
    – Ryo
    Commented Jun 20 at 3:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .