I would like to change certain aspects of how the bibliography looks for those entries that are in Hungarian, i.e. marked as langid = {magyar} in the bib file. Changing the look of the bibliography based on the langid field works well in these cases for example:
% no comma between family and given name if langid is magyar
\renewcommand{\revsdnamepunct}{%
\ifboolexpr{%
test {\iffieldequalstr{langid}{magyar}}%
}{}{,\space}%
}
% book title is in italics if langid is magyar
\DeclareFieldFormat[book]{title}{
\ifboolexpr{%
test {\iffieldequalstr{langid}{magyar}}}{\emph{#1}}{#1}}
With the code below I can change the order of authors to family name first then given name, which I would like to have for Hungarian names, but this modifies the order of all names not just the Hungarian ones:
\DeclareNameAlias{sortname}{family-given}
And so I would like to introduce the same condition as in the above examples that only those names should have the family-given order where langid={magyar} in the bib file, but this gives an error:
\DeclareNameAlias{sortname}{
\ifboolexpr{%
test {\iffieldequalstr{langid}{magyar}}}{family-given}{given-family}}}
! Missing \endcsname inserted.
<to be read again>
\begingroup
l.45 ...id}{magyar}}}{family-given}{given-family}}
}
?
How can I change the order of authors to family-given for the bib entries for the Hungarian language entries?
Full minimal example:
\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{hungarian}
\usepackage[backend=biber,
bibstyle=authoryear,citestyle=authoryear-comp,
sorting=nyt,
maxbibnames=10,maxcitenames=2]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@Book{KovacsKiss2022,
author = {Kovács, Béla and János Kiss},
date = {2022},
title = {A {Hungarian} book with two authors},
location = {Budapest},
publisher = {Kiadó},
langid = {magyar},
}
@Book{Smith2022,
author = {Smith, John and Leslie Taylor},
date = {2022},
title = {An {English} book with two authors},
publisher = {Publisher},
address = {City},
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\renewcommand{\revsdnamepunct}{%
\ifboolexpr{%
test {\iffieldequalstr{langid}{magyar}}%
}{}{,\space}%
}
\DeclareFieldFormat[book]{title}{
\ifboolexpr{%
test {\iffieldequalstr{langid}{magyar}}}{\emph{#1}}{#1}}
\DeclareNameAlias{sortname}{family-given}
\DeclareNameAlias{sortname}{
\ifboolexpr{%
test {\iffieldequalstr{langid}{magyar}}}{family-given}{given-family}}}
\begin{document}
\nocite{Smith2022,KovacsKiss2022}
\printbibliography[heading=subbibliography]
\end{document}



