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
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/config"
|
||||
"github.com/mattermost/mattermost-server/v5/mlog"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
@@ -106,7 +107,7 @@ func init() {
|
||||
|
||||
func configValidateCmdF(command *cobra.Command, args []string) error {
|
||||
utils.TranslationsPreInit()
|
||||
model.AppErrorInit(utils.T)
|
||||
model.AppErrorInit(i18n.T)
|
||||
|
||||
_, err := getConfigStore(command)
|
||||
if err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v5/app"
|
||||
"github.com/mattermost/mattermost-server/v5/config"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
@@ -37,7 +38,7 @@ func initDBCommandContext(configDSN string, readOnlyConfigStore bool) (*app.App,
|
||||
if err := utils.TranslationsPreInit(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
model.AppErrorInit(utils.T)
|
||||
model.AppErrorInit(i18n.T)
|
||||
|
||||
s, err := app.NewServer(
|
||||
app.Config(configDSN, false, readOnlyConfigStore, nil),
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/audit"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
)
|
||||
|
||||
var PermissionsCmd = &cobra.Command{
|
||||
@@ -102,7 +102,7 @@ func exportPermissionsCmdF(command *cobra.Command, args []string) error {
|
||||
defer a.Srv().Shutdown()
|
||||
|
||||
if license := a.Srv().License(); license == nil {
|
||||
return errors.New(utils.T("cli.license.critical"))
|
||||
return errors.New(i18n.T("cli.license.critical"))
|
||||
}
|
||||
|
||||
if err = a.ExportPermissions(os.Stdout); err != nil {
|
||||
@@ -123,7 +123,7 @@ func importPermissionsCmdF(command *cobra.Command, args []string) error {
|
||||
defer a.Srv().Shutdown()
|
||||
|
||||
if license := a.Srv().License(); license == nil {
|
||||
return errors.New(utils.T("cli.license.critical"))
|
||||
return errors.New(i18n.T("cli.license.critical"))
|
||||
}
|
||||
|
||||
file, err := os.Open(args[0])
|
||||
|
||||
@@ -6,9 +6,8 @@ package commands
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
)
|
||||
|
||||
func TestPermissionsExport_rejectsUnlicensed(t *testing.T) {
|
||||
@@ -16,7 +15,7 @@ func TestPermissionsExport_rejectsUnlicensed(t *testing.T) {
|
||||
defer th.TearDown()
|
||||
|
||||
actual, _ := th.RunCommandWithOutput(t, "permissions", "export")
|
||||
assert.Contains(t, actual, utils.T("cli.license.critical"))
|
||||
assert.Contains(t, actual, i18n.T("cli.license.critical"))
|
||||
}
|
||||
|
||||
func TestPermissionsImport_rejectsUnlicensed(t *testing.T) {
|
||||
@@ -25,5 +24,5 @@ func TestPermissionsImport_rejectsUnlicensed(t *testing.T) {
|
||||
|
||||
actual, _ := th.RunCommandWithOutput(t, "permissions", "import")
|
||||
|
||||
assert.Contains(t, actual, utils.T("cli.license.critical"))
|
||||
assert.Contains(t, actual, i18n.T("cli.license.critical"))
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v5/api4"
|
||||
"github.com/mattermost/mattermost-server/v5/model"
|
||||
"github.com/mattermost/mattermost-server/v5/utils"
|
||||
"github.com/mattermost/mattermost-server/v5/shared/i18n"
|
||||
"github.com/mattermost/mattermost-server/v5/wsapi"
|
||||
)
|
||||
|
||||
@@ -52,7 +52,7 @@ func webClientTestsCmdF(command *cobra.Command, args []string) error {
|
||||
}
|
||||
defer a.Srv().Shutdown()
|
||||
|
||||
utils.InitTranslations(a.Config().LocalizationSettings)
|
||||
i18n.InitTranslations(*a.Config().LocalizationSettings.DefaultServerLocale, *a.Config().LocalizationSettings.DefaultClientLocale)
|
||||
serverErr := a.Srv().Start()
|
||||
if serverErr != nil {
|
||||
return serverErr
|
||||
@@ -73,7 +73,7 @@ func serverForWebClientTestsCmdF(command *cobra.Command, args []string) error {
|
||||
}
|
||||
defer a.Srv().Shutdown()
|
||||
|
||||
utils.InitTranslations(a.Config().LocalizationSettings)
|
||||
i18n.InitTranslations(*a.Config().LocalizationSettings.DefaultServerLocale, *a.Config().LocalizationSettings.DefaultClientLocale)
|
||||
serverErr := a.Srv().Start()
|
||||
if serverErr != nil {
|
||||
return serverErr
|
||||
|
||||
Ссылка в новой задаче
Block a user