From 282f72dd2ff226bc14ca6c4234b661eaac7ed8aa Mon Sep 17 00:00:00 2001 From: Rochdi Bazine Date: Mon, 16 Dec 2024 17:19:57 +0100 Subject: [PATCH 1/3] Added support for Tunisian Dinar (#593) * Added support for Tunisian Dinar * Added tests for TND currency * Set parPrecision for other AR currencies --------- Co-authored-by: Marlon Rodriguez Garcia <47992153+mrodriguezg1991@users.noreply.github.com> --- num2words/lang_AR.py | 11 ++++++++++- tests/test_ar.py | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/num2words/lang_AR.py b/num2words/lang_AR.py index 7195dd47..7813d3aa 100644 --- a/num2words/lang_AR.py +++ b/num2words/lang_AR.py @@ -31,6 +31,8 @@ ("قرش", "قرشان", "قروش", "قرش")] CURRENCY_KWD = [("دينار", "ديناران", "دينارات", "ديناراً"), ("فلس", "فلسان", "فلس", "فلس")] +CURRENCY_TND = [("دينار", "ديناران", "دينارات", "ديناراً"), + ("مليماً", "ميلمان", "مليمات", "مليم")] ARABIC_ONES = [ "", "واحد", "اثنان", "ثلاثة", "أربعة", "خمسة", "ستة", "سبعة", "ثمانية", @@ -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) diff --git a/tests/test_ar.py b/tests/test_ar.py index 91e648a6..5781db52 100644 --- a/tests/test_ar.py +++ b/tests/test_ar.py @@ -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): From 6abe2c64714a38e41de23fe20fa319d0ad2fd845 Mon Sep 17 00:00:00 2001 From: Frederik Haa Date: Mon, 16 Dec 2024 17:34:18 +0100 Subject: [PATCH 2/3] Change danish language code to DA (#596) Co-authored-by: Marlon Rodriguez Garcia <47992153+mrodriguezg1991@users.noreply.github.com> --- num2words/__init__.py | 4 ++-- num2words/{lang_DK.py => lang_DA.py} | 4 ++-- tests/{test_dk.py => test_da.py} | 22 +++++++++++----------- 3 files changed, 15 insertions(+), 15 deletions(-) rename num2words/{lang_DK.py => lang_DA.py} (98%) rename tests/{test_dk.py => test_da.py} (68%) diff --git a/num2words/__init__.py b/num2words/__init__.py index 0c216ad2..882aa229 100644 --- a/num2words/__init__.py +++ b/num2words/__init__.py @@ -18,7 +18,7 @@ from __future__ import unicode_literals from . import (lang_AM, lang_AR, lang_AZ, lang_BE, lang_BN, lang_CA, lang_CE, - lang_CS, lang_CY, lang_DE, lang_DK, lang_EN, lang_EN_IN, + lang_CS, lang_CY, lang_DA, lang_DE, lang_EN, lang_EN_IN, lang_EN_NG, lang_EO, lang_ES, lang_ES_CO, lang_ES_CR, lang_ES_GT, lang_ES_NI, lang_ES_VE, lang_FA, lang_FI, lang_FR, lang_FR_BE, lang_FR_CH, lang_FR_DZ, lang_HE, lang_HU, lang_ID, @@ -69,7 +69,7 @@ 'sr': lang_SR.Num2Word_SR(), 'sv': lang_SV.Num2Word_SV(), 'no': lang_NO.Num2Word_NO(), - 'dk': lang_DK.Num2Word_DK(), + 'da': lang_DA.Num2Word_DA(), 'pt': lang_PT.Num2Word_PT(), 'pt_BR': lang_PT_BR.Num2Word_PT_BR(), 'he': lang_HE.Num2Word_HE(), diff --git a/num2words/lang_DK.py b/num2words/lang_DA.py similarity index 98% rename from num2words/lang_DK.py rename to num2words/lang_DA.py index 50ab110c..c6607383 100644 --- a/num2words/lang_DK.py +++ b/num2words/lang_DA.py @@ -20,12 +20,12 @@ from . import lang_EU -class Num2Word_DK(lang_EU.Num2Word_EU): +class Num2Word_DA(lang_EU.Num2Word_EU): GIGA_SUFFIX = "illiarder" MEGA_SUFFIX = "illioner" def setup(self): - super(Num2Word_DK, self).setup() + super(Num2Word_DA, self).setup() self.negword = "minus " self.pointword = "komma" diff --git a/tests/test_dk.py b/tests/test_da.py similarity index 68% rename from tests/test_dk.py rename to tests/test_da.py index 4c2e6ce3..3e1b4eba 100644 --- a/tests/test_dk.py +++ b/tests/test_da.py @@ -20,25 +20,25 @@ from unittest import TestCase from num2words import num2words -from num2words.lang_DK import Num2Word_DK +from num2words.lang_DA import Num2Word_DA class Num2WordsDKTest(TestCase): def test_ordinal(self): - self.assertEqual(num2words(1, to="ordinal", lang="dk"), "første") - self.assertEqual(num2words(5, to="ordinal", lang="dk"), "femte") + self.assertEqual(num2words(1, to="ordinal", lang="da"), "første") + self.assertEqual(num2words(5, to="ordinal", lang="da"), "femte") def test_cardinal(self): - self.assertEqual(num2words(0, to="cardinal", lang="dk"), "nul") - self.assertEqual(num2words(1, to="cardinal", lang="dk"), "et") - self.assertEqual(num2words(2, to="cardinal", lang="dk"), "to") - self.assertEqual(num2words(5, to="cardinal", lang="dk"), "fem") - self.assertEqual(num2words(8, to="cardinal", lang="dk"), "otte") - self.assertEqual(num2words(18, to="cardinal", lang="dk"), "atten") - self.assertEqual(num2words(45, to="cardinal", lang="dk"), "femogfyrre") + self.assertEqual(num2words(0, to="cardinal", lang="da"), "nul") + self.assertEqual(num2words(1, to="cardinal", lang="da"), "et") + self.assertEqual(num2words(2, to="cardinal", lang="da"), "to") + self.assertEqual(num2words(5, to="cardinal", lang="da"), "fem") + self.assertEqual(num2words(8, to="cardinal", lang="da"), "otte") + self.assertEqual(num2words(18, to="cardinal", lang="da"), "atten") + self.assertEqual(num2words(45, to="cardinal", lang="da"), "femogfyrre") def test_to_ordinal_num(self): - num2words_dk = Num2Word_DK() + num2words_dk = Num2Word_DA() self.assertEqual(num2words_dk.to_ordinal_num(1), "1te") self.assertEqual(num2words_dk.to_ordinal_num(2), "2en") self.assertEqual(num2words_dk.to_ordinal_num(5), "5te") From 2b4d0bbef8354aa6fbdee8ff4b7da95a35922a9a Mon Sep 17 00:00:00 2001 From: Marlon Rodriguez Garcia <47992153+mrodriguezg1991@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:00:01 -0500 Subject: [PATCH 3/3] New release (#606) Co-authored-by: Marlon Rodriguez Garcia --- CHANGES.rst | 17 +++++++++++++++++ README.rst | 16 +++++++++------- bin/num2words | 2 +- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index ea33f3e2..32a6e616 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,23 @@ Changelog ========= +Version 0.5.14 -- 2024/12/16 +---------------------------- + +* Fixed a typo in PL (#466) +* Run tests against Python 3.12 (#544) +* ADD num2words: es_CR language (#565) +* New languages: Welsh (Celtic) and Chechen (Nakho-Dagestanian) (#543) +* Add catalan language support (#581) +* Adding Tetum Language (#576) +* FIX ISO code for Belarusian language is be, not by. (#574) +* Add test to improve coverage (#595) +* Added Bangla language support to num2word for Bangladesh. (#589) +* Czech language ISO 639-1 code fix (#587) +* Added support for Tunisian Dinar (#593) +* Change danish language code to DA (#596) + + Version 0.5.13 -- 2023/10/18 --------------------------- diff --git a/README.rst b/README.rst index 16d33f59..7e0bc1f2 100644 --- a/README.rst +++ b/README.rst @@ -81,25 +81,26 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a * ``az`` (Azerbaijani) * ``be`` (Belarusian) * ``bn`` (Bangladeshi) +* ``ca`` (Catalan) * ``ce`` (Chechen) * ``cs`` (Czech) * ``cy`` (Welsh) +* ``da`` (Danish) * ``de`` (German) -* ``dk`` (Danish) * ``en_GB`` (English - Great Britain) * ``en_IN`` (English - India) * ``en_NG`` (English - Nigeria) * ``es`` (Spanish) * ``es_CO`` (Spanish - Colombia) * ``es_CR`` (Spanish - Costa Rica) -* ``es_VE`` (Spanish - Venezuela) * ``es_GT`` (Spanish - Guatemala) +* ``es_VE`` (Spanish - Venezuela) * ``eu`` (EURO) * ``fa`` (Farsi) * ``fi`` (Finnish) * ``fr`` (French) -* ``fr_CH`` (French - Switzerland) * ``fr_BE`` (French - Belgium) +* ``fr_CH`` (French - Switzerland) * ``fr_DZ`` (French - Algeria) * ``he`` (Hebrew) * ``hu`` (Hungarian) @@ -112,23 +113,24 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a * ``kz`` (Kazakh) * ``lt`` (Lithuanian) * ``lv`` (Latvian) +* ``nl`` (Dutch) * ``no`` (Norwegian) * ``pl`` (Polish) * ``pt`` (Portuguese) * ``pt_BR`` (Portuguese - Brazilian) +* ``ro`` (Romanian) +* ``ru`` (Russian) * ``sl`` (Slovene) +* ``sk`` (Slovak) * ``sr`` (Serbian) * ``sv`` (Swedish) -* ``ro`` (Romanian) -* ``ru`` (Russian) * ``te`` (Telugu) * ``tet`` (Tetum) * ``tg`` (Tajik) * ``tr`` (Turkish) * ``th`` (Thai) -* ``vi`` (Vietnamese) -* ``nl`` (Dutch) * ``uk`` (Ukrainian) +* ``vi`` (Vietnamese) You can supply values like ``fr_FR``; if the country doesn't exist but the language does, the code will fall back to the base language (i.e. ``fr``). If diff --git a/bin/num2words b/bin/num2words index 359d1bdb..c6dbd52f 100755 --- a/bin/num2words +++ b/bin/num2words @@ -55,7 +55,7 @@ import sys from docopt import docopt import num2words -__version__ = "0.5.13" +__version__ = "0.5.14" __license__ = "LGPL"