[MM-14361] Initialise the translations before loading the config store (#10435)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ca52ca7016
Коммит
434d01a284
@@ -169,11 +169,9 @@ func NewServer(options ...Option) (*Server, error) {
|
|||||||
|
|
||||||
s.ImageProxy = imageproxy.MakeImageProxy(s, s.HTTPService)
|
s.ImageProxy = imageproxy.MakeImageProxy(s, s.HTTPService)
|
||||||
|
|
||||||
if utils.T == nil {
|
|
||||||
if err := utils.TranslationsPreInit(); err != nil {
|
if err := utils.TranslationsPreInit(); err != nil {
|
||||||
return nil, errors.Wrapf(err, "unable to load Mattermost translation files")
|
return nil, errors.Wrapf(err, "unable to load Mattermost translation files")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
err := s.RunOldAppInitalization()
|
err := s.RunOldAppInitalization()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/config"
|
"github.com/mattermost/mattermost-server/config"
|
||||||
"github.com/mattermost/mattermost-server/manualtesting"
|
"github.com/mattermost/mattermost-server/manualtesting"
|
||||||
"github.com/mattermost/mattermost-server/mlog"
|
"github.com/mattermost/mattermost-server/mlog"
|
||||||
|
"github.com/mattermost/mattermost-server/utils"
|
||||||
"github.com/mattermost/mattermost-server/web"
|
"github.com/mattermost/mattermost-server/web"
|
||||||
"github.com/mattermost/mattermost-server/wsapi"
|
"github.com/mattermost/mattermost-server/wsapi"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,6 +44,9 @@ func serverCmdF(command *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
interruptChan := make(chan os.Signal, 1)
|
interruptChan := make(chan os.Signal, 1)
|
||||||
|
|
||||||
|
if err = utils.TranslationsPreInit(); err != nil {
|
||||||
|
return errors.Wrapf(err, "unable to load Mattermost translation files")
|
||||||
|
}
|
||||||
configStore, err := config.NewStore(configDSN, !disableConfigWatch)
|
configStore, err := config.NewStore(configDSN, !disableConfigWatch)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -21,9 +21,13 @@ var TDefault i18n.TranslateFunc
|
|||||||
var locales map[string]string = make(map[string]string)
|
var locales map[string]string = make(map[string]string)
|
||||||
var settings model.LocalizationSettings
|
var settings model.LocalizationSettings
|
||||||
|
|
||||||
// this functions loads translations from filesystem
|
// this functions loads translations from filesystem if they are not
|
||||||
// and assign english while loading server config
|
// loaded already and assigns english while loading server config
|
||||||
func TranslationsPreInit() error {
|
func TranslationsPreInit() error {
|
||||||
|
if T != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Set T even if we fail to load the translations. Lots of shutdown handling code will
|
// Set T even if we fail to load the translations. Lots of shutdown handling code will
|
||||||
// segfault trying to handle the error, and the untranslated IDs are strictly better.
|
// segfault trying to handle the error, and the untranslated IDs are strictly better.
|
||||||
T = TfuncWithFallback("en")
|
T = TfuncWithFallback("en")
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user