mirror of
https://github.com/bblaz/num2words.git
synced 2025-12-06 06:42:25 +00:00
Add translations to spanish of several currencies
This commit is contained in:
committed by
Willem Van Onsem
parent
3e494d71a0
commit
402b1e88e7
@@ -21,13 +21,190 @@ import math
|
||||
|
||||
from .lang_EU import Num2Word_EU
|
||||
|
||||
GENERIC_DOLLARS = ('dolar', 'dólares')
|
||||
GENERIC_CENTS = ('centavo', 'centavos')
|
||||
CURRENCIES_UNA = ('SLL', 'SEK', 'NOK', 'CZK', 'DKK', 'ISK',
|
||||
'SKK', 'GBP', 'CYP', 'EGP', 'FKP', 'GIP',
|
||||
'LBP', 'SDG', 'SHP', 'SSP', 'SYP', 'INR',
|
||||
'IDR', 'LKR', 'MUR', 'NPR', 'PKR', 'SCR',
|
||||
'ESP')
|
||||
|
||||
|
||||
class Num2Word_ES(Num2Word_EU):
|
||||
CURRENCY_FORMS = {
|
||||
'EUR': (('euro', 'euros'), ('céntimo', 'céntimos')),
|
||||
'ESP': (('peseta', 'pesetas'), ('céntimo', 'céntimos')),
|
||||
'USD': (('dolar', 'dólares'), ('centavo', 'centavos')),
|
||||
'USD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'PEN': (('sol', 'soles'), ('céntimo', 'céntimos')),
|
||||
'CRC': (('colón', 'colones'), GENERIC_CENTS),
|
||||
'AUD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'CAD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'GBP': (('libra', 'libras'), ('penny', 'pence')),
|
||||
'RUB': (('rublo', 'rublos'), ('kopeyka', 'kopeykas')),
|
||||
'SEK': (('corona', 'coronas'), ('öre', 'öre')),
|
||||
'NOK': (('corona', 'coronas'), ('øre', 'øre')),
|
||||
'PLN': (('zloty', 'zlotys'), ('grosz', 'groszy')),
|
||||
'MXN': (('peso', 'pesos'), GENERIC_CENTS),
|
||||
'RON': (('leu', 'leus'), ('ban', 'bani')),
|
||||
'INR': (('rupia', 'rupias'), ('paisa', 'paisas')),
|
||||
'HUF': (('florín', 'florines'), ('fillér', 'fillér')),
|
||||
'FRF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'CNY': (('yuan', 'yuanes'), ('fen', 'jiaos')),
|
||||
'CZK': (('corona', 'coronas'), ('haléř', 'haléř')),
|
||||
'NIO': (('córdoba', 'córdobas'), GENERIC_CENTS),
|
||||
'VES': (('bolívar', 'bolívares'), ('céntimo', 'céntimos')),
|
||||
'BRL': (('real', 'reales'), GENERIC_CENTS),
|
||||
'CHF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'JPY': (('yen', 'yenes'), ('sen', 'sen')),
|
||||
'KRW': (('won', 'wones'), ('jeon', 'jeon')),
|
||||
'KPW': (('won', 'wones'), ('chon', 'chon')),
|
||||
'TRY': (('lira', 'liras'), ('kuruş', 'kuruş')),
|
||||
'ZAR': (('rand', 'rands'), ('céntimo', 'céntimos')),
|
||||
'KZT': (('tenge', 'tenges'), ('tïın', 'tïın')),
|
||||
'UAH': (('hryvnia', 'hryvnias'), ('kopiyka', 'kopiykas')),
|
||||
'THB': (('baht', 'bahts'), ('satang', 'satang')),
|
||||
'AED': (('dirham', 'dirhams'), ('fils', 'fils')),
|
||||
'AFN': (('afghani', 'afghanis'), ('pul', 'puls')),
|
||||
'ALL': (('lek ', 'leke'), ('qindarkë', 'qindarka')),
|
||||
'AMD': (('dram', 'drams'), ('luma', 'lumas')),
|
||||
'ANG': (('florín', 'florines'), GENERIC_CENTS),
|
||||
'AOA': (('kwanza', 'kwanzas'), ('céntimo', 'céntimos')),
|
||||
'ARS': (('peso', 'pesos'), GENERIC_CENTS),
|
||||
'AWG': (('florín', 'florines'), GENERIC_CENTS),
|
||||
'AZN': (('manat', 'manat'), ('qəpik', 'qəpik')),
|
||||
'BBD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'BDT': (('taka', 'takas'), ('paisa', 'paisas')),
|
||||
'BGN': (('lev', 'leva'), ('stotinka', 'stotinki')),
|
||||
'BHD': (('dinar', 'dinares'), ('fils', 'fils')),
|
||||
'BIF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'BMD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'BND': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'BOB': (('boliviano', 'bolivianos'), GENERIC_CENTS),
|
||||
'BSD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'BTN': (('ngultrum', 'ngultrum'), ('chetrum', 'chetrum')),
|
||||
'BWP': (('pula', 'pulas'), ('thebe', 'thebes')),
|
||||
'BYN': (('rublo', 'rublos'), ('kópek', 'kópeks')),
|
||||
'BYR': (('rublo', 'rublos'), ('kópek', 'kópeks')),
|
||||
'BZD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'CDF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'CLP': (('peso', 'pesos'), GENERIC_CENTS),
|
||||
'COP': (('peso', 'pesos'), GENERIC_CENTS),
|
||||
'CUP': (('peso', 'pesos'), GENERIC_CENTS),
|
||||
'CVE': (('escudo', 'escudos'), GENERIC_CENTS),
|
||||
'CYP': (('libra', 'libras'), ('céntimo', 'céntimos')),
|
||||
'DJF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'DKK': (('corona', 'coronas'), ('øre', 'øre')),
|
||||
'DOP': (('peso', 'pesos'), GENERIC_CENTS),
|
||||
'DZD': (('dinar', 'dinares'), ('céntimo', 'céntimos')),
|
||||
'ECS': (('sucre', 'sucres'), GENERIC_CENTS),
|
||||
'EGP': (('libra', 'libras'), ('piastra', 'piastras')),
|
||||
'ERN': (('nakfa', 'nakfas'), ('céntimo', 'céntimos')),
|
||||
'ETB': (('birr', 'birrs'), ('céntimo', 'céntimos')),
|
||||
'FJD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'FKP': (('libra', 'libras'), ('penny', 'peniques')),
|
||||
'GEL': (('lari', 'laris'), ('tetri', 'tetris')),
|
||||
'GHS': (('cedi', 'cedis'), ('pesewa', 'pesewas')),
|
||||
'GIP': (('libra', 'libras'), ('penique', 'peniques')),
|
||||
'GMD': (('dalasi', 'dalasis'), ('butut', 'bututs')),
|
||||
'GNF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'GTQ': (('quetzal', 'quetzales'), GENERIC_CENTS),
|
||||
'GYD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'HKD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'HNL': (('lempira', 'lempiras'), GENERIC_CENTS),
|
||||
'HRK': (('kuna', 'kunas'), ('lipa', 'lipas')),
|
||||
'HTG': (('gourde', 'gourdes'), ('céntimo', 'céntimos')),
|
||||
'IDR': (('rupia', 'rupias'), ('céntimo', 'céntimos')),
|
||||
'ILS': (('séquel', 'séqueles'), ('agora', 'agoras')),
|
||||
'IQD': (('dinar', 'dinares'), ('fils', 'fils')),
|
||||
'IRR': (('rial', 'riales'), ('dinar', 'dinares')),
|
||||
'ISK': (('corona', 'coronas'), ('eyrir', 'aurar')),
|
||||
'ITL': (('lira', 'liras'), ('céntimo', 'céntimos')),
|
||||
'JMD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'JOD': (('dinar', 'dinares'), ('piastra', 'piastras')),
|
||||
'KES': (('chelín', 'chelines'), ('céntimo', 'céntimos')),
|
||||
'KGS': (('som', 'som'), ('tyiyn', 'tyiyn')),
|
||||
'KHR': (('riel', 'rieles'), ('céntimo', 'céntimos')),
|
||||
'KMF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'KWD': (('dinar', 'dinares'), ('fils', 'fils')),
|
||||
'KYD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'LAK': (('kip', 'kips'), ('att', 'att')),
|
||||
'LBP': (('libra', 'libras'), ('piastra', 'piastras')),
|
||||
'LKR': (('rupia', 'rupias'), ('céntimo', 'céntimos')),
|
||||
'LRD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'LSL': (('loti', 'lotis'), ('céntimo', 'céntimos')),
|
||||
'LTL': (('lita', 'litas'), ('céntimo', 'céntimos')),
|
||||
'LVL': (('lat', 'lats'), ('céntimo', 'céntimos')),
|
||||
'LYD': (('dinar', 'dinares'), ('dírham', 'dírhams')),
|
||||
'MAD': (('dírham', 'dirhams'), ('céntimo', 'céntimos')),
|
||||
'MDL': (('leu', 'lei'), ('ban', 'bani')),
|
||||
'MGA': (('ariary', 'ariaris'), ('iraimbilanja', 'iraimbilanja')),
|
||||
'MKD': (('denar', 'denares'), ('deni', 'denis')),
|
||||
'MMK': (('kiat', 'kiats'), ('pya', 'pyas')),
|
||||
'MNT': (('tugrik', 'tugriks'), ('möngö', 'möngö')),
|
||||
'MOP': (('pataca', 'patacas'), ('avo', 'avos')),
|
||||
'MRO': (('ouguiya', 'ouguiyas'), ('khoums', 'khoums')),
|
||||
'MRU': (('ouguiya', 'ouguiyas'), ('khoums', 'khoums')),
|
||||
'MUR': (('rupia', 'rupias'), ('céntimo', 'céntimos')),
|
||||
'MVR': (('rufiyaa', 'rufiyaas'), ('laari', 'laari')),
|
||||
'MWK': (('kuacha', 'kuachas'), ('tambala', 'tambalas')),
|
||||
'MYR': (('ringgit', 'ringgit'), ('céntimo', 'céntimos')),
|
||||
'MZN': (('metical', 'metical'), GENERIC_CENTS),
|
||||
'NAD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'NGN': (('naira', 'nairas'), ('kobo', 'kobo')),
|
||||
'NPR': (('rupia', 'rupias'), ('paisa', 'paisas')),
|
||||
'NZD': (GENERIC_DOLLARS, GENERIC_CENTS),
|
||||
'OMR': (('rial', 'riales'), ('baisa', 'baisa')),
|
||||
'PAB': (('balboa', 'balboas'), ('centésimo', 'centésimos')),
|
||||
'PGK': (('kina', 'kinas'), ('toea', 'toea')),
|
||||
'PHP': (('peso', 'pesos'), GENERIC_CENTS),
|
||||
'PKR': (('rupia', 'rupias'), ('paisa', 'paisas')),
|
||||
'PLZ': (('zloty', 'zlotys'), ('grosz', 'groszy')),
|
||||
'PYG': (('guaraní', 'guaranís'), ('céntimo', 'céntimos')),
|
||||
'QAR': (('rial', 'riales'), ('dírham', 'dírhams')),
|
||||
'QTQ': (('quetzal', 'quetzales'), GENERIC_CENTS),
|
||||
'RSD': (('dinar', 'dinares'), ('para', 'para')),
|
||||
'RUR': (('rublo', 'rublos'), ('kopek', 'kopeks')),
|
||||
'RWF': (('franco', 'francos'), ('céntimo', 'céntimos')),
|
||||
'SAR': (('riyal', 'riales'), ('halala', 'halalas')),
|
||||
'SBD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'SCR': (('rupia', 'rupias'), ('céntimo', 'céntimos')),
|
||||
'SDG': (('libra', 'libras'), ('piastra', 'piastras')),
|
||||
'SGD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'SHP': (('libra', 'libras'), ('penny', 'peniques')),
|
||||
'SKK': (('corona', 'coronas'), ('halier', 'haliers')),
|
||||
'SLL': (('leona', 'leonas'), ('céntimo', 'céntimos')),
|
||||
'SRD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'SSP': (('libra', 'libras'), ('piastra', 'piastras')),
|
||||
'STD': (('dobra', 'dobras'), ('céntimo', 'céntimos')),
|
||||
'SVC': (('colón', 'colones'), GENERIC_CENTS),
|
||||
'SYP': (('libra', 'libras'), ('piastra', 'piastras')),
|
||||
'SZL': (('lilangeni', 'emalangeni'), ('céntimo', 'céntimos')),
|
||||
'TJS': (('somoni', 'somonis'), ('dirame', 'dirames')),
|
||||
'TMT': (('manat', 'manat'), ('tenge', 'tenge')),
|
||||
'TND': (('dinar', 'dinares'), ('milésimo', 'milésimos')),
|
||||
'TOP': (('paanga', 'paangas'), ('céntimo', 'céntimos')),
|
||||
'TTD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'TWD': (('nuevo dólar', 'nuevos dolares'), ('céntimo', 'céntimos')),
|
||||
'TZS': (('chelín', 'chelines'), ('céntimo', 'céntimos')),
|
||||
'UAG': (('hryvnia', 'hryvnias'), ('kopiyka', 'kopiykas')),
|
||||
'UGX': (('chelín', 'chelines'), ('céntimo', 'céntimos')),
|
||||
'UYU': (('peso', 'pesos'), ('centésimo', 'centésimos')),
|
||||
'UZS': (('sum', 'sum'), ('tiyin', 'tiyin')),
|
||||
'VEF': (('bolívar fuerte', 'bolívares fuertes'),
|
||||
('céntimo', 'céntimos')),
|
||||
'VND': (('dong', 'dongs'), ('xu', 'xu')),
|
||||
'VUV': (('vatu', 'vatu'), ('nenhum', 'nenhum')),
|
||||
'WST': (('tala', 'tala'), GENERIC_CENTS),
|
||||
'XAF': (('franco CFA', 'francos CFA'), ('céntimo', 'céntimos')),
|
||||
'XCD': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'XOF': (('franco CFA', 'francos CFA'), ('céntimo', 'céntimos')),
|
||||
'XPF': (('franco CFP', 'francos CFP'), ('céntimo', 'céntimos')),
|
||||
'YER': (('rial', 'riales'), ('fils', 'fils')),
|
||||
'YUM': (('dinar', 'dinares'), ('para', 'para')),
|
||||
'ZMW': (('kwacha', 'kwachas'), ('ngwee', 'ngwee')),
|
||||
'ZRZ': (('zaire', 'zaires'), ('likuta', 'makuta')),
|
||||
'ZWL': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
'ZWL': (GENERIC_DOLLARS, ('céntimo', 'céntimos')),
|
||||
}
|
||||
|
||||
# //CHECK: Is this sufficient??
|
||||
@@ -176,4 +353,14 @@ class Num2Word_ES(Num2Word_EU):
|
||||
val, currency=currency, cents=cents, separator=separator,
|
||||
adjective=adjective)
|
||||
# Handle exception, in spanish is "un euro" and not "uno euro"
|
||||
return result.replace("uno", "un")
|
||||
# except in this currencies: leona, corona,
|
||||
# libra, rupia, lempira, peseta, is 'una'
|
||||
# but only when it's first word, otherwise
|
||||
# it's replaced in others words like 'veintiun'
|
||||
if currency in CURRENCIES_UNA:
|
||||
list_result = result.split(" ")
|
||||
if list_result[0] == "uno":
|
||||
list_result[0] = list_result[0].replace("uno", "una")
|
||||
result = " ".join(list_result)
|
||||
result = result.replace("uno", "un")
|
||||
return result
|
||||
|
||||
2826
tests/test_es.py
2826
tests/test_es.py
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user