summaryrefslogtreecommitdiffstats
path: root/tpl/inflect
diff options
context:
space:
mode:
authorsusiwen8 <susiwen8@gmail.com>2021-02-15 01:30:59 +0800
committerGitHub <noreply@github.com>2021-02-14 18:30:59 +0100
commitbf55afd71f2fdb47272ebf1188c9cc87df47b233 (patch)
tree3509fcb64abe26736fb954f5b485dfbb411505e8 /tpl/inflect
parent5f621df2570236a08cd21e8dd1c60502ec3db328 (diff)
Fix some humanize issues
Fixes #7912
Diffstat (limited to 'tpl/inflect')
-rw-r--r--tpl/inflect/inflect.go6
-rw-r--r--tpl/inflect/inflect_test.go2
2 files changed, 6 insertions, 2 deletions
diff --git a/tpl/inflect/inflect.go b/tpl/inflect/inflect.go
index 187f360d6..787e2c53b 100644
--- a/tpl/inflect/inflect.go
+++ b/tpl/inflect/inflect.go
@@ -16,8 +16,9 @@ package inflect
import (
"strconv"
+ "strings"
- _inflect "github.com/markbates/inflect"
+ _inflect "github.com/gobuffalo/flect"
"github.com/spf13/cast"
)
@@ -53,7 +54,8 @@ func (ns *Namespace) Humanize(in interface{}) (string, error) {
return _inflect.Ordinalize(word), nil
}
- return _inflect.Humanize(word), nil
+ str := _inflect.Humanize(word)
+ return _inflect.Humanize(strings.ToLower(str)), nil
}
// Pluralize returns the plural form of a single word.
diff --git a/tpl/inflect/inflect_test.go b/tpl/inflect/inflect_test.go
index 609d4a470..7e2839a8a 100644
--- a/tpl/inflect/inflect_test.go
+++ b/tpl/inflect/inflect_test.go
@@ -26,6 +26,8 @@ func TestInflect(t *testing.T) {
{ns.Humanize, int64(92), "92nd"},
{ns.Humanize, "5.5", "5.5"},
{ns.Humanize, t, false},
+ {ns.Humanize, "this is a TEST", "This is a test"},
+ {ns.Humanize, "my-first-Post", "My first post"},
{ns.Pluralize, "cat", "cats"},
{ns.Pluralize, "", ""},
{ns.Pluralize, t, false},