TransWikia.com

Declare bibliography entry in a foreign language, with translation

TeX - LaTeX Asked on January 16, 2021

I am using BibLaTeX with the Biber backend for the bibliography of my PhD thesis, written in English.

The Harvard style that my university recommends, encourages the translation of titles and journal titles written in a foreign language.

To get correct hyphenation patterns, one would use the langid field to declare the foreign language. However, what about if I want to add the title translated in English? Is there a way to declare languages ‘locally’ in a clean manner?

An example of such an entry would be:

@article{doe2000,
  title     = {Die numerische Strömungsmechanik [Computational Fluid Dynamics]},
  author    = {J. Doe},
  booktitle = {Internationalen Mathematiker Kongresses [International Congress of Mathematics]},
  date      = {2000},
  langid    = {german} % but translated titles are in English
}

One Answer

The best input here will strongly depend on your your overall setup and the desired outcome.

Generally it is a bad idea to add too much markup commands to fields, as formatting should be up to the style and markup can be problematic for sorting. But here it seems not totally crazy to add some language switching markup at the end of the field (which is unlikely to matter for sorting).

documentclass[german,english]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{csquotes}

usepackage[style=authoryear, backend=biber, autolang=hyphen]{biblatex}


begin{filecontents}{jobname.bib}
@incollection{doe2000,
  title     = {Die numerische Strömungsmechanik
               foreignlanguage{english}{[Computational Fluid Dynamics]}},
  author    = {J. Doe},
  booktitle = {Internationaler Mathematikerkongress
               foreignlanguage{english}{[International Congress of Mathematicians]}},
  date      = {2000},
  langid    = {german},
}
end{filecontents}
addbibresource{jobname.bib}
addbibresource{biblatex-examples.bib}


begin{document}
cite{doe2000}
printbibliography
end{document}

Doe, J. (2000). “Die numerische Strömungsmechanik [Computational Fluid Dynamics]”. In: Internationaler Mathematikerkongress [International Congress of Mathematicians].

For a fully multilingual bibliography with the possibility to translate certain fields, you'll probably have to wait until the biblatex multiscript development branch makes it into the released version. See https://github.com/plk/biblatex/issues/416 for more details and an available test version.

In the meantime you can do some translating with field annotations.

documentclass[ngerman,english]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{csquotes}

usepackage[style=authoryear, backend=biber]{biblatex}

% expand the first argument of foreignlanguage
% needs a modern TeX engine with expanded primitive
newcommand*{foreignlanguageE}[1]{foreignlanguage{expanded{#1}}}

newcommand*{foreignlangbyannotation}[2][currentfield]{%
  hasfieldannotation[#1][lang]
    {foreignlanguageE{csuse{abx@annotation@literal@field@#1@lang}}{#2}}
    {#2}}

newcommand*{printtranslation}[1][currentfield]{%
  hasfieldannotation[#1][translation]
    {addspace mkbibbrackets{getfieldannotation[#1][translation]}}
    {}}

DeclareFieldFormat{title}{%
  mkbibemph{%
    foreignlangbyannotation[title]{#1}%
    printtranslation[title]}}

DeclareFieldFormat
  [article,inbook,incollection,inproceedings,patent,thesis,unpublished]
  {title}{%
  mkbibquote{%
    foreignlangbyannotation[title]{#1}%
    printtranslation[title]isdot}}

DeclareFieldFormat
  [suppbook,suppcollection,suppperiodical]
  {title}{%
    foreignlangbyannotation[title]{#1}%
    printtranslation[title]}

DeclareFieldFormat{booktitle}{%
  mkbibemph{%
    foreignlangbyannotation[booktitle]{#1}%
    printtranslation[booktitle]}}

begin{filecontents}{jobname.bib}
@incollection{doe2000,
  title                    = {Die numerische Strömungsmechanik},
  title+an:lang            = {="ngerman"},
  title+an:translation     = {="Computational Fluid Dynamics"},
  author                   = {J. Doe},
  booktitle                = {Internationaler Mathematikerkongress},
  booktitle+an:lang        = {="ngerman"},
  booktitle+an:translation = {="International Congress of Mathematicians"},
  date                     = {2000},
}
end{filecontents}
addbibresource{jobname.bib}
addbibresource{biblatex-examples.bib}


begin{document}
cite{doe2000}
printbibliography
end{document}

Doe, J. (2000). “Die numerische Strömungsmechanik [Computational Fluid Dynamics]”. In: Internationaler Mathematikerkongress [International Congress of Mathematicians].

I have shown a similar approach on TeXwelt: https://texwelt.de/fragen/24268/biblatexbiber-deutscher-autorenname-eines-bibliographie-eintrags-englischer-rest

Correct answer by moewe on January 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP