Skip to content

Commit

Permalink
[FIX] ISO code for Belarusian language is be, not by. + coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SkiBY committed May 3, 2024
1 parent 5e6fa94 commit 0e497c9
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 92 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Besides the numerical argument, there are two main optional arguments, ``to:`` a
* ``am`` (Amharic)
* ``ar`` (Arabic)
* ``az`` (Azerbaijani)
* ``by`` (Belarusian)
* ``be`` (Belarusian)
* ``ce`` (Chechen)
* ``cy`` (Welsh)
* ``cz`` (Czech)
Expand Down
4 changes: 2 additions & 2 deletions num2words/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from __future__ import unicode_literals

from . import (lang_AM, lang_AR, lang_AZ, lang_BY, lang_CE, lang_CY, lang_CZ,
from . import (lang_AM, lang_AR, lang_AZ, lang_BE, 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,
Expand All @@ -31,7 +31,7 @@
'am': lang_AM.Num2Word_AM(),
'ar': lang_AR.Num2Word_AR(),
'az': lang_AZ.Num2Word_AZ(),
'by': lang_BY.Num2Word_BY(),
'be': lang_BE.Num2Word_BE(),
'ce': lang_CE.Num2Word_CE(),
'cy': lang_CY.Num2Word_CY(),
'cz': lang_CZ.Num2Word_CZ(),
Expand Down
6 changes: 3 additions & 3 deletions num2words/lang_BY.py → num2words/lang_BE.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
}


class Num2Word_BY(Num2Word_Base):
class Num2Word_BE(Num2Word_Base):
CURRENCY_FORMS = {
"RUB": (
("расійскі рубель", "расійскія рублі", "расійскіх рублёў"),
Expand Down Expand Up @@ -204,6 +204,8 @@ def pluralize(self, n, forms):

def to_ordinal(self, number, gender="m"):
self.verify_ordinal(number)
if isinstance(gender, bool) and gender:
gender = "f"
outwords = self.to_cardinal(number, gender).split(" ")
lastword = outwords[-1].lower()
try:
Expand Down Expand Up @@ -294,8 +296,6 @@ def _cents_verbose(self, number, currency):
return self._int2word(number, gender)

def _int2word(self, n, gender="m"):
if isinstance(gender, bool) and gender:
gender = "f"
if n < 0:
return " ".join([self.negword, self._int2word(abs(n), gender)])

Expand Down
2 changes: 1 addition & 1 deletion num2words/lang_EU.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Num2Word_EU(Num2Word_Base):

CURRENCY_ADJECTIVES = {
'AUD': 'Australian',
'BYN': 'Belarussian',
'BYN': 'Belarusian',
'CAD': 'Canadian',
'EEK': 'Estonian',
'USD': 'US',
Expand Down
7 changes: 7 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ def test_is_title(self):
self.base.title("one"),
"one"
)

def test_set_high_numwords_raises(self):
with self.assertRaises(NotImplementedError):
from num2words.base import Num2Word_Base
Num2Word_Base.high_numwords = ["cent"]
Num2Word_Base()

Loading

0 comments on commit 0e497c9

Please sign in to comment.