Fix some humanize issues

Fixes #7912
This commit is contained in:
susiwen8
2021-02-15 01:30:59 +08:00
committed by GitHub
parent 5f621df257
commit bf55afd71f
6 changed files with 13 additions and 12 deletions

View File

@@ -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.

View File

@@ -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},