biblatex icon indicating copy to clipboard operation
biblatex copied to clipboard

Language option doesn't work

Open Doc73 opened this issue 7 years ago • 17 comments

Dear Devs, if I well understand the manual (pag. 48), it seems that language option doens't work as expected. Here is a MWE with explanations within it:

% !TeX program = xelatex
% !TeX encoding = UTF-8
% !TeX spellcheck = it_IT

\begin{filecontents}{biblio.bib}
@Article{Cufalo2017,
	author          = {Cufalo, Domenico},
	journaltitle    = {Exemplaria Classica},
	pages           = {227--242},
	title           = {{\em Scholia in scholia}: su una nuova edizione di Hermias di Alessandria},
	volume          = {21},
	date            = {2017},
	journalsubtitle = {Journal of Classical Philology},
}

@Book{Cufalo2007,
  Title                    = {Scholia Graeca in Platonem},
  Author                   = {Cufalo, Domenico},
  Location                 = {Roma},
  Publisher                = {Edizioni di Storia e Letteratura},
  Year                     = {2007},
  Number                   = {5.1},
  Series                   = {«Pleiadi»},
  Titleaddon               = {I: Scholia ad dialogos tetralogiarum I--VII continens},
}
\end{filecontents}

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{italian}
\setotherlanguage[variant=ancient]{greek}

\usepackage{fontspec}
\setmainfont{Libertinus Serif}

\usepackage{filecontents}

\usepackage[%
	backend=biber,%
	language=italian,%
	style=authoryear,
	]{biblatex}
\addbibresource{biblio.bib}

\begin{document}
\section{Italian}
In this section, according to main language definition, the sigla “pp.” are written in Italian.

\cite[230-231]{Cufalo2017}

\cite[230-231]{Cufalo2007}


\section{Greek}
\begin{greek}
In this section I have instead “σσ.” in Greek. It seems therefore that “language” option of Biblatex is not working.
	
\cite[230-231]{Cufalo2017}

\cite[230-231]{Cufalo2007}
\end{greek}

\end{document}

Many thanks in advance, DC

Doc73 avatar Jun 06 '18 17:06 Doc73

I'll admit that the way the language option works is a bit counter-intuitive. In addition to language you also need to specify an autolang value different from none (presumably other), this is what the

It is also possible to select the package language manually. In this case, the language chosen will override the langid of entries and you should still choose a language switching environment with the autolang option to select how the switch to the manually chosen language is handled.

in the documentation of the language option tries to tell you.

Consequently

% !TeX program = xelatex
% !TeX encoding = UTF-8
% !TeX spellcheck = it_IT

\begin{filecontents}{biblio.bib}
@Article{Cufalo2017,
	author          = {Cufalo, Domenico},
	journaltitle    = {Exemplaria Classica},
	pages           = {227--242},
	title           = {{\em Scholia in scholia}: su una nuova edizione di Hermias di Alessandria},
	volume          = {21},
	date            = {2017},
	journalsubtitle = {Journal of Classical Philology},
}

@Book{Cufalo2007,
  Title                    = {Scholia Graeca in Platonem},
  Author                   = {Cufalo, Domenico},
  Location                 = {Roma},
  Publisher                = {Edizioni di Storia e Letteratura},
  Year                     = {2007},
  Number                   = {5.1},
  Series                   = {«Pleiadi»},
  Titleaddon               = {I: Scholia ad dialogos tetralogiarum I--VII continens},
}
\end{filecontents}

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{italian}
\setotherlanguage[variant=ancient]{greek}

\usepackage{fontspec}
\setmainfont{Libertinus Serif}

\usepackage{filecontents}

\usepackage[%
	backend=biber,%
	language=italian,%
	autolang=other,
	style=authoryear,
	]{biblatex}
\addbibresource{biblio.bib}

\begin{document}
\section{Italian}
In this section, according to main language definition, the sigla “pp.” are written in Italian.

\cite[230-231]{Cufalo2017}

\cite[230-231]{Cufalo2007}


\section{Greek}
\begin{greek}
In this section I have instead “σσ.” in Greek. It seems therefore that “language” option of Biblatex is not working.
	
