Commit cfc70fbe authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '61960-translatable-strings-in-issue-closure-emails' into 'master'

Extract strings to gettext

Closes #61960

See merge request gitlab-org/gitlab-ce!28489
parents ee01d54a e72efed3
...@@ -98,16 +98,17 @@ module EmailsHelper ...@@ -98,16 +98,17 @@ module EmailsHelper
case format case format
when :html when :html
" via merge request #{link_to(merge_request.to_reference, merge_request.web_url)}" merge_request_link = link_to(merge_request.to_reference, merge_request.web_url)
_("via merge request %{link}").html_safe % { link: merge_request_link }
else else
# If it's not HTML nor text then assume it's text to be safe # If it's not HTML nor text then assume it's text to be safe
" via merge request #{merge_request.to_reference} (#{merge_request.web_url})" _("via merge request %{link}") % { link: "#{merge_request.to_reference} (#{merge_request.web_url})" }
end end
when String when String
# Technically speaking this should be Commit but per # Technically speaking this should be Commit but per
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15610#note_163812339 # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15610#note_163812339
# we can't deserialize Commit without custom serializer for ActiveJob # we can't deserialize Commit without custom serializer for ActiveJob
" via #{closed_via}" _("via %{closed_via}") % { closed_via: closed_via }
else else
"" ""
end end
......
...@@ -29,7 +29,7 @@ module Issues ...@@ -29,7 +29,7 @@ module Issues
event_service.close_issue(issue, current_user) event_service.close_issue(issue, current_user)
create_note(issue, closed_via) if system_note create_note(issue, closed_via) if system_note
closed_via = "commit #{closed_via.id}" if closed_via.is_a?(Commit) closed_via = _("commit %{commit_id}") % { commit_id: closed_via.id } if closed_via.is_a?(Commit)
notification_service.async.close_issue(issue, current_user, closed_via: closed_via) if notifications notification_service.async.close_issue(issue, current_user, closed_via: closed_via) if notifications
todo_service.close_issue(issue, current_user) todo_service.close_issue(issue, current_user)
......
%p %p
Issue was closed by #{sanitize_name(@updated_by.name)} #{closure_reason_text(@closed_via, format: formats.first)}. = _("Issue was closed by %{name} %{reason}").html_safe % { name: sanitize_name(@updated_by.name), reason: closure_reason_text(@closed_via, format: formats.first) }
Issue was closed by #{sanitize_name(@updated_by.name)} #{closure_reason_text(@closed_via, format: formats.first)}. = _("Issue was closed by %{name} %{reason}").html_safe % { name: sanitize_name(@updated_by.name), reason: closure_reason_text(@closed_via, format: formats.first) }
Issue ##{@issue.iid}: #{project_issue_url(@issue.project, @issue)} Issue ##{@issue.iid}: #{project_issue_url(@issue.project, @issue)}
---
title: I18n for issue closure reason in emails
merge_request: 28489
author: Michał Zając
type: changed
...@@ -5444,6 +5444,9 @@ msgstr "" ...@@ -5444,6 +5444,9 @@ msgstr ""
msgid "Issue update failed" msgid "Issue update failed"
msgstr "" msgstr ""
msgid "Issue was closed by %{name} %{reason}"
msgstr ""
msgid "IssueBoards|Board" msgid "IssueBoards|Board"
msgstr "" msgstr ""
...@@ -11988,6 +11991,9 @@ msgstr "" ...@@ -11988,6 +11991,9 @@ msgstr ""
msgid "commented on %{link_to_project}" msgid "commented on %{link_to_project}"
msgstr "" msgstr ""
msgid "commit %{commit_id}"
msgstr ""
msgid "confidentiality|You are going to turn off the confidentiality. This means <strong>everyone</strong> will be able to see and leave a comment on this issue." msgid "confidentiality|You are going to turn off the confidentiality. This means <strong>everyone</strong> will be able to see and leave a comment on this issue."
msgstr "" msgstr ""
...@@ -12513,6 +12519,12 @@ msgstr "" ...@@ -12513,6 +12519,12 @@ msgstr ""
msgid "verify ownership" msgid "verify ownership"
msgstr "" msgstr ""
msgid "via %{closed_via}"
msgstr ""
msgid "via merge request %{link}"
msgstr ""
msgid "view it on GitLab" msgid "view it on GitLab"
msgstr "" msgstr ""
......
...@@ -8,19 +8,19 @@ describe EmailsHelper do ...@@ -8,19 +8,19 @@ describe EmailsHelper do
context "and format is text" do context "and format is text" do
it "returns plain text" do it "returns plain text" do
expect(closure_reason_text(merge_request, format: :text)).to eq(" via merge request #{merge_request.to_reference} (#{merge_request_presenter.web_url})") expect(closure_reason_text(merge_request, format: :text)).to eq("via merge request #{merge_request.to_reference} (#{merge_request_presenter.web_url})")
end end
end end
context "and format is HTML" do context "and format is HTML" do
it "returns HTML" do it "returns HTML" do
expect(closure_reason_text(merge_request, format: :html)).to eq(" via merge request #{link_to(merge_request.to_reference, merge_request_presenter.web_url)}") expect(closure_reason_text(merge_request, format: :html)).to eq("via merge request #{link_to(merge_request.to_reference, merge_request_presenter.web_url)}")
end end
end end
context "and format is unknown" do context "and format is unknown" do
it "returns plain text" do it "returns plain text" do
expect(closure_reason_text(merge_request, format: :text)).to eq(" via merge request #{merge_request.to_reference} (#{merge_request_presenter.web_url})") expect(closure_reason_text(merge_request, format: :text)).to eq("via merge request #{merge_request.to_reference} (#{merge_request_presenter.web_url})")
end end
end end
end end
...@@ -29,7 +29,7 @@ describe EmailsHelper do ...@@ -29,7 +29,7 @@ describe EmailsHelper do
let(:closed_via) { "5a0eb6fd7e0f133044378c662fcbbc0d0c16dbfa" } let(:closed_via) { "5a0eb6fd7e0f133044378c662fcbbc0d0c16dbfa" }
it "returns plain text" do it "returns plain text" do
expect(closure_reason_text(closed_via)).to eq(" via #{closed_via}") expect(closure_reason_text(closed_via)).to eq("via #{closed_via}")
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment