Skip to content

Commit

Permalink
Fallback count="other" format in format_currency()
Browse files Browse the repository at this point in the history
  • Loading branch information
jun66j5 authored and akx committed May 10, 2022
1 parent 3ae5402 commit b203c67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion babel/numbers.py
Expand Up @@ -127,7 +127,11 @@ def get_currency_name(currency, count=None, locale=LC_NUMERIC):
plural_form = loc.plural_form(count)
plural_names = loc._data['currency_names_plural']
if currency in plural_names:
return plural_names[currency][plural_form]
currency_plural_names = plural_names[currency]
if plural_form in currency_plural_names:
return currency_plural_names[plural_form]
if 'other' in currency_plural_names:
return currency_plural_names['other']
return loc.currencies.get(currency, currency)


Expand Down
6 changes: 6 additions & 0 deletions tests/test_numbers.py
Expand Up @@ -413,6 +413,12 @@ def test_format_currency():
assert (numbers.format_currency(1099.98, 'USD', format=None,
locale='en_US')
== u'$1,099.98')
assert (numbers.format_currency(1, 'USD', locale='es_AR')
== u'US$\xa01,00') # one
assert (numbers.format_currency(1000000, 'USD', locale='es_AR')
== u'US$\xa01.000.000,00') # many
assert (numbers.format_currency(0, 'USD', locale='es_AR')
== u'US$\xa00,00') # other


def test_format_currency_format_type():
Expand Down

0 comments on commit b203c67

Please sign in to comment.