jaraco / inflect

Correctly generate plurals, ordinals, indefinite articles; convert numbers to words
https://pypi.org/project/inflect
MIT License
957 stars 107 forks source link

Feature: currency mode #213

Open m-aciek opened 2 months ago

m-aciek commented 2 months ago

Hello @jaraco, would you accept a currency mode as an contribution, in scope for this library?

Possible API:

>>> from inflect import engine
>>> engine().number_to_words(100_020.56, decimal="and", decimal_format="currency")
'one hundred thousand and twenty and 56/100'
jaraco commented 2 months ago

That seems reasonable and perfectly in scope.

Could you write a short description of what benefit this feature would add (where would you use the feature)? Does this feature apply only to US currency or is this syntax used in other currencies?

The proposed API seems suitable, if a bit roundabout. Thinking about the user's ergonomics, should we consider a separate method (e.g. number_to_currency)?

m-aciek commented 2 months ago

Could you write a short description of what benefit this feature would add (where would you use the feature)?

I would use it in documents that need that format as an output for currency.

Does this feature apply only to US currency or is this syntax used in other currencies?

I'm not familiar with the standards in many countries. I know that such format is used in US, Canada and in Poland (in documents and for postal money orders).

The proposed API seems suitable, if a bit roundabout. Thinking about the user's ergonomics, should we consider a separate method (e.g. number_to_currency)?

I don't have a strong opinion on it. Separate method could be ergonomic indeed. cc @szymon-borkowski ?

jaraco commented 2 months ago

Sounds good. Feel free to proceed with a PR.