| 1 |
% Language definition file (part of polyglossia v2.10 -- 2026/04/18) |
| 2 |
% |
| 3 |
\ProvidesFile{gloss-chinese.ldf}[polyglossia: module for Chinese] |
| 4 |
|
| 5 |
\PolyglossiaSetup{chinese}{ |
| 6 |
bcp47=zh, |
| 7 |
bcp47-language=zh, |
| 8 |
bcp47-region=CN, |
| 9 |
bcp47-script=Hans, |
| 10 |
script=CJK, |
| 11 |
scripttag=hani, |
| 12 |
language={Chinese Simplified}, |
| 13 |
langtag=ZHS, |
| 14 |
hyphennames={nohyphenation}, |
| 15 |
frenchspacing=false, |
| 16 |
localnumeral=chinesenumerals, |
| 17 |
Localnumeral=chinesenumerals |
| 18 |
} |
| 19 |
|
| 20 |
% BCP-47 compliant aliases |
| 21 |
\setlanguagealias*{chinese}{zh} |
| 22 |
\setlanguagealias*[variant=simplified]{chinese}{zh-CN} |
| 23 |
\setlanguagealias*[variant=traditional]{chinese}{zh-TW} |
| 24 |
|
| 25 |
\@ifundefined{ifchinese@traditional}% |
| 26 |
{\newif\ifchinese@traditional}{} |
| 27 |
|
| 28 |
\@ifundefined{ifchinese@numerals}% |
| 29 |
{\newif\ifchinese@numerals}{} |
| 30 |
|
| 31 |
\def\chinese@variant{chinese} |
| 32 |
|
| 33 |
\DeclareKeys[polyglossia/gloss/chinese] |
| 34 |
{ |
| 35 |
variant.choice:, |
| 36 |
variant / cn.code = |
| 37 |
{% |
| 38 |
\chinese@traditionalfalse |
| 39 |
\SetLanguageKeys{chinese}{language={Chinese Simplified},langtag=ZHS,bcp47=zh-CN,bcp47-language=zh,bcp47-region=CN,bcp47-script=Hans}% |
| 40 |
}, |
| 41 |
variant / simplified.code = |
| 42 |
{% |
| 43 |
\chinese@traditionalfalse |
| 44 |
\SetLanguageKeys{chinese}{language={Chinese Simplified},langtag=ZHS,bcp47=zh-CN,bcp47-language=zh,bcp47-region=CN,bcp47-script=Hans}% |
| 45 |
}, |
| 46 |
variant / tw.code = |
| 47 |
{% |
| 48 |
\chinese@traditionaltrue |
| 49 |
\SetLanguageKeys{chinese}{language={Chinese Traditional},langtag=ZHT,bcp47=zh-TW,bcp47-language=zh,bcp47-region=TW,bcp47-script=Hant}% |
| 50 |
}, |
| 51 |
variant / traditional.code = |
| 52 |
{% |
| 53 |
\chinese@traditionaltrue |
| 54 |
\SetLanguageKeys{chinese}{language={Chinese Traditional},langtag=ZHT,bcp47=zh-TW,bcp47-language=zh,bcp47-region=TW,bcp47-script=Hant}% |
| 55 |
}, |
| 56 |
variant.default:n = cn, |
| 57 |
variant/unknown.code = \xpg@warning{Unknown Chinese variant `#1'}, |
| 58 |
numerals.choice:, |
| 59 |
numerals / arabic.code = |
| 60 |
{% |
| 61 |
\chinese@numeralsfalse |
| 62 |
\SetLanguageKeys{chinese}{bcp47-extension-u=nu-latn}% |
| 63 |
}, |
| 64 |
numerals / chinese.code = |
| 65 |
{% |
| 66 |
\chinese@numeralstrue |
| 67 |
\SetLanguageKeys{chinese}{bcp47-extension-u=nu-hant}% |
| 68 |
}, |
| 69 |
numerals.default:n = arabic, |
| 70 |
numerals/unknown.code = \xpg@warning{Unknown Chinese numerals value `#1'} |
| 71 |
} |
| 72 |
|
| 73 |
% Register default options |
| 74 |
\InitializeGlossOptions{chinese}{variant=cn,numerals=arabic} |
| 75 |
%\InitializeGlossOptions{chinese}{variant=tw,numerals=arabic} |
| 76 |
% Register alias options |
| 77 |
\SetLanguageAliasValues{chinese}{variant}{cn,simplified} |
| 78 |
\SetLanguageAliasValues{chinese}{variant}{tw,traditional} |
| 79 |
|
| 80 |
|
| 81 |
\providecommand*\presection{} |
| 82 |
\providecommand*\presubsection{} |
| 83 |
\providecommand*\presubsubsection{} |
| 84 |
\providecommand*\postsection{} |
| 85 |
\providecommand*\postsubsection{} |
| 86 |
\providecommand*\postsubsubsection{} |
| 87 |
\let\xpg@save@presection\presection |
| 88 |
\let\xpg@save@presubsection\presubsection |
| 89 |
\let\xpg@save@presubsubsection\presubsubsection |
| 90 |
\let\xpg@save@postsection\postsection |
| 91 |
\let\xpg@save@postsubsection\postsubsection |
| 92 |
\let\xpg@save@postsubsubsection\postsubsubsection |
| 93 |
\let\xpg@save@seccntformat\@seccntformat |
| 94 |
|
| 95 |
\def\chinese@capsformat{% |
| 96 |
\def\@seccntformat##1{% |
| 97 |
\csname pre##1\endcsname% |
| 98 |
\csname the##1\endcsname% |
| 99 |
\csname post##1\endcsname% |
| 100 |
}% |
| 101 |
\ifchinese@traditional |
| 102 |
\def\postsection{節\space}% |
| 103 |
\def\postsubsection{節\space}% |
| 104 |
\def\postsubsubsection{節\space}% |
| 105 |
\else |
| 106 |
\def\postsection{节\space}% |
| 107 |
\def\postsubsection{节\space}% |
| 108 |
\def\postsubsubsection{节\space}% |
| 109 |
\fi |
| 110 |
\def\presection{第}% |
| 111 |
\def\presubsection{第}% |
| 112 |
\def\presubsubsection{第}% |
| 113 |
} |
| 114 |
|
| 115 |
\def\nochinese@capsformat{% |
| 116 |
\let\presection\xpg@save@presection% |
| 117 |
\let\presubsection\xpg@save@presubsection% |
| 118 |
\let\presubsubsection\xpg@save@presubsubsection% |
| 119 |
\let\postsection\xpg@save@postsection% |
| 120 |
\let\postsubsection\xpg@save@postsubsection% |
| 121 |
\let\postsubsubsection\xpg@save@postsubsubsection% |
| 122 |
\let\@seccntformat\xpg@save@seccntformat% |
| 123 |
} |
| 124 |
|
| 125 |
\def\captionschinese{% |
| 126 |
\ifchinese@traditional |
| 127 |
\captions@chinese@traditional |
| 128 |
\else |
| 129 |
\captions@chinese@simplified |
| 130 |
\fi |
| 131 |
} |
| 132 |
|
| 133 |
\def\captions@chinese@traditional{% |
| 134 |
\def\contentsname{目錄}% |
| 135 |
\def\listfigurename{插圖}% |
| 136 |
\def\listtablename{表格}% |
| 137 |
\def\figurename{圖}% |
| 138 |
\def\tablename{表}% |
| 139 |
\def\abstractname{摘要}% |
| 140 |
\def\prefacename{前言}% |
| 141 |
\def\indexname{索引}% |
| 142 |
\def\bibname{參考文獻}% |
| 143 |
\def\appendixname{附錄}% |
| 144 |
\def\proofname{證明}% |
| 145 |
\def\refname{參考文獻}% |
| 146 |
\def\partname##1##2{第##1##2 部分}% |
| 147 |
\def\chaptername##1##2{第##1##2 章}% |
| 148 |
\def\pagename##1##2{第##1##2 頁}% |
| 149 |
\def\seename{參照}% |
| 150 |
\def\alsoname{參照}% |
| 151 |
\def\enclname{附件}% |
| 152 |
\def\ccname{抄送}% |
| 153 |
\def\headtoname{收件人}% |
| 154 |
\def\glossaryname{詞彙表}% |
| 155 |
} |
| 156 |
\def\captions@chinese@simplified{% |
| 157 |
\def\contentsname{目录}% |
| 158 |
\def\listfigurename{插图}% |
| 159 |
\def\listtablename{表格}% |
| 160 |
\def\figurename{图}% |
| 161 |
\def\tablename{表}% |
| 162 |
\def\abstractname{摘要}% |
| 163 |
\def\prefacename{前言}% |
| 164 |
\def\indexname{索引}% |
| 165 |
\def\bibname{参考文献}% |
| 166 |
\def\appendixname{附录}% |
| 167 |
\def\proofname{证明}% |
| 168 |
\def\refname{参考文献}% |
| 169 |
\def\partname##1##2{第##1##2 部分}% |
| 170 |
\def\chaptername##1##2{第##1##2 章}% |
| 171 |
\def\pagename##1##2{第##1##2 页}% |
| 172 |
\def\seename{参照}% |
| 173 |
\def\alsoname{参照}% |
| 174 |
\def\enclname{附件}% |
| 175 |
\def\ccname{抄送}% |
| 176 |
\def\headtoname{收件人}% |
| 177 |
\def\glossaryname{词汇表}% |
| 178 |
} |
| 179 |
|
| 180 |
\newcount\c@TempJNum% |
| 181 |
|
| 182 |
\def\@ChineseDigit#1{% |
| 183 |
\ifcase#1\or 一\or 二\or 三\or 四\or 五\or% |
| 184 |
六\or 七\or 八\or 九\or 十\or% |
| 185 |
十一\or 十二\or 十三\or 十四\or 十五\or% |
| 186 |
十六\or 十七\or 十八\or 十九\or 二十\or% |
| 187 |
二十一\or 二十二\or 二十三\or 二十四\or 二十五\or% |
| 188 |
二十六\or 二十七\or 二十八\or 二十九\or 三十\or% |
| 189 |
三十一\or 三十二\or 三十三\or 三十四\or 三十五\or% |
| 190 |
三十六\or 三十七\or 三十八\or 三十九\or 四十\or% |
| 191 |
四十一\or 四十二\or 四十三\or 四十四\or 四十五\or% |
| 192 |
四十六\or 四十七\or 四十八\or 四十九\or 五十\or% |
| 193 |
五十一\or 五十二\or 五十三\or 五十四\or 五十五\or% |
| 194 |
五十六\or 五十七\or 五十八\or 五十九\or 六十\or% |
| 195 |
六十一\or 六十二\or 六十三\or 六十四\or 六十五\or% |
| 196 |
六十六\or 六十七\or 六十八\or 六十九\or 七十\or% |
| 197 |
七十一\or 七十二\or 七十三\or 七十四\or 七十五\or% |
| 198 |
七十六\or 七十七\or 七十八\or 七十九\or 八十\or% |
| 199 |
八十一\or 八十二\or 八十三\or 八十四\or 八十五\or% |
| 200 |
八十六\or 八十七\or 八十八\or 八十九\or 九十\or% |
| 201 |
九十一\or 九十二\or 九十三\or 九十四\or 九十五\or% |
| 202 |
九十六\or 九十七\or 九十八\or 九十九% |
| 203 |
\else |
| 204 |
\@ctrerr% |
| 205 |
\fi\relax% |
| 206 |
} |
| 207 |
|
| 208 |
\def\@ChineseNum#1{% |
| 209 |
\c@TempJNum=#1\divide\c@TempJNum by 1000\relax% |
| 210 |
\ifnum\c@TempJNum=\z@\c@TempJNum=#1% |
| 211 |
\divide\c@TempJNum by 100\relax% |
| 212 |
\ifnum\c@TempJNum=\z@\@ChineseDigit{#1}\relax% |
| 213 |
\else |
| 214 |
\ifcase\c@TempJNum\or 百\or 二百\or 三百\or 四百\or 五百\or |
| 215 |
六百\or 七百\or 八百\or 九百% |
| 216 |
\fi |
| 217 |
\c@TempJNum=#1\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@ChineseDigit\c@TempJNum\relax% |
| 218 |
\fi% |
| 219 |
\else |
| 220 |
\ifcase\c@TempJNum\or 千\or 二千\or 三千\or 四千\or 五千\or |
| 221 |
六千\or 七千\or 八千\or 九千% |
| 222 |
\fi |
| 223 |
\c@TempJNum=#1\divide\c@TempJNum by 1000\multiply\c@TempJNum by -1000\advance\c@TempJNum#1\divide\c@TempJNum by 100\relax% |
| 224 |
\ifnum\c@TempJNum=\z@\c@TempJNum=#1% |
| 225 |
\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@ChineseDigit\c@TempJNum\relax% |
| 226 |
\else |
| 227 |
\ifcase\c@TempJNum\or 百\or 二百\or 三百\or 四百\or 五百\or |
| 228 |
六百\or 七百\or 八百\or 九百% |
| 229 |
\fi |
| 230 |
\c@TempJNum=#1\divide\c@TempJNum by 100\multiply\c@TempJNum by -100\advance\c@TempJNum#1\@ChineseDigit\c@TempJNum\relax% |
| 231 |
\fi |
| 232 |
\fi |
| 233 |
} |
| 234 |
|
| 235 |
\def\@chinesenumber#1{% |
| 236 |
\@tempcnta=#1% |
| 237 |
\ifnum\@tempcnta=\z@{〇}% |
| 238 |
\else |
| 239 |
\ifnum\@tempcnta<\z@{負}% |
| 240 |
\multiply\@tempcnta by -1% |
| 241 |
\fi |
| 242 |
\@tempcntb=\@tempcnta\divide\@tempcntb by 10000\relax% |
| 243 |
\ifnum\@tempcntb=\z@\@ChineseNum% |
| 244 |
\@tempcnta% |
| 245 |
\else |
| 246 |
\@tempcntb=\@tempcnta\divide\@tempcntb by 100000000\relax% |
| 247 |
\ifnum\@tempcntb=\z@\@tempcntb=\@tempcnta% |
| 248 |
\divide\@tempcntb by 10000% |
| 249 |
\@ChineseNum\@tempcntb{万}\@tempcntb=\@tempcnta% |
| 250 |
\divide\@tempcntb by 10000\multiply\@tempcntb by -10000% |
| 251 |
\advance\@tempcntb\@tempcnta\relax\@ChineseNum\@tempcntb% |
| 252 |
\else |
| 253 |
\@ChineseNum\@tempcntb{億}\@tempcntb=\@tempcnta% |
| 254 |
\divide\@tempcntb by 100000000\multiply\@tempcntb by -100000000% |
| 255 |
\advance\@tempcntb\@tempcnta\divide\@tempcntb by 10000\relax% |
| 256 |
\ifnum\@tempcntb=\z@% |
| 257 |
\else |
| 258 |
\@ChineseNum\@tempcntb{万}% |
| 259 |
\fi |
| 260 |
\@tempcntb=\@tempcnta\divide\@tempcntb by 10000% |
| 261 |
\multiply\@tempcntb by -10000\advance\@tempcntb\@tempcnta% |
| 262 |
\@ChineseNum\@tempcntb% |
| 263 |
\fi |
| 264 |
\fi |
| 265 |
\fi |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
\newcommand{\chinesenumerals}[2]{\chinesenumber{#2}} |
| 270 |
|
| 271 |
\def\chinesenumber#1{% |
| 272 |
\ifchinese@numerals |
| 273 |
\@chinesenumber{\number#1}% |
| 274 |
\else |
| 275 |
\number#1% |
| 276 |
\fi} |
| 277 |
|
| 278 |
\let\chinesenumeral=\chinesenumber |
| 279 |
|
| 280 |
\def\datechinese{% |
| 281 |
\def\today{% |
| 282 |
\ifchinese@numerals |
| 283 |
\@chinesenumber{\number\year}% |
| 284 |
\else |
| 285 |
\number\year\,% |
| 286 |
\fi |
| 287 |
{年}% |
| 288 |
\ifchinese@numerals |
| 289 |
\@chinesenumber{\number\month}% |
| 290 |
\else |
| 291 |
\,\number\month\,% |
| 292 |
\fi |
| 293 |
{月}% |
| 294 |
\ifchinese@numerals |
| 295 |
\@chinesenumber{\number\day}% |
| 296 |
\else |
| 297 |
\,\number\day\,% |
| 298 |
\fi |
| 299 |
{日}% |
| 300 |
}% |
| 301 |
} |
| 302 |
|
| 303 |
\ifluatex |
| 304 |
\@ifundefined{xpg@attr@cjkspacing}{\newattribute\xpg@attr@cjkspacing}{} |
| 305 |
\directlua{ require"polyglossia-cjk-spacing" } |
| 306 |
\def\chinese@simplified@spacing {\xpg@attr@cjkspacing=\thr@@} % chinese simplified |
| 307 |
\def\chinese@traditional@spacing{\xpg@attr@cjkspacing=4\relax} % chinese traditional |
| 308 |
\def\nochinese@spacing{\unsetattribute\xpg@attr@cjkspacing} |
| 309 |
\else |
| 310 |
\@ifundefined{xpg@orig@XeTeXlinebreakskip}{\newskip\xpg@orig@XeTeXlinebreakskip}{} |
| 311 |
\xpg@orig@XeTeXlinebreakskip=\XeTeXlinebreakskip |
| 312 |
\def\chinese@simplified@spacing{% |
| 313 |
\XeTeXlinebreaklocale "zh"% |
| 314 |
\XeTeXlinebreakskip = 0pt plus 0.1em minus 0.01em% |
| 315 |
} |
| 316 |
\let\chinese@traditional@spacing\chinese@simplified@spacing |
| 317 |
\def\nochinese@spacing{% |
| 318 |
\XeTeXlinebreakskip=\xpg@orig@XeTeXlinebreakskip% |
| 319 |
\XeTeXlinebreaklocale ""% |
| 320 |
} |
| 321 |
\fi |
| 322 |
|
| 323 |
\def\noextras@chinese{% |
| 324 |
\nochinese@capsformat% |
| 325 |
\nochinese@spacing% |
| 326 |
} |
| 327 |
|
| 328 |
\def\blockextras@chinese{% |
| 329 |
\chinese@capsformat% |
| 330 |
\ifchinese@traditional |
| 331 |
\chinese@traditional@spacing% |
| 332 |
\else |
| 333 |
\chinese@simplified@spacing% |
| 334 |
\fi% |
| 335 |
} |
| 336 |
|
| 337 |
\def\inlineextras@chinese{% |
| 338 |
\chinese@capsformat% |
| 339 |
\ifchinese@traditional |
| 340 |
\chinese@traditional@spacing% |
| 341 |
\else |
| 342 |
\chinese@simplified@spacing% |
| 343 |
\fi% |
| 344 |
} |
| 345 |
|
| 346 |
\ifxetex |
| 347 |
% \XeTeXlinebreaklocale is global, |
| 348 |
% so we need to reset after nested language got closed |
| 349 |
\def\nestedextras@chinese{% |
| 350 |
\ifchinese@traditional |
| 351 |
\chinese@traditional@spacing% |
| 352 |
\else |
| 353 |
\chinese@simplified@spacing% |
| 354 |
\fi% |
| 355 |
} |
| 356 |
\fi |
| 357 |
|
| 358 |
% Based on contributions of Toru Inagaki, Norio Iwase, François Charette |
| 359 |
|