MM-46577: Remove empty translation strings (#20876)

We replace the empty translation key with <untranslated>
which is ignored by the translation check tool.

https://mattermost.atlassian.net/browse/MM-46577

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2022-08-25 19:59:16 +05:30
коммит произвёл GitHub
родитель e8a45a8cf7
Коммит c72e9131f4
16 изменённых файлов: 29 добавлений и 116 удалений

Просмотреть файл

@@ -330,11 +330,11 @@ app-layers: ## Extract interface from App struct
$(GO) run ./app/layer_generators -in ./app/app_iface.go -out ./app/opentracing/opentracing_layer.go -template ./app/layer_generators/opentracing_layer.go.tmpl
i18n-extract: ## Extract strings for translation from the source code
$(GO) install github.com/mattermost/mattermost-utilities/mmgotool@v0.0.0-20210721133912-8b250bf4d0f6
$(GO) install github.com/mattermost/mattermost-utilities/mmgotool@fdf2cd651b261bcd511a32da33dd76febedd44a8
$(GOBIN)/mmgotool i18n extract --portal-dir=""
i18n-check: ## Exit on empty translation strings and translation source strings
$(GO) install github.com/mattermost/mattermost-utilities/mmgotool@v0.0.0-20210721133912-8b250bf4d0f6
$(GO) install github.com/mattermost/mattermost-utilities/mmgotool@fdf2cd651b261bcd511a32da33dd76febedd44a8
$(GOBIN)/mmgotool i18n clean-empty --portal-dir="" --check
$(GOBIN)/mmgotool i18n check-empty-src --portal-dir=""

Просмотреть файл

@@ -214,7 +214,7 @@ func minimumProfessionalLicense(f handlerFunc) handlerFunc {
return func(c *Context, w http.ResponseWriter, r *http.Request) {
lic := c.App.Srv().License()
if lic == nil || (lic.SkuShortName != model.LicenseShortSkuProfessional && lic.SkuShortName != model.LicenseShortSkuEnterprise) {
c.Err = model.NewAppError("", "api.license_error.professional_or_enterprise", nil, "", http.StatusNotImplemented)
c.Err = model.NewAppError("", model.NoTranslation, nil, "license is neither professional nor enterprise", http.StatusNotImplemented)
return
}
f(c, w, r)
@@ -224,7 +224,7 @@ func minimumProfessionalLicense(f handlerFunc) handlerFunc {
func rejectGuests(f handlerFunc) handlerFunc {
return func(c *Context, w http.ResponseWriter, r *http.Request) {
if c.AppContext.Session().Props[model.SessionPropIsGuest] == "true" {
c.Err = model.NewAppError("", "api.authorization_error.guest", nil, "", http.StatusNotImplemented)
c.Err = model.NewAppError("", model.NoTranslation, nil, "insufficient permissions as a guest user", http.StatusNotImplemented)
return
}
f(c, w, r)

Просмотреть файл

@@ -3255,7 +3255,7 @@ func updateReadStateAllThreadsByUser(c *Context, w http.ResponseWriter, r *http.
func getUsersWithInvalidEmails(c *Context, w http.ResponseWriter, r *http.Request) {
if *c.App.Config().TeamSettings.EnableOpenServer {
c.Err = model.NewAppError("GetUsersWithInvalidEmails", "api.users.invalid_emails.enable_open_server.app_error", nil, "", http.StatusBadRequest)
c.Err = model.NewAppError("GetUsersWithInvalidEmails", model.NoTranslation, nil, "TeamSettings.EnableOpenServer is enabled", http.StatusBadRequest)
return
}

Просмотреть файл

@@ -255,29 +255,29 @@ func (a *App) GetLatestVersion(latestVersionUrl string) (*model.GithubReleaseInf
res, err := http.Get(latestVersionUrl)
if err != nil {
return nil, model.NewAppError("GetLatestVersion", "app.admin.latest_version_external_error.failure", nil, "", http.StatusInternalServerError)
return nil, model.NewAppError("GetLatestVersion", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
defer res.Body.Close()
responseData, err := io.ReadAll(res.Body)
if err != nil {
return nil, model.NewAppError("GetLatestVersion", "app.admin.latest_version_read_all.failure", nil, "", http.StatusInternalServerError)
return nil, model.NewAppError("GetLatestVersion", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
var releaseInfoResponse *model.GithubReleaseInfo
err = json.Unmarshal(responseData, &releaseInfoResponse)
if err != nil {
return nil, model.NewAppError("GetLatestVersion", "app.admin.latest_version_unmarshal.failure", nil, "", http.StatusInternalServerError)
return nil, model.NewAppError("GetLatestVersion", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
if validErr := releaseInfoResponse.IsValid(); validErr != nil {
return nil, model.NewAppError("GetLatestVersion", "app.admin.latest_version_external_error.failure", nil, "", http.StatusInternalServerError)
return nil, model.NewAppError("GetLatestVersion", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(validErr)
}
err = latestVersionCache.Set("latest_version_cache", releaseInfoResponse)
if err != nil {
return nil, model.NewAppError("GetLatestVersion", "app.admin.latest_version_set_cache.failure", nil, "", http.StatusInternalServerError)
return nil, model.NewAppError("GetLatestVersion", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return releaseInfoResponse, nil

Просмотреть файл

@@ -84,8 +84,7 @@ func TestGetLatestVersion(t *testing.T) {
}))
defer ts.Close()
_, err := th.App.GetLatestVersion(errorServer.URL)
require.NotNil(t, err)
require.Equal(t, "app.admin.latest_version_external_error.failure", err.Id)
_, appErr := th.App.GetLatestVersion(errorServer.URL)
require.NotNil(t, appErr)
})
}

Просмотреть файл

@@ -3416,7 +3416,7 @@ func (a *App) GetTopChannelsForTeamSince(c request.CTX, teamID, userID string, o
topChannels, err := a.Srv().Store.Channel().GetTopChannelsForTeamSince(teamID, userID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage)
if err != nil {
return nil, model.NewAppError("GetTopChannelsForTeamSince", "app.channel.get_top_for_team_since.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return nil, model.NewAppError("GetTopChannelsForTeamSince", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return topChannels, nil
}
@@ -3428,7 +3428,7 @@ func (a *App) GetTopChannelsForUserSince(c request.CTX, userID, teamID string, o
topChannels, err := a.Srv().Store.Channel().GetTopChannelsForUserSince(userID, teamID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage)
if err != nil {
return nil, model.NewAppError("GetTopChannelsForUserSince", "app.channel.get_top_for_user_since.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return nil, model.NewAppError("GetTopChannelsForUserSince", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return topChannels, nil
}
@@ -3444,7 +3444,7 @@ func (a *App) PostCountsByDuration(c request.CTX, channelIDs []string, sinceUnix
}
postCountByDay, err := a.Srv().Store.Channel().PostCountsByDuration(channelIDs, sinceUnixMillis, userID, grouping, groupingLocation)
if err != nil {
return nil, model.NewAppError("PostCountsByDuration", "app.channel.get_post_count_by_day.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return nil, model.NewAppError("PostCountsByDuration", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return postCountByDay, nil
}
@@ -3455,7 +3455,7 @@ func (a *App) GetTopInactiveChannelsForTeamSince(c request.CTX, teamID, userID s
}
topChannels, err := a.Srv().Store.Channel().GetTopInactiveChannelsForTeamSince(teamID, userID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage)
if err != nil {
return nil, model.NewAppError("GetTopInactiveChannelsForTeamSince", "app.channel.get_top_invalid_for_team_since.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, model.NewAppError("GetTopInactiveChannelsForTeamSince", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return topChannels, nil
}
@@ -3467,7 +3467,7 @@ func (a *App) GetTopInactiveChannelsForUserSince(c request.CTX, teamID, userID s
topChannels, err := a.Srv().Store.Channel().GetTopInactiveChannelsForUserSince(teamID, userID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage)
if err != nil {
return nil, model.NewAppError("GetTopInactiveChannelsForUserSince", "app.channel.get_top_invalid_for_user_since.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, model.NewAppError("GetTopInactiveChannelsForUserSince", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return topChannels, nil
}

Просмотреть файл

@@ -6,6 +6,7 @@ package app
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"github.com/mattermost/mattermost-server/v6/model"
@@ -113,10 +114,10 @@ func (a *App) isUniqueToUsernames(val string) *model.AppError {
var notFoundErr *store.ErrNotFound
user, err := a.Srv().Store.User().GetByUsername(val)
if err != nil && !errors.As(err, &notFoundErr) {
return model.NewAppError("", "app.group.get_by_username_failure", nil, "", http.StatusInternalServerError).Wrap(err)
return model.NewAppError("isUniqueToUsernames", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
if user != nil {
return model.NewAppError("", "app.group.username_conflict", nil, "", http.StatusBadRequest)
return model.NewAppError("isUniqueToUsernames", model.NoTranslation, nil, fmt.Sprintf("user name %s exists", val), http.StatusBadRequest)
}
return nil
}

Просмотреть файл

@@ -93,7 +93,6 @@ func TestCreateGroup(t *testing.T) {
}
g, err = th.App.CreateGroup(usernameGroup)
require.NotNil(t, err)
require.Equal(t, "app.group.username_conflict", err.Id)
require.Nil(t, g)
}
@@ -111,7 +110,6 @@ func TestUpdateGroup(t *testing.T) {
g.Name = &user.Username
g, err = th.App.UpdateGroup(g)
require.NotNil(t, err)
require.Equal(t, "app.group.username_conflict", err.Id)
require.Nil(t, g)
}

Просмотреть файл

@@ -1959,12 +1959,12 @@ func (a *App) SetPostReminder(postID, userID string, targetTime int64) *model.Ap
}
err := a.Srv().Store.Post().SetPostReminder(reminder)
if err != nil {
return model.NewAppError("SetPostReminder", "app.post_reminder.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return model.NewAppError("SetPostReminder", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
metadata, err := a.Srv().Store.Post().GetPostReminderMetadata(postID)
if err != nil {
return model.NewAppError("SetPostReminder", "app.post_reminder.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return model.NewAppError("SetPostReminder", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
parsed := time.Unix(targetTime, 0).UTC().Format(time.RFC822)

Просмотреть файл

@@ -103,7 +103,7 @@ func (a *App) GetTopReactionsForTeamSince(teamID string, userID string, opts *mo
topReactionList, err := a.Srv().Store.Reaction().GetTopForTeamSince(teamID, userID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage)
if err != nil {
return nil, model.NewAppError("GetTopReactionsForTeamSince", "app.reaction.get_top_for_team_since.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return nil, model.NewAppError("GetTopReactionsForTeamSince", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return topReactionList, nil
}
@@ -115,7 +115,7 @@ func (a *App) GetTopReactionsForUserSince(userID string, teamID string, opts *mo
topReactionList, err := a.Srv().Store.Reaction().GetTopForUserSince(userID, teamID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage)
if err != nil {
return nil, model.NewAppError("GetTopReactionsForUserSince", "app.reaction.get_top_for_user_since.app_error", nil, "", http.StatusInternalServerError).Wrap(err)
return nil, model.NewAppError("GetTopReactionsForUserSince", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return topReactionList, nil
}

Просмотреть файл

@@ -2141,7 +2141,7 @@ func (a *App) GetNewTeamMembersSince(c request.CTX, teamID string, opts *model.I
ntms, count, err := a.Srv().Store.Team().GetNewTeamMembersSince(teamID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage)
if err != nil {
return nil, 0, model.NewAppError("GetNewTeamMembersSince", "app.post.get_new_team_members_since.app_error", nil, err.Error(), http.StatusInternalServerError)
return nil, 0, model.NewAppError("GetNewTeamMembersSince", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
return ntms, count, nil

Просмотреть файл

@@ -1102,10 +1102,10 @@ func (a *App) isUniqueToGroupNames(val string) *model.AppError {
var notFoundErr *store.ErrNotFound
group, err := a.Srv().Store.Group().GetByName(val, model.GroupSearchOpts{})
if err != nil && !errors.As(err, &notFoundErr) {
return model.NewAppError("", "app.user.get_by_name_failure", nil, "", http.StatusInternalServerError).Wrap(err)
return model.NewAppError("isUniqueToGroupNames", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
if group != nil {
return model.NewAppError("", "app.user.group_name_conflict", nil, "", http.StatusBadRequest)
return model.NewAppError("isUniqueToGroupNames", model.NoTranslation, nil, fmt.Sprintf("group name %s exists", val), http.StatusBadRequest)
}
return nil
}

Просмотреть файл

@@ -192,7 +192,6 @@ func TestUpdateUser(t *testing.T) {
user.Username = *group.Name
u, err := th.App.UpdateUser(th.Context, user, false)
require.NotNil(t, err)
require.Equal(t, "app.user.group_name_conflict", err.Id)
require.Nil(t, u)
})
}
@@ -246,7 +245,6 @@ func TestCreateUser(t *testing.T) {
user.Username = *group.Name
u, err := th.App.CreateUser(th.Context, user)
require.NotNil(t, err)
require.Equal(t, "app.user.group_name_conflict", err.Id)
require.Nil(t, u)
})

Просмотреть файл

@@ -187,10 +187,6 @@
"id": "api.admin.upload_brand_image.too_large.app_error",
"translation": "Unable to upload file. File is too large."
},
{
"id": "api.authorization_error.guest",
"translation": " "
},
{
"id": "api.back_to_app",
"translation": "Back to {{.SiteName}}"
@@ -2073,10 +2069,6 @@
"id": "api.license_error",
"translation": "api endpoint requires a license"
},
{
"id": "api.license_error.professional_or_enterprise",
"translation": " "
},
{
"id": "api.marshal_error",
"translation": "Failed to marshal."
@@ -4411,10 +4403,6 @@
"id": "api.user.view_archived_channels.get_users_in_channel.app_error",
"translation": "Cannot retrieve users for an archived channel"
},
{
"id": "api.users.invalid_emails.enable_open_server.app_error",
"translation": " "
},
{
"id": "api.web_socket.connect.upgrade.app_error",
"translation": "Failed to upgrade websocket connection."
@@ -4471,22 +4459,6 @@
"id": "api.websocket_handler.server_busy.app_error",
"translation": "Server is busy, non-critical services are temporarily unavailable."
},
{
"id": "app.admin.latest_version_external_error.failure",
"translation": " "
},
{
"id": "app.admin.latest_version_read_all.failure",
"translation": " "
},
{
"id": "app.admin.latest_version_set_cache.failure",
"translation": " "
},
{
"id": "app.admin.latest_version_unmarshal.failure",
"translation": " "
},
{
"id": "app.admin.saml.failure_decode_metadata_xml_from_idp.app_error",
"translation": "Could not decode the XML metadata information received from the Identity Provider."
@@ -4707,10 +4679,6 @@
"id": "app.channel.get_pinnedpost_count.app_error",
"translation": "Unable to get the channel pinned post count."
},
{
"id": "app.channel.get_post_count_by_day.app_error",
"translation": " "
},
{
"id": "app.channel.get_private_channels.get.app_error",
"translation": "Unable to get private channels."
@@ -4719,22 +4687,6 @@
"id": "app.channel.get_public_channels.get.app_error",
"translation": "Unable to get public channels."
},
{
"id": "app.channel.get_top_for_team_since.app_error",
"translation": " "
},
{
"id": "app.channel.get_top_for_user_since.app_error",
"translation": " "
},
{
"id": "app.channel.get_top_invalid_for_team_since.app_error",
"translation": " "
},
{
"id": "app.channel.get_top_invalid_for_user_since.app_error",
"translation": " "
},
{
"id": "app.channel.get_unread.app_error",
"translation": "Unable to get the channel unread messages."
@@ -5047,10 +4999,6 @@
"id": "app.group.crud_permission",
"translation": "Unable to perform operation for that source type."
},
{
"id": "app.group.get_by_username_failure",
"translation": " "
},
{
"id": "app.group.group_syncable_already_deleted",
"translation": "group syncable was already deleted"
@@ -5071,10 +5019,6 @@
"id": "app.group.uniqueness_error",
"translation": "group member already exists"
},
{
"id": "app.group.username_conflict",
"translation": " "
},
{
"id": "app.import.attachment.bad_file.error",
"translation": "Error reading the file at: \"{{.FilePath}}\""
@@ -6043,10 +5987,6 @@
"id": "app.post.get_flagged_posts.app_error",
"translation": "Unable to get the flagged posts."
},
{
"id": "app.post.get_new_team_members_since.app_error",
"translation": " "
},
{
"id": "app.post.get_post_after_time.app_error",
"translation": "Unable to get post after time bound."
@@ -6123,10 +6063,6 @@
"id": "app.post.update.app_error",
"translation": "Unable to update the Post."
},
{
"id": "app.post_reminder.app_error",
"translation": " "
},
{
"id": "app.post_reminder_dm",
"translation": "Hi there, here's your reminder about this message from @{{.Username}}: {{.SiteURL}}/{{.TeamName}}/pl/{{.PostId}}"
@@ -6171,14 +6107,6 @@
"id": "app.reaction.get_for_post.app_error",
"translation": "Unable to get reactions for post."
},
{
"id": "app.reaction.get_top_for_team_since.app_error",
"translation": " "
},
{
"id": "app.reaction.get_top_for_user_since.app_error",
"translation": " "
},
{
"id": "app.reaction.save.save.app_error",
"translation": "Unable to save reaction."
@@ -6651,10 +6579,6 @@
"id": "app.user.get_by_auth.other.app_error",
"translation": "We encountered an error trying to find the account by authentication type."
},
{
"id": "app.user.get_by_name_failure",
"translation": " "
},
{
"id": "app.user.get_by_username.app_error",
"translation": "Unable to find an existing account matching your username for this team. This team may require an invite from the team owner to join."
@@ -6711,10 +6635,6 @@
"id": "app.user.get_users_batch_for_indexing.get_users.app_error",
"translation": "Unable to get the users batch for indexing."
},
{
"id": "app.user.group_name_conflict",
"translation": " "
},
{
"id": "app.user.missing_account.const",
"translation": "Unable to find the user."
@@ -8659,10 +8579,6 @@
"id": "model.file_info.is_valid.user_id.app_error",
"translation": "Invalid value for user_id."
},
{
"id": "model.github_release_info.is_valid.id.app_error",
"translation": " "
},
{
"id": "model.group.create_at.app_error",
"translation": "invalid create at property for group."

Просмотреть файл

@@ -19,7 +19,7 @@ type GithubReleaseInfo struct {
func (g *GithubReleaseInfo) IsValid() *AppError {
if g.Id == 0 {
return NewAppError("GithubReleaseInfo.IsValid", "model.github_release_info.is_valid.id.app_error", nil, "", http.StatusInternalServerError)
return NewAppError("GithubReleaseInfo.IsValid", NoTranslation, nil, "empty ID", http.StatusInternalServerError)
}
return nil

Просмотреть файл

@@ -33,6 +33,7 @@ const (
NUMBERS = "0123456789"
SYMBOLS = " !\"\\#$%&'()*+,-./:;<=>?@[]^_`|~"
BinaryParamKey = "MM_BINARY_PARAMETERS"
NoTranslation = "<untranslated>"
)
type StringInterface map[string]any