Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tr] return Turkish 0 ordinal and cardinal #347

Merged
merged 4 commits into from
May 7, 2021
Merged
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
8 changes: 7 additions & 1 deletion num2words/lang_TR.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

from __future__ import unicode_literals

from .base import Num2Word_Base

class Num2Word_TR(object):

class Num2Word_TR(Num2Word_Base):
def __init__(self):
self.precision = 2
self.negword = u"eksi"
Expand Down Expand Up @@ -152,6 +154,8 @@ def to_cardinal(self, value):
wrd += self.CARDINAL_ONES.get(
self.integers_to_read[0][0], ""
)
if self.integers_to_read[0][0] == "0":
return self.ZERO
return wrd

if self.total_digits_outside_triplets == 0:
Expand Down Expand Up @@ -507,6 +511,8 @@ def to_ordinal(self, value):
wrd += self.ORDINAL_ONES.get(
self.integers_to_read[0][0], ""
)
if self.integers_to_read[0][0] == "0":
return u"sıfırıncı"
return wrd

if self.total_digits_outside_triplets == 0:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_tr.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_tr(self):
"expected": u"birmilyonikibinbirlira"},
{"test": 1100000, "to": "currency",
"expected": u"birmilyonyüzbinlira"},
{"test": 0, "to": "ordinal", "expected": u"sıfırıncı"},
{"test": 1, "to": "ordinal", "expected": u"birinci"},
{"test": 2, "to": "ordinal", "expected": u"ikinci"},
{"test": 9, "to": "ordinal", "expected": u"dokuzuncu"},
Expand Down Expand Up @@ -108,6 +109,7 @@ def test_tr(self):
"expected": u"birmilyonüçbininci"},
{"test": 1200000, "to": "ordinal",
"expected": u"birmilyonikiyüzbininci"},
{"test": 0, "to": "cardinal", "expected": u"sıfır"},
{"test": 1, "to": "cardinal", "expected": u"bir"},
{"test": 2, "to": "cardinal", "expected": u"iki"},
{"test": 9, "to": "cardinal", "expected": u"dokuz"},
Expand Down