From fe0d1850592f208dd1b3c369bffcccd98f31b53e Mon Sep 17 00:00:00 2001 From: Cris140 <60457418+Cris140@users.noreply.github.com> Date: Fri, 29 Oct 2021 22:42:10 -0400 Subject: [PATCH] Update lang_PT_BR.py To fix a problem with the thousands when the hundreds are exacts. --- num2words/lang_PT_BR.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/num2words/lang_PT_BR.py b/num2words/lang_PT_BR.py index 80eb5e7..2c50f03 100644 --- a/num2words/lang_PT_BR.py +++ b/num2words/lang_PT_BR.py @@ -53,6 +53,8 @@ class Num2Word_PT_BR(lang_PT.Num2Word_PT): ctext = "cento" if nnum < cnum: + if cnum < 100: + return ("%s e %s" % (ctext, ntext), cnum + nnum) return ("%s e %s" % (ctext, ntext), cnum + nnum) elif (not nnum % 1000000) and cnum > 1: @@ -75,7 +77,7 @@ class Num2Word_PT_BR(lang_PT.Num2Word_PT): for ext in ( 'mil', 'milhão', 'milhões', 'bilhão', 'bilhões', 'trilhão', 'trilhões', 'quatrilhão', 'quatrilhões'): - if re.match('.*{} e \\w*ento'.format(ext), result): + if re.match('.*{} e \\w*entos? (?=.*e)'.format(ext), result): result = result.replace( '{} e'.format(ext), '{},'.format(ext), 1 )