%% This package must be loaded just before hyperref
\NeedsTeXFormat{LaTeX2e}[2018/04/01]
\ProvidesPackage{citebackref}[2021/01/28 0.5 back references in  bibliography (J.Hare)]
\RequirePackage{etoolbox}
\PassOptionsToPackage{pagebackref}{hyperref}%hyperpageref

\@ifpackageloaded{babel}{
	\@ifpackagewith{babel}{french} {
		\iflanguage{french}{
			\newcommand{\Br@lang}{french}
			\PassOptionsToPackage{french}{backref}
			\newcommand{\BR@cit@d}{Cité }
			\newcommand{\BR@not@cit@d}{Non cité.}
			\newcommand{\BR@nd}{et}%
		}{}
	}{
	}
}{}

\providecommand{\BR@cit@d}{Cited }
\providecommand{\BR@not@cit@d}{Not cited. }
\providecommand{\BR@nd}{and}%
\providecommand{\Br@lang}{english}
\PassOptionsToPackage{\Br@lang}{backref}

\AtEndPreamble{
\@ifpackageloaded{hyperref}{}{\PassOptionsToPackage{pageref}{backref}\RequirePackage{backref}}
\newcommand{\frm@tbackref}[1]{\hspace*{\fill}\mbox{\small #1}}
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{%
\ifcase#1\frm@tbackref{\BR@not@cit@d}\or\frm@tbackref{\BR@cit@d~page #2}\else\frm@tbackref{\BR@cit@d~pages #2}\fi}
\renewcommand*{\backreftwosep}{ \BR@nd~}
\renewcommand*{\backreflastsep}{, \BR@nd~}
}

\endinput
%end of citebackref package
