From 51119cb388f532e903a560533795c30b083688a7 Mon Sep 17 00:00:00 2001 From: jolheiser Date: Fri, 5 Feb 2021 12:36:13 -0600 Subject: [PATCH 1/2] Fix locale init Signed-off-by: jolheiser --- modules/translation/translation.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/translation/translation.go b/modules/translation/translation.go index 28ff6a5db1510..9e22109e44ad2 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.Fatal("Failed to set messages to %s: %v", setting.Langs[i], err) + } } } i18n.SetDefaultLang("en-US") From 2ab5e400aa80f9a605c2ec448e655641692f718c Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 5 Feb 2021 21:39:38 +0100 Subject: [PATCH 2/2] Update modules/translation/translation.go Co-authored-by: zeripath --- modules/translation/translation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/translation/translation.go b/modules/translation/translation.go index 9e22109e44ad2..b7276e53c0149 100644 --- a/modules/translation/translation.go +++ b/modules/translation/translation.go @@ -64,7 +64,7 @@ func InitLocales() { // 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.Fatal("Failed to set messages to %s: %v", setting.Langs[i], err) + log.Error("Failed to set messages to %s: %v", setting.Langs[i], err) } } }