ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Cc: Taco Hoekwater <taco@elvenkind.com>
Subject: Re: How to preserve a TeX token list across passes (the	ConTeXt way)?
Date: Mon, 15 May 2006 10:52:58 +0200	[thread overview]
Message-ID: <4468416A.9040002@wxs.nl> (raw)
In-Reply-To: <7EB85204-2670-45AE-9F5D-3B7CFDFF70CD@kotikone.fi>

Jyrki Ruuskanen wrote:
> Ok, the module is read in cont-sys.rme with \usemodule[jtex]. It 
> initializes the lists inside protect / unprotect pair with 
> \newtoks\usedAbbreviations and \newtoks\usedReferences along with 
> macro definitions.
first of all, here is an alternative to setting your texts; instead of doing the check-next-char stuff yourself ...

%%% handle multilingual texts (and uppercase)
% usage: \setText[lang]{key}{value}
\def\setText{\futurelet\testchar\maybeLangSetText}
\def\maybeLangSetText%
	{\ifx[\testchar \let\next\langSetText
	\else \let\next\defaultSetText \fi \next}
\def\langSetText[#1]#2#3{\def\name{#2@#1}\def\bigname{#2@#1@uppercase}
	\expandafter\def\csname \name \endcsname{#3}
	\expandafter\def\csname \bigname \endcsname{\uppercase{#3}}}
\def\defaultSetText#1#2{\langSetText[\currentmainlanguage]{#1}{#2}}

% usage: \getText{key}
\def\langGetText[#1]#2{\def\name{#2@#1}%
	\expandafter\ifx\csname \name \endcsname\relax
	\name missing!\else\csname \name \endcsname\fi}
\def\getText#1{\def\name{#1@\currentlanguage}%
	\expandafter\ifx\csname \name \endcsname\relax
	\langGetText[\currentmainlanguage]{#1}
	\else\langGetText[\currentlanguage]{#1}\fi}


... you can use the built in functionality: 

\let\dowithText\firstofoneargument

\def\setText
  {\dosingleempty\dosetText}

\def\dosetText[#1]#2#3%
  {\setvalue{\iffirstargument#1\else\currentmainlanguage\fi @TXT@#2}{\dowithText{#3}}}

\def\getText
  {\let\dowithText\firstofoneargument
   \dosingleempty\dogetText}

\def\dogetText[#1]#2%
  {\executeifdefined{\iffirstargument#1\else\currentlanguage\fi @TXT@#2}%
     {\executeifdefined{\iffirstargument#1\else\currentmainlanguage\fi @TXT@#2}%
        {missing #2}}}

\def\getUppercaseText
  {\let\dowithText\WORD
   \dosingleempty\dogetText}


\starttext

\setText{oeps}{whatever}
\setText[de]{oeps}{de-whatever}

\getText{oeps}
\getText[de]{oeps}
\getUppercaseText{oeps}
\getUppercaseText[de]{oeps}

\stoptext

but, when possible, use: 

\setuplabeltext[oeps=whatever]
\setuplabeltext[de][oeps=de-whatever]

{\labeltext{oeps} \mainlanguage[de] \labeltext{oeps} \LABELTEXT{oeps}}

because that is kind of integrated 

Hans 


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

  parent reply	other threads:[~2006-05-15  8:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-11 17:50 Jyrki Ruuskanen
2006-05-11 18:29 ` Hans Hagen
2006-05-11 21:49 ` Hans Hagen
2006-05-15  8:28 ` Hans Hagen
2006-05-15  8:52 ` Hans Hagen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-05-11 19:32 Jyrki Ruuskanen
2006-05-10 17:28 Jyrki Ruuskanen
2006-05-11  8:33 ` Taco Hoekwater
2006-05-11  8:45 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4468416A.9040002@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    --cc=taco@elvenkind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).