Go-carbon v1.3.2 is released, adding some methods for i18n

go-carbon is a simple,semantic and developer-friendly golang package for datetime

github:github.com/golang-module/carbon

Set locale
// Way one(recommend)
c := carbon.Now().AddHours(1).SetLocale("zh-CN") 
if c.Error != nil {
    // Error handle...
    fmt.Println(c.Error)
}
c.DiffForHumans() // 1 小时后

// Way two
lang := NewLanguage()
if err := lang.SetLocale("zh-CN");err != nil {
    // Error handle...
    fmt.Println(err)
}
carbon.Now().AddHours(1).SetLanguage(lang).DiffForHumans() // 1 小时后
Set dir
lang := NewLanguage()
if err := lang.SetDir("lang");err != nil {
    // Error handle...
    fmt.Println(err)
}
carbon.Now().AddHours(1).SetLanguage(lang).DiffForHumans() // 1 小时后
Set some resources(the rest still translate from the specific locale)
lang := NewLanguage()

if err := lang.SetLocale("en");err != nil {
    // Error handle...
    fmt.Println(err)
}

resources := map[string]string{
    "hour":"%dh",
}
lang.SetResources(resources)

carbon.Now().AddYears(1).SetLanguage(lang).DiffForHumans() // 1 year from now
carbon.Now().AddHours(1).SetLanguage(lang).DiffForHumans() // 1h from now
Set all resources
lang := NewLanguage()
resources := map[string]string{
"year":"1 yr|%d yrs",
"month":"1 mo|%d mos",
"week":"%dw",
"day":"%dd",
"hour":"%dh",
"minute":"%dm",
"second":"%ds",
"now": "just now",
"ago":"%s ago",
"from_now":"in %s",
"before":"%s before",
"after":"%s after",
}
lang.SetResources(resources)

carbon.Now().AddYears(1).SetLanguage(lang).DiffForHumans() // in 1 yr
carbon.Now().AddHours(1).SetLanguage(lang).DiffForHumans() // in 1h