diff options
author | 6543 <6543@obermui.de> | 2021-03-21 16:11:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-21 16:11:36 +0100 |
commit | 24f7bd589945c8fc22c9cfc00bc21fca679da9d0 (patch) | |
tree | eb53dbc3679638b491b11eda5f1c4e231e60f7fa /modules/translation | |
parent | 17731e05ff47c72013fb52d1fc2236b4d7da269b (diff) | |
download | gitea-24f7bd589945c8fc22c9cfc00bc21fca679da9d0.tar.gz gitea-24f7bd589945c8fc22c9cfc00bc21fca679da9d0.zip |
Use i18n.Reset to reload locales (#15073)
Diffstat (limited to 'modules/translation')
-rw-r--r-- | modules/translation/translation.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/modules/translation/translation.go b/modules/translation/translation.go index b7276e53c0..dec48c7a65 100644 --- a/modules/translation/translation.go +++ b/modules/translation/translation.go @@ -5,8 +5,6 @@ package translation import ( - "errors" - "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/setting" @@ -38,6 +36,7 @@ func AllLangs() []LangType { // InitLocales loads the locales func InitLocales() { + i18n.Reset() localeNames, err := options.Dir("locale") if err != nil { log.Fatal("Failed to list locale files: %v", err) @@ -60,12 +59,7 @@ func InitLocales() { 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 { - 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) - } + log.Error("Failed to set messages to %s: %v", setting.Langs[i], err) } } i18n.SetDefaultLang("en-US") |