diff options
author | Luke Plant <L.Plant.98@cantab.net> | 2018-06-07 15:21:19 +0300 |
---|---|---|
committer | Luke Plant <L.Plant.98@cantab.net> | 2018-06-07 15:37:27 +0300 |
commit | 4c7e9b645cfec72672f836e04d8587ca66ba98c3 (patch) | |
tree | 7be9d2495b8fc3799643299c0adcd070bca90a9e /docs | |
parent | 4b5097f6064dda281ce7a1c5ef74e047cfdc558c (diff) | |
download | babel-4c7e9b645cfec72672f836e04d8587ca66ba98c3.tar.gz |
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.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/api/numbers.rst | 2 |
1 files changed, 2 insertions, 0 deletions
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 |