mirror of
https://gitee.com/johng/gf.git
synced 2024-12-01 19:57:40 +08:00
improve example for gi18n
This commit is contained in:
parent
1665d92136
commit
2b20c77bc0
@ -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"))
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user