-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] language pack support for model
- Loading branch information
Showing
15 changed files
with
143 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package lang | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/yaoapp/gou/lang" | ||
"github.com/yaoapp/kun/log" | ||
"github.com/yaoapp/yao/config" | ||
) | ||
|
||
func init() { | ||
lang.RegisterWidget("tables", "table") | ||
lang.RegisterWidget("charts", "chart") | ||
lang.RegisterWidget("kanban", "kanban") | ||
} | ||
|
||
// Load language packs | ||
func Load(cfg config.Config) error { | ||
root := filepath.Join(cfg.Root, "langs") | ||
err := lang.Load(root) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
name := os.Getenv("YAO_LANG") | ||
if name != "" { | ||
if _, has := lang.Dicts[name]; !has { | ||
log.Error("The language pack %s does not found", name) | ||
return nil | ||
} | ||
lang.Pick(name).AsDefault() | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package lang | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/yaoapp/gou/lang" | ||
"github.com/yaoapp/yao/config" | ||
"github.com/yaoapp/yao/share" | ||
) | ||
|
||
func TestLoad(t *testing.T) { | ||
share.DBConnect(config.Conf.DB) | ||
Load(config.Conf) | ||
assert.Len(t, lang.Dicts, 2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Latest: 最新信息 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Demo: 演示 | ||
Phone: 电话号码 | ||
ZipCode: 邮政编码 | ||
Uptime: 更新时间 | ||
Action: 动作 | ||
Yao: YAO | ||
Xiang: 象传 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SN: 编码 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Latest: 最新信息 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Demo: 演示 | ||
Phone: 電話號碼 | ||
ZipCode: 郵政編碼 | ||
Uptime: 更新時間 | ||
Action: 動作 | ||
Yao: YAO | ||
Xiang: 像傳 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SN: 編碼 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "::Demo", | ||
"connector": "trace", | ||
"table": { "name": "user_trace", "comment": "::Demo" }, | ||
"columns": [ | ||
{ "label": "ID", "name": "id", "type": "ID" }, | ||
{ | ||
"label": "::SN", | ||
"name": "user_sn", | ||
"type": "string", | ||
"length": 42, | ||
"index": true | ||
}, | ||
{ | ||
"label": "::Uptime", | ||
"name": "uptime", | ||
"type": "datetime", | ||
"index": true | ||
}, | ||
{ | ||
"label": "::Action", | ||
"name": "action", | ||
"type": "enum", | ||
"option": ["进入", "离开"], | ||
"index": true | ||
} | ||
], | ||
"indexes": [ | ||
{ | ||
"name": "user_sn_action_unique", | ||
"type": "unique", | ||
"columns": ["user_sn", "action"] | ||
} | ||
] | ||
} |