go-i18next is a port of i18next in Go.
$ go get -u https://github.com/craftheon/go-18next
import "github.com/craftheon/go-18next"
var i18n i18next.I18n
func main() {
i18n = i18next.Init(i18next.I18nOptions{
Lng: []string{"en", "cn"},
DefaultLng: "en",
Ns: "json",
Backend: i18next.Backend{
LoadPath: []string{"./examples/datas/{{.Ns}}/{{.Lng}}/home.json"},
},
})
text, err := i18n.T("title", struct {
Name string
}{Name: "Mike"})
fmt.Println(val) // Hello, Mike
}
go-i18next is available under the MIT license. See the LICENSE file for more info.