Skip to content

Commit

Permalink
Merge branch 'master' into nepali-number-system
Browse files Browse the repository at this point in the history
  • Loading branch information
ajiragroup authored Dec 18, 2024
2 parents b86dbe6 + 2b4d0bb commit 8fbd3b7
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 24 deletions.
17 changes: 17 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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
---------------------------

Expand Down
16 changes: 9 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,26 +81,27 @@ 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)
* ``en_NP`` (English - Nepal)
* ``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)
Expand All @@ -113,23 +114,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
Expand Down
2 changes: 1 addition & 1 deletion bin/num2words
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import sys
from docopt import docopt
import num2words

__version__ = "0.5.13"
__version__ = "0.5.14"
__license__ = "LGPL"


Expand Down
4 changes: 2 additions & 2 deletions num2words/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


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_EN_NP,
lang_CS, lang_CY, lang_DA, lang_DE, lang_EN, lang_EN_IN, lang_EN_NP,
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,
Expand Down Expand Up @@ -71,7 +71,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(),
Expand Down
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
4 changes: 2 additions & 2 deletions num2words/lang_DK.py → num2words/lang_DA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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
22 changes: 11 additions & 11 deletions tests/test_dk.py → tests/test_da.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 8fbd3b7

Please sign in to comment.