Merge pull request #421 from Cris140/patch-1

To fix a problem in Brazilian Portuguese code referred to thousands when the hundreds are exact.
This commit is contained in:
Marlon Rodriguez Garcia
2022-08-19 11:16:43 -04:00
committed by GitHub

View File

@@ -53,6 +53,8 @@ class Num2Word_PT_BR(lang_PT.Num2Word_PT):
ctext = "cento" ctext = "cento"
if nnum < cnum: if nnum < cnum:
if cnum < 100:
return ("%s e %s" % (ctext, ntext), cnum + nnum)
return ("%s e %s" % (ctext, ntext), cnum + nnum) return ("%s e %s" % (ctext, ntext), cnum + nnum)
elif (not nnum % 1000000) and cnum > 1: elif (not nnum % 1000000) and cnum > 1:
@@ -75,7 +77,7 @@ class Num2Word_PT_BR(lang_PT.Num2Word_PT):
for ext in ( for ext in (
'mil', 'milhão', 'milhões', 'bilhão', 'bilhões', 'mil', 'milhão', 'milhões', 'bilhão', 'bilhões',
'trilhão', 'trilhões', 'quatrilhão', 'quatrilhõ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( result = result.replace(
'{} e'.format(ext), '{},'.format(ext), 1 '{} e'.format(ext), '{},'.format(ext), 1
) )