Перевод текста сообщений, приходящих в телеграм бот #88 #115

Merged
redex2000 merged 1 commits from sergey_aksenov-patch-1 into dev_mirocod 2 years ago
  1. 34
      services/webhook/general.go

34
services/webhook/general.go

@ -36,36 +36,36 @@ func getIssuesPayloadInfo(p *api.IssuePayload, linkFormatter linkFormatter, with
switch p.Action { switch p.Action {
case api.HookIssueOpened: case api.HookIssueOpened:
text = fmt.Sprintf("[%s] Issue opened: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Задача открыта: %s", repoLink, titleLink)
color = orangeColor color = orangeColor
case api.HookIssueClosed: case api.HookIssueClosed:
text = fmt.Sprintf("[%s] Issue closed: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Задача закрыта: %s", repoLink, titleLink)
color = redColor color = redColor
case api.HookIssueReOpened: case api.HookIssueReOpened:
text = fmt.Sprintf("[%s] Issue re-opened: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Задача вновь открыта: %s", repoLink, titleLink)
case api.HookIssueEdited: case api.HookIssueEdited:
text = fmt.Sprintf("[%s] Issue edited: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Задача отредактирована: %s", repoLink, titleLink)
case api.HookIssueAssigned: case api.HookIssueAssigned:
list := make([]string, len(p.Issue.Assignees)) list := make([]string, len(p.Issue.Assignees))
for i, user := range p.Issue.Assignees { for i, user := range p.Issue.Assignees {
list[i] = linkFormatter(setting.AppURL+url.PathEscape(user.UserName), user.UserName) list[i] = linkFormatter(setting.AppURL+url.PathEscape(user.UserName), user.UserName)
} }
text = fmt.Sprintf("[%s] Issue assigned to %s: %s", repoLink, strings.Join(list, ", "), titleLink) text = fmt.Sprintf("[%s] Задача назначена участику %s: %s", repoLink, strings.Join(list, ", "), titleLink)
color = greenColor color = greenColor
case api.HookIssueUnassigned: case api.HookIssueUnassigned:
text = fmt.Sprintf("[%s] Issue unassigned: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Задача ни кому не назначена: %s", repoLink, titleLink)
case api.HookIssueLabelUpdated: case api.HookIssueLabelUpdated:
text = fmt.Sprintf("[%s] Issue labels updated: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Обновлены метки задачи: %s", repoLink, titleLink)
case api.HookIssueLabelCleared: case api.HookIssueLabelCleared:
text = fmt.Sprintf("[%s] Issue labels cleared: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Удалены метки задачи: %s", repoLink, titleLink)
case api.HookIssueSynchronized: case api.HookIssueSynchronized:
text = fmt.Sprintf("[%s] Issue synchronized: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Задача синхронизирована: %s", repoLink, titleLink)
case api.HookIssueMilestoned: case api.HookIssueMilestoned:
mileStoneLink := fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.Issue.Milestone.ID) mileStoneLink := fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.Issue.Milestone.ID)
text = fmt.Sprintf("[%s] Issue milestoned to %s: %s", repoLink, text = fmt.Sprintf("[%s] Контрольные показатели задачи выданы для %s: %s", repoLink,
linkFormatter(mileStoneLink, p.Issue.Milestone.Title), titleLink) linkFormatter(mileStoneLink, p.Issue.Milestone.Title), titleLink)
case api.HookIssueDemilestoned: case api.HookIssueDemilestoned:
text = fmt.Sprintf("[%s] Issue milestone cleared: %s", repoLink, titleLink) text = fmt.Sprintf("[%s] Контрольная точка задачи устранена: %s", repoLink, titleLink)
} }
if withSender { if withSender {
text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+url.PathEscape(p.Sender.UserName), p.Sender.UserName)) text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+url.PathEscape(p.Sender.UserName), p.Sender.UserName))
@ -145,13 +145,13 @@ func getReleasePayloadInfo(p *api.ReleasePayload, linkFormatter linkFormatter, w
switch p.Action { switch p.Action {
case api.HookReleasePublished: case api.HookReleasePublished:
text = fmt.Sprintf("[%s] Release created: %s", repoLink, refLink) text = fmt.Sprintf("[%s] Созданный релиз: %s", repoLink, refLink)
color = greenColor color = greenColor
case api.HookReleaseUpdated: case api.HookReleaseUpdated:
text = fmt.Sprintf("[%s] Release updated: %s", repoLink, refLink) text = fmt.Sprintf("[%s] Обновленный релиз: %s", repoLink, refLink)
color = yellowColor color = yellowColor
case api.HookReleaseDeleted: case api.HookReleaseDeleted:
text = fmt.Sprintf("[%s] Release deleted: %s", repoLink, refLink) text = fmt.Sprintf("[%s] Удаленный релиз: %s", repoLink, refLink)
color = redColor color = redColor
} }
if withSender { if withSender {
@ -178,16 +178,16 @@ func getIssueCommentPayloadInfo(p *api.IssueCommentPayload, linkFormatter linkFo
switch p.Action { switch p.Action {
case api.HookIssueCommentCreated: case api.HookIssueCommentCreated:
text = fmt.Sprintf("[%s] New comment on %s %s", repoLink, typ, titleLink) text = fmt.Sprintf("[%s] Новый коментарий на %s %s", repoLink, typ, titleLink)
if p.IsPull { if p.IsPull {
color = greenColorLight color = greenColorLight
} else { } else {
color = orangeColorLight color = orangeColorLight
} }
case api.HookIssueCommentEdited: case api.HookIssueCommentEdited:
text = fmt.Sprintf("[%s] Comment edited on %s %s", repoLink, typ, titleLink) text = fmt.Sprintf("[%s] Комментарий изменен на %s %s", repoLink, typ, titleLink)
case api.HookIssueCommentDeleted: case api.HookIssueCommentDeleted:
text = fmt.Sprintf("[%s] Comment deleted on %s %s", repoLink, typ, titleLink) text = fmt.Sprintf("[%s] Комментарий удален на %s %s", repoLink, typ, titleLink)
color = redColor color = redColor
} }
if withSender { if withSender {

Loading…
Cancel
Save