Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tpl/lang
diff options
context:
space:
mode:
authorPaul Gottschling <paul.gottschling@gmail.com>2021-09-02 03:26:42 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-09-22 21:00:30 +0300
commita864ffe9acf295034bb38e789a0efa62906b2ae4 (patch)
treee212c4ea1e860629559bcd129cc6ffe7c4718eea /tpl/lang
parentb49da33280cb01795ce833e70c2b7b78cca1867e (diff)
Clarify "precision" in currency format functions
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
Diffstat (limited to 'tpl/lang')
-rw-r--r--tpl/lang/lang.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/tpl/lang/lang.go b/tpl/lang/lang.go
index 0e170e041..3fb321e1a 100644
--- a/tpl/lang/lang.go
+++ b/tpl/lang/lang.go
@@ -80,8 +80,10 @@ func (ns *Namespace) FormatPercent(precision, number interface{}) (string, error
return ns.translator.FmtPercent(n, p), nil
}
-// FormatCurrency returns the currency reprecentation of number for the given currency and precision
+// FormatCurrency returns the currency representation of number for the given currency and precision
// for the current language.
+//
+// The return value is formatted with at least two decimal places.
func (ns *Namespace) FormatCurrency(precision, currency, number interface{}) (string, error) {
p, n, err := ns.castPrecisionNumber(precision, number)
if err != nil {
@@ -94,8 +96,10 @@ func (ns *Namespace) FormatCurrency(precision, currency, number interface{}) (st
return ns.translator.FmtCurrency(n, p, c), nil
}
-// FormatAccounting returns the currency reprecentation of number for the given currency and precision
+// FormatAccounting returns the currency representation of number for the given currency and precision
// for the current language in accounting notation.
+//
+// The return value is formatted with at least two decimal places.
func (ns *Namespace) FormatAccounting(precision, currency, number interface{}) (string, error) {
p, n, err := ns.castPrecisionNumber(precision, number)
if err != nil {