\cite[230-231]{Cufalo2017}

\cite[230-231]{Cufalo2007}
\end{greek}

\end{document}

should do what you want.

moewew avatar Jun 06 '18 19:06 moewew

GREAT! Now I finally understood!

Many thanks, DC

Doc73 avatar Jun 07 '18 16:06 Doc73

Very good. As unintuitive as the situation might be I don't think there is a simple way out. If we force a language we really must use a language switching environment as soon as the surrounding language differs from the forced language. Otherwise hyphenation and possibly other things might be off. So autolang is really necessary.

Is the quoted passage in the documentation clear enough or do you thing it needs to be extended?

moewew avatar Jun 07 '18 16:06 moewew

Maybe the problem is due to the myriad of options of this extraordinary tool. :smile:

Certainly, the documentation can be expanded. For example, I'm now reading the langid field and I understand that I can use this field for a better hyphenation, but I fear that in my ancient greek text, where there are notes that contain bibliographic citations, I could obtain "σσ." instead of "pp."; or "herausgegeben" (deutsch) in bibliography instead of "a cura di" (italian). The language options are related not only to hyphenation, but also to other stuff!

In short, there are many obscure points in the documentation, at least for me, and any other clarification would be much appreciated.

Doc73 avatar Jun 07 '18 16:06 Doc73

The langid field only becomes important if you use language=auto (or autobib/autocite). If you use language=italian langid is overruled and effectively the value of langid is replaced by italian for all entries. Depending on the value of the autolang option langid can control hyphenation (autolang=hyphen) or everything - including strings - (autolang=other/other*). Normally the bibliography and citation commands are typeset in the currently active language (unless that is prevented with one of the mentioned options).

In you case that means

  • If you want language=italian, langid is useless because it is effectively overruled.
  • If you wanted the hyphenation rules to changed depending on langid you would need language=autobib, autolang=hyphen. But then citations in the Greek bits of your document would be typeset with Greek localisation, you would have to wrap them into and Italian language environment yourself.

So with manual intervention you could do something like this

%\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{Cufalo2017,
	author          = {Cufalo, Domenico},
	journaltitle    = {Exemplaria Classica},
	pages           = {227--242},
	title           = {{\em Scholia in scholia}: su una nuova edizione di Hermias di Alessandria},
	volume          = {21},
	date            = {2017},
	journalsubtitle = {Journal of Classical Philology},
    langid = {italian},
}

@Book{Cufalo2007,
  Title                    = {Scholia Graeca in Platonem},
  Author                   = {Cufalo, Domenico},
  Location                 = {Roma},
  Publisher                = {Edizioni di Storia e Letteratura},
  Year                     = {2007},
  Number                   = {5.1},
  Series                   = {«Pleiadi»},
  Titleaddon               = {I: Scholia ad dialogos tetralogiarum I--VII continens},
    langid = {latin},
}
\end{filecontents}

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{italian}
\setotherlanguage[variant=ancient]{greek}

\usepackage{fontspec}
\setmainfont{Libertinus Serif}

\usepackage{filecontents}

\usepackage[%
	backend=biber,%
	language=autobib,%
	autolang=hyphen,
	style=authoryear,
	]{biblatex}
\addbibresource{\jobname.bib}

\begin{document}
\section{Italian}
In this section, according to main language definition, the sigla “pp.” are written in Italian.

\cite[230-231]{Cufalo2017}

\cite[230-231]{Cufalo2007}


\section{Greek}
\begin{greek}
In this section I have instead “σσ.” in Greek. It seems therefore that “language” option of Biblatex is not working.
	
\textitalian{\cite[230-231]{Cufalo2017}}

\textitalian{\cite[230-231]{Cufalo2007}}
\end{greek}

\printbibliography

\end{document}

moewew avatar Jun 07 '18 20:06 moewew

Yes, thank you! I had guessed the need to specify \textitalian, but in this case is preferable to specify language environment inside bib entries, for example inside titles etc. It would be much more difficult to search for individual citations with linguistic issues.

Anyway, many thanks for your kindly explanations!

Doc73 avatar Jun 07 '18 20:06 Doc73

