Adds commas to number formatting in english.Plural.
diff --git a/english/words.go b/english/words.go
index 26e9918..68c4948 100644
--- a/english/words.go
+++ b/english/words.go
@@ -4,6 +4,8 @@
import (
"fmt"
"strings"
+
+ humanize "github.com/dustin/go-humanize"
)
// These are included because they are common technical terms.
@@ -61,7 +63,7 @@
// The simple English rules of regular pluralization will be used
// if the plural form is an empty string (i.e. not explicitly given).
func Plural(quantity int, singular, plural string) string {
- return fmt.Sprintf("%d %s", quantity, PluralWord(quantity, singular, plural))
+ return fmt.Sprintf("%s %s", humanize.Comma(int64(quantity)), PluralWord(quantity, singular, plural))
}
// WordSeries converts a list of words into a word series in English.
diff --git a/english/words_test.go b/english/words_test.go
index 3c1d7be..61db7b3 100644
--- a/english/words_test.go
+++ b/english/words_test.go
@@ -47,6 +47,7 @@
}{
{1, "object", "", "1 object"},
{42, "object", "", "42 objects"},
+ {1234567, "object", "", "1,234,567 objects"},
}
for _, tt := range tests {
if got := Plural(tt.n, tt.singular, tt.plural); got != tt.want {