| 1 |
% Language definition file (part of polyglossia v2.10 -- 2026/04/18) |
| 2 |
% |
| 3 |
\ProvidesFile{gloss-tibetan.ldf}[polyglossia: module for Tibetan] |
| 4 |
%% Copyright 2013 Elie Roux |
| 5 |
%% Under the CC0 license <http://creativecommons.org/publicdomain/zero/1.0/> |
| 6 |
%% |
| 7 |
%% A good font to make tests is \newfontfamily\tibetanfont{Tibetan Machine Uni} |
| 8 |
%% |
| 9 |
|
| 10 |
\PolyglossiaSetup{tibetan}{ |
| 11 |
bcp47=bo, |
| 12 |
bcp47-language=bo, |
| 13 |
bcp47-script=Tibt, |
| 14 |
script=Tibetan, |
| 15 |
scripttag=tibt, |
| 16 |
langtag=TIB, |
| 17 |
hyphennames={nohyphenation}, |
| 18 |
localnumeral=tibetannumerals, |
| 19 |
Localnumeral=tibetannumerals |
| 20 |
%TODO localalph={xxx@alph,xxx@Alph} |
| 21 |
} |
| 22 |
|
| 23 |
% BCP-47 compliant aliases |
| 24 |
\setlanguagealias*{tibetan}{bo} |
| 25 |
|
| 26 |
\newif\if@tibetan@numerals |
| 27 |
\DeclareKeys[polyglossia/gloss/tibetan] |
| 28 |
{ |
| 29 |
numerals.choice:, |
| 30 |
numerals/tibetan.code = \@tibetan@numeralstrue |
| 31 |
\SetLanguageKeys{tibetan}{bcp47-extension-u=nu-tibt}, |
| 32 |
numerals/arabic.code = \@tibetan@numeralsfalse |
| 33 |
\SetLanguageKeys{tibetan}{bcp47-extension-u=nu-latn}, |
| 34 |
numerals.default:n = tibetan |
| 35 |
} |
| 36 |
|
| 37 |
\ifluatex |
| 38 |
\newattribute\xpg@tibteol % |
| 39 |
\directlua{require('polyglossia-tibt')}% |
| 40 |
\fi |
| 41 |
|
| 42 |
\def\tibetan@eol{% |
| 43 |
\ifluatex% |
| 44 |
\xpg@tibteol=1\relax% |
| 45 |
\directlua{polyglossia.activate_tibt_eol()}% |
| 46 |
\else% |
| 47 |
\XeTeXlinebreaklocale "bo"% |
| 48 |
\XeTeXlinebreakskip=0pt plus 0.1em% doesn't do much, but doesn't harm I guess... |
| 49 |
\fi% |
| 50 |
} |
| 51 |
|
| 52 |
\def\notibetan@eol{% |
| 53 |
\ifluatex% |
| 54 |
\xpg@tibteol=0\relax% |
| 55 |
%\directlua{polyglossia.activate_tibt_eol()}% |
| 56 |
\else% |
| 57 |
\XeTeXlinebreaklocale "en"% en? really? |
| 58 |
\XeTeXlinebreakskip=0pt plus 0pt% |
| 59 |
\fi% |
| 60 |
} |
| 61 |
|
| 62 |
% Register default options |
| 63 |
\InitializeGlossOptions{tibetan}{numerals=tibetan} |
| 64 |
|
| 65 |
% some are known, but very few |
| 66 |
% a few come from "Standardizing Tibetan Terms of Information Technology" |
| 67 |
% from the China Tibetology Research Center |
| 68 |
\def\captionstibetan{% |
| 69 |
%\def\refname{}% |
| 70 |
\def\abstractname{གནད་བསྡུས།}% |
| 71 |
\def\bibname{དཔེ་ཆའི་ཐོ་གཞུང་།}% or dpe deb kyi re'u mig? |
| 72 |
\def\prefacename{དཔེ་དེབ་ཀྱི་གླེང་བརྗོད།}% or gleng brjod 'god pa or ngo sprod? |
| 73 |
\def\chaptername{ལེའུ་}% |
| 74 |
\def\appendixname{ཞར་བྱུང་།}% |
| 75 |
\def\contentsname{དཀར་ཆག།}% |
| 76 |
%\def\listfigurename{}% |
| 77 |
%\def\listtablename{}% |
| 78 |
\def\indexname{གསུལ་བྱང་།}% |
| 79 |
\def\figurename{པར་རིས་}% or dpe ris? |
| 80 |
\def\tablename{རེའུ་མིག་}% |
| 81 |
%\def\thepart{}% |
| 82 |
\def\partname{ཆ་ཤས་}% |
| 83 |
\def\pagename{ཤོག་}% |
| 84 |
%\def\seename{}% |
| 85 |
%\def\alsoname{}% |
| 86 |
%\def\enclname{}% |
| 87 |
\def\ccname{འདྲ་བཤུས་ལེན་མཁན་}% |
| 88 |
%\def\headtoname{}% |
| 89 |
\def\proofname{བདེན་དཔང་།}% not sure about this one... |
| 90 |
\def\glossaryname{མིང་ཚིག་རེའུ་མིག།}% |
| 91 |
} |
| 92 |
|
| 93 |
\def\datetibetan{% |
| 94 |
\def\tibetan@month{% |
| 95 |
\ifcase\month\or |
| 96 |
ཟླ་དང་པོ\or ཟླ་གཉིས་པ\or ཟླ་གསུམ་པ% |
| 97 |
\or ཟླ་བཞི་པ\or ཟླ་ལྔ་པ\or ཟླ་དྲུག་པ\or ཟླ་བདུན་པ% |
| 98 |
\or ཟླ་བརྒྱད་པ\or ཟླ་དགུ་པ\or ཟླ་བཆུ་པ\or ཟླ་བཆུ་གཅིག་པ\or ཟླ་བཆུ་གཉིས་པ\fi}% |
| 99 |
\def\tibetan@daynum{% |
| 100 |
\ifcase\day\or དང་པོ\or གཉིས་པ\or གསུམ་པ \or བཞི་པ\or ལྔ་པ\or དྲུག་པ\or བདུན་པ\or བརྒྱད་པ\or དགུ་པ\or བཆུ་པ% |
| 101 |
\or བཆུ་གཅིག་པ\or བཆུ་གཉིས་པ\or བཆུ་གསུམ་པ\or བཆུ་བཞི་པ\or བཆུ་ལྔ་པ\or བཆུ་དྲུག་པ\or བཆུ་བདུན་པ\or བཆུ་བརྒྱད་པ\or བཆུ་དགུ་པ\or ཉི་ཤུ་པ% |
| 102 |
|
| 103 |
\or ཉི་ཤུ་རྩ་གཅིག་པ\or ཉི་ཤུ་རྩ་གཉིས་པ\or ཉི་ཤུ་རྩ་གསུམ་པ\or ཉི་ཤུ་རྩ་བཞི་པ\or ཉི་ཤུ་རྩ་ལྔ་པ\or ཉི་ཤུ་རྩ་དྲུག་པ\or ཉི་ཤུ་རྩ་བདུན་པ\or ཉི་ཤུ་རྩ་བརྒྱད་པ\or ཉི་ཤུ་རྩ་དགུ་པ\or སུམ་ཆུ་པ% |
| 104 |
\or སུམ་ཆུ་སོ་གཅིག་པ\fi}% |
| 105 |
% As we use gregorian calendar, it's better to stick with spyi lo |
| 106 |
%\newcount\tibetan@year% |
| 107 |
%\tibetan@year=\year% |
| 108 |
%\advance\tibetan@year by 127% this is bod rgyal lo, the most common, but there are others... |
| 109 |
% I'm not sure the / character is in most tibetan fonts |
| 110 |
%\def\today{\tibetannumber\day /\tibetannumber\day /\tibetannumber\year}% |
| 111 |
\def\today{\tibetannumber\day །\tibetannumber\month །\tibetannumber\year}% |
| 112 |
% this is more litterate, but longer |
| 113 |
%\def\today{སྤྱི་ལོ་\tibetannumber\year ་སྤྱི་\tibetan@month{}་ད་རེས་\tibetan@daynum{}།}% |
| 114 |
} |
| 115 |
|
| 116 |
\def\tibetandigits#1{\expandafter\@tibetan@digits #1@} |
| 117 |
|
| 118 |
\def\@tibetan@digits#1{% |
| 119 |
\ifx @#1% then terminate |
| 120 |
\else |
| 121 |
\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 |
| 122 |
\expandafter\@tibetan@digits |
| 123 |
\fi |
| 124 |
} |
| 125 |
|
| 126 |
\def\tibetannumber#1{% |
| 127 |
\if@tibetan@numerals |
| 128 |
\tibetandigits{\number#1}% |
| 129 |
%%{\protect\addfontfeature{Mapping=tibetandigits}\protect\number#1} |
| 130 |
\else |
| 131 |
\number#1% |
| 132 |
%%{\protect\reset@font\number#1} |
| 133 |
\fi} |
| 134 |
|
| 135 |
\def\@tibetanalph#1{% |
| 136 |
\ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or |
| 137 |
ཇ\or ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or |
| 138 |
བ\or མ\or ཙ\or ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or |
| 139 |
འ\or ཡ\or ར\or ལ\or ཤ\or ས\or ཧ\or ཨ |
| 140 |
\else% |
| 141 |
\xpg@ill@value{#1}{@tibetanalph}% |
| 142 |
\fi% |
| 143 |
} |
| 144 |
|
| 145 |
\def\tibetanAlph#1{% |
| 146 |
\expandafter\@tibetanAlph\csname c@#1\endcsname% |
| 147 |
} |
| 148 |
|
| 149 |
\def\@tibetanAlph#1{% |
| 150 |
\ifcase#1\or ཀ\or ཁ\or ག\or ང\or ཅ\or ཆ\or ཇ\or |
| 151 |
ཉ\or ཏ\or ཐ\or ད\or ན\or པ\or ཕ\or བ\or མ\or ཙ\or |
| 152 |
ཚ\or ཛ\or ཝ\or ཞ\or ཟ\or འ\or ཡ\or ར\or ལ\or ཤ\or |
| 153 |
ས\or ཧ\or ཨ% |
| 154 |
\else% |
| 155 |
\xpg@ill@value{#1}{@tibetanalph}% |
| 156 |
\fi% |
| 157 |
} |
| 158 |
|
| 159 |
\newcommand{\tibetanumerals}[2]{\tibetannumber{#2}} |
| 160 |
|
| 161 |
\def\tibetan@numbers{% |
| 162 |
\if@tibetan@numerals |
| 163 |
\let\@alph\@tibetanalph% |
| 164 |
\let\@Alph\@tibetanAlph% |
| 165 |
\fi |
| 166 |
} |
| 167 |
|
| 168 |
\def\notibetan@numbers{% |
| 169 |
\let\@alph\latin@alph% |
| 170 |
\let\@Alph\latin@Alph% |
| 171 |
} |
| 172 |
|
| 173 |
% Store original definition |
| 174 |
\let\xpg@orig@arabic\@arabic |
| 175 |
|
| 176 |
\def\tibetan@globalnumbers{% |
| 177 |
\let\@arabic\tibetannumber% |
| 178 |
\renewcommand{\thefootnote}{\localnumeral*{footnote}}% |
| 179 |
} |
| 180 |
|
| 181 |
\def\notibetan@globalnumbers{% |
| 182 |
\let\@arabic\xpg@orig@arabic% |
| 183 |
} |
| 184 |
|
| 185 |
\def\noextras@tibetan{% |
| 186 |
\notibetan@eol% |
| 187 |
\ifcsname xpg@orig@baselinestretch\endcsname% |
| 188 |
\renewcommand{\baselinestretch}{\xpg@orig@baselinestretch}% |
| 189 |
\fi% |
| 190 |
} |
| 191 |
|
| 192 |
\def\inlineextras@tibetan{% |
| 193 |
\xdef\xpg@orig@baselinestretch{% |
| 194 |
\ifcsname baselinestretch\endcsname |
| 195 |
\baselinestretch |
| 196 |
\else |
| 197 |
1% |
| 198 |
\fi% |
| 199 |
}% |
| 200 |
\renewcommand{\baselinestretch}{1.2}% |
| 201 |
\tibetan@eol% |
| 202 |
} |
| 203 |
|
| 204 |
\def\blockextras@tibetan{% |
| 205 |
\xdef\xpg@orig@baselinestretch{% |
| 206 |
\ifcsname baselinestretch\endcsname |
| 207 |
\baselinestretch |
| 208 |
\else |
| 209 |
1% |
| 210 |
\fi% |
| 211 |
}% |
| 212 |
\renewcommand{\baselinestretch}{1.2}% |
| 213 |
\tibetan@eol% |
| 214 |
} |
| 215 |
|
| 216 |
\endinput |