biblatex
biblatex copied to clipboard
Change language on a per field basis
Continued from this SX question, in turn from this one. I thought this should at least be noted as an issue, even if I don't really need a solution. In addition to those examples, another use case:
If we have an author with a Turkish name containing i
writing an English book, and want to print their name in (small) capitals, we need a language change only for the name.
(Turkish distinguishes dotless I
ı
and dotted İ
i
, with case transformations not matching English. If the name only contains ı
or İ
that's currently fine as they are unambiguous.)
What would be intuitive to me is if the individual fields had companion *langid[opts] fields (e.g. authorlangid, titlelangid, etc.)
\documentclass{article}
\usepackage{filecontents}
\usepackage{fontspec}
\setmainfont{SourceSerifPro-Regular.otf}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{turkish}
\usepackage{biblatex}
\begin{filecontents}{\jobname.bib}
@book{idot,
author = {Bilgili},
title = {English language book},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\def\mkbibnamefamily{\textsc}
\begin{document}
\textturkish{\citeauthor{idot}}
\textenglish{\citeauthor{idot}}
\printbibliography
\end{document}
I'd love to see something like this, but the exact timing of the language switching is extremely tricky and may need to be adjusted depending on the desired outcome. It is plausible that a user would only want to switch the hyphenation rules for a field keeping the \bibstring
in the main document language, but it might also be that a user would want to switch language for the complete field with \bibstrings
. See also https://tex.stackexchange.com/q/444016/35864 that you linked already.
For names in particular it might not be enough to switch the language for the whole name list, you'd actually want to switch the language per name (item) so that the Turkish Bilgili and the English Miller both come out with the respective expected small caps version of i
.
\documentclass{article}
\usepackage{libertine}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{turkish}
\usepackage{biblatex}
\renewcommand\mkbibnamefamily{\textsc}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{idot,
author = {Bilgili and Miller},
title = {English language book},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\textturkish{\citeauthor{idot}}
\textenglish{\citeauthor{idot}}
\printbibliography
\end{document}
Since *langid
fields would need to be added to the data model, I think I'd prefer something like named field annotations instead.
Related-ish: https://github.com/plk/biblatex/issues/757
Another case where this is needed are multi-language volumes. Consider the following case:
\documentclass{article}
\usepackage{libertine}
\usepackage[english,ngerman]{babel}
\usepackage[style=apa]{biblatex}
\begin{filecontents}{\jobname.bib}
@collection{AntosNiehrSpitzmueller:HSW10,
editor = {Gerd Antos and Thomas Niehr and Jürgen Spitzmüller},
title = {Handbuch Sprache im Urteil der Öffentlichkeit},
publisher = {De Gruyter},
address = {Berlin and Boston},
year = {2019},
langid = {ngerman}
}
@incollection{Preston:FolkLing19,
author = {Dennis R. Preston},
crossref = {AntosNiehrSpitzmueller:HSW10},
pages = {140--164},
title = {Folk Linguistics and the Perception of Language Variety},
langid = {english}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{AntosNiehrSpitzmueller:HSW10,Preston:FolkLing19}
\printbibliography
\end{document}
This comes out with wrong booktitle-casing for the @incollection
entry:
I know this can be worked-around by brace protection, but ideally, the language of the book title field should be settable.
(and of course hyphenation cannot be fixed by case protection)
I am looking at this in the multiscript branch currently and will report it here when there is something working there. It's not trivial to do this in the current biber/biblatex versions. The multiscript version will have a dedicated data annotation for language switching.
This is now possible in the multiscript branch of biber/biblatex (found in the experimental) folders on SF. Your example works as it should, I believe. This branch also supports lang switching on a per-list item basis to address the other examples in this thread. As you mentioned, this is based on a dedicated data annotation (see PDF docs for the experimental v4.0 branch)
So, just out of curiosity, did I get it right from the biblatex 4.0
manual that the above example would need this?
title = {Handbuch Sprache im Urteil der Öffentlichkeit},
title+an:langtags = {=de},
langtags
is now mslang
in the latest upload by the way ...
But no, you won't need that in this case as biber will automatically add the annotations for crossrefed fields which differ in the inferred langid
from the parent entry.
But no, you won't need that in this case as biber will automatically add the annotations for crossrefed fields which differ in the inferred
langid
from the parent entry.
Oh, how cool!
I should also point out that the multiscript branch, in your crossref case, will do more than just make sentence casing work (which is a somewhat special subsystem in biblatex), it will also (optionally) make the inherited german fields automatically be wrapped in a babel/polyglossia german hyphenation environment or full language environment (depending on the setting of the autofieldlang
option) and optionally use the german biblatex bibstrings (depending on the setting of the autofieldlangstrings
option). These options also influence automatic language switching for specific items in lists and names.
Thanks. That's really a significant improvement not only to multiscript, but also to multiligual references.