Debian Codegraph @

texmf-dist/tex/latex/polyglossia/gloss-thai.ldf

raw
1 % Language definition file (part of polyglossia v2.10 -- 2026/04/18)
2 %
3 \ProvidesFile{gloss-thai.ldf}[polyglossia: module for Thai]
4 %% This is partly based on thai-latex for Babel:
5 %%%% Copyright (C) 1999 - 2006
6 %%%% by Surapant Meknavin,
7 %%%% Theppitak Karoonboonyanan (thep at linux.thai.net),
8 %%%% Chanop Silpa-Anan (chanop at debian.org),
9 %%%% Poonlap Veerathanabutr (poonlap at linux.thai.net)
10 %%%% Thai Linux Working Group
11 %%%% http://linux.thai.net/
12 %%%%
13 \PolyglossiaSetup{thai}{
14 bcp47=th,
15 bcp47-language=th,
16 bcp47-script=Thai,
17 script=Thai,
18 scripttag=thai,
19 langtag=THA,
20 hyphennames={nohyphenation},
21 localnumeral=thainumerals,
22 Localnumeral=thainumerals
23 %TODO localalph={xxx@alph,xxx@Alph}
24 %TODO localdigits=thainumber
25 }
26
27 % BCP-47 compliant aliases
28 \setlanguagealias*{thai}{th}
29
30 \newif\if@thai@numerals
31 \def\tmp@thai{thai}
32
33 \DeclareKeys[polyglossia/gloss/thai]
34 {
35 numerals.choice:,
36 numerals / arabic.code =
37 {%
38 \@thai@numeralsfalse
39 \SetLanguageKeys{thai}{bcp47-extension-u=nu-latn}%
40 },
41 numerals / thai.code =
42 {%
43 \@thai@numeralstrue
44 \SetLanguageKeys{thai}{bcp47-extension-u=nu-thai}%
45 },
46 numerals.default:n = arabic,
47 }
48
49 % Register default options
50 \InitializeGlossOptions{thai}{numerals=arabic}
51
52 \def\captionsthai{%
53 \def\refname{หนังสืออ้างอิง}%
54 \def\abstractname{บทคัดย่อ}%
55 \def\bibname{บรรณานุกรม}%
56 \def\prefacename{คำนำ}%
57 \def\chaptername{บทที่}%
58 \def\appendixname{ภาคผนวก}%
59 \def\contentsname{สารบัญ}%
60 \def\listfigurename{สารบัญรูป}%
61 \def\listtablename{สารบัญตาราง}%
62 \def\indexname{ดรรชนี}%
63 \def\figurename{รูปที่}%
64 \def\tablename{ตารางที่}%
65 %\def\thepart{}%
66 \def\partname{ภาค}%
67 \def\pagename{หน้า}%
68 \def\seename{ดู}%
69 \def\alsoname{ดูเพิ่มเติม}%
70 \def\enclname{สิ่งที่แนบมาด้วย}%
71 \def\ccname{สำเนาถึง}%
72 \def\headtoname{เรียน}%
73 \def\proofname{พิสูจน์}%
74 %\def\glossaryname{}%
75 }
76 \def\datethai{%
77 \def\thai@month{%
78 \ifcase\month\or
79 มกราคม\or กุมภาพันธ์\or มีนาคม\or เมษายน%
80 \or พฤษภาคม\or มิถุนายน\or กรกฎาคม\or สิงหาคม%
81 \or กันยายน\or ตุลาคม\or พฤศจิกายน\or ธันวาคม\fi}%
82 \newcount\thai@year%
83 \thai@year=\year%
84 \advance\thai@year by 543%
85 \def\today{\thainumber\day \space \thai@month\space พ.ศ.~\thainumber\thai@year}%
86 }
87
88 %NB: thai-latex had "plus 0.6pt", but .4em appears to give better results
89 % FIXME to avoid name clashes, rename \wbr to \wordbreak or \thaiworkbreak ?
90 \def\wbr{\hskip0pt plus .4em\relax} %%OR \char"200B = ZWSP ? Does not work
91 %\catcode"200b=\active
92 %\def^^200b{\hskip 0pt plus .4em}
93
94 \def\thaidigits#1{\expandafter\@thai@digits #1@}
95 \def\@thai@digits#1{%
96 \ifx @#1% then terminate
97 \else
98 \ifx0#1๐\else\ifx1#1๑\else\ifx2#1๒\else\ifx3#1๓\else\ifx4#1๔\else\ifx5#1๕\else\ifx6#1๖\else\ifx7#1๗\else\ifx8#1๘\else\ifx9#1๙\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
99 \expandafter\@thai@digits
100 \fi
101 }
102
103 \newcommand{\thainumerals}[2]{\thainumber{#2}}
104
105 \def\thainumber#1{%
106 \if@thai@numerals
107 \thaidigits{\number#1}%
108 %%{\protect\addfontfeature{Mapping=thaidigits}\protect\number#1}
109 \else
110 \number#1%
111 %%{\protect\reset@font\number#1}
112 \fi}
113
114 \def\@thaialph#1{%
115 \ifcase#1\or ก\or ข\or ค\or ง\or จ\or ฉ\or ช\or ซ\or ฌ\or ญ\or ฎ\or
116 ฏ\or ฐ\or ฑ\or ฒ\or ณ\or ด\or ต\or ถ\or ท\or ธ\or น\or บ\or ป\or ผ\or
117 ฝ\or พ\or ฟ\or ภ\or ม\or ย\or ร\or ล\or ว\or ศ\or ษ\or ส\or ห\or ฬ\or อ\or
118 ฮ\else\xpg@ill@value{#1}{@thaialph}\fi}
119 \def\thaiAlph#1{\expandafter\@thaiAlph\csname c@#1\endcsname}
120 \def\@thaiAlph#1{%
121 \ifcase#1\or ก\or ข\or ฃ\or ค\or ฅ\or ฆ\or ง\or จ\or ฉ\or ช\or ซ\or
122 ฌ\or ญ\or ฎ\or ฏ\or ฐ\or ฑ\or ฒ\or ณ\or ด\or ต\or ถ\or ท\or ธ\or น\or
123 บ\or ป\or ผ\or ฝ\or พ\or ฟ\or ภ\or ม\or ย\or ร\or ฤ\or ล\or ฦ\or ว\or
124 ศ\or ษ\or ส\or ห\or ฬ\or อ\or ฮ\else\xpg@ill@value{#1}{@thaialph}\fi}
125
126 \def\thai@numbers{%
127 \if@thai@numerals
128 \let\@alph\@thaialph%
129 \let\@Alph\@thaiAlph%
130 \fi
131 }
132 \def\nothai@numbers{%
133 \let\@alph\latin@alph%
134 \let\@Alph\latin@Alph%
135 }
136
137 \def\thai@globalnumbers{%
138 \let\orig@arabic\@arabic%
139 \let\@arabic\thainumber%
140 \renewcommand{\thefootnote}{\localnumeral*{footnote}}%
141 }
142 \def\nothai@globalnumbers{%
143 \let\@arabic\orig@arabic%
144 }
145
146 \def\blockextras@thai{%
147 %%TODO \XeTeXlinebreaklocales "th"% uses ICU to find line breaks on the basis of a dictionary lookup-- make this optional? (in case a user might prefer a preprocessor
148 \let\orig@baselinestrech\baselinestretch%
149 \renewcommand{\baselinestretch}{1.2}%
150 }
151 \def\noblockextras@thai{%
152 %%TODO \XeTeXlinebreaklocales "en"%
153 \let\baselinestrech\orig@baselinestretch%
154 }
155
156 \endinput
157
158 %TODO ?
159
160 %\def\thainum#1{\expandafter\thainumber\csname c@#1\endcsname}
161 %\def\thaibracenum#1{(\expandafter\thainumber\csname c@#1\endcsname)}
162 %\def\thaialph#1{\expandafter\@thaialph\csname c@#1\endcsname}
163
164 \@ifclassloaded{book}{%
165 % redefine page numbering for frontmatter and mainmatter
166 \def\ps@headnum{\let\@mkboth\@gobbletwo
167 \def\@oddhead{\reset@font\hfil\thepage\hfil}\let\@oddfoot\@empty
168 \let\@evenhead\@oddhead\let\@evenfoot\@empty}
169 \let\@ltxfrontmatter\frontmatter
170 \renewcommand\frontmatter{\@ltxfrontmatter\pagestyle{headnum}\pagenumbering{thaibracenum}}
171 \let\@ltxmainmatter\mainmatter
172 \renewcommand\mainmatter{\@ltxmainmatter\pagestyle{headings}\pagenumbering{thainum}}
173 }{}
174
175 \@ifclassloaded{book}{%
176 \renewcommand\appendix{\par
177 \setcounter{chapter}{0}%
178 \setcounter{section}{0}%
179 \gdef\@chapapp{\appendixname}%
180 \gdef\thechapter{\@thaialph\c@chapter}}
181 }{}
182 \@ifclassloaded{report}{%
183 \renewcommand\appendix{\par
184 \setcounter{chapter}{0}%
185 \setcounter{section}{0}%
186 \gdef\@chapapp{\appendixname}%
187 \gdef\thechapter{\@thaialph\c@chapter}}
188 }{}
189 \@ifclassloaded{article}{%
190 \renewcommand\appendix{\par
191 \setcounter{section}{0}%
192 \setcounter{subsection}{0}%
193 \gdef\thesection{\@thaialph\c@section}}
194 }{}