Skip to content

Commit 19fccdc

Browse files
jolheiser6543zeripath
authored
Fix locale init (#14582)
just log if lang is already loaded since we can not reload it Co-authored-by: jolheiser <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent f72ce26 commit 19fccdc

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

modules/translation/translation.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package translation
66

77
import (
8+
"errors"
9+
810
"code.gitea.io/gitea/modules/log"
911
"code.gitea.io/gitea/modules/options"
1012
"code.gitea.io/gitea/modules/setting"
@@ -57,8 +59,13 @@ func InitLocales() {
5759
matcher = language.NewMatcher(tags)
5860
for i := range setting.Names {
5961
key := "locale_" + setting.Langs[i] + ".ini"
60-
if err := i18n.SetMessageWithDesc(setting.Langs[i], setting.Names[i], localFiles[key]); err != nil {
61-
log.Fatal("Failed to set messages to %s: %v", setting.Langs[i], err)
62+
if err = i18n.SetMessageWithDesc(setting.Langs[i], setting.Names[i], localFiles[key]); err != nil {
63+
if errors.Is(err, i18n.ErrLangAlreadyExist) {
64+
// just log if lang is already loaded since we can not reload it
65+
log.Warn("Can not load language '%s' since already loaded", setting.Langs[i])
66+
} else {
67+
log.Error("Failed to set messages to %s: %v", setting.Langs[i], err)
68+
}
6269
}
6370
}
6471
i18n.SetDefaultLang("en-US")

0 commit comments

Comments
 (0)