# Problem with babel + Greek and endnote package

I am typesetting a document which includes both French text (the main language) and some Greek. It's a kind of scholarly work and I would like to have both footnotes and endnotes. I would like to use Roman numerals for the endnote counters, rather than letters, since there may be more than 26 of them.

The problem is that it throws an error when I set the endnote counter to Roman numerals with Greek as part of the babel package. At least, as far as I can tell, this is what is happening; I'm probably not seeing what is really going on. Below is a MWE which produces the problem; if greek is removed from babel's option list, the error goes away.

Could someone help me see what I'm missing?

\documentclass{article}
\usepackage[frenchb]{babel}

\usepackage{endnotes}% http://ctan.org/pkg/endnotes
\renewcommand{\theendnote}{\roman{endnote}}

\begin{document}

tester\endnote{tester}

\theendnotes

\end{document}


The greek option to babel modifies the \roman and \@roman commands so that they're independent of the current language; doing so, however, breaks the usage with endnote.

Here's a possible solution:

\documentclass{article}
\usepackage[greek,frenchb]{babel}

\usepackage{endnotes}% http://ctan.org/pkg/endnotes
\usepackage{etoolbox}

\robustify{\textlatin} % make \textlatin legal in \edef
\renewcommand{\theendnote}{\roman{endnote}}

\begin{document}

tester\endnote{tester}

\textgreek{aaabbbccc\endnote{\textgreek{dddeeefff}}}

\theendnotes

\end{document}