Change implementation of to_currency() in es_ES (#167)

* Change implementation of to_currency()
* Change OLD to ESP and add USD
This commit is contained in:
Abraham Anes
2018-04-18 15:05:13 +02:00
committed by Ernesto Rodriguez Ortiz
parent 551a980e54
commit b492530cfa
2 changed files with 49 additions and 24 deletions

View File

@@ -22,6 +22,12 @@ from .lang_EU import Num2Word_EU
class Num2Word_ES(Num2Word_EU):
CURRENCY_FORMS = {
'EUR': (('euro', 'euros'), ('centimo', 'centimos')),
'ESP': (('peseta', 'pesetas'), ('centimo', 'centimos')),
'USD': (('dolar', 'dolares'), ('centavo', 'centavos')),
}
# //CHECK: Is this sufficient??
def set_high_numwords(self, high):
max = 3 + 6 * len(high)
@@ -165,11 +171,10 @@ class Num2Word_ES(Num2Word_EU):
self.verify_ordinal(value)
return "%s%s" % (value, "º" if self.gender_stem == 'o' else "ª")
def to_currency(self, val, longval=True, old=False):
hightxt, lowtxt = "euro/s", "centavo/s"
if old:
hightxt, lowtxt = "peso/s", "peseta/s"
result = self.to_splitnum(val, hightxt=hightxt, lowtxt=lowtxt,
divisor=1, jointxt="y", longval=longval)
def to_currency(self, val, currency='EUR', cents=True, seperator=' con',
adjective=False):
result = super(Num2Word_ES, self).to_currency(
val, currency=currency, cents=cents, seperator=seperator,
adjective=adjective)
# Handle exception, in spanish is "un euro" and not "uno euro"
return result.replace("uno", "un")