11

I am using biblatex and would like to quote English and German works. When writing a document in German, this works nicely with the help of \DeclareLanguageMapping and hyphenation to specify if a reference should be quoted in either German or English style. However when writing the document I need the German bibliography entries to be changed - by adding the English translation in brackets in the corresponding fields (see attached MWE).

\documentclass{article}

\usepackage[english,american,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{extarrows}
\usepackage{csquotes}
\usepackage[style=apa,
        bibencoding=utf8,
        sortcites=true,
        bibwarn=true,
        firstinits=true,
        isbn=false,
        dashed=false,
        maxbibnames=99,
        babel=other,
        backend=biber,
        hyperref=true]{biblatex}

\begin{filecontents}{myworks.bib}

@article{articleD,
  author  = {Peter Adams}, 
  title   = {Deutscher Titel},
  journal = {Journalname},
  year    = 1993,
  number  = 2,
  pages   = {201-213},
  month   = 7,
  note    = {Beispielkommentar}, 
  keyword = {D},
  volume  = 4
}

@article{articleE,
  author  = {Peter Adams}, 
  title   = {English Title},
  journal = {The name of the journal},
  year    = 1993,
  number  = 2,
  pages   = {201-213},
  month   = 7,
  note    = {An optional note}, 
  keyword = {E},
  volume  = 4
}

\end{filecontents}


\addbibresource{myworks.bib} 

\DeclareLanguageMapping{ngerman}{ngerman-apa}
\DeclareLanguageMapping{american}{american-apa}

\begin{document}
\nocite{*}
\selectlanguage{american}
\printbibliography[keyword=E]
\end{document}

One can achieve this by have a German and a English version of each bibliography entry (cf article, articleE), however this is not a nice solution. The best way for keeping the bibliography would be something like this (where translation is added after the title in brackets when the document is being written in English):

@article{article,
  author  = {Peter Adams}, 
  title   = {Deutscher Titel},
  titleE  = {English Title},
  journal = {Journalname},
  journalE= {The name of the journal},
  year    = 1993,
  number  = 2,
  pages   = {201-213},
  month   = 7,
  note    = {Beispielkommentar},
  noteE   = {An optional note}, 
  keyword = {E},
  volume  = 4
}

resulting in

Adams, P. (1993). Deutscher Titel [English Title]. Journalname/The name of the journal, 2, 201–213.

Does anyone know how to achieve this?

Cheers

  • 2
    What would you expect a "better solution" to do? As I see it you would have to define a new translated field for each field you want to translate (or use fields that already exist origtitle, titleaddon, ...). There is (was?) a plan to have a "multiscript" version of biblatex that would allow for that natively without having to define new fields (ms branch on github and this issue), but development seems to have stalled in the last months or so. – moewe Dec 2 '15 at 9:13
  • 1
    Yes, exactly, I need a new translated field for each field that needs translation. I edited the question to show an example where more than one field needs translation. – Mil Dec 2 '15 at 10:17
  • 1
    Mhh, OK. I believe currently your only option is creating a new field for each of those via a new datamodel (.dbx file). You will then have to inject those new fields into the appropriate macros so that they are indeed printed in the end. I believe there is no "automatic" way to do that for all fields, you will have to do that for each field manually. (The unreleased ms version of biblatex would of course do half of this for us automatically.) – moewe Dec 2 '15 at 10:22
  • 1
    In Articleno in biblatex?, Add field “tome” to biblatex entries you can find out more about creating new fields with .dbx files. – moewe Dec 2 '15 at 10:25
11

As mentioned in the comments the experimental biblatex 4.0 knows "variant" of a field and together with biber 4.0 beta one can use them.

But it is not easy (and an complicated style like apa makes it even more difficult) and rather time consuming. One has to check a lot of macros to decide where and how one should inject the translation (and what to do if there is more than one variant, e.g. a translation and a transscription of some japanese title).

The following example shows an example code and its output with the experimental biblatex/biber:

\documentclass{article}

\usepackage[english,american,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{extarrows}
\usepackage{csquotes}
\usepackage[style=apa,
        bibencoding=utf8,
        sortcites=true,
        bibwarn=true,
        firstinits=true,
        isbn=false,
        dashed=false,
        maxbibnames=99,
        babel=other,
        backend=biber,
        hyperref=true]{biblatex}


\addbibresource{test.bib}

\DeclareLanguageMapping{ngerman}{ngerman-apa}
\DeclareLanguageMapping{american}{american-apa}


\renewbibmacro*{journal}{%
  \iffieldundef{journaltitle}
    {}
    {\printtext[journaltitle]{%
       \printfield[titlecase]{journaltitle}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{journalsubtitle}}}%
  \iffieldundef[form=translated,lang=english]{journaltitle}
    {}
    {%
     \setunit{/}%
     \printfield[][form=translated,lang=english]{journaltitle}%
    }%       
  }  

\renewbibmacro*{title}{%
  \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}
    {}
    {\iffieldundef{origtitle}
      {\printtext[title]{%
        \printfield[apacase]{title}%
        \setunit{\subtitlepunct}%
        \printfield[apacase]{subtitle}}
       \iffieldundef[form=translated,lang=english]{title}
       {}
       {%
       \setunit{}%
       \addspace
       \mkbibbrackets{\printfield[][form=translated,lang=english]{title}}%
       }%
      }
      {\printfield{origtitle}%
       \setunit{\addspace}%
       \printtext[brackets]{%
        \printfield[apacase]{title}%
        \setunit{\subtitlepunct}%
        \printfield[apacase]{subtitle}}}%
     \setunit{\addspace}%
     \printfield{titleaddon}%
     \iffieldequalstr{entrytype}{book}%
       {\setunit{\addspace}\usebibmacro{bookaddinfo}}%
       {}%
     \ifthenelse{%
       \ifnameundef{author}\AND%
       \(\ifnameundef{editor}\AND\NOT\boolean{bbx:editorinauthpos}\)\AND%
       \ifnameundef{producer}\AND%
       \ifnameundef{director}\AND%
       \ifnameundef{writer}}
        {\newunit\newblock
         \usebibmacro{labelyear+extrayear}}
        {}}}

\DeclareBibliographyDriver{article}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit\newblock
  \usebibmacro{journal+issuetitle}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit\newblock
  \printfield{note}%
  \iffieldundef[form=translated,lang=english]{note}
       {}
       {%
       \setunit{}%
       \addspace
       \mkbibparens{\printfield[][form=translated,lang=english]{note}}%
       }%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \printfield{addendum}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{apa:finpunct}%
  \usebibmacro{apa:pageref}%
  \usebibmacro{finentry}}           
