Skip to content

Commit

Permalink
Merge pull request #490 from eyaler/master
Browse files Browse the repository at this point in the history
Hebrew long-form spelling, gender, ordinals, fractions, maxval=1e66, construct forms, etc
  • Loading branch information
mrodriguezg1991 authored Jan 22, 2023
2 parents f510792 + e272daa commit 3ef32f0
Show file tree
Hide file tree
Showing 7 changed files with 692 additions and 143 deletions.
6 changes: 3 additions & 3 deletions bin/num2words
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ def main():
sys.stdout.write(os.linesep)
sys.exit(0)
if args["--list-converters"]:
for lang in get_converters():
sys.stdout.write(lang)
for cvt in get_converters():
sys.stdout.write(cvt)
sys.stdout.write(os.linesep)
sys.exit(0)
try:
words = num2words.num2words(args['<number>'], lang=args['--lang'], to=args['--to'])
sys.stdout.write(words+os.linesep)
sys.stdout.write(words + os.linesep)
sys.exit(0)
except Exception as err:
sys.stderr.write(str(args['<number>']))
Expand Down
2 changes: 1 addition & 1 deletion num2words/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def num2words(number, ordinal=False, lang='en', to='cardinal', **kwargs):

# backwards compatible
if ordinal:
return converter.to_ordinal(number)
to = 'ordinal'

if to not in CONVERTES_TYPES:
raise NotImplementedError()
Expand Down
6 changes: 3 additions & 3 deletions num2words/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def parse_minus(self, num_str):
"""Detach minus and return it as symbol with new num_str."""
if num_str.startswith('-'):
# Extra spacing to compensate if there is no minus.
return '%s ' % self.negword, num_str[1:]
return '%s ' % self.negword.strip(), num_str[1:]
return '', num_str

def str_to_number(self, value):
Expand All @@ -109,7 +109,7 @@ def to_cardinal(self, value):
out = ""
if value < 0:
value = abs(value)
out = self.negword
out = "%s " % self.negword.strip()

if value >= self.MAXVAL:
raise OverflowError(self.errmsg_toobig % (value, self.MAXVAL))
Expand Down Expand Up @@ -292,7 +292,7 @@ def to_currency(self, val, currency='EUR', cents=True, separator=',',
if adjective and currency in self.CURRENCY_ADJECTIVES:
cr1 = prefix_currency(self.CURRENCY_ADJECTIVES[currency], cr1)

minus_str = "%s " % self.negword if is_negative else ""
minus_str = "%s " % self.negword.strip() if is_negative else ""
money_str = self._money_verbose(left, currency)
cents_str = self._cents_verbose(right, currency) \
if cents else self._cents_terse(right, currency)
Expand Down
Loading

0 comments on commit 3ef32f0

Please sign in to comment.