github.com/gogf/gf@v1.16.9/.example/i18n/gi18n/resource/gi18n-resource.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/gogf/gf/frame/g"
     7  
     8  	_ "github.com/gogf/gf/os/gres/testdata"
     9  )
    10  
    11  func main() {
    12  	m := g.I18n()
    13  	m.SetLanguage("ja")
    14  	err := m.SetPath("/i18n-dir")
    15  	if err != nil {
    16  		panic(err)
    17  	}
    18  	fmt.Println(m.Translate(`hello`))
    19  	fmt.Println(m.Translate(`{#hello}{#world}!`))
    20  }