根據文件/babel 語言翻譯參考書目中的位置

根據文件/babel 語言翻譯參考書目中的位置

我經常用德語和英語撰寫文本,並使用 JabRef 來組織我的參考資料。引用大量的會議論文,總是根據文件語言來改變位置的語言,這往往是相當煩人的。所以我想知道是否可以為 biblatex 提供一種字典,這樣我就不必每次都調整我的資料庫。

例如,在序言中我想定義:

Munich = München
Germany = Deutschland

如果文檔或 babel 語言是ngerman.

這可以做到嗎?


微量元素

\documentclass[ngerman]{article}

\usepackage[ngerman]{babel}

\begin{filecontents}{bla.bib}
    @inproceedings{Orwell1984,
        author  = "George Orwell",
        title   = "1984",
        year    = "1948",
        booktitle = "Books about big brothers",
        location = "Munich, Germany",
    }
\end{filecontents}

\RequirePackage[backend=biber,style=ieee-alphabetic]{biblatex}

\addbibresource{bla.bib}
\begin{document}
    \cite{Orwell1984}. \\
    \printbibliography 
\end{document}

答案1

您可以使用biblatex的 bibstring 來翻譯某些短語。問題是什麼才是一個好的介面。如果您希望能夠在一個欄位中組合任意術語,則必須執行類似以下操作(感覺有點笨拙)。

\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=ieee-alphabetic]{biblatex}

\NewBibliographyString{munich,germany}
\DefineBibliographyStrings{german}{
  munich  = {München},
  germany = {Deutschland},
}

\begin{filecontents}{\jobname.bib}
@inproceedings{Orwell1984,
  author    = {George Orwell},
  title     = {1984},
  year      = {1948},
  booktitle = {Books about big brothers},
  location  = {\bibstring{munich}, \bibstring{germany}},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
  \autocite{Orwell1984}
  \printbibliography 
\end{document}

G. Orwell,“1984”,《關於老大哥的書》,德國慕尼黑,1948 年。


如果您同意每個欄位僅使用一個字串,那麼您可以讓事情變得更好一點

\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=ieee-alphabetic]{biblatex}

\NewBibliographyString{de-munich}
\DefineBibliographyStrings{german}{
  de-munich  = {München},
}
\DefineBibliographyStrings{english}{
  de-munich  = {Munich, Germany},
}

\DeclareListFormat{location}{%
  \usebibmacro{list:delim}{#1}%
  \ifbibstring{#1}{\bibstring{#1}}{#1}\isdot
  \usebibmacro{list:andothers}}

\begin{filecontents}{\jobname.bib}
@inproceedings{Orwell1984,
  author    = {George Orwell},
  title     = {1984},
  year      = {1948},
  booktitle = {Books about big brothers},
  location  = {de-munich},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
  \autocite{Orwell1984}
  \printbibliography 
\end{document}

G. Orwell,“1984”,《關於老大哥的書籍》,慕尼黑,1948 年。


更多 BibTeX-y 解決方案使用@strings。您可以為不同文件中的每個位置定義字串.bib(每種語言一個),然後選擇.bib文件中所需語言的文件。

\documentclass[ngerman]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=ieee-alphabetic]{biblatex}


\begin{filecontents}{locationstrings-german.bib}
@string{de:munich = "München"}
\end{filecontents}
\begin{filecontents}{locationstrings-english.bib}
@string{de:munich = "Munich, Germany"}
\end{filecontents}
% select the bib file for the language you want
\addbibresource{locationstrings-german.bib}

\begin{filecontents}{\jobname.bib}
@inproceedings{Orwell1984,
  author    = {George Orwell},
  title     = {1984},
  year      = {1948},
  booktitle = {Books about big brothers},
  location  = de:munich,
}
\end{filecontents}
\addbibresource{\jobname.bib}


\begin{document}
  \autocite{Orwell1984}
  \printbibliography 
\end{document}

G. Orwell,“1984”,《關於老大哥的書籍》,慕尼黑,1948 年。


仍然非常實驗性的多腳本版本biblatex也可能令人感興趣:https://github.com/plk/biblatex/issues/416

答案2

\documentclass[ngerman]{article}

\usepackage[ngerman]{babel}

\begin{filecontents}{german-strings.bib}
    @string{muenchen={München}}
    @string{germany={Deutschland}}
\end{filecontents}


\begin{filecontents}[overwrite]{bla.bib}
    @inproceedings{Orwell1984,
        author  = "George Orwell",
        title   = "1984",
        year    = "1948",
        booktitle = "Books about big brothers",
        location = muenchen # ", " # germany
    }
\end{filecontents}

\RequirePackage[backend=biber,style=ieee-alphabetic]{biblatex}

\addbibresource{german-strings.bib}
\addbibresource{bla.bib}
\begin{document}
    \cite{Orwell1984}. \\
    \printbibliography
\end{document}

在此輸入影像描述

相關內容