We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format_currency throws a KeyError for any multiple of 1000000 when using the "pt_BR" locale.
from babel.numbers import format_currency format_currency(1000000, "BRL", locale="pt_BR")
KeyError Traceback (most recent call last) Input In [44], in <cell line: 1>() ----> 1 formatted_value = format_currency(valor, "BRL", locale="pt_BR") File /usr/local/lib/python3.9/site-packages/babel/numbers.py:533, in format_currency(number, currency, format, locale, currency_digits, format_type, decimal_quantization, group_separator) 529 except KeyError: 530 raise UnknownCurrencyFormatError( 531 "%r is not a known currency format type" % format_type) --> 533 return pattern.apply( 534 number, locale, currency=currency, currency_digits=currency_digits, 535 decimal_quantization=decimal_quantization, group_separator=group_separator) File /usr/local/lib/python3.9/site-packages/babel/numbers.py:1028, in NumberPattern.apply(self, value, locale, currency, currency_digits, decimal_quantization, force_frac, group_separator) 1021 retval = ''.join([ 1022 self.prefix[is_negative], 1023 number, 1024 self.suffix[is_negative]]) 1026 if u'¤' in retval: 1027 retval = retval.replace(u'¤¤¤', -> 1028 get_currency_name(currency, value, locale)) 1029 retval = retval.replace(u'¤¤', currency.upper()) 1030 retval = retval.replace(u'¤', get_currency_symbol(currency, locale)) File /usr/local/lib/python3.9/site-packages/babel/numbers.py:130, in get_currency_name(currency, count, locale) 128 plural_names = loc._data['currency_names_plural'] 129 if currency in plural_names: --> 130 return plural_names[currency][plural_form] 131 return loc.currencies.get(currency, currency) File /usr/local/lib/python3.9/site-packages/babel/localedata.py:238, in LocaleDataDict.__getitem__(self, key) 237 def __getitem__(self, key): --> 238 orig = val = self._data[key] 239 if isinstance(val, Alias): # resolve an alias 240 val = val.resolve(self.base) KeyError: 'many'
'R$\xa01.000.010,00'
This works fine for other values such as: 100000, 999999 and 1000001. But fails for any other multiple of 1000000 (2000000, 3000000, 4000000, etc.)
The text was updated successfully, but these errors were encountered:
It seems to be same issue of #868 and fixed in #872. Could you please try the latest of master branch?
Sorry, something went wrong.
Should be fixed in 2.10.2 (just released). Thanks for the fixes, @jun66j5!
No branches or pull requests
Overview Description
format_currency throws a KeyError for any multiple of 1000000 when using the "pt_BR" locale.
Steps to Reproduce
Actual Results
Expected Results
'R$\xa01.000.010,00'
Additional Information
This works fine for other values such as: 100000, 999999 and 1000001. But fails for any other multiple of 1000000 (2000000, 3000000, 4000000, etc.)
The text was updated successfully, but these errors were encountered: