Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
9fe09ba4
N
nightingale
项目概览
DiDi
/
nightingale
9 个月 前同步成功
通知
46
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9fe09ba4
编写于
11月 30, 2020
作者:
7
710leo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code refactor
上级
9a71c005
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
83 addition
and
47 deletion
+83
-47
src/modules/ams/ams.go
src/modules/ams/ams.go
+2
-0
src/modules/ams/config/yaml.go
src/modules/ams/config/yaml.go
+14
-3
src/modules/job/config/config.go
src/modules/job/config/config.go
+15
-4
src/modules/job/job.go
src/modules/job/job.go
+1
-1
src/modules/monapi/config/yaml.go
src/modules/monapi/config/yaml.go
+3
-6
src/modules/monapi/monapi.go
src/modules/monapi/monapi.go
+1
-1
src/modules/rdb/config/yaml.go
src/modules/rdb/config/yaml.go
+10
-0
src/modules/rdb/rdb.go
src/modules/rdb/rdb.go
+1
-1
src/toolkits/i18n/i18n.go
src/toolkits/i18n/i18n.go
+36
-31
未找到文件。
src/modules/ams/ams.go
浏览文件 @
9fe09ba4
...
...
@@ -58,6 +58,8 @@ func main() {
// 初始化数据库和相关数据
models
.
InitMySQL
(
"rdb"
,
"ams"
)
i18n
.
Init
(
config
.
Config
.
I18n
)
http
.
Start
()
endingProc
()
...
...
src/modules/ams/config/yaml.go
浏览文件 @
9fe09ba4
...
...
@@ -4,13 +4,16 @@ import (
"fmt"
"github.com/didi/nightingale/src/common/loggeri"
"github.com/didi/nightingale/src/toolkits/i18n"
"github.com/toolkits/pkg/file"
)
type
ConfigT
struct
{
Logger
loggeri
.
Config
`yaml:"logger"`
HTTP
httpSection
`yaml:"http"`
Tokens
[]
string
`yaml:"tokens"`
Logger
loggeri
.
Config
`yaml:"logger"`
HTTP
httpSection
`yaml:"http"`
Tokens
[]
string
`yaml:"tokens"`
I18n
i18n
.
I18nSection
`yaml:"i18n"`
}
type
httpSection
struct
{
...
...
@@ -35,6 +38,14 @@ func Parse() error {
}
Config
=
&
c
if
Config
.
I18n
.
DictPath
==
""
{
Config
.
I18n
.
DictPath
=
"etc/dict.json"
}
if
Config
.
I18n
.
Lang
==
""
{
Config
.
I18n
.
Lang
=
"zh"
}
fmt
.
Println
(
"config.file:"
,
ymlFile
)
return
nil
...
...
src/modules/job/config/config.go
浏览文件 @
9fe09ba4
...
...
@@ -7,13 +7,15 @@ import (
"github.com/didi/nightingale/src/common/identity"
"github.com/didi/nightingale/src/common/loggeri"
"github.com/didi/nightingale/src/toolkits/i18n"
)
type
ConfigT
struct
{
Logger
loggeri
.
Config
`yaml:"logger"`
HTTP
httpSection
`yaml:"http"`
Tokens
[]
string
`yaml:"tokens"`
Output
outputSection
`yaml:"output"`
Logger
loggeri
.
Config
`yaml:"logger"`
HTTP
httpSection
`yaml:"http"`
Tokens
[]
string
`yaml:"tokens"`
Output
outputSection
`yaml:"output"`
I18n
i18n
.
I18nSection
`yaml:"i18n"`
}
type
httpSection
struct
{
...
...
@@ -43,6 +45,15 @@ func Parse() error {
}
Config
=
&
c
if
Config
.
I18n
.
DictPath
==
""
{
Config
.
I18n
.
DictPath
=
"etc/dict.json"
}
if
Config
.
I18n
.
Lang
==
""
{
Config
.
I18n
.
Lang
=
"zh"
}
fmt
.
Println
(
"config.file:"
,
ymlFile
)
return
identity
.
Parse
()
...
...
src/modules/job/job.go
浏览文件 @
9fe09ba4
...
...
@@ -83,7 +83,7 @@ func main() {
// 将task_host_doing表缓存到内存里,减少DB压力
timer
.
CacheHostDoing
()
i18n
.
Init
()
i18n
.
Init
(
config
.
Config
.
I18n
)
go
rpc
.
Start
()
http
.
Start
()
...
...
src/modules/monapi/config/yaml.go
浏览文件 @
9fe09ba4
...
...
@@ -5,6 +5,8 @@ import (
"fmt"
"sync"
"github.com/didi/nightingale/src/toolkits/i18n"
"github.com/spf13/viper"
"github.com/toolkits/pkg/file"
)
...
...
@@ -26,12 +28,7 @@ type ConfYaml struct {
Notify
map
[
string
][]
string
`yaml:"notify"`
Link
linkSection
`yaml:"link"`
IndexMod
string
`yaml:"indexMod"`
I18n
i18nSection
`yaml:"i18n"`
}
type
i18nSection
struct
{
DictPath
string
`yaml:"dictPath"`
Lang
string
`yaml:"lang"`
I18n
i18n
.
I18nSection
`yaml:"i18n"`
}
type
mergeSection
struct
{
...
...
src/modules/monapi/monapi.go
浏览文件 @
9fe09ba4
...
...
@@ -66,7 +66,7 @@ func main() {
scache
.
Init
()
i18n
.
Init
(
config
.
Get
()
.
I18n
.
Lang
,
config
.
Get
()
.
I18n
.
DictPath
)
i18n
.
Init
(
config
.
Get
()
.
I18n
)
if
err
:=
scache
.
CheckJudge
();
err
!=
nil
{
logger
.
Errorf
(
"check judge fail: %v"
,
err
)
...
...
src/modules/rdb/config/yaml.go
浏览文件 @
9fe09ba4
...
...
@@ -6,6 +6,7 @@ import (
"github.com/toolkits/pkg/file"
"github.com/didi/nightingale/src/common/loggeri"
"github.com/didi/nightingale/src/toolkits/i18n"
)
type
ConfigT
struct
{
...
...
@@ -19,6 +20,7 @@ type ConfigT struct {
RabbitMQ
rabbitmqSection
`yaml:"rabbitmq"`
WeChat
wechatSection
`yaml:"wechat"`
Captcha
bool
`yaml:"captcha"`
I18n
i18n
.
I18nSection
`yaml:"i18n"`
}
type
wechatSection
struct
{
...
...
@@ -115,6 +117,14 @@ func Parse() error {
Config
=
&
c
fmt
.
Println
(
"config.file:"
,
ymlFile
)
if
Config
.
I18n
.
DictPath
==
""
{
Config
.
I18n
.
DictPath
=
"etc/dict.json"
}
if
Config
.
I18n
.
Lang
==
""
{
Config
.
I18n
.
Lang
=
"zh"
}
if
err
=
parseOps
();
err
!=
nil
{
return
err
}
...
...
src/modules/rdb/rdb.go
浏览文件 @
9fe09ba4
...
...
@@ -67,7 +67,7 @@ func main() {
// 初始化 redis 用来发送邮件短信等
redisc
.
InitRedis
()
cron
.
InitWorker
()
i18n
.
Init
()
i18n
.
Init
(
config
.
Config
.
I18n
)
// 初始化 rabbitmq 处理部分异步逻辑
rabbitmq
.
Init
()
...
...
src/toolkits/i18n/i18n.go
浏览文件 @
9fe09ba4
...
...
@@ -11,6 +11,42 @@ import (
"github.com/toolkits/pkg/file"
)
type
I18nSection
struct
{
DictPath
string
`yaml:"dictPath"`
Lang
string
`yaml:"lang"`
}
// Init will init i18n support via input language.
func
Init
(
config
...
I18nSection
)
{
l
:=
"zh"
fpath
:=
"etc/dict.json"
if
len
(
config
)
>
0
{
l
=
config
[
0
]
.
Lang
fpath
=
config
[
0
]
.
DictPath
}
lang
:=
language
.
Chinese
switch
l
{
case
"en"
:
lang
=
language
.
English
case
"zh"
:
lang
=
language
.
Chinese
}
tag
,
_
,
_
:=
supported
.
Match
(
lang
)
switch
tag
{
case
language
.
AmericanEnglish
,
language
.
English
:
initEnUS
(
lang
)
case
language
.
SimplifiedChinese
,
language
.
Chinese
:
initZhCN
(
lang
,
fpath
)
default
:
initZhCN
(
lang
,
fpath
)
}
p
=
message
.
NewPrinter
(
lang
)
}
func
initEnUS
(
tag
language
.
Tag
)
{
}
...
...
@@ -84,37 +120,6 @@ var supported = newMatcher([]language.Tag{
language
.
Chinese
,
})
// Init will init i18n support via input language.
func
Init
(
arr
...
string
)
{
l
:=
"zh"
fpath
:=
"etc/dict.json"
if
len
(
arr
)
==
2
{
l
=
arr
[
0
]
fpath
=
arr
[
1
]
}
lang
:=
language
.
Chinese
switch
l
{
case
"en"
:
lang
=
language
.
English
case
"zh"
:
lang
=
language
.
Chinese
}
tag
,
_
,
_
:=
supported
.
Match
(
lang
)
switch
tag
{
case
language
.
AmericanEnglish
,
language
.
English
:
initEnUS
(
lang
)
case
language
.
SimplifiedChinese
,
language
.
Chinese
:
initZhCN
(
lang
,
fpath
)
default
:
initZhCN
(
lang
,
fpath
)
}
p
=
message
.
NewPrinter
(
lang
)
}
// Fprintf is like fmt.Fprintf, but using language-specific formatting.
func
Fprintf
(
w
io
.
Writer
,
key
message
.
Reference
,
a
...
interface
{})
(
n
int
,
err
error
)
{
return
p
.
Fprintf
(
w
,
key
,
a
...
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录