Extracting i18n functionality to i18n core library (#16914)
* extracting i18n functionality to i18n core library * Removing utils.T * Adding documentation and changing one function name for better explanation * Changing other missing utils.T * Adding license string * Renaming corelibs to pkg * Renaming corelibs to pkg (moving directory) * Renaming from pkg to shared * Fixing bodyPage.Html casing * Fixing merges * Fixing merge problem * Fixing tests
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
85293fcf41
Коммит
5dd2e75c10
18
app/app.go
18
app/app.go
@@ -12,9 +12,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/go-i18n/i18n"
|
||||
goi18n "github.com/mattermost/go-i18n/i18n"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
@@ -23,6 +20,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/services/mailservice"
|
||||
"github.com/mattermost/mattermost-server/v5/services/searchengine"
|
||||
"github.com/mattermost/mattermost-server/v5/services/timezones"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
@@ -34,7 +32,7 @@ type App struct {
|
||||
// a cyclic dependency as bleve tests themselves import testlib.
|
||||
searchEngine *searchengine.Broker
|
||||
|
||||
t goi18n.TranslateFunc
|
||||
t i18n.TranslateFunc
|
||||
session model.Session
|
||||
requestId string
|
||||
ipAddress string
|
||||
@@ -366,7 +364,7 @@ func (a *App) notifyAdminsOfWarnMetricStatus(warnMetricId string, isE0Edition bo
|
||||
}
|
||||
}
|
||||
|
||||
T := utils.GetUserTranslations(sysAdmins[0].Locale)
|
||||
T := i18n.GetUserTranslations(sysAdmins[0].Locale)
|
||||
warnMetricsBot := &model.Bot{
|
||||
Username: model.BOT_WARN_METRIC_BOT_USERNAME,
|
||||
DisplayName: T("app.system.warn_metric.bot_displayname"),
|
||||
@@ -380,7 +378,7 @@ func (a *App) notifyAdminsOfWarnMetricStatus(warnMetricId string, isE0Edition bo
|
||||
}
|
||||
|
||||
for _, sysAdmin := range sysAdmins {
|
||||
T := utils.GetUserTranslations(sysAdmin.Locale)
|
||||
T := i18n.GetUserTranslations(sysAdmin.Locale)
|
||||
bot.DisplayName = T("app.system.warn_metric.bot_displayname")
|
||||
bot.Description = T("app.system.warn_metric.bot_description")
|
||||
|
||||
@@ -466,9 +464,9 @@ func (a *App) NotifyAndSetWarnMetricAck(warnMetricId string, sender *model.User,
|
||||
|
||||
if !forceAck {
|
||||
if *a.Config().EmailSettings.SMTPServer == "" {
|
||||
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.missing_server.app_error", nil, utils.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}), http.StatusInternalServerError)
|
||||
return model.NewAppError("NotifyAndSetWarnMetricAck", "api.email.send_warn_metric_ack.missing_server.app_error", nil, i18n.T("api.context.invalid_param.app_error", map[string]interface{}{"Name": "SMTPServer"}), http.StatusInternalServerError)
|
||||
}
|
||||
T := utils.GetUserTranslations(sender.Locale)
|
||||
T := i18n.GetUserTranslations(sender.Locale)
|
||||
bodyPage := a.Srv().EmailService.newEmailTemplate("warn_metric_ack", sender.Locale)
|
||||
bodyPage.Props["ContactNameHeader"] = T("api.templates.warn_metric_ack.body.contact_name_header")
|
||||
bodyPage.Props["ContactNameValue"] = sender.GetFullName()
|
||||
@@ -671,7 +669,7 @@ func (a *App) SetSession(s *model.Session) {
|
||||
a.session = *s
|
||||
}
|
||||
|
||||
func (a *App) SetT(t goi18n.TranslateFunc) {
|
||||
func (a *App) SetT(t i18n.TranslateFunc) {
|
||||
a.t = t
|
||||
}
|
||||
func (a *App) SetRequestId(s string) {
|
||||
@@ -695,7 +693,7 @@ func (a *App) SetContext(c context.Context) {
|
||||
func (a *App) SetServer(srv *Server) {
|
||||
a.srv = srv
|
||||
}
|
||||
func (a *App) GetT() goi18n.TranslateFunc {
|
||||
func (a *App) GetT() i18n.TranslateFunc {
|
||||
return a.t
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user