• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sile-typesetter / sile / 14860011647

06 May 2025 12:44PM UTC coverage: 67.057% (+32.5%) from 34.559%
14860011647

push

github

alerque
chore(typesetters): Fixup access to class from typesetter functions

7 of 7 new or added lines in 2 files covered. (100.0%)

1344 existing lines in 103 files now uncovered.

14880 of 22190 relevant lines covered (67.06%)

11549.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.75
/languages/tr/init.lua
1
local unicode = require("languages.unicode")
8✔
2

3
local language = pl.class(unicode)
8✔
4
language._name = "tr"
8✔
5

6
function language:setupNodeMaker ()
8✔
7
   self.nodemaker = require("languages.tr.nodemaker")
8✔
8
end
9

10
function language:setupHyphenator ()
8✔
11
   self.hyphenator = require("languages.tr.hyphenator")(self)
16✔
12
end
13

14
function language:declareSettings ()
8✔
15
   -- Different years of TDK and various publisher style guides differ on this point.
16
   -- Current official guidance suggests dropping the hyphenation mark if the break
17
   -- occurs at an apostrophe (kesme işareti). Some older guidance and some publishers
18
   -- suggest dropping the apostrophe instead.
19
   self.settings:declare({
16✔
20
      parameter = "languages.tr.replaceApostropheAtHyphenation",
21
      type = "boolean",
22
      default = false,
23
      help = "If enabled, substitute the apostophe for a hyphen at break points, otherwise keep the apostrophe and hide the hyphen.",
24
   })
25
end
26

27
-- local sum_tens = function (val, loc, digits)
28
--   local ten = string.sub(digits, loc+1, loc+1)
29
--   if ten:len() == 1 then val = val + tonumber(ten) * 10 end
30
--   return val
31
-- end
32

33
local sum_hundreds = function (val, loc, digits)
UNCOV
34
   local ten = string.sub(digits, loc + 1, loc + 1)
×
UNCOV
35
   local hundred = string.sub(digits, loc + 2, loc + 2)
×
UNCOV
36
   if ten:len() == 1 then
×
UNCOV
37
      val = val + tonumber(ten) * 10
×
38
   end
UNCOV
39
   if hundred:len() == 1 then
×
UNCOV
40
      val = val + tonumber(hundred) * 100
×
41
   end
UNCOV
42
   return val
×
43
end
44

45
local tr_nums = function (num, ordinal)
46
   local abs = math.abs(num)
×
47
   if abs >= 1e+36 then
×
48
      SU.error("Numbers past decillions not supported in Turkish")
×
49
   end
UNCOV
50
   ordinal = SU.boolean(ordinal, false)
×
51
   local minus = "eksi"
×
52
   local zero = "sıfır"
×
UNCOV
53
   local ones = { "bir", "iki", "üç", "dört", "beş", "altı", "yedi", "sekiz", "dokuz" }
×
54
   local tens = { "on", "yirmi", "otuz", "kırk", "eli", "altmış", "yetmiş", "seksen", "doksan" }
×
UNCOV
55
   local places = {
×
56
      "yüz",
57
      "bin",
58
      "milyon",
59
      "milyar",
60
      "trilyon",
61
      "katrilyon",
62
      "kentilyon",
63
      "sekstilyon",
64
      "septilyon",
65
      "oktilyon",
66
      "nonilyon",
67
      "desilyon",
68
   }
UNCOV
69
   local zeroordinal = "sıfırıncı"
×
70
   local onesordinals =
UNCOV
71
      { "birinci", "ikinci", "üçüncü", "dördüncü", "beşinci", "altıncı", "yedinci", "sekizinci", "dokuzuncu" }
×
UNCOV
72
   local tensordinals = {
×
73
      "onuncu",
74
      "yirmiyinci",
75
      "otuzuncu",
76
      "kırkıncı",
77
      "eliyinci",
78
      "altmışıncı",
79
      "yetmişinci",
80
      "sekseninci",
81
      "Doksanıncı",
82
   }
83
   local placesordinals = {
×
84
      "yüzüncü",
85
      "bininci",
86
      "milyonuncu",
87
      "milyarıncı",
88
      "trilyonuncu",
89
      "katrilyonuncu",
90
      "kentilyonuncu",
91
      "sekstilyonuncu",
92
      "septilyonuncu",
93
      "oktilyonuncu",
94
      "nonilyonuncu",
95
      "desilyonuncu",
96
   }
UNCOV
97
   local digits = string.reverse(string.format("%.f", abs))
×
UNCOV
98
   local words = {}
×
UNCOV
99
   for i = 1, #digits do
×
UNCOV
100
      local val, place, mod = tonumber(string.sub(digits, i, i)), math.floor(i / 3), i % 3
×
UNCOV
101
      if #digits == 1 and val == 0 then
×
UNCOV
102
         words[#words + 1] = ordinal and zeroordinal or zero
×
UNCOV
103
      elseif val >= 1 or i > 1 then
×
UNCOV
104
         if i == 1 then
×
UNCOV
105
            words[#words + 1] = ordinal and onesordinals[val] or ones[val]
×
UNCOV
106
            ordinal = false
×
UNCOV
107
         elseif mod == 2 then
×
UNCOV
108
            if val >= 1 then
×
109
               words[#words + 1] = ordinal and tensordinals[val] or tens[val]
×
110
               ordinal = false
×
111
            end
112
         elseif mod == 1 then
×
113
            if sum_hundreds(val, i, digits) >= 1 then
×
114
               words[#words + 1] = ordinal and placesordinals[place + 1] or places[place + 1]
×
115
               ordinal = false
×
116
               if val > 0 and (i >= 7 or sum_hundreds(val, i, digits) >= 2) then
×
117
                  words[#words + 1] = ones[val]
×
118
               end
119
            end
120
         elseif mod == 0 then
×
121
            if val > 0 then
×
122
               words[#words + 1] = ordinal and placesordinals[1] or places[1]
×
UNCOV
123
               ordinal = false
×
124
            end
125
            if val >= 2 then
×
126
               words[#words + 1] = ones[val]
×
127
            end
128
         end
129
      end
130
   end
UNCOV
131
   if abs > num then
×
132
      words[#words + 1] = minus
×
133
   end
134
   SU.flip_in_place(words)
×
135
   return table.concat(words, " ")
×
136
end
137

138
function language:numberToString (num)
8✔
UNCOV
139
   return tr_nums(num, false)
×
140
end
141

142
function language:numberToOrdinalString (num)
8✔
143
   return tr_nums(num, true)
×
144
end
145

146
return language
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc