On 2014-03-01 07:32, Wolfgang Schuster wrote:

\unexpanded\def\startTranslation
  {\begingroup
   \dosingleempty\dostartTranslation}

\def\dostartTranslation[#1]%
  {\iffirstargument
     \getrawparameters[Translation][setups=,language=en,#1]%
   \fi
   \grabbufferdata[Translation][startTranslation][stopTranslation]}

\def\stopTranslation
  {\language[\Translationlanguage]%
   \Translationsetups
   (\,\getbufferdata[Translation]\removeunwantedspaces\,)%
   \endgroup}

\starttext

\startTranslation[language=nl]
It betrays a slow-witted mentality to pursue the streams, but not to see the sources of things.
\stopTranslation

\stoptext

Wolfgang


Wolfgang (and list),

The above code works fine with simple texts, but is not movable. Adding a footnote, as in the following, to the text section shows that:

\starttext
\startTranslation[language=en]
  It betrays a slow-witted mentality to pursue the streams, but not to
  see the sources of things.%
  \footnote{%
    \startTranslation[language=la]
      Tardi ingeni est rivulos consectari, fontes rerum non videre.
    \stopTranslation%
  }
\stopTranslation
\stoptext

or even by:

\starttext
  It betrays a slow-witted mentality to pursue the streams, but not to
  see the sources of things.%
  \footnote{%
    \startTranslation[language=la]
      Tardi ingeni est rivulos consectari, fontes rerum non videre.
    \stopTranslation%
  }
\stoptext

In LaTeX, this might be dealt with by a combination robust command definitions and \protected. When I wrote an endnotes routine in LaTeX, I used those and wrote the notes to a file which was then read back in at the appropriate time, but that does not help with pagenotes.

I imagine that at the time the footnote is processed the Translationsetups and Translationlanguage macros are no longer defined, and I have no idea how one would reference the buffer contents, although it does look like they have stable names in the log file.

Can this be made movable?

Also, am I correct that the \iffirstargument test in the definition of dostarttranslation is redundant? My understanding is that \dosingleempty assures the presence of [#1].

--
Rik