%D \module
%D   [       file=lang-chi,
%D        version=2002.06.25, % 1998.10.10,
%D          title=\CONTEXT\ Language Macros,
%D       subtitle=Chinese,
%D         author={Hans Hagen \& Wang Lei},
%D           date=\currentdate,
%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
%C details.

\writestatus{loading}{ConTeXt Language Macros / Chinese}

%D This module is coded using the \UNICODE\ support built in
%D \CONTEXT. Therefore, \type {\uchar} is used instead of latin
%D characters.

\unprotect

\definesystemconstant {chinese}   \definesystemconstant {cn}

\installlanguage
  [\s!cn]
  [\c!leftsentence=\cnencoding\cnleftsentence,
   \c!rightsentence=\cnencoding\cnrightsentence,
   \c!leftsubsentence=\cnencoding\cnleftsubsentence,
   \c!rightsubsentence=\cnencoding\cnrightsubsentence,
   \c!leftquote=\cnencoding\cnupperleftsinglequote,
   \c!rightquote=\cnencoding\cnupperrightsinglequote,
   \c!leftquotation=\cnencoding\cnupperleftdoublequote,
   \c!rightquotation=\cnencoding\cnupperrightdoublequote,
   \c!date={\v!year,\cnyear,\ ,\v!month,\v!day,\cnday}]

\setupheadtext [\s!cn]       [\v!content={\cnencoding\cnencodedcontents}]
\setupheadtext [\s!cn]        [\v!tables={\cnencoding\cnencodedtables}]
\setupheadtext [\s!cn]       [\v!figures={\cnencoding\cnencodedfigures}]
\setupheadtext [\s!cn]      [\v!graphics={\cnencoding\cnencodedgraphics}]% RG & XJF
\setupheadtext [\s!cn]    [\v!intermezzi={\cnencoding\cnencodedintermezzo}]% RG & XJF
\setupheadtext [\s!cn]         [\v!index={\cnencoding\cnencodedindex}]
\setupheadtext [\s!cn] [\v!abbreviations={\cnencoding\cnencodedabbreviations}]
\setupheadtext [\s!cn]         [\v!logos={\cnencoding\cnencodedlogos}]
\setupheadtext [\s!cn]         [\v!units={\cnencoding\cnencodedunits}]

\setuplabeltext [\s!cn]        [\v!table={\cnencoding\cnencodedtable}]
\setuplabeltext [\s!cn]       [\v!figure={\cnencoding\cnencodedfigure}]
\setuplabeltext [\s!cn]   [\v!intermezzo={\cnencoding\cnencodedintermezzo}]% RG & XJF
\setuplabeltext [\s!cn]      [\v!graphic={\cnencoding\cnencodedillustration}]% RG & XJF
\setuplabeltext [\s!cn]     [\v!appendix={\cnencoding\cnencodedappendix}]% RG
\setuplabeltext [\s!cn]         [\v!part={\cnencoding\cnencodedintro,\cnencoding\cnencodedpart}]
\setuplabeltext [\s!cn]      [\v!chapter={\cnencoding\cnencodedintro,\cnencoding\cnencodedchapter}]
\setuplabeltext [\s!cn]      [\v!section={\cnencoding\cnencodedintro,\cnencoding\cnencodedsection}]
\setuplabeltext [\s!cn]         [\v!line={\cnencoding\cnencodedline}]% RG & XJF
\setuplabeltext [\s!cn]        [\v!lines={\cnencoding\cnencodedline}]% RG & XJF

\setuplabeltext [\s!cn]       [\v!subsection=]
\setuplabeltext [\s!cn]    [\v!subsubsection=]
\setuplabeltext [\s!cn] [\v!subsubsubsection=]

%D From this definition one can deduce that language, input
%D encoding, font encoding, and glyph meaning form a pretty
%D complex four dimensional space.

\startlanguagespecifics[\s!cn]

\setuplabeltext [\s!cn]   [\v!january=\cnencoding\cnencodedjanuary  ]
\setuplabeltext [\s!cn]  [\v!february=\cnencoding\cnencodedfebrary  ]
\setuplabeltext [\s!cn]     [\v!march=\cnencoding\cnencodedmarch    ]
\setuplabeltext [\s!cn]     [\v!april=\cnencoding\cnencodedapril    ]
\setuplabeltext [\s!cn]       [\v!may=\cnencoding\cnencodedmay      ]
\setuplabeltext [\s!cn]      [\v!june=\cnencoding\cnencodedjune     ]
\setuplabeltext [\s!cn]      [\v!july=\cnencoding\cnencodedjuly     ]
\setuplabeltext [\s!cn]    [\v!august=\cnencoding\cnencodedaugust   ]
\setuplabeltext [\s!cn] [\v!september=\cnencoding\cnencodedseptember]
\setuplabeltext [\s!cn]   [\v!october=\cnencoding\cnencodedoctober  ]
\setuplabeltext [\s!cn]  [\v!november=\cnencoding\cnencodednovember ]
\setuplabeltext [\s!cn]  [\v!december=\cnencoding\cnencodeddecember ]

\setuplabeltext [\s!cn]    [\v!sunday=\cnencoding\cnencodedsunday   ]
\setuplabeltext [\s!cn]    [\v!monday=\cnencoding\cnencodedmonday   ]
\setuplabeltext [\s!cn]   [\v!tuesday=\cnencoding\cnencodedtuesday  ]
\setuplabeltext [\s!cn] [\v!wednesday=\cnencoding\cnencodedwednesday]
\setuplabeltext [\s!cn]  [\v!thursday=\cnencoding\cnencodedthursday ]
\setuplabeltext [\s!cn]    [\v!friday=\cnencoding\cnencodedfriday   ]
\setuplabeltext [\s!cn]  [\v!saturday=\cnencoding\cnencodedsaturday ]

\stoplanguagespecifics

%D One can specify a split labeltext, as demonstrated in
%D the definition of the \type {part} label. Unfortunately
%D the glyphs of both part depend on the encoding. Therefore,
%D we have an encoding section here.

\unexpanded\def\cnencoding{\enableencoding[\chineseencoding]} % ugly and temporary

\startencoding[cjk-uni]
  \definecommand cnleftsentence            {\uchar{32}{20}\uchar{32}{20}}
  \definecommand cnrightsentence           {\uchar{32}{20}\uchar{32}{20}}
  \definecommand cnleftsubsentence         {\uchar{32}{20}\uchar{32}{20}}
  \definecommand cnrightsubsentence        {\uchar{32}{20}\uchar{32}{20}}
  \definecommand cnupperleftsinglequote    {\uchar{32}{24}}
  \definecommand cnupperrightsinglequote   {\uchar{32}{25}}
  \definecommand cnupperleftdoublequote    {\uchar{32}{28}}
  \definecommand cnupperrightdoublequote   {\uchar{32}{29}}
  \definecommand cnupperleftsinglequote-v  {\uchar{48}{12}}
  \definecommand cnupperrightsinglequote-v {\uchar{48}{13}}
  \definecommand cnupperleftdoublequote-v  {\uchar{48}{14}}
  \definecommand cnupperrightdoublequote-v {\uchar{48}{15}}
  \definecommand cnencodedcontents         {\uchar{118}{238}\uchar{95}{85}}
  \definecommand cnencodedtables           {\uchar{136}{104}\uchar{104}{60}}
  \definecommand cnencodedfigures          {\uchar{86}{254}\uchar{95}{98}}
  \definecommand cnencodedindex            {\uchar{125}{34}\uchar{95}{21}}
  \definecommand cnencodedabbreviations    {\uchar{127}{41}\uchar{117}{101}\uchar{139}{237}}
  \definecommand cnencodedlogos            {\uchar{95}{189}\uchar{141}{44}}
  \definecommand cnencodedunits            {\uchar{139}{161}\uchar{145}{207}\uchar{83}{85}\uchar{79}{77}}
  \definecommand cnencodedtable            {\uchar{136}{104}}
  \definecommand cnencodedfigure           {\uchar{86}{254}}
  \definecommand cnencodedintro            {\uchar{123}{44}}
  \definecommand cnencodedpart             {\uchar{144}{232}\uchar{82}{6}}
  \definecommand cnencodedchapter          {\uchar{122}{224}}
  \definecommand cnencodedsection          {\uchar{130}{130}}
  \definecommand cnencodedjanuary          {\uchar{78}{0}\uchar{103}{8}}
  \definecommand cnencodedfebrary          {\uchar{78}{140}\uchar{103}{8}}
  \definecommand cnencodedmarch            {\uchar{78}{9}\uchar{103}{8}}
  \definecommand cnencodedapril            {\uchar{86}{219}\uchar{103}{8}}
  \definecommand cnencodedmay              {\uchar{78}{148}\uchar{103}{8}}
  \definecommand cnencodedjune             {\uchar{81}{109}\uchar{103}{8}}
  \definecommand cnencodedjuly             {\uchar{78}{3}\uchar{103}{8}}
  \definecommand cnencodedaugust           {\uchar{81}{107}\uchar{103}{8}}
  \definecommand cnencodedseptember        {\uchar{78}{93}\uchar{103}{8}}
  \definecommand cnencodedoctober          {\uchar{83}{65}\uchar{103}{8}}
  \definecommand cnencodednovember         {\uchar{83}{65}\uchar{78}{0}\uchar{103}{8}}
  \definecommand cnencodeddecember         {\uchar{83}{65}\uchar{78}{140}\uchar{103}{8}}
  \definecommand cnencodedsunday           {\uchar{102}{31}\uchar{103}{31}\uchar{101}{229}}
  \definecommand cnencodedmonday           {\uchar{102}{31}\uchar{103}{31}\uchar{78}{0}}
  \definecommand cnencodedtuesday          {\uchar{102}{31}\uchar{103}{31}\uchar{78}{140}}
  \definecommand cnencodedwednesday        {\uchar{102}{31}\uchar{103}{31}\uchar{78}{9}}
  \definecommand cnencodedthursday         {\uchar{102}{31}\uchar{103}{31}\uchar{86}{219}}
  \definecommand cnencodedfriday           {\uchar{102}{31}\uchar{103}{31}\uchar{78}{148}}
  \definecommand cnencodedsaturday         {\uchar{102}{31}\uchar{103}{31}\uchar{81}{109}}
  % RG & XJF
  \definecommand cnencodedgraphics         {\uchar{86}{254}}
  \definecommand cnencodedintermezzo       {\uchar{210}{99}\uchar{242}{102}}
  \definecommand cnencodedillustration     {\uchar{99}{210}\uchar{86}{254}}
  \definecommand cnencodedappendix         {\uchar{150}{68}\uchar{95}{85}}
  \definecommand cnencodedline             {\uchar{136}{76}}
  % Tobias Burnus & XJF
  \definecommand cnyear                    {\uchar{94}{116}}
  \definecommand cnmonth                   {\uchar{103}{8}}
  \definecommand cnday                     {\uchar{101}{229}}
\stopencoding

\startencoding[gbk]
  \definecommand cnleftsentence            {\uchar{161}{170}\uchar{161}{170}}
  \definecommand cnrightsentence           {\uchar{161}{170}\uchar{161}{170}}
  \definecommand cnleftsubsentence         {\uchar{161}{170}\uchar{161}{170}}
  \definecommand cnrightsubsentence        {\uchar{161}{170}\uchar{161}{170}}
  \definecommand cnupperleftsinglequote    {\uchar{161}{174}}
  \definecommand cnupperrightsinglequote   {\uchar{161}{175}}
  \definecommand cnupperleftdoublequote    {\uchar{161}{176}}
  \definecommand cnupperrightdoublequote   {\uchar{161}{177}}
  \definecommand cnupperleftsinglequote-v  {\uchar{161}{184}}
  \definecommand cnupperrightsinglequote-v {\uchar{161}{185}}
  \definecommand cnupperleftdoublequote-v  {\uchar{161}{186}}
  \definecommand cnupperrightdoublequote-v {\uchar{161}{187}}
  \definecommand cnencodedcontents         {\uchar{196}{191}\uchar{194}{188}}
  \definecommand cnencodedtables           {\uchar{177}{237}\uchar{184}{241}}
  \definecommand cnencodedfigures          {\uchar{205}{188}\uchar{208}{206}}
  \definecommand cnencodedindex            {\uchar{203}{247}\uchar{210}{253}}
  \definecommand cnencodedabbreviations    {\uchar{203}{245}\uchar{194}{212}\uchar{211}{239}}
  \definecommand cnencodedlogos            {\uchar{187}{213}\uchar{177}{225}}
  \definecommand cnencodedunits            {\uchar{188}{198}\uchar{193}{191}\uchar{181}{165}\uchar{206}{187}}
  \definecommand cnencodedtable            {\uchar{177}{237}}
  \definecommand cnencodedfigure           {\uchar{205}{188}}
  \definecommand cnencodedintro            {\uchar{181}{218}}
  \definecommand cnencodedpart             {\uchar{178}{191}\uchar{183}{214}}
  \definecommand cnencodedchapter          {\uchar{213}{194}}
  \definecommand cnencodedsection          {\uchar{189}{218}}
  \definecommand cnencodedjanuary          {\uchar{210}{187}\uchar{212}{194}}
  \definecommand cnencodedfebrary          {\uchar{182}{254}\uchar{212}{194}}
  \definecommand cnencodedmarch            {\uchar{200}{253}\uchar{212}{194}}
  \definecommand cnencodedapril            {\uchar{203}{196}\uchar{212}{194}}
  \definecommand cnencodedmay              {\uchar{206}{229}\uchar{212}{194}}
  \definecommand cnencodedjune             {\uchar{193}{249}\uchar{212}{194}}
  \definecommand cnencodedjuly             {\uchar{198}{223}\uchar{212}{194}}
  \definecommand cnencodedaugust           {\uchar{176}{203}\uchar{212}{194}}
  \definecommand cnencodedseptember        {\uchar{190}{197}\uchar{212}{194}}
  \definecommand cnencodedoctober          {\uchar{202}{174}\uchar{212}{194}}
  \definecommand cnencodednovember         {\uchar{202}{174}\uchar{210}{187}\uchar{212}{194}}
  \definecommand cnencodeddecember         {\uchar{202}{174}\uchar{182}{254}\uchar{212}{194}}
  \definecommand cnencodedsunday           {\uchar{208}{199}\uchar{198}{218}\uchar{200}{213}}
  \definecommand cnencodedmonday           {\uchar{208}{199}\uchar{198}{218}\uchar{210}{187}}
  \definecommand cnencodedtuesday          {\uchar{208}{199}\uchar{198}{218}\uchar{182}{254}}
  \definecommand cnencodedwednesday        {\uchar{208}{199}\uchar{198}{218}\uchar{200}{253}}
  \definecommand cnencodedthursday         {\uchar{208}{199}\uchar{198}{218}\uchar{203}{196}}
  \definecommand cnencodedfriday           {\uchar{208}{199}\uchar{198}{218}\uchar{206}{229}}
  \definecommand cnencodedsaturday         {\uchar{208}{199}\uchar{198}{218}\uchar{193}{249}}
  % RG & XJF
  \definecommand cnencodedgraphics         {\uchar{205}{188}}
  \definecommand cnencodedintermezzo       {\uchar{178}{229}\uchar{199}{250}}
  \definecommand cnencodedillustration     {\uchar{178}{229}\uchar{205}{188}}
  \definecommand cnencodedappendix         {\uchar{184}{189}\uchar{194}{188}}
  \definecommand cnencodedline             {\uchar{208}{208}}
  % Tobias Burnus & XJF
  \definecommand cnyear                    {\uchar{196}{234}}
  \definecommand cnmonth                   {\uchar{212}{194}}
  \definecommand cnday                     {\uchar{200}{213}}
\stopencoding

\startencoding[big5]
  \definecommand cnleftsentence            {\uchar{162}{119}\uchar{162}{119}}
  \definecommand cnrightsentence           {\uchar{162}{119}\uchar{162}{119}}
  \definecommand cnleftsubsentence         {\uchar{162}{119}\uchar{162}{119}}
  \definecommand cnrightsubsentence        {\uchar{162}{119}\uchar{162}{119}}
  \definecommand cnupperleftsinglequote    {\uchar{161}{165}}
  \definecommand cnupperrightsinglequote   {\uchar{161}{166}}
  \definecommand cnupperleftdoublequote    {\uchar{161}{167}}
  \definecommand cnupperrightdoublequote   {\uchar{161}{168}}
  \definecommand cnupperleftsinglequote-v  {\uchar{161}{117}}
  \definecommand cnupperrightsinglequote-v {\uchar{161}{118}}
  \definecommand cnupperleftdoublequote-v  {\uchar{161}{121}}
  \definecommand cnupperrightdoublequote-v {\uchar{161}{122}}
  \definecommand cnencodecontents          {\uchar{165}{216}\uchar{191}{253}}
  \definecommand cnencodetables            {\uchar{170}{237}\uchar{174}{230}}
  \definecommand cnencodefigures           {\uchar{185}{207}\uchar{167}{206}}
  \definecommand cnencodeindex             {\uchar{175}{193}\uchar{174}{222}}
  \definecommand cnencodeabbreviations     {\uchar{191}{89}\uchar{178}{164}\uchar{187}{121}}
  \definecommand cnencodelogos             {\uchar{192}{178}\uchar{188}{208}}
  \definecommand cnencodeunits             {\uchar{173}{112}\uchar{182}{113}\uchar{179}{230}\uchar{166}{236}}
  \definecommand cnencodetable             {\uchar{170}{237}}
  \definecommand cnencodefigure            {\uchar{185}{207}}
  \definecommand cnencodedintro            {\uchar{178}{196}}
  \definecommand cnencodedpart             {\uchar{179}{161}\uchar{164}{192}}
  \definecommand cnencodedchapter          {\uchar{179}{185}}
  \definecommand cnencodedsection          {\uchar{184} {96}}
  \definecommand cnencodedjanuary          {\uchar{164} {64}\uchar{164}{235}}
  \definecommand cnencodedfebrary          {\uchar{164} {71}\uchar{164}{235}}
  \definecommand cnencodedmarch            {\uchar{164} {84}\uchar{164}{235}}
  \definecommand cnencodedapril            {\uchar{165}{124}\uchar{164}{235}}
  \definecommand cnencodedmay              {\uchar{164}{173}\uchar{164}{235}}
  \definecommand cnencodedjune             {\uchar{164}{187}\uchar{164}{235}}
  \definecommand cnencodedjuly             {\uchar{164} {67}\uchar{164}{235}}
  \definecommand cnencodedaugust           {\uchar{164} {75}\uchar{164}{235}}
  \definecommand cnencodedseptember        {\uchar{164} {69}\uchar{164}{235}}
  \definecommand cnencodedoctober          {\uchar{164} {81}\uchar{164}{235}}
  \definecommand cnencodednovember         {\uchar{164} {81}\uchar{164} {64}\uchar{164}{235}}
  \definecommand cnencodeddecember         {\uchar{164} {81}\uchar{164} {71}\uchar{164}{235}}
  \definecommand cnencodedsunday           {\uchar{172} {80}\uchar{180}{193}\uchar{164}{233}}
  \definecommand cnencodedmonday           {\uchar{172} {80}\uchar{180}{193}\uchar{164} {64}}
  \definecommand cnencodedtuesday          {\uchar{172} {80}\uchar{180}{193}\uchar{164} {71}}
  \definecommand cnencodedwednesday        {\uchar{172} {80}\uchar{180}{193}\uchar{164} {84}}
  \definecommand cnencodedthursday         {\uchar{172} {80}\uchar{180}{193}\uchar{165}{124}}
  \definecommand cnencodedfriday           {\uchar{172} {80}\uchar{180}{193}\uchar{164}{173}}
  \definecommand cnencodedsaturday         {\uchar{172} {80}\uchar{180}{193}\uchar{164}{187}}
  % Tobias Burnus &\XJF
  \definecommand cnyear                    {\uchar{166}{126}}
  \definecommand cnmonth                   {\uchar{164}{235}}
  \definecommand cnday                     {\uchar{164}{233}}

% Traditional Chinese characters (only where they differ to the
% simplified ones) for lang-chi.tex and font-chi.tex.

% \startencoding[cjk-uni]
%   \defineudigit     10000 132  44
%   \defineudigit 100000000  81   4

%   \definecommand cnencodedsection          {\uchar{123}{192}}
%   \definecommand cnencodedfigure           {\uchar{87}{22}}
%   \definecommand cnencodedunits            {\uchar{138}{8}\uchar{145}{207}\uchar{85}{174}\uchar{79}{77}}
%   \definecommand cnencodedlogos            {\uchar{95}{189}\uchar{140}{182}}
%   \definecommand cnencodedabbreviations    {\uchar{126}{46}\uchar{117}{101}\uchar{138}{158}}
%   \definecommand cnencodedfigures          {\uchar{87}{22}\uchar{95}{98}}
%   \definecommand cnencodedcontents         {\uchar{118}{238}\uchar{147}{4}}
% \stopencoding

% \startencoding[gbk]
%   \defineudigit     10000 200 102
%   \defineudigit 100000000 131 124

%   \definecommand cnencodedsection          {\uchar{185}{157}}
%   \definecommand cnencodedfigure           {\uchar{136}{68}}
%   \definecommand cnencodedunits            {\uchar{211}{139}\uchar{193}{191}\uchar{134}{206}\uchar{206}{187}}
%   \definecommand cnencodedlogos            {\uchar{187}{213}\uchar{217}{72}
%   \definecommand cnencodedabbreviations    {\uchar{191}{115}\uchar{194}{212}\uchar{213}{90}}
%   \definecommand cnencodedfigures          {\uchar{136}{68}\uchar{208}{206}}
%   \definecommand cnencodedcontents         {\uchar{196}{191}\uchar{228}{155}}
% \stopencoding

% \startencoding[big5]
%   \defineudigit     10000 184  85
%   \defineudigit 100000000 187 245

%   \definecommand cnencodedsection          {\uchar{184}{96}}
%   \definecommand cnencodedfigure           {\uchar{185}{207}}
%   \definecommand cnencodedunits            {\uchar{173}{112}\uchar{182}{113}\uchar{179}{230}\uchar{166}{236}}
%   \definecommand cnencodedlogos            {\uchar{192}{178}\uchar{182}{83}}
%   \definecommand cnencodedabbreviations    {\uchar{193}{89}\uchar{178}{164}\uchar{187}{121}}
%   \definecommand cnencodedfigures          {\uchar{185}{207}\uchar{167}{206}}
%   \definecommand cnencodedcontents         {\uchar{165}{216}\uchar{191}{253}}
% \stopencoding

\stopencoding

\protect \endinput
