diff options
author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-12-24 13:06:39 +0100 |
---|---|---|
committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-12-24 13:06:39 +0100 |
commit | 9358aec78689e5360218855687d7884844294a01 (patch) | |
tree | 6ca90499a0a57643f629ca3c2e17b6b3d7ad9f43 | |
parent | 1702a800ec09c99e514185a34becb53309da7054 (diff) | |
download | transliterator-9358aec78689e5360218855687d7884844294a01.tar.gz |
migration to new namespace model
-rw-r--r-- | tex/context/third/transliterator/t-transliterator.mkiv | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/tex/context/third/transliterator/t-transliterator.mkiv b/tex/context/third/transliterator/t-transliterator.mkiv index 25c4231..7ba1f01 100644 --- a/tex/context/third/transliterator/t-transliterator.mkiv +++ b/tex/context/third/transliterator/t-transliterator.mkiv @@ -14,19 +14,26 @@ \writestatus{loading}{Transliteration from non-Latin scripts} -\startmodule[transliterator] +\unprotect + +\definenamespace [TRL] [ + name=transliterate, + type=module, + setup=list, + parent=TRL, + style=no, + version=hg-r16, + comment=Transliteration from non-Latin scripts., +] %\ctxlua{environment.loadluafile ("transliterator")} \ctxlua{dofile ("transliterator.lua")} -\unprotect %D Use the Transliterator by adding \type{\usemodule[transliterator]} somewhere %D before \type{\starttext}. Adjust the Transliterator through the %D \type{\setuptransliterate} command. As a first argument it accepts a set of %D key-value options; at present you may configure \type{mode} and %D \type{hyphenate}. -% emendation by Wolfgang Schuster -\def\setuptransliterate{\dodoubleargument\getparameters[TRL]} %D At first we'll set some defaults: \setuptransliterate[mode=ru_old,hyphenate=cz,debug=false] @@ -55,6 +62,7 @@ %D %D The user-level command to output a single substitution table is %D \type{\showOneTranslitTab{#1}}. + \define[1]\showOneTranslitTab{% \startluacode environment.loadluafile ("trans_tables_iso9") @@ -65,19 +73,19 @@ environment.loadluafile ("trans_tables_gr") translit.gen_rules_en() translit.gen_rules_de() - translit.show_tab("\luaescapestring{#1}") + translit.show_tab(translit["\luaescapestring{#1}"]) \stopluacode } %D The user-level command to output all defined tables is %D \type{\showTranslitTabs}. + \define\showTranslitTabs{% \ctxlua{translit.show_all_tabs()}% } \def\translitDebug#1{% - \doif{\TRLdebug}{true}{% - %\inmargin{\ctxlua{translit.debug_next()} #1}% Unreadable with too many debug messages. + \doif{\transliterateparameter{debug}}{yes}{% {\ss\inmargin{\ctxlua{translit.debug_next()}} #1}% }% } @@ -98,36 +106,34 @@ %D % All credits for rewriting the TeX code go to Wolfgang as well. % http://www.ntg.nl/pipermail/ntg-context/2010/047816.html + \def\dotransliterate[#1]#2{% - \bgroup - \iffirstargument - \getparameters[TRL][#1]% + \bgroup\iffirstargument + \setuptransliterate[#1]% \fi - \language[\TRLhyphenate]% - \ctxlua{translit.transliterate("\TRLmode","\luaescapestring{#2}")}% - \egroup + \language[\transliterateparameter{hyphenate}]% + \ctxlua{translit.transliterate("\transliterateparameter{mode}","\luaescapestring{#2}")}% + \egroup% } \unexpanded\def\transliterate{\dosingleempty\dotransliterate} \unexpanded\def\starttransliterate{% \bgroup% - \dosingleempty\dostarttransliterate + \dosingleempty\dostarttransliterate% } \let\stoptransliterate\relax \def\dostarttransliterate[#1]#2\stoptransliterate{% \iffirstargument - \setuptransliterate[#1]% -\fi - \language[\TRLhyphenate]% - \ctxlua{translit.transliterate("\TRLmode","\luaescapestring{#2}")}% - \egroup + \setuptransliterate[#1]% + \fi + \language[\transliterateparameter{hyphenate}]% + \ctxlua{translit.transliterate("\transliterateparameter{mode}","\luaescapestring{#2}")}% + \egroup% } -\protect - -\endinput +\protect \endinput % vim:ft=context |