I need some glosses and use covington.sty for that (if you can solve my problem with another package I don't mind, I'd need to refactor everything for the solution, anyway). \gll expects two lines: the text to be glossed (Hallo Welt in the example) and the gloss of the text (Hello World in the example). Now I want a command \autogloss that automatically writes the second line for me. That is, the commands \hello{} \world{} that are common to both lines of \gll become the first argument of \autogloss. However, this fails to compile with Something's wrong--perhaps a missing \item..
I guessed it might be because the argument is not expanded, though then it should still have glossed it (just not properly) - and no amount of \expandafter seems to work.
I get the same message when I put a % at the ends of the lines of the working example so I thought the solution from this problem might work, but it doesn't seem to (but maybe I did something wrong there).
\documentclass{article}
\usepackage{etoolbox}
\usepackage{covington}
\newcounter{@language}
\setcounter{@language}{0}
\def\english{\setcounter{@language}{0}}
\def\german{\setcounter{@language}{1}}
\newcommand\hello{\ifnumcomp{\value{@language}}{=}{0}{Hello}{Hallo}}
\newcommand\world{\ifnumcomp{\value{@language}}{=}{0}{World}{Welt}}
\newcommand\autogloss[2]{%
\gll \german{}#1
\english{}#1
\glt `#2'
\glend
}
\begin{document}
\begin{examples}
\item this one works:
\gll \german{}\hello{} \world{}
\english{}\hello{} \world{}
\glt `Hello World.'
\glend
\item this one doesn't: % comment next line to compile.
\autogloss{\hello{} \world{}}{`Hello World.'}
\end{examples}
\end{document}

TeX capacity exceeded, sorry [parameter stack size=10000]which can be reproduced in the MWE by adding\usepackage{xstring}after\usepackage{gb4e}, so I'll have to put it before. – user66554 Dec 20 '14 at 20:29xstringbeforegb4e. – karlkoeller Dec 20 '14 at 20:33gb4eshould be loaded as late as possible in the loading order. – Alan Munn Dec 20 '14 at 20:36