improve example for gi18n

This commit is contained in:
John 2019-09-15 13:47:44 +08:00
parent 1665d92136
commit 2b20c77bc0
3 changed files with 14 additions and 3 deletions

View File

@ -8,8 +8,19 @@ import (
func main() {
t := gi18n.New()
t.SetPath("/Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/i18n/gi18n/i18n")
t.SetLanguage("en")
fmt.Println(t.Translate(`hello`))
fmt.Println(t.Translate(`{#hello}{#world}!`))
t.SetLanguage("ja")
fmt.Println(t.Translate(`hello`))
fmt.Println(t.Translate(`{#hello}{#world}!`))
t.SetLanguage("ru")
fmt.Println(t.Translate(`hello`))
fmt.Println(t.Translate(`{#hello}{#world}!`))
fmt.Println(t.Translate(`hello`, "zh-CN"))
fmt.Println(t.Translate(`{#hello}{#world}!`, "zh-CN"))
}

View File

@ -9,8 +9,8 @@ func main() {
g.I18n().SetPath("/Users/john/Workspace/Go/GOPATH/src/github.com/gogf/gf/.example/i18n/gi18n/i18n")
s := g.Server()
s.BindHandler("/", func(r *ghttp.Request) {
r.Response.WriteTplContent(`{#hello}{#world}`, g.Map{
"I18nLanguage": r.Get("lang", "en"),
r.Response.WriteTplContent(`{#hello}{#world}!`, g.Map{
"I18nLanguage": r.Get("lang", "zh-CN"),
})
})
s.SetPort(8199)

View File

@ -179,7 +179,7 @@ func (m *Manager) init() {
}
}
}
} else {
} else if m.options.Path != "" {
files, _ := gfile.ScanDirFile(m.options.Path, "*.*", true)
if len(files) > 0 {
var path string