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

Added support for Tunisian Dinar #593

Merged
merged 5 commits into from
Dec 16, 2024
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
11 changes: 10 additions & 1 deletion num2words/lang_AR.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
("قرش", "قرشان", "قروش", "قرش")]
CURRENCY_KWD = [("دينار", "ديناران", "دينارات", "ديناراً"),
("فلس", "فلسان", "فلس", "فلس")]
CURRENCY_TND = [("دينار", "ديناران", "دينارات", "ديناراً"),
("مليماً", "ميلمان", "مليمات", "مليم")]

ARABIC_ONES = [
"", "واحد", "اثنان", "ثلاثة", "أربعة", "خمسة", "ستة", "سبعة", "ثمانية",
Expand Down Expand Up @@ -352,15 +354,22 @@ def validate_number(self, number):
return number

def set_currency_prefer(self, currency):
if currency == 'EGP':
if currency == 'TND':
self.currency_unit = CURRENCY_TND[0]
self.currency_subunit = CURRENCY_TND[1]
self.partPrecision = 3
elif currency == 'EGP':
self.currency_unit = CURRENCY_EGP[0]
self.currency_subunit = CURRENCY_EGP[1]
self.partPrecision = 2
elif currency == 'KWD':
self.currency_unit = CURRENCY_KWD[0]
self.currency_subunit = CURRENCY_KWD[1]
self.partPrecision = 2
else:
self.currency_unit = CURRENCY_SR[0]
self.currency_subunit = CURRENCY_SR[1]
self.partPrecision = 2

def to_currency(self, value, currency='SR', prefix='', suffix=''):
self.set_currency_prefer(currency)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ def test_currency_parm(self):
self.assertEqual(
num2words(1000000.99, to='currency', lang='ar', currency="KWD"),
'مليون دينار و تسع و تسعون فلس')
self.assertEqual(
num2words(1000.42, to='currency', lang='ar', currency="TND"),
'ألف دينار و أربعمائة و عشرون مليم')
self.assertEqual(
num2words(123.21, to='currency', lang='ar', currency="TND"),
'مائة و ثلاثة و عشرون ديناراً و مئتان و عشر مليمات')

def test_ordinal(self):

Expand Down
Loading