Skip to content

Commit

Permalink
Rename parcel to collection
Browse files Browse the repository at this point in the history
  • Loading branch information
vorlif committed May 18, 2022
1 parent cc53607 commit 43fb4f9
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gofmt:


lint:
go install github.com/golangci/golangci-lint/cmd/[email protected].1
go install github.com/golangci/golangci-lint/cmd/[email protected].2

@echo Running golangci-lint
golangci-lint run --fix ./...
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ import (

func main() {
// Load the translations for the desired languages
parcel := humanize.MustNew(
collection := humanize.MustNew(
humanize.WithLocale(es.New(), ar.New(), zhHans.New()),
)

// Create a humanizer.
// A humanizer features a collection of humanize functions for a language.
h := parcel.CreateHumanizer(language.English)
h := collection.CreateHumanizer(language.English)

// Uses the functions...
fmt.Println(h.Intword(1_000_000_000))
Expand All @@ -173,7 +173,7 @@ func main() {
// Output: 3 days, 8 hours

// ... for different languages
h = parcel.CreateHumanizer(language.Spanish)
h = collection.CreateHumanizer(language.Spanish)
fmt.Println(h.TimeSince(d))
// Output: 3 días, 8 horas
}
Expand Down
6 changes: 3 additions & 3 deletions humanize/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
//
// Usage
//
// Create a parcel with the languages you want to use.
// parcel := humanize.MustNew(
// Create a collection with the languages you want to use.
// collection := humanize.MustNew(
// humanize.WithLocale(es.New(), ar.New(), zhHans.New()),
// )
//
// Create a humanizer
// h := parcel.CreateHumanizer(language.Spanish)
// h := collection.CreateHumanizer(language.Spanish)
//
// Use it
// fmt.Println(h.Intword(1_000_000_000))
Expand Down
92 changes: 46 additions & 46 deletions humanize/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
)

func ExampleHumanizer_Apnumber() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.German, language.Spanish, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.Apnumber(5))
}
// Output:
Expand All @@ -32,10 +32,10 @@ func ExampleHumanizer_Apnumber() {
}

func ExampleHumanizer_Intword() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.Spanish, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.Intword(1_000_000_000))
}
// Output:
Expand All @@ -45,10 +45,10 @@ func ExampleHumanizer_Intword() {
}

func ExampleHumanizer_Intcomma() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.Spanish, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.Intcomma(1_000_000_000))
}
// Output:
Expand All @@ -58,10 +58,10 @@ func ExampleHumanizer_Intcomma() {
}

func ExampleHumanizer_Ordinal() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.Spanish, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.Ordinal(5))
}
// Output:
Expand All @@ -71,10 +71,10 @@ func ExampleHumanizer_Ordinal() {
}

func ExampleHumanizer_LanguageName() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.Spanish, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Printf("Examples in: %s, %s", h.LanguageName("English"), h.LanguageName("Spanish"))
fmt.Printf(" and %s\n", h.LanguageName("Simplified Chinese"))
}
Expand All @@ -85,18 +85,18 @@ func ExampleHumanizer_LanguageName() {
}

func ExampleHumanizer_NaturalDay() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), de.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.Spanish, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.NaturalDay(time.Now()))
}

fmt.Println("---")

d := time.Date(2022, 05, 01, 0, 0, 0, 0, time.UTC)
for _, tag := range []language.Tag{language.English, language.Spanish, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.NaturalDay(d))
}
// Output:
Expand All @@ -110,10 +110,10 @@ func ExampleHumanizer_NaturalDay() {
}

func ExampleHumanizer_NaturalTime() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), ar.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), ar.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.Arabic, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
t := time.Now().Add(5 * time.Minute)
fmt.Println(h.NaturalTime(t))
}
Expand All @@ -124,10 +124,10 @@ func ExampleHumanizer_NaturalTime() {
}

func ExampleHumanizer_NaturalTime_past() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), ar.New(), zhHans.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), ar.New(), zhHans.New()))

for _, tag := range []language.Tag{language.English, language.Arabic, language.SimplifiedChinese} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
t := time.Now().Add(-2*time.Hour - 30*time.Minute)
fmt.Println(h.NaturalTime(t))
}
Expand All @@ -138,11 +138,11 @@ func ExampleHumanizer_NaturalTime_past() {
}

func ExampleHumanizer_TimeSince() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))

t := time.Now().Add(-37 * time.Hour)
for _, tag := range []language.Tag{language.English, language.MustParse("be"), language.German} {
h := parcel.CreateHumanizer(tag)
t := time.Now().Add(-37 * time.Hour)
h := collection.CreateHumanizer(tag)
fmt.Println(h.TimeSince(t))
}
// Output:
Expand All @@ -152,11 +152,11 @@ func ExampleHumanizer_TimeSince() {
}

func ExampleHumanizer_TimeSince_duration() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))

