Skip to content

Commit

Permalink
Merging with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Храмцов Дмитрий Романович authored and Храмцов Дмитрий Романович committed Jan 10, 2025
2 parents a18f298 + 5267ce1 commit b29ee24
Show file tree
Hide file tree
Showing 20 changed files with 1,219 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', '3.11', '3.12']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
Expand Down
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
22 changes: 13 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,30 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a
* ``ar`` (Arabic)
* ``az`` (Azerbaijani)
* ``be`` (Belarusian)
* ``bn`` (Bangladeshi)
* ``ca`` (Catalan)
* ``ce`` (Chechen)
* ``cs`` (Czech)
* ``cy`` (Welsh)
* ``cz`` (Czech)
* ``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)
* ``hi`` (Hindi)
* ``hu`` (Hungarian)
* ``id`` (Indonesian)
* ``is`` (Icelandic)
Expand All @@ -111,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 Expand Up @@ -160,4 +164,4 @@ added Lithuanian support, but didn't take over maintenance of the project.
I am thus basing myself on Marius Grigaitis' improvements and re-publishing
``pynum2word`` as ``num2words``.

Virgil Dupras, Savoir-faire Linux
Virgil Dupras, Savoir-faire Linux
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
25 changes: 14 additions & 11 deletions num2words/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@

from __future__ import unicode_literals

from . import (lang_AM, lang_AR, lang_AZ, lang_BE, lang_CA, lang_CE, lang_CY,
lang_CZ, lang_DE, lang_DK, 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, lang_IS,
lang_IT, lang_JA, lang_KN, lang_KO, lang_KZ, lang_LT, lang_LV,
lang_NL, lang_NO, lang_PL, lang_PT, lang_PT_BR, lang_RO,
lang_RU, lang_SK, lang_SL, lang_SR, lang_SV, lang_TE, lang_TET,
lang_TG, lang_TH, lang_TR, lang_UK, lang_VI)
from . import (lang_AM, lang_AR, lang_AZ, lang_BE, lang_BN, lang_CA, lang_CE,
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_HI, lang_HU,
lang_ID, lang_IS, lang_IT, lang_JA, lang_KN, lang_KO, lang_KZ,
lang_LT, lang_LV, lang_NL, lang_NO, lang_PL, lang_PT,
lang_PT_BR, lang_RO, lang_RU, lang_SK, lang_SL, lang_SR,
lang_SV, lang_TE, lang_TET, lang_TG, lang_TH, lang_TR, lang_UK,
lang_VI)

CONVERTER_CLASSES = {
'am': lang_AM.Num2Word_AM(),
'ar': lang_AR.Num2Word_AR(),
'az': lang_AZ.Num2Word_AZ(),
'be': lang_BE.Num2Word_BE(),
'bn': lang_BN.Num2Word_BN(),
'ca': lang_CA.Num2Word_CA(),
'ce': lang_CE.Num2Word_CE(),
'cs': lang_CS.Num2Word_CS(),
'cy': lang_CY.Num2Word_CY(),
'cz': lang_CZ.Num2Word_CZ(),
'en': lang_EN.Num2Word_EN(),
'en_IN': lang_EN_IN.Num2Word_EN_IN(),
'en_NG': lang_EN_NG.Num2Word_EN_NG(),
Expand Down Expand Up @@ -68,7 +70,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 All @@ -83,6 +85,7 @@
'tet': lang_TET.Num2Word_TET(),
'hu': lang_HU.Num2Word_HU(),
'is': lang_IS.Num2Word_IS(),
'hi': lang_HI.Num2Word_HI(),
}

CONVERTES_TYPES = ['cardinal', 'ordinal', 'ordinal_num', 'year', 'currency']
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
Loading

0 comments on commit b29ee24

Please sign in to comment.