% Language definition file (part of polyglossia v2.2 -- 2024/07/15) % \ProvidesFile{gloss-thai.ldf}[polyglossia: module for Thai] %% This is partly based on thai-latex for Babel: %%%% Copyright (C) 1999 - 2006 %%%% by Surapant Meknavin, %%%% Theppitak Karoonboonyanan (thep at linux.thai.net), %%%% Chanop Silpa-Anan (chanop at debian.org), %%%% Poonlap Veerathanabutr (poonlap at linux.thai.net) %%%% Thai Linux Working Group %%%% http://linux.thai.net/ %%%% \PolyglossiaSetup{thai}{ bcp47=th, bcp47-language=th, bcp47-script=Thai, script=Thai, scripttag=thai, langtag=THA, hyphennames={nohyphenation}, fontsetup=true, localnumeral=thainumerals %TODO localalph={xxx@alph,xxx@Alph} %TODO localdigits=thainumber } % BCP-47 compliant aliases \setlanguagealias*{thai}{th} \newif\if@thai@numerals \def\tmp@thai{thai} \DeclareKeys[polyglossia/gloss/thai] { numerals.choice:, numerals / arabic.code = {% \@thai@numeralsfalse \SetLanguageKeys{thai}{bcp47-extension-u=nu-latn}% }, numerals / thai.code = {% \@thai@numeralstrue \SetLanguageKeys{thai}{bcp47-extension-u=nu-thai}% }, numerals.default:n = arabic, } % Register default options \InitializeGlossOptions{thai}{numerals=arabic} \def\captionsthai{% \def\refname{หนังสืออ้างอิง}% \def\abstractname{บทคัดย่อ}% \def\bibname{บรรณานุกรม}% \def\prefacename{คำนำ}% \def\chaptername{บทที่}% \def\appendixname{ภาคผนวก}% \def\contentsname{สารบัญ}% \def\listfigurename{สารบัญรูป}% \def\listtablename{สารบัญตาราง}% \def\indexname{ดรรชนี}% \def\figurename{รูปที่}% \def\tablename{ตารางที่}% %\def\thepart{}% \def\partname{ภาค}% \def\pagename{หน้า}% \def\seename{ดู}% \def\alsoname{ดูเพิ่มเติม}% \def\enclname{สิ่งที่แนบมาด้วย}% \def\ccname{สำเนาถึง}% \def\headtoname{เรียน}% \def\proofname{พิสูจน์}% %\def\glossaryname{}% } \def\datethai{% \def\thai@month{% \ifcase\month\or มกราคม\or กุมภาพันธ์\or มีนาคม\or เมษายน% \or พฤษภาคม\or มิถุนายน\or กรกฎาคม\or สิงหาคม% \or กันยายน\or ตุลาคม\or พฤศจิกายน\or ธันวาคม\fi}% \newcount\thai@year% \thai@year=\year% \advance\thai@year by 543% \def\today{\thainumber\day \space \thai@month\space พ.ศ.~\thainumber\thai@year}% } %NB: thai-latex had "plus 0.6pt", but .4em appears to give better results % FIXME to avoid name clashes, rename \wbr to \wordbreak or \thaiworkbreak ? \def\wbr{\hskip0pt plus .4em\relax} %%OR \char"200B = ZWSP ? Does not work %\catcode"200b=\active %\def^^200b{\hskip 0pt plus .4em} \def\thaidigits#1{\expandafter\@thai@digits #1@} \def\@thai@digits#1{% \ifx @#1% then terminate \else \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 \expandafter\@thai@digits \fi } \newcommand{\thainumerals}[2]{\thainumber{#2}} \def\thainumber#1{% \if@thai@numerals \thaidigits{\number#1}% %%{\protect\addfontfeature{Mapping=thaidigits}\protect\number#1} \else \number#1% %%{\protect\reset@font\number#1} \fi} \def\@thaialph#1{% \ifcase#1\or ก\or ข\or ค\or ง\or จ\or ฉ\or ช\or ซ\or ฌ\or ญ\or ฎ\or ฏ\or ฐ\or ฑ\or ฒ\or ณ\or ด\or ต\or ถ\or ท\or ธ\or น\or บ\or ป\or ผ\or ฝ\or พ\or ฟ\or ภ\or ม\or ย\or ร\or ล\or ว\or ศ\or ษ\or ส\or ห\or ฬ\or อ\or ฮ\else\xpg@ill@value{#1}{@thaialph}\fi} \def\thaiAlph#1{\expandafter\@thaiAlph\csname c@#1\endcsname} \def\@thaiAlph#1{% \ifcase#1\or ก\or ข\or ฃ\or ค\or ฅ\or ฆ\or ง\or จ\or ฉ\or ช\or ซ\or ฌ\or ญ\or ฎ\or ฏ\or ฐ\or ฑ\or ฒ\or ณ\or ด\or ต\or ถ\or ท\or ธ\or น\or บ\or ป\or ผ\or ฝ\or พ\or ฟ\or ภ\or ม\or ย\or ร\or ฤ\or ล\or ฦ\or ว\or ศ\or ษ\or ส\or ห\or ฬ\or อ\or ฮ\else\xpg@ill@value{#1}{@thaialph}\fi} \def\thai@numbers{% \if@thai@numerals \let\@alph\@thaialph% \let\@Alph\@thaiAlph% \fi } \def\nothai@numbers{% \let\@alph\latin@alph% \let\@Alph\latin@Alph% } \def\thai@globalnumbers{% \let\orig@arabic\@arabic% \let\@arabic\thainumber% \renewcommand{\thefootnote}{\localnumeral*{footnote}}% } \def\nothai@globalnumbers{% \let\@arabic\orig@arabic% } \def\blockextras@thai{% %%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 \let\orig@baselinestrech\baselinestretch% \renewcommand{\baselinestretch}{1.2}% } \def\noblockextras@thai{% %%TODO \XeTeXlinebreaklocales "en"% \let\baselinestrech\orig@baselinestretch% } \endinput %TODO ? %\def\thainum#1{\expandafter\thainumber\csname c@#1\endcsname} %\def\thaibracenum#1{(\expandafter\thainumber\csname c@#1\endcsname)} %\def\thaialph#1{\expandafter\@thaialph\csname c@#1\endcsname} \@ifclassloaded{book}{% % redefine page numbering for frontmatter and mainmatter \def\ps@headnum{\let\@mkboth\@gobbletwo \def\@oddhead{\reset@font\hfil\thepage\hfil}\let\@oddfoot\@empty \let\@evenhead\@oddhead\let\@evenfoot\@empty} \let\@ltxfrontmatter\frontmatter \renewcommand\frontmatter{\@ltxfrontmatter\pagestyle{headnum}\pagenumbering{thaibracenum}} \let\@ltxmainmatter\mainmatter \renewcommand\mainmatter{\@ltxmainmatter\pagestyle{headings}\pagenumbering{thainum}} }{} \@ifclassloaded{book}{% \renewcommand\appendix{\par \setcounter{chapter}{0}% \setcounter{section}{0}% \gdef\@chapapp{\appendixname}% \gdef\thechapter{\@thaialph\c@chapter}} }{} \@ifclassloaded{report}{% \renewcommand\appendix{\par \setcounter{chapter}{0}% \setcounter{section}{0}% \gdef\@chapapp{\appendixname}% \gdef\thechapter{\@thaialph\c@chapter}} }{} \@ifclassloaded{article}{% \renewcommand\appendix{\par \setcounter{section}{0}% \setcounter{subsection}{0}% \gdef\thesection{\@thaialph\c@section}} }{}