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

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/gogf/gf/i18n/gi18n"
     8  )
     9  
    10  func main() {
    11  	t := gi18n.New()
    12  	t.SetLanguage("ja")
    13  	err := t.SetPath("./i18n-file")
    14  	if err != nil {
    15  		panic(err)
    16  	}
    17  	fmt.Println(t.Translate(context.TODO(), `hello`))
    18  	fmt.Println(t.Translate(context.TODO(), `{#hello}{#world}!`))
    19  }