Skip to content

Commit b28fb08

Browse files
Merge pull request #421 from Cris140/patch-1
To fix a problem in Brazilian Portuguese code referred to thousands when the hundreds are exact.
2 parents 1fd633c + 5142fe8 commit b28fb08

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

num2words/lang_PT_BR.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def merge(self, curr, next):
5353
ctext = "cento"
5454

5555
if nnum < cnum:
56+
if cnum < 100:
57+
return ("%s e %s" % (ctext, ntext), cnum + nnum)
5658
return ("%s e %s" % (ctext, ntext), cnum + nnum)
5759

5860
elif (not nnum % 1000000) and cnum > 1:
@@ -75,7 +77,7 @@ def to_cardinal(self, value):
7577
for ext in (
7678
'mil', 'milhão', 'milhões', 'bilhão', 'bilhões',
7779
'trilhão', 'trilhões', 'quatrilhão', 'quatrilhões'):
78-
if re.match('.*{} e \\w*ento'.format(ext), result):
80+
if re.match('.*{} e \\w*entos? (?=.*e)'.format(ext), result):
7981
result = result.replace(
8082
'{} e'.format(ext), '{},'.format(ext), 1
8183
)

0 commit comments

Comments
 (0)