[Tex/LaTex] Localization of biblatex headings

babelbiblatex

My Bibliography is subdivided into 2 parts (published / online references). I would like to get an automatic localization of the 2 subheadings, which is controled by the setting of the babel package.

Example with \usepackage[english]{babel}:

Bibliography
List of Published References
Author, A. (2013) – This is the Title.
Author, B. (2013) – This is the second Title.

List of Online References
Author, A. (2013) – URL http://www.test.com

Example with \usepackage[ngerman]{babel}:

Quellenverzeichnis
Literaturverzeichnis
Author, A. (2013) – This is the Title.
Author, B. (2013) – This is the second Title.

Liste der Internetquellen
Author, A. (2013) – URL http://www.test.com

My commands to setup the bibliography look like this:

\printbibheading[title={\bibname}]
\printbibliography[heading=subbibliography,title={\pubname},nottype=online]
\printbibliography[heading=subbibliography,title={\unpubname},type=online]

The commands \pubname and \unpubname are not defined right now. I don't know how to.

I thought it would be best to work with new bibliography strings, since the localization of \bibname works this way. Therefore I introduced the 2 bibliography strings publishedSources and unpublishedSources and defined them afterwards for the different languages. Unfortunately I have no clue about getting those values into the title key of \printbibliography:

\NewBibliographyString{publishedSources,unpublishedSources}
\DefineBibliographyStrings{english}{%
    publishedSources   = {List of Published References},
    unpublishedSources = {List of Online References},
}
\DefineBibliographyStrings{ngerman}{%
    bibliography       = {Quellenverzeichnis},
    publishedSources   = {Literaturverzeichnis},
    unpublishedSources = {Liste der Internetquellen},
}

Best Answer

Well, I found a way, but it needs to hack some biblatex internal code.

Keep your definitions:

\NewBibliographyString{publishedSources,unpublishedSources}
\DefineBibliographyStrings{english}{%
    publishedSources   = {List of Published References},
    unpublishedSources = {List of Online References},
}
\DefineBibliographyStrings{ngerman}{%
    bibliography       = {Quellenverzeichnis},
    publishedSources   = {Literaturverzeichnis},
    unpublishedSources = {Liste der Internetquellen},
}

and then add in your preamble

\makeatletter
\def\blx@defbibstrings#1#2{%
  \def\do##1{\csundef{abx@lstr@##1}\csundef{abx@sstr@##1}}%
  \abx@dostrings
  \csuse{abx@strings@#1}%
  \setkeys{blx@lbx}{#2}%
  \let\do\blx@defbibstrings@i
  \csxdef{abx@strings@#1}{\abx@dostrings}%
  \csgappto{abx@strings@#1}{%
    \ifcsdef{\abx@str @bibliography}
      {\letcs\bibname{\abx@str @bibliography}}
      {\let\bibname\@empty}%
    \ifcsdef{\abx@str @references}
      {\letcs\refname{\abx@str @references}}
      {\let\refname\@empty}%
    \ifcsdef{\abx@str @shorthands}
      {\letcs\losname{\abx@str @shorthands}}
      {\let\losname\@empty}
    \ifcsdef{\abx@str @publishedSources}
      {\letcs\pubname{\abx@str @publishedSources}}
      {\let\pubname\@empty}
    \ifcsdef{\abx@str @unpublishedSources}
      {\letcs\unpubname{\abx@str @unpublishedSources}}
      {\let\unpubname\@empty}
    }
  }
\makeatother

Thus the MWE

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[style=authortitle,backend=biber]{biblatex}
\usepackage[ngerman]{babel}
\usepackage{hyperref}
\addbibresource{biblatex-examples.bib}

\NewBibliographyString{publishedSources,unpublishedSources}
\DefineBibliographyStrings{english}{%
    publishedSources   = {List of Published References},
    unpublishedSources = {List of Online References},
}
\DefineBibliographyStrings{ngerman}{%
    bibliography       = {Quellenverzeichnis},
    publishedSources   = {Literaturverzeichnis},
    unpublishedSources = {Liste der Internetquellen},
}

\makeatletter
\def\blx@defbibstrings#1#2{%
  \def\do##1{\csundef{abx@lstr@##1}\csundef{abx@sstr@##1}}%
  \abx@dostrings
  \csuse{abx@strings@#1}%
  \setkeys{blx@lbx}{#2}%
  \let\do\blx@defbibstrings@i
  \csxdef{abx@strings@#1}{\abx@dostrings}%
  \csgappto{abx@strings@#1}{%
    \ifcsdef{\abx@str @bibliography}
      {\letcs\bibname{\abx@str @bibliography}}
      {\let\bibname\@empty}%
    \ifcsdef{\abx@str @references}
      {\letcs\refname{\abx@str @references}}
      {\let\refname\@empty}%
    \ifcsdef{\abx@str @shorthands}
      {\letcs\losname{\abx@str @shorthands}}
      {\let\losname\@empty}
    \ifcsdef{\abx@str @publishedSources}
      {\letcs\pubname{\abx@str @publishedSources}}
      {\let\pubname\@empty}
    \ifcsdef{\abx@str @unpublishedSources}
      {\letcs\unpubname{\abx@str @unpublishedSources}}
      {\let\unpubname\@empty}
    }
  }
\makeatother

\begin{document}

\cite{itzhaki}\cite{wassenberg}\cite{aksin}\cite{angenendt}

\printbibheading[title={\bibname}]
\printbibliography[heading=subbibliography,title={\pubname},nottype=online]
\printbibliography[heading=subbibliography,title={\unpubname},type=online]

\end{document}

yields

enter image description here