diff --git a/go.mod b/go.mod index 165c8f6933f7f..33586e67feec5 100644 --- a/go.mod +++ b/go.mod @@ -120,7 +120,7 @@ require ( github.com/tstranex/u2f v1.0.0 github.com/ulikunitz/xz v0.5.10 // indirect github.com/unknwon/com v1.0.1 - github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c + github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44 github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae github.com/unrolled/render v1.0.3 github.com/urfave/cli v1.22.5 diff --git a/go.sum b/go.sum index 09dc22e8f00cf..cf7148fbbeadc 100644 --- a/go.sum +++ b/go.sum @@ -1111,8 +1111,8 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs= github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= -github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c h1:679/gJXwrsHC3RATr0YYjZvDMJPYN7W9FGSGNoLmKxM= -github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ= +github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44 h1:7bSo/vjZKVYUoZfxpYh9Y9JV+9hi1gYJp4WIykhrZag= +github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ= github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs= github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM= github.com/unrolled/render v1.0.3 h1:baO+NG1bZSF2WR4zwh+0bMWauWky7DVrTOfvE2w+aFo= diff --git a/modules/translation/translation.go b/modules/translation/translation.go index b7276e53c0149..dec48c7a657b2 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") diff --git a/vendor/github.com/unknwon/i18n/i18n.go b/vendor/github.com/unknwon/i18n/i18n.go index cfe982f5f7df9..bdb8ee7923ccc 100644 --- a/vendor/github.com/unknwon/i18n/i18n.go +++ b/vendor/github.com/unknwon/i18n/i18n.go @@ -174,6 +174,11 @@ func SetMessageWithDesc(lang, langDesc string, localeFile interface{}, otherLoca return err } +// Reset resets locale store. +func Reset() { + locales = &localeStore{store: make(map[string]*locale)} +} + // SetMessage sets the message file for localization. func SetMessage(lang string, localeFile interface{}, otherLocaleFiles ...interface{}) error { return SetMessageWithDesc(lang, lang, localeFile, otherLocaleFiles...) diff --git a/vendor/modules.txt b/vendor/modules.txt index 7069aaffef27c..96ac0b77d9a05 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -772,7 +772,7 @@ github.com/ulikunitz/xz/lzma # github.com/unknwon/com v1.0.1 ## explicit github.com/unknwon/com -# github.com/unknwon/i18n v0.0.0-20200823051745-09abd91c7f2c +# github.com/unknwon/i18n v0.0.0-20210321134014-0ebbf2df1c44 ## explicit github.com/unknwon/i18n # github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae