Change s_() calls to _() calls

There are no namespaces in the strings so we don't need those
This commit is contained in:
Michał Zając 2019-06-04 09:56:32 +00:00 committed by Rémy Coutable
parent ee01d54a6a
commit e72efed323
7 changed files with 28 additions and 10 deletions

View file

@ -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

View file

@ -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)

View file

@ -1,2 +1,2 @@
%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) }

View file

@ -1,3 +1,3 @@
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)}

View file

@ -0,0 +1,5 @@
---
title: I18n for issue closure reason in emails
merge_request: 28489
author: Michał Zając
type: changed

View file

@ -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 ""
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 ""
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 ""

View file

@ -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
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