Some clarifications about the language options are in https://github.com/plk/biblatex/commit/3b8bbdc35cdd024d24f613cda73cd4d84dd7ab9b?w=1 Does that make the docs easier to understand?

moewew avatar Jun 08 '18 07:06 moewew

Yes, this version is by far better! But... another question: if I'd use autolang=hyphen, I'd obtain hyphenation patterns for bibliographic item according their langid entry. In this case, I will however get "σσ." etc. in the section of my book where the Greek is main language? Because my bibliography contain books and articles of several languages, it would be very nice if I could obtain hyphenation according language of bibliogrphic item (langid) and localization according a specific language (for ex. Italian, even in chapters where greek is main language).

Doc73 avatar Jun 08 '18 16:06 Doc73

That is correct as

%\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{Cufalo2017,
	author          = {Cufalo, Domenico},
	journaltitle    = {Exemplaria Classica},
	pages           = {227--242},
	title           = {{\em Scholia in scholia}: su una nuova edizione di Hermias di Alessandria},
	volume          = {21},
	date            = {2017},
	journalsubtitle = {Journal of Classical Philology},
    langid = {italian},
}

@Book{Cufalo2007,
  Title                    = {Scholia Graeca in Platonem},
  Author                   = {Cufalo, Domenico},
  Location                 = {Roma},
  Publisher                = {Edizioni di Storia e Letteratura},
  Year                     = {2007},
  Number                   = {5.1},
  Series                   = {«Pleiadi»},
  Titleaddon               = {I: Scholia ad dialogos tetralogiarum I--VII continens},
    langid = {latin},
}
\end{filecontents}

\documentclass{article}

\usepackage{polyglossia}
\setmainlanguage{italian}
\setotherlanguage[variant=ancient]{greek}

\usepackage{fontspec}
\setmainfont{Libertinus Serif}

\usepackage{filecontents}

\usepackage[%
	backend=biber,%
	language=autobib,%
	autolang=hyphen,
	style=authoryear,
	]{biblatex}
\addbibresource{\jobname.bib}

\begin{document}
\section{Italian}
In this section, according to main language definition, the sigla “pp.” are written in Italian.

\cite[230-231]{Cufalo2017}

\cite[230-231]{Cufalo2007}


\section{Greek}
\begin{greek}
In this section I have instead “σσ.” in Greek. It seems therefore that “language” option of Biblatex is not working.
	
\cite[230-231]{Cufalo2017}

\textitalian{\cite[230-231]{Cufalo2007}}
\begin{italian}
\printbibliography
\end{italian}
\end{greek}

\printbibliography

\end{document}

shows.

You can't get what you want fully automatically, unfortunately. You would have to wrap all \cite and \printbibliographys in Greek chapters in an Italian environment. This is shown in the MWE as well.

moewew avatar Jun 08 '18 16:06 moewew

Yes, many thanks for all your clarifications! In this case, I'll stay with autolang=other.

Issue solved, for me! :+1:

Doc73 avatar Jun 08 '18 16:06 Doc73

A similar problem (hyphenation and fonts of one the language of the work and bibliography strings from the main document language) was discussed in https://tex.stackexchange.com/q/444016/35864

If anyone has a good idea how to tackle this, please share ...

moewew avatar Aug 23 '18 06:08 moewew

@moewew I'll have a look

josephwright avatar Aug 23 '18 07:08 josephwright

@josephwright Cool, thank you. No need to hurry, though, I know you have a lot of other things on your plate.

moewew avatar Aug 23 '18 07:08 moewew

This is probably better closed now and a link from the multiscript issue made?

plk avatar Aug 19 '22 12:08 plk

Yeah, but it would be great to have an MWE using the multiscript code based on the code from above. I can look into that once the multscript biblatex is in MikTeX (is it on CTAN yet?).

moewew avatar Aug 19 '22 13:08 moewew

Not released yet as a stand-alone package. I can try to get that done but it needs a biber release too of course. I'll see what I can do.

plk avatar Aug 19 '22 13:08 plk

No need to hurry for me. It's just more convenient to have the example here and only close the issue when one is available, so things don't get lost in the multiscript megathread.

moewew avatar Aug 19 '22 13:08 moewew