From b6a3ec531bdfcb03358bcf2e6cbd7863b2ca5b78 Mon Sep 17 00:00:00 2001 From: Bryan Anderson Date: Thu, 16 Jan 2025 02:25:22 -0800 Subject: [PATCH] Portuguese: add more currencies and test cases --- num2words/lang_PT.py | 8 ++++++++ tests/test_pt.py | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/num2words/lang_PT.py b/num2words/lang_PT.py index ddfa7713..4fca810a 100644 --- a/num2words/lang_PT.py +++ b/num2words/lang_PT.py @@ -30,8 +30,16 @@ class Num2Word_PT(Num2Word_EU): CURRENCY_FORMS = { 'AUD': (DOLLAR, CENTS), 'CAD': (DOLLAR, CENTS), + 'NZD': (DOLLAR, CENTS), + 'HKD': (DOLLAR, CENTS), 'EUR': (('euro', 'euros'), CENTS), 'GBP': (('libra', 'libras'), ('péni', 'pence')), + 'CNY': (('yuan', 'yuans'), ('fen', 'fen')), + 'JPY': (('iene', 'ienes'), ('sen', 'sen')), + 'INR': (('rupia', 'rupias'), ('paisa', 'paisas')), + 'RUB': (('rublo', 'rublos'), ('copeque', 'copeques')), + 'KRW': (('won', 'wons'), ('jeon', 'jeons')), + 'MXN': (('peso', 'pesos'), ('centavo', 'centavos')), 'USD': (DOLLAR, CENTS), } diff --git a/tests/test_pt.py b/tests/test_pt.py index bc49d45d..5763d578 100644 --- a/tests/test_pt.py +++ b/tests/test_pt.py @@ -364,6 +364,26 @@ def test_currency_integer(self): 'um dólar') self.assertEqual(self.n2w.to_currency(1.50, currency='USD'), 'um dólar e cinquenta cêntimos') + self.assertEqual(self.n2w.to_currency(1.50, currency='CAD'), + 'um dólar e cinquenta cêntimos') + self.assertEqual(self.n2w.to_currency(1.50, currency='AUD'), + 'um dólar e cinquenta cêntimos') + self.assertEqual(self.n2w.to_currency(1.50, currency='NZD'), + 'um dólar e cinquenta cêntimos') + self.assertEqual(self.n2w.to_currency(1.50, currency='HKD'), + 'um dólar e cinquenta cêntimos') + self.assertEqual(self.n2w.to_currency(1.50, currency='CNY'), + 'um yuan e cinquenta fen') + self.assertEqual(self.n2w.to_currency(1.50, currency='JPY'), + 'um iene e cinquenta sen') + self.assertEqual(self.n2w.to_currency(1.50, currency='INR'), + 'um rupia e cinquenta paisas') + self.assertEqual(self.n2w.to_currency(1.50, currency='RUB'), + 'um rublo e cinquenta copeques') + self.assertEqual(self.n2w.to_currency(1.50, currency='KRW'), + 'um won e cinquenta jeons') + self.assertEqual(self.n2w.to_currency(1.50, currency='MXN'), + 'um peso e cinquenta centavos') with self.assertRaises(NotImplementedError): self.n2w.to_currency(1.00, currency='CHF')