Skip to content

gavinleige/go-i18next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-i18next

go-i18next is a port of i18next in Go.

Installation

$ go get -u https://github.com/yuangwei/go-18next

Usage

import "github.com/yuangwei/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
	
}

License

go-i18next is available under the MIT license. See the LICENSE file for more info.