Skip to content

Commit

Permalink
fix(language): default zh language code
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc authored and ibuler committed Aug 13, 2020
1 parent 2f8292a commit 074d1c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ type Config struct {
LogLevel string `yaml:"LOG_LEVEL"`
RootPath string `yaml:"ROOT_PATH"`
Comment string `yaml:"COMMENT"`
Language string `yaml:"LANG"`
LanguageCode string `yaml:"LANGUAGE_CODE"` // Abandon
LanguageCode string `yaml:"LANGUAGE_CODE"`
UploadFailedReplay bool `yaml:"UPLOAD_FAILED_REPLAY_ON_START"`
AssetLoadPolicy string `yaml:"ASSET_LOAD_POLICY"` // all
ZipMaxSize string `yaml:"ZIP_MAX_SIZE"`
Expand All @@ -59,12 +58,8 @@ type Config struct {
}

func (c *Config) EnsureConfigValid() {
// 兼容原来config
if c.LanguageCode != "" && c.Language == "" {
c.Language = c.LanguageCode
}
if c.Language == "" {
c.Language = "zh"
if c.LanguageCode == "" {
c.LanguageCode = "zh"
}
// 确保至少有一个认证
if !c.PublicKeyAuth && !c.PasswordAuth {
Expand Down
6 changes: 3 additions & 3 deletions pkg/i18n/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (
func Initial()() {
cf := config.GetConf()
localePath := path.Join(cf.RootPath, "locale")
if strings.HasPrefix(cf.Language, "zh") {
gotext.Configure(localePath, "zh_CN", "koko")
} else {
if strings.HasPrefix(strings.ToLower(cf.LanguageCode), "en") {
gotext.Configure(localePath, "en_US", "koko")
} else {
gotext.Configure(localePath, "zh_CN", "koko")
}
}

Expand Down

0 comments on commit 074d1c8

Please sign in to comment.