humanize icon indicating copy to clipboard operation
humanize copied to clipboard

How to set thousands and decimal separators to `intword`?

Open aborruso opened this issue 2 years ago • 5 comments

What did you do?

Hi, in Italian the thousands separator is , (comma )and the decimal one is . (dot).

If I activate Italian - _t = humanize.i18n.activate("Italian") - and run humanize.intword(1234559), I get 1.2 milioni and not 1,2 milioni. And If I run humanize.thousands_separator() I have ,.

What did you expect to happen?

To have Italian separators, i.e. have them inverted.

What actually happened?

I wrote it above

What versions are you using?

  • OS: Debian 11
  • Python: 3.9.2
  • Humanize: 4.5.0

Thank you

aborruso avatar Jan 31 '23 07:01 aborruso

Hi, we need three things.

First, use the language code "it_IT" rather than "Italian": humanize.i18n.activate("it_IT")

Second, for humanize.thousands_separator() and humanize.decimal_separator(), we need to add it_IT into:

https://github.com/python-humanize/humanize/blob/1feba83f1c0a64d63c15c52bdad75dfd064e8df8/src/humanize/i18n.py#L16-L27

Finally, intword doesn't yet use thousands_separator and decimal_separator. We should add support, perhaps similar to how intcomma does it: https://github.com/python-humanize/humanize/pull/53.

hugovk avatar Feb 04 '23 13:02 hugovk

Second, for humanize.thousands_separator() and humanize.decimal_separator(), we need to add it_IT into:

Done https://github.com/python-humanize/humanize/pull/98

aborruso avatar Feb 04 '23 13:02 aborruso

Finally, intword doesn't yet use thousands_separator and decimal_separator. We should add support, perhaps similar to how intcomma does it: #53.

I'm not able to open a PR about it :(

aborruso avatar Feb 04 '23 13:02 aborruso

No problem, I'll have a look when I gave time, unless someone else would like to check it :) And thanks for the other PRs.

hugovk avatar Feb 04 '23 14:02 hugovk

No problem, I'll have a look when I gave time, unless someone else would like to check it :) And thanks for the other PRs.

This is a great project, thank you very much

aborruso avatar Feb 04 '23 14:02 aborruso