# BibLaTeX - The localization without a language key

Generally, we can do the localization by setting the language key in each .bib entry and using \DeclareBibliographyStrings(BibLaTeX Document, p.204).

Mendeley can generate .bib resources, but there is no way to include the language key in each entry.

My question is how to change the BibLaTeX references format for each language without a language key.

I know that BibTeX can get the multiple .bib resources. Can BibLaTeX use different format settings in each .bib resource? Or, is there any suggestion in order to do the localization without a language key?

• Welcome to TeX.SX! Feb 10 '15 at 14:42
• Can it not generate arbitrary fields? That seems like a serious shortcoming.... Another idea: if you can add a unique string to one of the accepted fields, you could use \DeclareSourcemap to remove it and then add language fields....
– jon
Feb 10 '15 at 15:32
• @jon Would you mind if I stole your idea and added it to my answer as an alternative solution? Or would you prefer to add it as an answer yourself? Feb 10 '15 at 18:02
• @moewe -- No, by all means add it! One (more) 'definitive' answer seems best to me. My idea was just that this would allow for there to be one .bib file.
– jon
Feb 10 '15 at 18:55

Obviously it would be best for Mendeley to just allow to add the langid field for convenient language switching.

If you cannot have that, you might organise your bibliography in .bib files by language. You then can add the langid field for each entry like this

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\perdatasource{\jobname-en.bib}
\step[fieldset=langid, fieldvalue={english}]
}
\map{
\perdatasource{\jobname-de.bib}
\step[fieldset=langid, fieldvalue={ngerman}]
}
\map{
\perdatasource{\jobname-fr.bib}
\step[fieldset=langid, fieldvalue={french}]
}
}
}


Where we use \perdatasource to restrict the mapping to the appropriate .bib file.

MWE

\documentclass[ngerman,french,english,british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[style=authoryear, backend=biber, abbreviate=false, autolang=other]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname-en.bib}
@book{abook,
author     = {Ann Uthor},
editor     = {Emily Ditor},
translator = {Tracy R. Anslator},
title      = {A Fancy Title},
date       = {2015},
}
\end{filecontents*}
\begin{filecontents*}{\jobname-de.bib}
@book{einbuch,
author     = {Andrea Torin},
editor     = {Herbert R. Ausgeber},
title      = {Ein Titel},
date       = {2014},
}
\end{filecontents*}
\begin{filecontents*}{\jobname-fr.bib}
@book{livre,
author     = {Amelie Uteur},
editor     = {R. Édactrice},
title      = {Titre},
date       = {2014},
}
\end{filecontents*}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\perdatasource{\jobname-en.bib}
\step[fieldset=langid, fieldvalue={english}]
}
\map{
\perdatasource{\jobname-de.bib}
\step[fieldset=langid, fieldvalue={ngerman}]
}
\map{
\perdatasource{\jobname-fr.bib}
\step[fieldset=langid, fieldvalue={french}]
}
}
}

\nocite{*}

\begin{document}
\printbibliography
\end{document}


Note that the language is different for all the entries.

Alternatively - thanks to @jon for the idea - you could also add a unique string to a field you can export to. In our example we add [[<langid>]] to the title field (where <langid> should expand to a language identifier biblatex or rather babel/polyglossia can cope with). The language string is then added to the langid field and deleted from the title.

Here, the mapping looks like this

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=title, match=\regexp{\s*$\[(.+)$\]}, final]
\step[fieldset=langid, fieldvalue=\regexp{$1}] \step[fieldsource=title, match=\regexp{\s*$\[(.+)$\]}, replace={}] } } }  And you add the language to the .bib entry like this @book{einbuch, author = {Andrea Torin}, editor = {Herbert R. Ausgeber}, title = {Ein Titel[[ngerman]]}, date = {2014}, }  MWE \documentclass[ngerman,french,english,british]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{babel} \usepackage[style=authoryear, backend=biber, abbreviate=false, autolang=other]{biblatex} \usepackage{filecontents} \begin{filecontents*}{\jobname.bib} @book{abook, author = {Ann Uthor}, editor = {Emily Ditor}, translator = {Tracy R. Anslator}, title = {A Fancy Title [[english]]}, date = {2015}, } @book{einbuch, author = {Andrea Torin}, editor = {Herbert R. Ausgeber}, title = {Ein Titel[[ngerman]]}, date = {2014}, } @book{livre, author = {Amelie Uteur}, editor = {R. Édactrice}, title = {Titre [[french]]}, date = {2014}, } \end{filecontents*} \addbibresource{\jobname.bib} \DeclareSourcemap{ \maps[datatype=bibtex]{ \map{ \step[fieldsource=title, match=\regexp{\s*$\[(.+)$\]}, final] \step[fieldset=langid, fieldvalue=\regexp{$1}]
\step[fieldsource=title, match=\regexp{\s*$\[(.+)$\]}, replace={}]
}
}
}

\nocite{*}

\begin{document}
\printbibliography
\end{document}