summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/lang-lab.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-lab.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/lang-lab.mkiv183
1 files changed, 95 insertions, 88 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-lab.mkiv b/Master/texmf-dist/tex/context/base/lang-lab.mkiv
index 025958ade6a..a9744f69973 100644
--- a/Master/texmf-dist/tex/context/base/lang-lab.mkiv
+++ b/Master/texmf-dist/tex/context/base/lang-lab.mkiv
@@ -5,7 +5,7 @@
%D subtitle=Labels,
%D author=Hans Hagen / Tobias Burnus,
%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
@@ -18,8 +18,9 @@
\unprotect
-%C The UPPERCASE variants are obsolete as we can now use \WORD
-%C in an non-interfering way.
+%D Left-overs:
+
+\ifdefined\sixperemspace \else \def\sixperemspace{ } \fi % \utfchar{2006"} % we could embed 0x2006 but it does not show up in a editor
%D In this module we deal with language dependant labels and
%D prefixes, like in {\em Figure~12} and {\em Chapter 1}. In
@@ -37,7 +38,6 @@
%D current implementation of labels supports two labels too.
\ifdefined\simplifiedcommands \else \newtoks\simplifiedcommands \fi
-\ifdefined\Word \else \let\Word\relax \fi
%D \macros
%D {setupheadtext, setuplabeltext}
@@ -61,12 +61,16 @@
%D
%D The last two cases concern the current language.
-\def\definelabelclass
- {\dodoubleempty\dodefinelabelclass}
+\installcorenamespace{label}
+
+\let\currentlabelcategory\empty
+
+\unexpanded\def\definelabelclass
+ {\dodoubleempty\lang_labels_define_class}
-\def\dodefinelabelclass[#1][#2]%
+\def\lang_labels_define_class[#1][#2]%
{\normalexpanded
- {\noexpand\dododefinelabelclass
+ {\lang_labels_define_class_indeed
{#1}%
{\ifsecondargument#2\else\zerocount\fi}%
\expandafter\noexpand\csname dogetupsome#1text\endcsname
@@ -77,41 +81,29 @@
\expandafter\noexpand\csname #1texts\endcsname
\expandafter\noexpand\csname #1text\endcsname}}
-\let\currentlabelcategory\empty
-
-\def\dododefinelabelclass#1#2#3#4#5#6#7#8#9%
- {\setuvalue{setup#1text}{\protecttextprefixes#2\def\currenttextprefixclass{#1}\dodoubleempty\dosetupsometextprefix}%
- \setuvalue{preset#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dodoubleempty\dosetupsometextprefix}%
+\unexpanded\def\lang_labels_define_class_indeed#1#2#3#4#5#6#7#8#9%
+ {\setuvalue{setup#1text}{\protecttextprefixes#2\def\currenttextprefixclass{#1}\dodoubleempty\lang_labels_text_prefix_setup}%
+ \setuvalue{preset#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dodoubleempty\lang_labels_text_prefix_setup}%
+ \setuvalue{start#1text}{\protecttextprefixes1\def\currenttextprefixclass{#1}\dotripleempty\lang_labels_text_prefix_start[#1]}%
+ \letvalue{stop#1text}\relax
\def#4{\reallanguagetag{\defaultlanguage\currentmainlanguage}}%
\ifnum#2=\plustwo
\def#3{#5#4}%
-% \def#5##1##2% ##1=language
-% {\ifcsname\??ml:#1:##1:##2\endcsname
-% \csname\??ml:#1:##1:##2\endcsname
-% \else\ifcsname\??la#4\s!default\endcsname
-% \expandafter#5\csname\??la#4\s!default\endcsname{##2}%
-% \else\ifcsname\??ml:#1:##2\endcsname
-% \csname\??ml:#1:##2\endcsname
-% \else\ifcsname\??ml:#1:\s!en:##2\endcsname
-% \csname\??ml:#1:\s!en:##2\endcsname
-% \else
-% ##2%
-% \fi\fi\fi\fi}%
\def#5##1##2% ##1=language
- {\ifcsname\??ml:\currentlabelcategory#1:##1:##2\endcsname
- \csname\??ml:\currentlabelcategory#1:##1:##2\endcsname
- \else\ifcsname\??ml:#1:##1:##2\endcsname
- \csname\??ml:#1:##1:##2\endcsname
- \else\ifcsname\??la#4\s!default\endcsname
- \expandafter#5\csname\??la#4\s!default\endcsname{##2}%
- \else\ifcsname\??ml:\currentlabelcategory#1:##2\endcsname
- \csname\??ml:\currentlabelcategory#1:##2\endcsname
- \else\ifcsname\??ml:#1:##2\endcsname
- \csname\??ml:#1:##2\endcsname
- \else\ifcsname\??ml:\currentlabelcategory#1:\s!en:##2\endcsname
- \csname\??ml:\currentlabelcategory#1:\s!en:##2\endcsname
- \else\ifcsname\??ml:#1:\s!en:##2\endcsname
- \csname\??ml:#1:\s!en:##2\endcsname
+ {\ifcsname\??label\currentlabelcategory#1:##1:##2\endcsname
+ \csname\??label\currentlabelcategory#1:##1:##2\endcsname
+ \else\ifcsname\??label#1:##1:##2\endcsname
+ \csname\??label#1:##1:##2\endcsname
+ \else\ifcsname\??language#4\s!default\endcsname
+ \expandafter#5\csname\??language#4\s!default\endcsname{##2}%
+ \else\ifcsname\??label\currentlabelcategory#1:##2\endcsname
+ \csname\??label\currentlabelcategory#1:##2\endcsname
+ \else\ifcsname\??label#1:##2\endcsname
+ \csname\??label#1:##2\endcsname
+ \else\ifcsname\??label\currentlabelcategory#1:\s!en:##2\endcsname
+ \csname\??label\currentlabelcategory#1:\s!en:##2\endcsname
+ \else\ifcsname\??label#1:\s!en:##2\endcsname
+ \csname\??label#1:\s!en:##2\endcsname
\else
##2%
\fi\fi\fi\fi\fi\fi\fi}%
@@ -122,14 +114,14 @@
\else
\unexpanded\def#3{#5#4}%
\unexpanded\def#5##1##2%
- {\ifcsname\??ml:#1:##1:##2\endcsname
- \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:##1:##2\endcsname
- \else\ifcsname\??la#4\s!default\endcsname
- \expandafter#5\csname\??la#4\s!default\endcsname{##2}%
- \else\ifcsname\??ml:#1:##2\endcsname
- \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:##2\endcsname
- \else\ifcsname\??ml:#1:\s!en:##2\endcsname
- \expandafter\let\expandafter\thetextprefix\csname\??ml:#1:\s!en:##2\endcsname
+ {\ifcsname\??label#1:##1:##2\endcsname
+ \expandafter\let\expandafter\thetextprefix\csname\??label#1:##1:##2\endcsname
+ \else\ifcsname\??language#4\s!default\endcsname
+ \expandafter#5\csname\??language#4\s!default\endcsname{##2}%
+ \else\ifcsname\??label#1:##2\endcsname
+ \expandafter\let\expandafter\thetextprefix\csname\??label#1:##2\endcsname
+ \else\ifcsname\??label#1:\s!en:##2\endcsname
+ \expandafter\let\expandafter\thetextprefix\csname\??label#1:\s!en:##2\endcsname
\else
\let\thetextprefix\dummytextprefix
\fi\fi\fi\fi}%
@@ -169,11 +161,6 @@
%D These macros enable us to automatically define head and label
%D texts without replacing predefined ones. They are internal macros.
-\definelabelclass [head] [0] % titles
-\definelabelclass [label] [0] % texts
-\definelabelclass [mathlabel] [0] % functions
-\definelabelclass [taglabel] [2] % tags
-
\appendtoks \let\labellanguage\currentlanguage \to \everycurrentdate
\newconstant\protecttextprefixes
@@ -181,55 +168,83 @@
\let\currenttextprefixtag \s!unknown
\let\currenttextprefixclass\s!unknown
-\def\dosetupsometextprefix[#1][#2]%
+\def\lang_labels_text_prefix_start[#1][#2][#3]% class language name
+ {\ifthirdargument
+ \edef\currenttextprefixtag{\reallanguagetag{#2}}%
+ \edef\currenttextprefixname{#3}%
+ \else
+ \edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
+ \edef\currenttextprefixname{#2}%
+ \fi
+ \grabuntil{stop#1text}\lang_labels_text_prefix_start_indeed}
+
+\def\lang_labels_text_prefix_start_indeed#1% text (not special checking done here yet, only for long texts anyway)
+ {\expandafter\edef\csname\??label\currenttextprefixclass:\currenttextprefixtag:\currenttextprefixname\endcsname{{\ctxlua{context(string.strip(\!!bs#1\!!es))}}\empty}}
+
+\def\lang_labels_text_prefix_setup[#1][#2]%
{\ifsecondargument
\edef\currenttextprefixtag{\reallanguagetag{#1}}%
- \processcommalist[#2]\dodosetupsometextprefix
+ \processcommalist[#2]\lang_labels_text_prefix_setup_indeed
\else
\edef\currenttextprefixtag{\reallanguagetag\currentmainlanguage}%
- \processcommalist[#1]\dodosetupsometextprefix
+ \processcommalist[#1]\lang_labels_text_prefix_setup_indeed
\fi}
-\def\dodosetupsometextprefix#1%
- {\dododosetupsometextprefix[#1]}
+\def\lang_labels_text_prefix_setup_indeed#1%
+ {\lang_labels_text_prefix_assign[#1]}
-\def\dododosetupsometextprefix[#1=#2]%
- {\doassignsometextprefix{#1}[#2,,]}
+\def\lang_labels_text_prefix_assign[#1=#2]%
+ {\lang_labels_text_prefix_assign_indeed{#1}[#2,,]}
-\def\doassignsometextprefix#1%
+\def\lang_labels_text_prefix_assign_indeed#1%
{\ifcase\protecttextprefixes
% no checking
- \expandafter\doassignsometextprefixyes
+ \expandafter\lang_labels_text_prefix_assign_yes
\or
% checking
- \ifcsname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname
- \expandafter\expandafter\expandafter\doassignsometextprefixnop
+ \ifcsname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname
+ \expandafter\expandafter\expandafter\lang_labels_text_prefix_assign_nop
\else
- \expandafter\expandafter\expandafter\doassignsometextprefixyes
+ \expandafter\expandafter\expandafter\lang_labels_text_prefix_assign_yes
\fi
\or
% simple assignment (a bit overkill but it fits in the whole)
- \expandafter\doassignsometextprefixdumb
+ \expandafter\lang_labels_text_prefix_assign_dumb
\fi{#1}}
-\def\doassignsometextprefixyes#1[#2,#3,#4]%
- {\edef\!!stringa{#2}%
- \edef\!!stringb{#3}%
- \ifx\!!stringb\empty
- \ifx\!!stringa\empty
- \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{\empty\empty}%
+\let\m_lang_labels_left \empty
+\let\m_lang_labels_right\empty
+
+\def\lang_labels_text_prefix_assign_yes#1[#2,#3,#4]%
+ {\def\m_lang_labels_left {#2}% no longer an edef ... else \Word undefined expansion issues
+ \def\m_lang_labels_right{#3}% no longer an edef ... else \Word undefined expansion issues
+ \ifx\m_lang_labels_right\empty
+ \ifx\m_lang_labels_left\empty
+ \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{\empty\empty}%
\else
- \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}\empty}%
+ \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}\empty}%
\fi
\else
- \expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}{#3}}%
+ \expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{{#2}{#3}}%
\fi}
-\def\doassignsometextprefixnop#1[#2]%
+\def\lang_labels_text_prefix_assign_nop#1[#2]%
{}
-\def\doassignsometextprefixdumb#1[#2,#3]%
- {\expandafter\def\csname\??ml:\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}}
+\def\lang_labels_text_prefix_assign_dumb#1[#2,#3]%
+ {\expandafter\def\csname\??label\currenttextprefixclass:\currenttextprefixtag:#1\endcsname{#2}}
+
+\definelabelclass [head] [0] % titles
+\definelabelclass [label] [0] % texts
+\definelabelclass [mathlabel] [0] % functions
+\definelabelclass [taglabel] [2] % tags
+
+\ctxlua{
+ languages.labels.define("setupheadtext","titles",true)%
+ languages.labels.define("setuplabeltext","texts",true)%
+ languages.labels.define("setupmathlabeltext","functions",false)%
+ languages.labels.define("setuptaglabeltext","tags",false)%
+}
%D \macros
%D {translate}
@@ -249,7 +264,10 @@
%D which expands to {\em something} or {\em iets}, depending on
%D de current language.
-\def\dotranslate[#1]%
+\unexpanded\def\translate
+ {\dosingleempty\lang_translate}
+
+\def\lang_translate[#1]%
{\getparameters[\??lg][#1]%
\ifcsname\??lg\currentlanguage\endcsname
\csname\??lg\currentlanguage\endcsname
@@ -259,9 +277,6 @@
[translation #1]%
\fi\fi}
-\unexpanded\def\translate
- {\dosingleempty\dotranslate}
-
%D When used without argument, the last defined values are
%D used. This enables repetitive use like
%D
@@ -283,12 +298,4 @@
{\getparameters[\??lg][#1]%
\edef#2{\csname\??lg\currentlanguage\endcsname}}
-%D Now we load the labels:
-
-\ifdefined\sixperemspace \else \def\sixperemspace{ } \fi % we could embed 0x2006 but it does not show up in a editor
-
-%D Now we can load the labels:
-
-\ctxlua{languages.labels.define()}
-
\protect \endinput