-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lang.FormatCurrency & lang.FormatAccounting do not allow PRECISION < 2 #8858
Comments
I'm attempting to reproduce the issue via unit tests in my feature branch (see the diff here). I've reproduced the issue with
I'm working on reproducing this via Hugo template (see my unit test in language_test.go), though I'm still getting acquainted with the repo and haven't managed to get the site to build in the test. |
Reproduced this in a unit test that builds the site with the template provided in the issue description (https://github.com/ptgott/hugo/blob/97d12f274272b3fb6824a14cef2f8e0449b05569/hugolib/language_test.go#L141):
|
@divinerites It looks like @bep should this behavior be documented? |
Most currencies have two minor units, but per ISO 4217 there are 17 currencies with zero minor units: BIF, CLP, DJF, GNF, ISK, JPY, KMF, KRW, PYG, RWF, UGX, UYI, VND, VUV, XAF, XOF, XPF. The go-playground/locales module, from which gohugoio/locales was forked, has no provision for minor unit determination. The minimum number of minor units is always two. For example: https://github.com/go-playground/locales/blob/master/en/en.go#L334-L343 There are two reasons for displaying zero minor units:
I cannot think of a valid reason to display one minor unit, but there could be. |
This is exactly my use case. But I can understand why it is technically like this now, and I'll keep my old code for those use cases. |
The documentation of the FormatAccounting and FormatCurrency functions could be clearer in terms of how the precision param works. This commit makes it more explicit that adding a precision of < 2 will not format the return values to include fewer decimals. Resolves gohugoio#8858
The documentation of the FormatAccounting and FormatCurrency functions could be clearer in terms of how the precision param works. This commit makes it more explicit that adding a precision of < 2 will not format the return values to include fewer decimals. Resolves gohugoio#8858
The documentation of the FormatAccounting and FormatCurrency functions could be clearer in terms of how the precision param works. This commit makes it more explicit that adding a precision of < 2 will not format the return values to include fewer decimals. Resolves gohugoio#8858
The documentation of the FormatAccounting and FormatCurrency functions could be clearer in terms of how the precision param works. This commit makes it more explicit that adding a precision of < 2 will not format the return values to include fewer decimals. Resolves gohugoio#8858
The documentation of the FormatAccounting and FormatCurrency functions could be clearer in terms of how the precision param works. This commit makes it more explicit that adding a precision of < 2 will not format the return values to include fewer decimals. Resolves #8858
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
yes.
Not sure if it is related to the "Add new localized versions of lang.FormatNumber etc." from v0.87.0, or if it is intended (not on doc) but I can't get PRECISION = 0 or 1 for
lang.FormatCurrency
&lang.FormatAccounting
produce
The text was updated successfully, but these errors were encountered: