gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
73.52k stars 7.38k forks source link

tpl/inflect: Add the SI function to format numbers with SI notation #12563

Closed razonyang closed 3 weeks ago

razonyang commented 4 weeks ago

https://en.wikipedia.org/wiki/Metric_prefix

One of use case of mine: a repository card.

image

Not sure if I put this function into the right place/package.

jmooring commented 3 weeks ago

How would I use this with the lang.FormatSomething functions? Each of these functions returns a string. I imagine in some locales you might want 12,3 kb instead of 12.3 kb.

Maybe this should be lang.FormatNumberSI, and possibly create derivatives of lang.FormatNumberCustom and lang.FormatCurrency as well.

I suggest closing this PR and opening a proposal to work out the details.

razonyang commented 3 weeks ago

I imagine in some locales you might want 12,3 kb instead of 12.3 kb.

Haven't thought about this.

Done, create a topic on forum, which might be visible to much more developers.

Close PR for now.