summaryrefslogtreecommitdiff
path: root/tex/context/base/lang-spe.tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/lang-spe.tex')
-rw-r--r--tex/context/base/lang-spe.tex141
1 files changed, 50 insertions, 91 deletions
diff --git a/tex/context/base/lang-spe.tex b/tex/context/base/lang-spe.tex
index 306d4369c..30180e671 100644
--- a/tex/context/base/lang-spe.tex
+++ b/tex/context/base/lang-spe.tex
@@ -11,40 +11,24 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-%D This code was originally placed in the language
-%D initialization module, but isolating it is clearer. Language
-%D specifics evolved out of user demands for special features,
-%D like the german active quote. After a while I decided to
-%D associate them to languages in a more general way so that we
-%D could associate all kind of things with language switching.
-%D
-%D This is a typical example of functionality that occasionally
-%D gets improved based on user input and experience. Much of the
-%D code is pretty old and could probabbly be done in better ways.
-%D It's probably also the kind of code that has been and will be
-%D written over and over again by \TEX\ users around the world,
-%D so there are probably better implementations of similar
-%D functionality around. Therefore, users are invited to pop in
-%D their own handling as long as it does not interfere with
-%D existing code. Writing the more obscure macros that deal with
-%D this is a good learning experience (catcodes, lccodes, token
-%D lists, expansion, \unknown).
+%D This code was originally placed in the language
+%D initialization module, but isolating it is clearer.
\writestatus{loading}{Context Language Macros / Specifics}
\unprotect
-%D \macros
+%D \macros
%D {everyresetlanguagespecifics,resetlanguagespecifics}
-%D
-%D Cleanup macros.
+%D
+%D Cleanup macros.
\newevery \everyresetlanguagespecifics \relax
\def\resetlanguagespecifics
{\ifcase\protectionlevel
\the\everyresetlanguagespecifics
- \else % to be translated
+ \else % to be translated
\writestatus\m!systems{don't change language in unprotected mode!}%
\fi}
@@ -63,13 +47,13 @@
%D macro in return calls for the setup of language specific
%D macros. Such specifics are defined as:
%D
-%D \starttyping
+%D \starttypen
%D \startlanguagespecifics[de]
%D \installcompoundcharacter "a {\"a}
%D \installcompoundcharacter "e {\"e}
%D \installcompoundcharacter "s {\SS}
%D \stoplanguagespecifics
-%D \stoptyping
+%D \stoptypen
%D
%D Instead of \type{[du]} we can pass a comma separated
%D list, like \type{[du,nl]}. Next calls to this macro add the
@@ -92,7 +76,7 @@
%D be sure, we check on spurious spaces. The second dummy
%D argument gobbles spaces.
-\def\languageencoding
+\def\languageencoding%
{\ifx\characterencoding\nocharacterencoding \else
\characterencoding-%
\fi}
@@ -106,11 +90,11 @@
% \getvalue{\??la\languageencoding##1\??la}{#3}}
% {\setvalue{\??la\languageencoding##1\??la}{\do{##1}{#3}}}%
% \bgroup
-% \setbox0\hbox{\enablelanguagespecifics[##1]}%
-% \ifdim\wd0>\zeropoint
-% \showmessage\m!linguals7{\currentencoding-##1,\the\wd0\space}\wait
+% \setbox0=\hbox{\enablelanguagespecifics[##1]}%
+% \ifdim\wd0>\!!zeropoint
+% \showmessage{\m!linguals}{7}{\currentencoding-##1,\the\wd0\space}\wait
% \else
-% \showmessage\m!linguals8{\currentencoding-##1}%
+% \showmessage{\m!linguals}{8}{\currentencoding-##1}%
% \fi
% \egroup
% \doif{##1}{\currentmainlanguage}
@@ -119,45 +103,26 @@
% This saves 3K in the fmt file.
-% This should be a token register, but alas, we run out of them and
-% \ETEX\ has a bug.
-
-\long\def\dostartlanguagespecifics[#1][#2]#3\stoplanguagespecifics
+\long\def\dostartlanguagespecifics[#1][#2]#3\stoplanguagespecifics%
{\egroup
\processcommalist[#1]{\dosetlanguagespecifics{#3}}}
-% \long\def\dosetlanguagespecifics#1#2%
-% {\doifdefinedelse{\??la\languageencoding#2\??la}
-% {\long\def\do##1##2##3{\setvalue{\??la\languageencoding##1\??la}{\do{##1}{##2##3}}}%
-% \getvalue{\??la\languageencoding#2\??la}{#1}}
-% {\setvalue{\??la\languageencoding#2\??la}{\do{#2}{#1}}}%
-% \bgroup
-% \setbox\scratchbox\hbox{\enablelanguagespecifics[#2]}%
-% \ifdim\wd\scratchbox>\zeropoint
-% \showmessage\m!linguals7{\currentencoding-#2,\the\wd\scratchbox\space}\wait
-% \else
-% \showmessage\m!linguals8{\currentencoding-#2}%
-% \fi
-% \egroup
-% \doif{#2}\currentmainlanguage
-% {\enablelanguagespecifics[#2]}}
-
\long\def\dosetlanguagespecifics#1#2%
- {%ifundefined{\??la\languageencoding#2\??la}\letvalue{\??la\languageencoding#2\??la}\empty\fi
- \ifundefined{\??la\languageencoding#2\??la}\forgetlanguagespecifics[#2]\fi
- \appendvalue{\??la\languageencoding#2\??la}{#1}%
+ {\doifdefinedelse{\??la\languageencoding#2\??la}
+ {\long\def\do##1##2##3%
+ {\setvalue{\??la\languageencoding##1\??la}{\do{##1}{##2##3}}}%
+ \getvalue{\??la\languageencoding#2\??la}{#1}}
+ {\setvalue{\??la\languageencoding#2\??la}{\do{#2}{#1}}}%
\bgroup
- \setbox\scratchbox\hbox{\enablelanguagespecifics[#2]}%
- \ifdim\wd\scratchbox>\zeropoint
- \showmessage\m!linguals7{\currentencoding-#2,\the\wd\scratchbox\space}\wait
+ \setbox0=\hbox{\enablelanguagespecifics[#2]}%
+ \ifdim\wd0>\zeropoint
+ \showmessage{\m!linguals}{7}{\currentencoding-#2,\the\wd0\space}\wait
\else
- \showmessage\m!linguals8{\currentencoding-#2}%
+ \showmessage{\m!linguals}{8}{\currentencoding-#2}%
\fi
\egroup
- \doif{#2}\currentmainlanguage{\enablelanguagespecifics[#2]}}
-
-\def\forgetlanguagespecifics[#1]%
- {\letvalue{\??la\languageencoding#1\??la}\empty}
+ \doif{#2}{\currentmainlanguage}
+ {\enablelanguagespecifics[#2]}}
%D Enabling them is rather straightforward. We only have to
%D define \type{\do} in such a way that \type{{ }} is removed
@@ -174,7 +139,7 @@
% sped up since used often:
\def\enablelanguagespecifics[#1]%
- {%\let\do\secondoftwoarguments
+ {\let\do\secondoftwoarguments
\csname
\??la
\@EA\ifx\csname\??la#1\c!default\endcsname\relax
@@ -187,14 +152,14 @@
\csname\??la#1\??la\endcsname
\csname\??la\languageencoding#1\??la\endcsname} % dup ?
-%D \macros
+%D \macros
%D {deactivatelanguagespecific}
-%D
+%D
%D The next code makes it possible to disable the specifics.
\def\deactivatelanguagespecific#1%
{\ifundefined{l g s \string#1}%
- \letgvalueempty{l g s \string#1}% signal to prevent dup def
+ \letgvalueempty{l g s \string#1}% signal to prevent dup def
\bgroup
\catcode`#1=\@@active
\uccode`~=`#1
@@ -206,18 +171,18 @@
% \def\dodeactivatetoken#1#2#3%
% {\def#1{#2}\catcode`#2=#3\relax}
-\def\dodeactivatetoken#1#2#3% test needed to avoid clash with \unprotect
+\def\dodeactivatetoken#1#2#3% tets needed to avoid clash with \unprotect
{\def#1{#2}\ifnum\catcode`#2=\@@active\catcode`#2=#3\relax\fi}
-%D We cannot hook this into the installer since language
-%D specifics can be anything. So far, we have the following
-%D potentially active characters.
+%D We cannot hook this into the installer since language
+%D specifics can be anything. So far, we have the following
+%D potentially active characters.
-%D Beware, this should happen under an unprotected regime;
-%D thanks to Giuseppe Oblomov Bilotta, who first noticed
-%D that something was wrong.
+%D Beware, this should happen under an unprotected regime;
+%D thanks to Giuseppe Oblomov Bilotta, who first noticed
+%D that something was wrong.
-\protect
+\protect
\deactivatelanguagespecific "
\deactivatelanguagespecific /
@@ -226,19 +191,13 @@
\deactivatelanguagespecific ?
\deactivatelanguagespecific !
-\unprotect
-
-% yes or no (taco wins: no)
-
-% \startlanguagespecifics[nl,cz,sk,fr]
-% \lccode`\'=`\'
-% \stoplanguagespecifics
+\unprotect
-%D \macros
-%D {ordinaldaynumber, highordinalstr, ordinalstr}
-%D
-%D Efficient general ordinal number converters are sometimes
-%D difficult to implement. Fortunately dates never exceed the
+%D \macros
+%D {ordinaldaynumber, highordinalstr, ordinalstr}
+%D
+%D Efficient general ordinal number converters are sometimes
+%D difficult to implement. Fortunately dates never exceed the
%D number~31.
\def\highordinalstr#1{\high{\nocap{#1}}}
@@ -249,17 +208,17 @@
\noexpand\firstofoneargument{\number#1}}}
%D Language specific converters have definitions like:
-%D
-%D \starttyping
-%D \def\enordinaldaynumber#1{...}
-%D \stoptyping
-%D
+%D
+%D \starttypen
+%D \def\enordinaldaynumber#1{...}
+%D \stoptypen
+%D
%D Examples can be found in the other \type {lang} modules.
-% \ifprocessingXML is a nasty dependency
+% \ifprocessingXML is a nasty dependency
\appendtoks
\ifprocessingXML \else \resetlanguagespecifics \fi
\to \everylanguage
-\protect \endinput
+\protect \endinput