t := -80 * time.Hour
for _, tag := range []language.Tag{language.English, language.MustParse("be"), language.German} {
h := parcel.CreateHumanizer(tag)
t := -80 * time.Hour
h := collection.CreateHumanizer(tag)
fmt.Println(h.TimeSince(t))
}
// Output:
Expand All @@ -166,11 +166,11 @@ func ExampleHumanizer_TimeSince_duration() {
}

func ExampleHumanizer_TimeUntil() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))

t := time.Now().Add(37 * time.Hour)
for _, tag := range []language.Tag{language.English, language.MustParse("be"), language.German} {
h := parcel.CreateHumanizer(tag)
t := time.Now().Add(37 * time.Hour)
h := collection.CreateHumanizer(tag)
fmt.Println(h.TimeUntil(t))
}
// Output:
Expand All @@ -180,11 +180,11 @@ func ExampleHumanizer_TimeUntil() {
}

func ExampleHumanizer_FormatTime() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))

now := time.Date(2022, 05, 15, 18, 0, 0, 0, time.Local)
for _, tag := range []language.Tag{language.English, language.MustParse("be"), language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.FormatTime(now, humanize.DateTimeFormat))
}
// Output:
Expand All @@ -194,11 +194,11 @@ func ExampleHumanizer_FormatTime() {
}

func ExampleHumanizer_FormatTime_shortDate() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))

now := time.Date(2022, 05, 15, 18, 0, 0, 0, time.Local)
for _, tag := range []language.Tag{language.English, language.SimplifiedChinese, language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.FormatTime(now, humanize.ShortDateFormat))
}
// Output:
Expand All @@ -208,11 +208,11 @@ func ExampleHumanizer_FormatTime_shortDate() {
}

func ExampleHumanizer_FormatTime_shortDateTime() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))

now := time.Date(2022, 05, 15, 18, 0, 0, 0, time.Local)
for _, tag := range []language.Tag{language.English, language.SimplifiedChinese, language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.FormatTime(now, humanize.ShortDatetimeFormat))
}
// Output:
Expand All @@ -222,10 +222,10 @@ func ExampleHumanizer_FormatTime_shortDateTime() {
}

func ExampleHumanizer_Date() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), it.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), it.New(), de.New()))

for _, tag := range []language.Tag{language.English, language.Italian, language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.Date())
}
// May 16, 2022
Expand All @@ -234,10 +234,10 @@ func ExampleHumanizer_Date() {
}

func ExampleHumanizer_Time() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), it.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), it.New(), de.New()))

for _, tag := range []language.Tag{language.English, language.Italian, language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.Time())
}
// 12:30 a.m.
Expand All @@ -246,10 +246,10 @@ func ExampleHumanizer_Time() {
}

func ExampleHumanizer_Now() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), it.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), it.New(), de.New()))

for _, tag := range []language.Tag{language.English, language.Italian, language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.Now())
}
// May 16, 2022, 12:34 a.m.
Expand All @@ -258,10 +258,10 @@ func ExampleHumanizer_Now() {
}

func ExampleHumanizer_FilesizeFormat() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))

for _, tag := range []language.Tag{language.English, language.SimplifiedChinese, language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.FilesizeFormat(make([]byte, 1000)))
fmt.Println(h.FilesizeFormat(math.Pow(1024, 3)))
}
Expand All @@ -275,11 +275,11 @@ func ExampleHumanizer_FilesizeFormat() {
}

func ExampleWithDepth() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), be.New(), de.New()))

t := -3080*time.Hour - 5*time.Minute
for _, tag := range []language.Tag{language.English, language.MustParse("be"), language.German} {
h := parcel.CreateHumanizer(tag)
t := -3080*time.Hour - 5*time.Minute
h := collection.CreateHumanizer(tag)
fmt.Println(h.TimeSince(t, humanize.WithDepth(1), humanize.WithoutAdjacentCheck()))
fmt.Println(h.TimeSince(t, humanize.WithoutAdjacentCheck())) // 2 is default
fmt.Println(h.TimeSince(t, humanize.WithDepth(3), humanize.WithoutAdjacentCheck()))
Expand Down Expand Up @@ -309,12 +309,12 @@ func ExampleWithDepth() {
}

func ExampleWithNow() {
parcel := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))
collection := humanize.MustNew(humanize.WithLocale(es.New(), zhHans.New(), de.New()))

event := time.Date(2000, 01, 01, 00, 0, 0, 0, time.Local)
now := time.Date(1999, 12, 24, 00, 0, 0, 0, time.Local)
event := time.Date(2000, 01, 01, 00, 0, 0, 0, time.Local)
for _, tag := range []language.Tag{language.English, language.SimplifiedChinese, language.German} {
h := parcel.CreateHumanizer(tag)
h := collection.CreateHumanizer(tag)
fmt.Println(h.TimeUntil(event, humanize.WithNow(now)))
}
// Output:
Expand Down
Loading

0 comments on commit 43fb4f9

Please sign in to comment.