How to get LuaLaTeX to work with babel's \textgreek?

I'm completely at a loss with how to get LuaLaTeX to output Greek text. I have tested the following MWE with PDFLaTeX and LuaLaTeX on both TeXlive 2009 (Linux) and TeXlive 2011 (Win32) and in both cases PDFLaTeX produces the expected output while LuaLaTeX seems to gobble up the Greek text and then do nothing with it.

\documentclass{minimal}
% Use LGRx if installed else LGR.
% Forcing one or the other makes no difference either.
\IfFileExists{lgrxenc.def}{%
\usepackage[LGRx,T1]{fontenc}}{%
\usepackage[LGR,T1]{fontenc}}
%\fi
\usepackage{lmodern,trace,ifluatex}
\usepackage[greek,british]{babel}
\unless\ifluatex
\usepackage[utf8]{inputenc}
\fi
\begin{document}
% pdflatex: OK.
%lualatex:  "τρίγωνον" is missing from the output,
%           and the sum total of output from \traceon is this:
%             {into \tracingonline=1}
%             {the character τ}
%             {end-group character }}
Triangle: \textgreek{\traceon τρίγωνον}.
\end{document}

-

If you want to use the original CB fonts for Greek, there is a way out, but you need to have lgrenc.dfu, so I'll assume it's available along with its sibling lgrxenc.def:

\documentclass{minimal}
\usepackage[LGRx,T1]{fontenc}
\usepackage{lmodern,ifluatex}
\usepackage[greek,british]{babel}
\ifluatex
\let\LtxDeclareUnicodeCharacter\DeclareUnicodeCharacter
\def\DeclareUnicodeCharacter#1{%
\catcode\string"#1=\active
\begingroup
\lccode~=\string"#1\relax
\lowercase{\endgroup
\protected\def~}}
\input{lgrenc.dfu}
\let\DeclareUnicodeCharacter\LtxDeclareUnicodeCharacter
\else
\usepackage[utf8]{inputenc}
\fi
\begin{document}
Triangle: \textgreek{τρίγωνον}.
\end{document}


With LuaLaTeX I use lgrenc.dfu for a different purpose, that is for activating the Greek characters and defining them to the required meaning.

However I don't see the advantages of using LuaLaTeX, in this case.

-

I am not 100% sure I understand all the packages you are loading, but I would think this is the LuaTeX way:

\documentclass{minimal}

\usepackage[greek,british]{babel}

\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}

\begin{document}

Triangle: τρίγωνον.

\end{document}


You need to use a compatible font, you can find TeX Gyre Pagella and other fonts at fontsquirrel, but it should come with your TeX.

-
That is what I would do if using fontspec was an option. But this has to work on TeXlive 2009 as shipped by Debian (and Debian-derived distributions), and before TeXlive 2010, it shipped with fontspec that started (after the usual boilerplate) with the lines \RequirePackage{ifxetex}\RequireXeTeX (it used a lot of XeTeX-specific features) –  kahen Nov 12 '11 at 8:25
@Andy: Obviously TeX Gyre Pagella is not compatible since it misses the “ί.” –  Philipp Nov 12 '11 at 14:54
@kahen: If you are stuck with using LuaTeX with TL2009 you have my sympathies; I strongly advise to upgrade your LuaTeX. –  Martin Schröder Nov 12 '11 at 16:02
@Philipp, I even had Greek in school and did not notice :( –  Andy Nov 12 '11 at 18:00
When you are using pdflatex and inputenc each greek input is a small command which is mapped by the definitions in lgrenc.dfu (or lgrxenc.dfu) to an internal command. Then this internal command is mapped by the definitions in lgrenc.def or lgrxenc.de to the correct position in the correct font.
You can try \usepackage[utf8]{luainputenc}` (I don't know if it exists in texlive 2009). This will convert the greek chars in commands like inputenc is doing it with pdflatex.