summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorJohn Olheiser <john.olheiser@gmail.com>2021-02-05 15:41:45 -0600
committerGitHub <noreply@github.com>2021-02-05 22:41:45 +0100
commit19fccdc45d250383f8b283c9dc1bca1bef26f5ba (patch)
treeb36e035193bcb64e1bca3af366be28875a5151b1 /modules
parentf72ce26326ea31d4bea8116e11c4c4f96b68639d (diff)
downloadgitea-19fccdc45d250383f8b283c9dc1bca1bef26f5ba.tar.gz
gitea-19fccdc45d250383f8b283c9dc1bca1bef26f5ba.zip
Fix locale init (#14582)
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>
Diffstat (limited to 'modules')
-rw-r--r--modules/translation/translation.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/translation/translation.go b/modules/translation/translation.go
index 28ff6a5db1..b7276e53c0 100644
--- a/modules/translation/translation.go
+++ b/modules/translation/translation.go
@@ -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"
@@ -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")