I would like to create a custom environment, let's say foo, with an optional and a mandatory argument. This could be an approach:
\NewDocumentEnvironment{foo}{O{default} m}{start #1 #2}{end}
This environment could be used like that:
\begin{foo}[optional value]{mandatory value}
text
\end{foo}
But I prefer the following method, which I could not implement:
\begin{foo}[optional value]
text
\end{foo}{mandatory value}
Is it possible to create such an environment, where the mandatory argument follows the end-clause?

textis a latin text and the mandatory value is its translation, the optional contains pgf keys. I have to combine the two texts (latin and translation) in one command/environment, because the formatting of both texts depends on the same pgf keys. (I could use a command\foo[key]{text}{translation}, which I find ugly when having long texts and which is inconsistent to my other environments.) To keep the order text+translation, I prefer this last position. I know, it's a little bit special... – Andreas Knobloch Feb 20 '22 at 09:59\begin{foo}[<options>] Text \BREAK Translation \end{foo}be better? With a better name than\BREAK, of course. – egreg Feb 20 '22 at 10:16