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
4 changes: 4 additions & 0 deletions num2words/lang_PL.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ def last_fragment_to_ordinal(self, last, words, level):
def to_ordinal(self, number):
if number % 1 != 0:
raise NotImplementedError()
if number == 0:
# splitbyx("0") yields a single zero fragment; the loop below would
# pop it and then index an empty list, so handle zero explicitly.
return "zerowy"
words = []
fragments = list(splitbyx(str(number), 3))
level = 0
Expand Down
5 changes: 5 additions & 0 deletions num2words/lang_UK.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,11 @@ def last_fragment_to_ordinal(last, words, level):
def to_ordinal(self, number):
self.verify_ordinal(number)

if number == 0:
# splitbyx("0") yields a single zero fragment; the loop below would
# pop it and then index an empty list, so handle zero explicitly.
return "нульовий"

words = []
fragments = list(splitbyx(str(number), 3))
level = 0
Expand Down
1 change: 1 addition & 0 deletions tests/test_pl.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_cardinal(self):
)

def test_to_ordinal(self):
self.assertEqual(num2words(0, lang='pl', to='ordinal'), "zerowy")
self.assertEqual(num2words(100, lang='pl', to='ordinal'), "setny")
self.assertEqual(
num2words(101, lang='pl', to='ordinal'), "sto pierwszy")
Expand Down
1 change: 1 addition & 0 deletions tests/test_uk.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@
)

TEST_CASES_ORDINAL = (
(0, "нульовий"),
(1, "перший"),
(2, "другий"),
(3, "третій"),
Expand Down