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
@@ -7,21 +7,21 @@ import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
goi18n "github.com/mattermost/go-i18n/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
)
|
||||
|
||||
type CommandArgs struct {
|
||||
UserId string `json:"user_id"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
TeamId string `json:"team_id"`
|
||||
RootId string `json:"root_id"`
|
||||
ParentId string `json:"parent_id"`
|
||||
TriggerId string `json:"trigger_id,omitempty"`
|
||||
Command string `json:"command"`
|
||||
SiteURL string `json:"-"`
|
||||
T goi18n.TranslateFunc `json:"-"`
|
||||
UserMentions UserMentionMap `json:"-"`
|
||||
ChannelMentions ChannelMentionMap `json:"-"`
|
||||
UserId string `json:"user_id"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
TeamId string `json:"team_id"`
|
||||
RootId string `json:"root_id"`
|
||||
ParentId string `json:"parent_id"`
|
||||
TriggerId string `json:"trigger_id,omitempty"`
|
||||
Command string `json:"command"`
|
||||
SiteURL string `json:"-"`
|
||||
T i18n.TranslateFunc `json:"-"`
|
||||
UserMentions UserMentionMap `json:"-"`
|
||||
ChannelMentions ChannelMentionMap `json:"-"`
|
||||
|
||||
// DO NOT USE Session field is deprecated. MM-26398
|
||||
Session Session `json:"-"`
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
goi18n "github.com/mattermost/go-i18n/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
"github.com/pborman/uuid"
|
||||
)
|
||||
|
||||
@@ -73,10 +73,10 @@ func (sa StringArray) Equals(input StringArray) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var translateFunc goi18n.TranslateFunc
|
||||
var translateFunc i18n.TranslateFunc
|
||||
var translateFuncOnce sync.Once
|
||||
|
||||
func AppErrorInit(t goi18n.TranslateFunc) {
|
||||
func AppErrorInit(t i18n.TranslateFunc) {
|
||||
translateFuncOnce.Do(func() {
|
||||
translateFunc = t
|
||||
})
|
||||
@@ -97,7 +97,7 @@ func (er *AppError) Error() string {
|
||||
return er.Where + ": " + er.Message + ", " + er.DetailedError
|
||||
}
|
||||
|
||||
func (er *AppError) Translate(T goi18n.TranslateFunc) {
|
||||
func (er *AppError) Translate(T i18n.TranslateFunc) {
|
||||
if T == nil {
|
||||
er.Message = er.Id
|
||||
return
|
||||
@@ -110,7 +110,7 @@ func (er *AppError) Translate(T goi18n.TranslateFunc) {
|
||||
}
|
||||
}
|
||||
|
||||
func (er *AppError) SystemMessage(T goi18n.TranslateFunc) string {
|
||||
func (er *AppError) SystemMessage(T i18n.TranslateFunc) string {
|
||||
if er.params == nil {
|
||||
return T(er.Id)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
goi18n "github.com/mattermost/go-i18n/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
)
|
||||
|
||||
// WebSocketRequest represents a request made to the server through a websocket.
|
||||
@@ -18,9 +18,9 @@ type WebSocketRequest struct {
|
||||
Data map[string]interface{} `json:"data"` // The metadata for an action.
|
||||
|
||||
// Server-provided fields
|
||||
Session Session `json:"-"`
|
||||
T goi18n.TranslateFunc `json:"-"`
|
||||
Locale string `json:"-"`
|
||||
Session Session `json:"-"`
|
||||
T i18n.TranslateFunc `json:"-"`
|
||||
Locale string `json:"-"`
|
||||
}
|
||||
|
||||
func (o *WebSocketRequest) ToJson() string {
|
||||
|
||||
Ссылка в новой задаче
Block a user