Skip to content

Commit

Permalink
Fix locale init (#14582)
Browse files Browse the repository at this point in the history
just log if lang is already loaded since we can not reload it

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
  • Loading branch information
3 people authored Feb 5, 2021
1 parent f72ce26 commit 19fccdc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions modules/translation/translation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package translation

import (
"errors"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/options"
"code.gitea.io/gitea/modules/setting"
Expand Down Expand Up @@ -57,8 +59,13 @@ func InitLocales() {
matcher = language.NewMatcher(tags)
for i := range setting.Names {
key := "locale_" + setting.Langs[i] + ".ini"
if err := i18n.SetMessageWithDesc(setting.Langs[i], setting.Names[i], localFiles[key]); err != nil {
log.Fatal("Failed to set messages to %s: %v", setting.Langs[i], err)
if err = i18n.SetMessageWithDesc(setting.Langs[i], setting.Names[i], localFiles[key]); err != nil {
if errors.Is(err, i18n.ErrLangAlreadyExist) {
// just log if lang is already loaded since we can not reload it
log.Warn("Can not load language '%s' since already loaded", setting.Langs[i])
} else {
log.Error("Failed to set messages to %s: %v", setting.Langs[i], err)
}
}
}
i18n.SetDefaultLang("en-US")
Expand Down

0 comments on commit 19fccdc

Please sign in to comment.