diff options
author | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
---|---|---|
committer | Mojca Miklavec <mojca.miklavec@gmail.com> | 2012-05-14 17:38:55 +0000 |
commit | 15995e10bfc68edf79970c4ea4fbb6678566c46e (patch) | |
tree | 2de7ca2a83f2d37ef043ad7429a5cb945bb79ddb /Master/texmf-dist/tex/context/base/lang-ini.mkiv | |
parent | c9a39f716f1e5ec820ed3aab2c9aef25c5a9d730 (diff) |
ConTeXt 2012.05.14 16:00
git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/lang-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/lang-ini.mkiv | 184 |
1 files changed, 101 insertions, 83 deletions
diff --git a/Master/texmf-dist/tex/context/base/lang-ini.mkiv b/Master/texmf-dist/tex/context/base/lang-ini.mkiv index 5dccab4dc82..150b68f702f 100644 --- a/Master/texmf-dist/tex/context/base/lang-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/lang-ini.mkiv @@ -5,7 +5,7 @@ %D subtitle=Initialization, %D author=Hans Hagen, %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 @@ -13,7 +13,7 @@ %D This module needs a further cleanup (real split between ii/iv). -% \ctxlua{tex.sprint(languages.numbers[tex.count.mainlanguagenumber])} +% \cldcontext{languages.numbers[tex.count.mainlanguagenumber]} %D This module implements the (for the moment still simple) %D multi||language support of \CONTEXT, which should not be @@ -39,8 +39,8 @@ % \testlanguage[de] \testlanguage[de-de] \testlanguage[de-at] \testlanguage[de-ch] \page % \testlanguage[en] \testlanguage[us] \testlanguage[en-us] \testlanguage[uk] \testlanguage[en-gb] \page -\ifx\nonfrenchspacing\undefined \let\nonfrenchspacing\relax \fi -\ifx\frenchspacing \undefined \let\frenchspacing \relax \fi +\ifdefined\nonfrenchspacing\else \let\nonfrenchspacing\relax \fi +\ifdefined\frenchspacing \else \let\frenchspacing \relax \fi %D When loading hyphenation patterns, \TEX\ assign a number to %D each loaded table, starting with~0. Switching to a specific @@ -79,34 +79,42 @@ %D \macros %D {defaultlanguage,languageparameter,specificlanguageparameter} +%D We don't use the commandhandler here (yet) because we have +%D a rather special fallback mechanism so quite some compatibility +%D testing is needed. + +\installcorenamespace{language} +\installcorenamespace{languagelinked} + \def\defaultlanguage#1% - {\ifcsname\??la#1\s!default\endcsname - \expandafter\defaultlanguage\csname\??la#1\s!default\endcsname + {\ifcsname\??language#1\s!default\endcsname + \expandafter\defaultlanguage\csname\??language#1\s!default\endcsname \else #1% \fi} \def\languageparameter#1% - {\ifcsname\??la\currentlanguage#1\endcsname - \csname\??la\currentlanguage#1\endcsname - \else\ifcsname\??la\currentlanguage\s!default\endcsname - \expandafter\specificlanguageparameter\csname\??la\currentlanguage\s!default\endcsname{#1}% - \else\ifcsname\??la\s!default#1\endcsname - \csname\??la\s!default#1\endcsname + {\ifcsname\??language\currentlanguage#1\endcsname + \csname\??language\currentlanguage#1\endcsname + \else\ifcsname\??language\currentlanguage\s!default\endcsname + \expandafter\specificlanguageparameter\csname\??language\currentlanguage\s!default\endcsname{#1}% + \else\ifcsname\??language\s!default#1\endcsname + \csname\??language\s!default#1\endcsname \fi\fi\fi} \def\specificlanguageparameter#1#2% - {\ifcsname\??la#1#2\endcsname - \csname\??la#1#2\endcsname - \else\ifcsname\??la#1\s!default\endcsname - \expandafter\specificlanguageparameter\csname\??la#1\s!default\endcsname{#2}% - \else\ifcsname\??la\s!default#2\endcsname - \csname\??la\s!default#2\endcsname + {\ifcsname\??language#1#2\endcsname + \csname\??language#1#2\endcsname + \else\ifcsname\??language#1\s!default\endcsname + \expandafter\specificlanguageparameter\csname\??language#1\s!default\endcsname{#2}% + \else\ifcsname\??language\s!default#2\endcsname + \csname\??language\s!default#2\endcsname \fi\fi\fi} -\unexpanded\def\setupcurrentlanguage[#1]{\setcurrentlanguage\currentmainlanguage{#1}} +\unexpanded\def\setupcurrentlanguage[#1]% + {\setcurrentlanguage\currentmainlanguage{#1}} -\def\setcurrentlanguage#1#2% sets modes: **id (currentmain) *id (current) +\unexpanded\def\setcurrentlanguage#1#2% sets modes: **id (currentmain) *id (current) {\edef\xaskedlanguage{#1}% otherwise clash with \askedlanguage \ifx\xaskedlanguage\empty \else \ifx\currentmainlanguage\empty\else\resetsystemmode{\systemmodeprefix\currentmainlanguage}\fi @@ -154,10 +162,6 @@ %D implementations support run time addition of patterns to a %D preloaded format). -% move to lua end - -\def\dodoinstalllanguage#1#2% - {\ifcsname#1\endcsname\else\setuvalue{#1}{\complexlanguage[#2]}\fi} %D \macros %D {preloadlanguages} @@ -172,43 +176,50 @@ \def\installedlanguages{\ctxlua{languages.installed()}} -\def\doiflanguageelse#1{\doifdefinedelse{\??la#1\c!state}} +\unexpanded\def\doiflanguageelse#1% + {\ifcsname\??language#1\c!state\endcsname + \expandafter\firstoftwoarguments + \else + \expandafter\secondoftwoarguments + \fi} + +\def\reallanguagetag#1% + {\ifcsname\??languagelinked#1\endcsname\csname\??languagelinked#1\endcsname\else#1\fi} -\def\doinstalllanguage[#1][#2]% +% \language[#1] gave unwanted side effect of loading language specifics + +\unexpanded\def\installlanguage + {\dodoubleargument\lang_basics_install} + +\def\lang_basics_install[#1][#2]% {\doifassignmentelse{#2} {\doiflanguageelse{#1} - {\getparameters[\??la#1][#2]} - {\setvalue{\l!prefix!#1}{#1}% - \dodoinstalllanguage{#1}{#1}% - \getparameters[\??la#1][\c!state=\v!start,#2]}% + {\getparameters[\??language#1][#2]} + {\setvalue{\??languagelinked#1}{#1}% + \lang_basics_install_indeed{#1}{#1}% + \getparameters[\??language#1][\c!state=\v!start,#2]}% \edef\currentsetuplanguage{#1}% \ctxlua{languages.define("#1","\specificlanguageparameter{#1}\s!default")}% \the\everysetuplanguage} - {\setvalue{\l!prefix!#1}{#2}% + {\setvalue{\??languagelinked#1}{#2}% \ctxlua{languages.synonym("#1","#2")}% - %\getparameters[\??la#1][\s!default=#2]% - \dodoinstalllanguage{#1}{#2}}} + \lang_basics_install_indeed{#1}{#2}}} -\def\reallanguagetag#1% - {\ifcsname\l!prefix!#1\endcsname\csname\l!prefix!#1\endcsname\else#1\fi} - -% \language[#1] gave unwanted side effect of loading language specifics - -\def\installlanguage - {\dodoubleargument\doinstalllanguage} +\def\lang_basics_install_indeed#1#2% + {\ifcsname#1\endcsname\else\setuvalue{#1}{\lang_basics_set_current[#2]}\fi} %D When the second argument is a language identifier, a %D synonym is created. This feature is present because we %D used dutch mnemonics in the dutch version, but nowadays %D conform a standard. -\def\doifpatternselse#1% - {\bgroup % will change +\unexpanded\def\doifpatternselse#1% + {\begingroup % will change \language[#1]% \ifnum\normallanguage>\zerocount - \bgroup\expandafter\firstoftwoarguments + \endgroup\expandafter\firstoftwoarguments \else - \bgroup\expandafter\secondoftwoarguments + \endgroup\expandafter\secondoftwoarguments \fi} %D \macros @@ -221,25 +232,26 @@ %D Beware, this command can only be used when a language is installed. \unexpanded\def\setuplanguage - {\dodoubleempty\dosetuplanguage} + {\dodoubleempty\lang_basics_setup} -\ifdefined\docomplexlanguage \else \let\docomplexlanguage\relax \fi +\ifdefined\lang_basics_synchronize \else + \let\lang_basics_synchronize\relax % be nice for setups till we have one +\fi -\def\dosetuplanguage[#1][#2]% +\def\lang_basics_setup[#1][#2]% {\ifsecondargument \pushmacro\currentlanguage % can be default \edef\currentsetuplanguage{\reallanguagetag{#1}}% - \getparameters[\??la\currentsetuplanguage][#2]% + \getparameters[\??language\currentsetuplanguage][#2]% \the\everysetuplanguage \popmacro\currentlanguage %\doif\currentsetuplanguage\currentlanguage we can have influenced inheritance (default) - \docomplexlanguage \else \let\currentsetuplanguage\currentlanguage - \getparameters[\??la\currentsetuplanguage][#1]% + \getparameters[\??language\currentsetuplanguage][#1]% \the\everysetuplanguage - \docomplexlanguage - \fi} + \fi + \lang_basics_synchronize} \appendtoks \ctxlua{languages.setdirty("\currentsetuplanguage")}% @@ -257,6 +269,9 @@ \c!righthyphen=-, \c!hyphen=-, \c!spacing=\v!packed, + \c!compoundhyphen=\compoundhyphen, + \c!rightcompoundhyphen=\compoundhyphen, + \c!leftcompoundhyphen=, \c!midsentence=---, \c!leftsentence=---, \c!rightsentence=---, @@ -273,14 +288,6 @@ \c!date={\v!year,\ ,\v!month,\ ,\v!day}, \c!text=Ag] -% rather new, split and per language - -\setuplanguage - [\s!default] - [\c!compoundhyphen=\compoundhyphen, - \c!rightcompoundhyphen=\compoundhyphen, - \c!leftcompoundhyphen=] - % to be tested: % % \setuplanguage @@ -346,8 +353,8 @@ \newtoks \everylanguage -\def\docomplexlanguage% assumes that \currentlanguage is set % % % use different name as complex - {\normallanguage\ctxlua{commands.languagenumber(% +\def\lang_basics_synchronize% assumes that \currentlanguage is set % % % use different name as complex + {\normallanguage\ctxcommand{languagenumber(% "\currentlanguage",% "\defaultlanguage\currentlanguage",% "\languageparameter\s!patterns"% @@ -363,6 +370,19 @@ \posthyphenchar\languageparameter\s!lefthyphenchar \relax \to \everylanguage +% \appendtoks +% \setups[\languageparameter\c!setups]% +% \to \everylanguage + +%D You can setup the 'default' language to reset settings. + +\appendtoks + \edef\currentlanguagesetups{\languageparameter\c!setups}% + \ifx\currentlanguagesetups\empty \else + \setups[\currentlanguagesetups]% + \fi +\to \everylanguage + % this will move to core-spa ! \appendtoks @@ -377,40 +397,40 @@ % The following may be a solution for the fact that one cannot % change catcodes of characters like : and ; inside an environment. -\def\complexlanguage[#1]% +% we will also permit access by the other names + +\unexpanded\def\lang_basics_set_current[#1]% {\edef\askedlanguage{#1}% \ifx\askedlanguage\empty \else - \ifcsname\l!prefix!\askedlanguage\endcsname - \edef\askedlanguage{\csname\l!prefix!\askedlanguage\endcsname}% + \ifcsname\??languagelinked\askedlanguage\endcsname + \edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}% \ifx\currentlanguage\askedlanguage \else \setcurrentlanguage\currentmainlanguage\askedlanguage - \docomplexlanguage + \lang_basics_synchronize \fi \else \showmessage\m!languages6{#1}% \fi \fi} -\let\simplelanguage\normallanguage - -\definecomplexorsimple\language +\unexpanded\def\language + {\doifnextoptionalelse\lang_basics_set_current\normallanguage} \newcount\mainlanguagenumber -\def\mainlanguage[#1]% +\unexpanded\def\mainlanguage[#1]% {\edef\askedlanguage{#1}% \ifx\askedlanguage\empty \else - \ifcsname\l!prefix!\askedlanguage\endcsname - \edef\askedlanguage{\csname\l!prefix!\askedlanguage\endcsname}% + \ifcsname\??languagelinked\askedlanguage\endcsname + \edef\askedlanguage{\csname\??languagelinked\askedlanguage\endcsname}% \ifx\currentlanguage\askedlanguage - \ifx\currentmainlanguage\askedlanguage - \else + \ifx\currentmainlanguage\askedlanguage \else \setcurrentlanguage\askedlanguage\askedlanguage - \docomplexlanguage + \lang_basics_synchronize \fi \else \setcurrentlanguage\askedlanguage\askedlanguage - \docomplexlanguage + \lang_basics_synchronize \fi \fi \fi @@ -533,17 +553,15 @@ %D \stoptable %D \protect -\def\nopatterns{\normallanguage\minusone} +\unexpanded\def\nopatterns{\normallanguage\minusone} %D We default to the language belonging to the interface. This %D is one of the few places outside the interface modules where %D \type{\startinterface} is used. -%D We default to english: - \setupcurrentlanguage[\s!en] -\def\initializemainlanguage +\unexpanded\def\initializemainlanguage {\mainlanguage[\currentlanguage]% \showmessage\m!languages9\currentlanguage} @@ -554,7 +572,7 @@ \unexpanded\def\startexceptions {\dosingleempty\dostartexceptions} -\long\def\dostartexceptions[#1]#2\stopexceptions % multilingual or not? +\def\dostartexceptions[#1]#2\stopexceptions % multilingual or not? {\begingroup \edef\askedlanguage{\reallanguagetag{#1}}% \ifx\askedlanguage\empty @@ -565,7 +583,7 @@ %D For the moment here: -\uchyph = 1 % also treat uppercase -\exhyphenchar=45 % to permit breaking at explicit hyphens +\uchyph 1 % also treat uppercase +\exhyphenchar 45 % to permit breaking at explicit hyphens \protect \endinput |