mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
9
example/pack/hack/config.yaml
Normal file
9
example/pack/hack/config.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
gfcli:
|
||||
build:
|
||||
name: "pack"
|
||||
arch: "amd64"
|
||||
system: "darwin"
|
||||
packSrc: "resource/public,manifest/i18n"
|
||||
packDst: "packed/build_packed_data.go"
|
||||
mod: ""
|
||||
cgo: 0
|
||||
28
example/pack/main.go
Normal file
28
example/pack/main.go
Normal file
@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "github.com/gogf/gf/example/pack/packed"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/i18n/gi18n"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gres"
|
||||
)
|
||||
|
||||
func main() {
|
||||
gres.Dump()
|
||||
|
||||
s := g.Server()
|
||||
s.SetPort(8199)
|
||||
s.SetServerRoot("resource/public")
|
||||
s.BindHandler("/i18n", func(r *ghttp.Request) {
|
||||
var (
|
||||
lang = r.Get("lang", "zh-CN").String()
|
||||
ctx = gi18n.WithLanguage(r.Context(), lang)
|
||||
content string
|
||||
)
|
||||
content = g.I18n().T(ctx, `{#hello} {#world}!`)
|
||||
r.Response.Write(content)
|
||||
})
|
||||
s.Run()
|
||||
}
|
||||
2
example/pack/manifest/i18n/ja.yaml
Normal file
2
example/pack/manifest/i18n/ja.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
hello: "こんにちは"
|
||||
world: "世界"
|
||||
2
example/pack/manifest/i18n/ru.yaml
Normal file
2
example/pack/manifest/i18n/ru.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
hello: "Привет"
|
||||
world: "мир"
|
||||
2
example/pack/manifest/i18n/zh-CN.yaml
Normal file
2
example/pack/manifest/i18n/zh-CN.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
hello: "你好"
|
||||
world: "世界"
|
||||
1
example/pack/packed/paked.go
Normal file
1
example/pack/packed/paked.go
Normal file
@ -0,0 +1 @@
|
||||
package packed
|
||||
8
example/pack/resource/public/index.html
Normal file
8
example/pack/resource/public/index.html
Normal file
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello World</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World!</h1>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user