PLT-3456 Fix Errors while starting the server (#3445)
* PLT-3456 AppErrors that are triggered before translations are loaded crash server or produce bad error messages. * Fixing tests
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
5dfa4fb629
Коммит
2305b2597f
@@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestConfig(t *testing.T) {
|
||||
TranslationsPreInit()
|
||||
LoadConfig("config.json")
|
||||
InitTranslations(Cfg.LocalizationSettings)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,16 @@ var T i18n.TranslateFunc
|
||||
var locales map[string]string = make(map[string]string)
|
||||
var settings model.LocalizationSettings
|
||||
|
||||
// this functions loads translations from filesystem
|
||||
// and assign english while loading server config
|
||||
func TranslationsPreInit() {
|
||||
InitTranslationsWithDir("i18n")
|
||||
T = TfuncWithFallback("en")
|
||||
}
|
||||
|
||||
func InitTranslations(localizationSettings model.LocalizationSettings) {
|
||||
settings = localizationSettings
|
||||
InitTranslationsWithDir("i18n")
|
||||
T = GetTranslationsBySystemLocale()
|
||||
}
|
||||
|
||||
func InitTranslationsWithDir(dir string) {
|
||||
@@ -30,8 +37,6 @@ func InitTranslationsWithDir(dir string) {
|
||||
i18n.MustLoadTranslationFile(i18nDirectory + filename)
|
||||
}
|
||||
}
|
||||
|
||||
T = GetTranslationsBySystemLocale()
|
||||
}
|
||||
|
||||
func GetTranslationsBySystemLocale() i18n.TranslateFunc {
|
||||
|
||||
@@ -79,14 +79,14 @@ func TestConnection(config *model.Config) {
|
||||
|
||||
conn, err1 := connectToSMTPServer(config)
|
||||
if err1 != nil {
|
||||
l4g.Error(T("utils.mail.test.configured.error"), err1.Message, err1.DetailedError)
|
||||
l4g.Error(T("utils.mail.test.configured.error"), T(err1.Message), err1.DetailedError)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
c, err2 := newSMTPClient(conn, config)
|
||||
if err2 != nil {
|
||||
l4g.Error(T("utils.mail.test.configured.error"), err2.Message, err2.DetailedError)
|
||||
l4g.Error(T("utils.mail.test.configured.error"), T(err2.Message), err2.DetailedError)
|
||||
return
|
||||
}
|
||||
defer c.Quit()
|
||||
|
||||
Ссылка в новой задаче
Block a user