+ Add initial multi-language support for the backend server.

+ Add language option to config.yaml (currently support en (English), zh (Chinese), ar (Arabic) languages).
+ Update English translation.
+ Add language selection support for init module.
+ Translated history component.
+ Translated setting module.
This commit is contained in:
Mohamed Hassan Nasr
2022-02-06 00:54:34 +02:00
committed by Mohamed Hassan
parent 62f1451a70
commit 4d08788af2
11 changed files with 115 additions and 22 deletions
+11
View File
@@ -30,6 +30,17 @@ func (i *DBApi) InitDB(c *gin.Context) {
response.FailWithMessage("参数校验不通过", c)
return
}
// added by mohamed hassan to allow multilanguage support
if dbInfo.Language != "" {
if dbInfo.Language == "en" || dbInfo.Language == "zh" || dbInfo.Language == "ar" {
global.GVA_CONFIG.Language = dbInfo.Language // set intial database and system langauge here
} else {
global.GVA_CONFIG.Language = "en" // set defualt language to initialize database and system to english
}
}
// end of adding
if err := initDBService.InitDB(dbInfo); err != nil {
global.GVA_LOG.Error("自动创建数据库失败!", zap.Error(err))
response.FailWithMessage("自动创建数据库失败,请查看后台日志,检查后在进行初始化", c)
+2
View File
@@ -203,3 +203,5 @@ cors:
allow-methods: GET, POST
expose-headers: Content-Length, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Content-Type
allow-credentials: true # 布尔值
# added by mohamed hassan to support multilanguage
language: ''
+3
View File
@@ -27,4 +27,7 @@ type Server struct {
// 跨域配置
Cors CORS `mapstructure:"cors" json:"cors" yaml:"cors"`
// added by mohamed hassan to support multi-language
Language string `mapstructure:"language" json:"language" yaml:"language"`
}
+1
View File
@@ -13,6 +13,7 @@ type InitDB struct {
UserName string `json:"userName" binding:"required"` // 数据库用户名
Password string `json:"password"` // 数据库密码
DBName string `json:"dbName" binding:"required"` // 数据库名
Language string `json:"language",omitempty` // DB initial langauge // added by mohamed hassan to support multilanguage
}
// MysqlEmptyDsn msyql 空数据库 建库链接