Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions num2words/lang_CA.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,20 @@ def to_ordinal(self, value):
text = "%s%s" % (self.ords[value], self.gender_stem)
elif value <= 30:
frac = value % 10
text = "%s%s%s" % (self.ords[20], "-i-", self.ords_3[frac])
if frac == 0:
# An exact ten ("trentè") has no units part to append.
text = "%s%s" % (self.ords[value], self.gender_stem)
else:
text = "%s%s%s" % (self.ords[20], "-i-", self.ords_3[frac])
elif value < 100:
dec = (value // 10) * 10
text = "%s%s%s%s" % (self.ords[dec], "a",
"-", self.ords_3[value - dec])
frac = value - dec
if frac == 0:
# An exact ten ("quarantè") has no units part to append.
text = "%s%s" % (self.ords[dec], self.gender_stem)
else:
text = "%s%s%s%s" % (self.ords[dec], "a",
"-", self.ords_3[frac])
elif value == 1e2:
text = "%s%s" % (self.ords[value], self.gender_stem)
elif value < 2e2:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_ca.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@
(12, "dotzè"),
(14, "catorzè"),
(28, "vint-i-vuitè"),
(30, "trentè"),
(33, "trenta-tresè"),
(40, "quarantè"),
(50, "cinquantè"),
(60, "seixantè"),
(70, "setantè"),
(80, "vuitantè"),
(88, "vuitanta-vuitè"),
(90, "norantè"),
(100, "centè"),
(128, "cent vint-i-vuitè"),
(130, "cent trentè"),
(199, "cent noranta-novè"),
(1000, "milè"),
(1827, "mil vuit-cents vint-i-setè"),
Expand Down