From 07ea1baca273101156cc2fb3c273eb34c502fbe1 Mon Sep 17 00:00:00 2001 From: gshekler Date: Sat, 3 Oct 2020 15:03:43 +0300 Subject: [PATCH] implement currency for HE --- num2words/lang_HE.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/num2words/lang_HE.py b/num2words/lang_HE.py index 2b96dc1..f987192 100644 --- a/num2words/lang_HE.py +++ b/num2words/lang_HE.py @@ -136,11 +136,13 @@ def n2w(n): return int2word(int(n)) -def to_currency(n, currency='EUR', cents=True, separator=','): - raise NotImplementedError() - - class Num2Word_HE(Num2Word_Base): + CURRENCY_FORMS = { + 'NIS': (('שקל', 'שקלים'), ('אגורה', 'אגורות')), + 'EUR': (('אירו', 'אירו'), ('סנט', 'סנט')), + 'USD': (('דולר', 'דולרים'), ('סנט', 'סנט')), + } + def to_cardinal(self, number): return n2w(number) @@ -150,6 +152,14 @@ class Num2Word_HE(Num2Word_Base): def pluralize(self, n, forms): return pluralize(n, forms) + def to_currency(self, val, currency='NIS', cents=True, separator=' ו', + adjective=False): + result = super(Num2Word_HE, self).to_currency( + val, currency=currency, cents=cents, separator=separator, + adjective=adjective) + # In Hebrew the separator is along with the following word + return result.replace(" ו ", " ו") + if __name__ == '__main__': yo = Num2Word_HE()