\newbibmacro*{note+pages}{%
  \printfield{note}%

  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit}

\begin{document}
\cite{articletranslated}
\selectlanguage{american}
\printbibliography
\end{document}

test.bib:

@article{articletranslated,
  author  = {Peter Adams},
  title   = {Deutscher Titel},
  title_translated_english  = {English Title},
  journal = {Journalname},
  journaltitle_translated_english= {The name of the journal},
  year    = 1993,
  number  = 2,
  pages   = {201-213},
  month   = 7,
  note    = {Beispielkommentar},
  note_translated_english   = {An optional note},
  keyword = {E},
  volume  = 4
}

enter image description here

In my opinion quite often the invested time is not worth it.

A more simple approach would be to inject conditional text directly in the bib:

@article{articlewithengl,
  author  = {Peter Adams},
  title   = {Deutscher {Titel}\ifbool{useenglish}{\addspace\mkbibbrackets{English Title}}{}},
  journal = {Journalname\ifbool{useenglish}{/The name of the journal}{}},
  year    = 1993,
  number  = 2,
  pages   = {201-213},
  month   = 7,
  note    = {Beispielkommentar\ifbool{useenglish}{\addspace(An optional note)}{}},
  keyword = {E},
  volume  = 4
}

this can then be used simply with

\usepackage{etoolbox}
\newbool{useenglish}
\booltrue{useenglish} %or \boolfalse{useenglish}
2

The simplest solution (given that the apa biblatex style is used) is to store the translation in the titleaddon field (which is one of the standard biblatex fields).

  • 1
    That's a good idea, but it doesn't work for different fields except the title then, e.g. note field, which is used in various other apa bibliography entries (such es poster presentations or talks). – Mil Nov 20 '14 at 11:42
  • 1
    What about using origtitle for what now is the title and title for the translation? – Guido Nov 20 '14 at 12:10
2
+50

Maybe these ideas will help you

% !TeX program = pdflatex 
\RequirePackage{filecontents}
\begin{filecontents*}{myworks.bib}
@article{article,
  author  = {Peter Adams}, 
  title   = {Deutscher Titel},
  titleE  = {English Title},
  journal = {Journalname},
  journalE= {The name of the journal},
  year    = 1993,
  number  = 2,
  pages   = {201-213},
  month   = 7,
  note    = {Beispielkommentar},
  noteE   = {An optional note}, 
  keywords = {E},
  volume  = 4
}
\end{filecontents*}

\documentclass{article}

\usepackage[english,american,ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{extarrows}
\usepackage{csquotes}
\usepackage[style=apa,
        bibencoding=utf8,
        sortcites=true,
        bibwarn=true,
        firstinits=true,
        isbn=false,
        dashed=false,
        maxbibnames=99,
        autolang=other,
        backend=biber,
        hyperref=true]{biblatex}

\addbibresource{myworks.bib} 

%%Thanks
%%http://tex.stackexchange.com/a/141831/79756
%%http://tex.stackexchange.com/a/226429/79756
%%for idea
\DeclareSourcemap{ 
    \maps{
        \map[overwrite]{
            \step[fieldsource=keywords,
            match={E},
            final]
            \step[fieldsource=titleE,]
            \step[fieldset=title, fieldvalue={~[}, append]
            \step[fieldset=title, origfieldval, append]
            \step[fieldset=title, fieldvalue={]}, append]
        }
        \map[overwrite]{
            \step[fieldsource=keywords,
            match={E},
            final]
            \step[fieldsource=journalE,]
            \step[fieldset=journal, fieldvalue={/}, append]
            \step[fieldset=journal, origfieldval, append]
        }
        \map[overwrite]{
            \step[fieldsource=keywords,
            match={E},
            final]
            \step[fieldsource=noteE,]
            \step[fieldset=note, fieldvalue={~[}, append]
            \step[fieldset=note, origfieldval, append]
            \step[fieldset=note, fieldvalue={]}, append]
        }
    }
}

\DeclareLanguageMapping{ngerman}{ngerman-apa}
\DeclareLanguageMapping{american}{american-apa}

\DeclareFieldFormat{apacase}{#1} %undo APA style sentence case correction for every field

\begin{document}
\nocite{*}
\selectlanguage{american}
\printbibliography[keyword=E]
\end{document}

code output

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.