From 4c7e9b645cfec72672f836e04d8587ca66ba98c3 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Thu, 7 Jun 2018 15:21:19 +0300 Subject: Simplify format_currency code by pulling out/using helpers. In detail: 1. Use the already existing get_currency_name function which does the plural form logic already. 2. Create a similar `get_currency_unit_pattern` function. This function could be useful if someone wanted to write something very similar to the _format_currency_long_name functionality but with some different customizations, so it is now publicly documented. 3. Simplify the _format_currency_long_name function - it is now much flatter. 4. Add more tests to ensure certain cases are really covered. (e.g. different unit patterns depending on the count) An upshot of the changes is that we have reduced (and made more consistent) the number of places where we need to peek into `Locale._data` - get_currency_name and get_currency_unit_pattern are the only places that babel.numbers does this. --- docs/api/numbers.rst | 2 ++ 1 file changed, 2 insertions(+) (limited to 'docs') diff --git a/docs/api/numbers.rst b/docs/api/numbers.rst index 1b21425..758ceba 100644 --- a/docs/api/numbers.rst +++ b/docs/api/numbers.rst @@ -38,6 +38,8 @@ Data Access .. autofunction:: get_currency_symbol +.. autofunction:: get_currency_unit_pattern + .. autofunction:: get_decimal_symbol .. autofunction:: get_plus_sign_symbol -- cgit v1.2.1