/usr/share/yelp-xsl/xslt/common/l10n-numbers.xsl is in yelp-xsl 3.20.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<!--
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program; see the file COPYING.LGPL. If not, see
<http://www.gnu.org/licenses/>.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math"
extension-element-prefixes="math"
version="1.0">
<!--!!==========================================================================
Localized Numbers
-->
<!--**==========================================================================
l10n.number
Formats a number according to a localized numbering system
$value: The numeric value of the number to format
$format: The numbering system to use
REMARK: Talk about numbering systems
-->
<xsl:template name="l10n.number">
<xsl:param name="value"/>
<xsl:param name="format"/>
<xsl:choose>
<xsl:when test="$format='decimal' or $format='1'">
<xsl:number format="1" value="$value"/>
</xsl:when>
<xsl:when test="$format='alpha-lower' or $format='a'">
<xsl:number format="a" value="$value"/>
</xsl:when>
<xsl:when test="$format='alpha-upper' or $format='A'">
<xsl:number format="A" value="$value"/>
</xsl:when>
<xsl:when test="$format='roman-lower' or $format='i'">
<xsl:number format="i" value="$value"/>
</xsl:when>
<xsl:when test="$format='roman-upper' or $format='I'">
<xsl:number format="I" value="$value"/>
</xsl:when>
<xsl:when test="$format='cjk-japanese' or
$format='cjk-chinese-simp' or
$format='cjk-chinese-trad' ">
<xsl:call-template name="l10n.number.cjk-ideographic">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="format" select="$format"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$format='ionic-lower' or $format='ionic-upper'">
<xsl:call-template name="l10n.number.ionic">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="format" select="$format"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$format='decimal-arabic'">
<xsl:call-template name="l10n.number.numeric">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="digits" select="'٠١٢٣٤٥٦٧٨٩'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$format='decimal-persian'">
<xsl:call-template name="l10n.number.numeric">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="digits" select="'۰۱۲۳۴۵۶۷۸۹'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$format='alpha-serbian-lower'">
<xsl:call-template name="l10n.number.alphabetic">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="alphabet"
select="'абвгдђежзијклљмнњопрстћуфхцчџш'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$format='alpha-serbian-upper'">
<xsl:call-template name="l10n.number.alphabetic">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="alphabet"
select="'АБВГДЂЕЖЗИЈКЛЉМНЊОПРСТЋУФХЦЧЏШ'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$format='alpha-thai'">
<xsl:call-template name="l10n.number.alphabetic">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="alphabet"
select="'กขคงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ'"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$format='decimal-thai'">
<xsl:call-template name="l10n.number.numeric">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="digits" select="'๐๑๒๓๔๕๖๗๘๙'"/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:template>
<!--**==========================================================================
l10n.number.alphabetic
Formats a number using an alphabetic numbering system
$value: The numeric value of the number to format
$alphabet: A string containing the characters of the alphabet to use
REMARK: Talk about alphabetic numbering systems
-->
<xsl:template name="l10n.number.alphabetic">
<xsl:param name="value"/>
<xsl:param name="alphabet"/>
<xsl:variable name="length" select="string-length($alphabet)"/>
<xsl:choose>
<xsl:when test="$value <= 0">
<xsl:number format="1" value="$value"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="digit">
<xsl:choose>
<xsl:when test="$value mod $length = 0">
<xsl:value-of select="$length"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$value mod $length"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:if test="$value - $digit != 0">
<xsl:call-template name="l10n.number.alphabetic">
<xsl:with-param name="value" select="($value - $digit) div $length"/>
<xsl:with-param name="alphabet" select="$alphabet"/>
</xsl:call-template>
</xsl:if>
<xsl:value-of select="substring($alphabet, $digit, 1)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--**==========================================================================
l10n.number.numeric
Formats a number using a numeric numbering system with any radix
$value: The numeric value of the number to format
$digits: A string containing the digits to use, starting with zero
REMARK: Talk about numeric numbering systems
-->
<xsl:template name="l10n.number.numeric">
<xsl:param name="value"/>
<xsl:param name="digits"/>
<xsl:param name="length" select="string-length($digits)"/>
<xsl:choose>
<xsl:when test="$value < 0">
<!-- FIXME: We need to localize the negative sign -->
<xsl:text>-</xsl:text>
<xsl:call-template name="l10n.number.numeric">
<xsl:with-param name="value" select="math:abs($value)"/>
<xsl:with-param name="digits" select="$digits"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="digit" select="$value mod $length"/>
<xsl:if test="$value - $digit != 0">
<xsl:call-template name="l10n.number.numeric">
<xsl:with-param name="value" select="($value - $digit) div $length"/>
<xsl:with-param name="digits" select="$digits"/>
</xsl:call-template>
</xsl:if>
<xsl:value-of select="substring($digits, $digit + 1, 1)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--**==========================================================================
l10n.number.cjk-ideographic
Formats a number using a CJK ideographic system
$value: The numeric value of the number to format
$format: Which ideographic system to use
REMARK: Talk about CJK ideographic numbering systems. Valid values of ${format}
are #{cjk-japanese}, #{cjk-chinese-simp}, and #{cjk-chinese-trad}.
-->
<xsl:template name="l10n.number.cjk-ideographic">
<xsl:param name="value"/>
<xsl:param name="format"/>
<xsl:call-template name="l10n.number.cjk-ideographic.private">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="format" select="$format"/>
<xsl:with-param name="level" select="0"/>
</xsl:call-template>
</xsl:template>
<!--#* l10n.number.cjk-ideographic.private -->
<xsl:template name="l10n.number.cjk-ideographic.private">
<xsl:param name="value"/>
<xsl:param name="format"/>
<xsl:param name="level" select="0"/>
<xsl:param name="zero" select="true()"/>
<xsl:variable name="ones">
<xsl:text>〇一二三四</xsl:text>
<xsl:text>五六七八九</xsl:text>
</xsl:variable>
<xsl:variable name="tens">
<xsl:text>十百千</xsl:text>
</xsl:variable>
<!-- FIXME: pick a upper bound and fallback to decimal -->
<xsl:variable name="myriads">
<xsl:choose>
<xsl:when test="$format='cjk-japanese'">
<xsl:text>万億兆京垓</xsl:text>
</xsl:when>
<xsl:when test="$format='cjk-chinese-simp'">
<xsl:text>万亿兆</xsl:text>
</xsl:when>
<xsl:when test="$format='cjk-chinese-trad'">
<xsl:text>萬億兆</xsl:text>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="digit" select="$value mod 10"/>
<xsl:if test="$value - $digit > 0">
<xsl:call-template name="l10n.number.cjk-ideographic.private">
<xsl:with-param name="value" select="($value - $digit) div 10"/>
<xsl:with-param name="format" select="$format"/>
<xsl:with-param name="level" select="$level + 1"/>
<xsl:with-param name="zero" select="$digit = 0"/>
</xsl:call-template>
</xsl:if>
<xsl:choose>
<xsl:when test="$digit = 0">
<xsl:choose>
<xsl:when test="$value = 0">
<xsl:value-of select="substring($ones, $digit + 1, 1)"/>
</xsl:when>
<xsl:when test="$format='cjk-chinese-simp' and not($zero)">
<xsl:value-of select="substring($ones, $digit + 1, 1)"/>
</xsl:when>
<xsl:when test="$format='cjk-chinese-trad' and not($zero)">
<xsl:value-of select="substring($ones, $digit + 1, 1)"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring($ones, $digit + 1, 1)"/>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="ten" select="$level mod 4"/>
<xsl:choose>
<xsl:when test="$ten != 0">
<xsl:if test="$digit != 0">
<xsl:value-of select="substring($tens, $ten, 1)"/>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="myriad" select="($level - $ten) div 4"/>
<xsl:if test="$myriad != 0">
<xsl:value-of select="substring($myriads, $myriad, 1)"/>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--**==========================================================================
l10n.number.ionic
Formats a number using the Ionic numeral system
$value: The numeric value of the number to format
$format: Which format to use
REMARK: Talk about the Ionic numeral system. Talk about ${format}
See #{http://en.wikipedia.org/wiki/Greek_numerals}.
-->
<xsl:template name="l10n.number.ionic">
<xsl:param name="value"/>
<xsl:param name="format" select="'ionic-lower'"/>
<xsl:choose>
<xsl:when test="$value < 1 or $value > 999999">
<xsl:number format="1" value="$value"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="l10n.number.ionic.private">
<xsl:with-param name="value" select="$value"/>
<xsl:with-param name="format" select="'ionic-lower'"/>
<xsl:with-param name="level" select="1"/>
</xsl:call-template>
<xsl:text>´</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--#* l10n.number.ionic.private -->
<xsl:template name="l10n.number.ionic.private">
<xsl:param name="value"/>
<xsl:param name="format" select="'ionic-lower'"/>
<xsl:param name="level" select="1"/>
<xsl:param name="stigma" select="false()"/>
<xsl:variable name="digit" select="$value mod 10"/>
<xsl:if test="$value - $digit > 0">
<xsl:call-template name="l10n.number.ionic.private">
<xsl:with-param name="value" select="($value - $digit) div 10"/>
<xsl:with-param name="format" select="$format"/>
<xsl:with-param name="level" select="$level + 1"/>
<xsl:with-param name="stigma" select="$stigma"/>
</xsl:call-template>
</xsl:if>
<xsl:choose>
<xsl:when test="$format='ionic-lower'">
<xsl:choose>
<xsl:when test="$digit = 0"/>
<xsl:when test="not($stigma) and $digit = 6 and $level = 1">
<xsl:text>στ</xsl:text>
</xsl:when>
<xsl:when test="$level = 1 or $level = 4">
<xsl:if test="$level = 4">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select="substring('αβγδεϛζηθ', $digit, 1)"/>
</xsl:when>
<xsl:when test="$level = 2 or $level = 5">
<xsl:if test="$level = 5">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select="substring('ικλμνξοπϟ', $digit, 1)"/>
</xsl:when>
<xsl:when test="$level = 3 or $level = 6">
<xsl:if test="$level = 6">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select="substring('ρστυφχψωϡ', $digit, 1)"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:when test="$format='ionic-upper'">
<xsl:choose>
<xsl:when test="$digit = 0"/>
<xsl:when test="not($stigma) and $digit = 6 and $level = 1">
<xsl:text>ΣΤ</xsl:text>
</xsl:when>
<xsl:when test="not($stigma) and $digit = 6 and $level = 1">
<xsl:text>,Σ,Τ</xsl:text>
</xsl:when>
<xsl:when test="$level = 1 or $level = 4">
<xsl:if test="$level = 4">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select="substring('ΑΒΓΔΕϚΖΗΘ', $digit, 1)"/>
</xsl:when>
<xsl:when test="$level = 2 or $level = 5">
<xsl:if test="$level = 5">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select="substring('ΙΚΛΜΝΞΟΠϘ', $digit, 1)"/>
</xsl:when>
<xsl:when test="$level = 3 or $level = 6">
<xsl:if test="$level = 6">
<xsl:text>,</xsl:text>
</xsl:if>
<xsl:value-of select="substring('ΡΣΤΥΦΧΨΩϠ', $digit, 1)"/>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$digit"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|