0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 23:33:15 -05:00

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>
This commit is contained in:
John Olheiser 2021-02-05 15:41:45 -06:00 committed by GitHub
parent f72ce26326
commit 19fccdc45d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,8 @@
package translation package translation
import ( import (
"errors"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/options" "code.gitea.io/gitea/modules/options"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
@ -57,8 +59,13 @@ func InitLocales() {
matcher = language.NewMatcher(tags) matcher = language.NewMatcher(tags)
for i := range setting.Names { for i := range setting.Names {
key := "locale_" + setting.Langs[i] + ".ini" key := "locale_" + setting.Langs[i] + ".ini"
if err := i18n.SetMessageWithDesc(setting.Langs[i], setting.Names[i], localFiles[key]); err != nil { 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 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") i18n.SetDefaultLang("en-US")