Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hardcoded strings from controllers, presenters and views #2116

Merged
merged 21 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
03d5930
Remove hardcoded string from Coming Soon view
brucebolt May 24, 2021
8cbe57c
Remove hardcoded strings from Consultation view
brucebolt May 24, 2021
ae25b69
Remove hardcoded strings from Contact view
brucebolt May 24, 2021
d410b6e
Remove hardcoded strings from Gone view
brucebolt May 24, 2021
54f2de9
Remove hardcoded strings from Guide views
brucebolt May 24, 2021
e543865
Remove hardcoded strings from Statistics Announcement view
brucebolt May 24, 2021
f3d6059
Remove hardcoded strings from Travel Advice view
brucebolt May 24, 2021
5ca4459
Remove hardcoded strings from Unpublishing view
brucebolt May 24, 2021
c6df8f9
Remove hardcoded strings from Working Group view
brucebolt May 24, 2021
39afcb9
Remove hardcoded strings from print metadata partial
brucebolt May 24, 2021
dc12497
Remove hardcoded strings from historically political partial
brucebolt May 24, 2021
8a04650
Remove hardcoded strings from webchat partial
brucebolt May 24, 2021
c80bab0
Remove hardcoded strings from Fatality Notice presenter
brucebolt May 24, 2021
180ca48
Remove hardcoded strings from Gone presenter
brucebolt May 24, 2021
e3dbdfc
Remove hardcoded strings from Specialist Document presenter
brucebolt May 24, 2021
8f85f9c
Remove hardcoded strings from Speech presenter
brucebolt May 24, 2021
61c4e7e
Remove hardcoded strings from Statistics Announcement presenter
brucebolt May 24, 2021
1bbf66c
Remove hardcoded strings from Travel Advice presenter
brucebolt May 24, 2021
9756a88
Remove hardcoded strings from Unpublishing presenter
brucebolt May 24, 2021
dd3b76c
Remove hardcoded strings from Working Group presenter
brucebolt May 24, 2021
0ec9f6c
Add placeholder translation keys for all languages
brucebolt May 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/presenters/fatality_notice_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ def field_of_operation
end

def image
{ "url" => view_context.image_url("ministry-of-defence-crest.png"), "alt_text" => "Ministry of Defence crest" }
{ "url" => view_context.image_url("ministry-of-defence-crest.png"), "alt_text" => I18n.t("fatality_notice.alt_text") }
end

def important_metadata
super.tap do |m|
if field_of_operation
m.merge!("Field of operation" => view_context.link_to(field_of_operation.title, field_of_operation.path, class: "govuk-link app-link"))
m.merge!(I18n.t("fatality_notice.field_of_operation") => view_context.link_to(field_of_operation.title, field_of_operation.path, class: "govuk-link app-link"))
end
end
end

def title_and_context
super.tap do |t|
if field_of_operation
t[:context] = "Operations in #{field_of_operation.try(:title)}"
t[:context] = I18n.t("fatality_notice.operations_in", location: field_of_operation.try(:title))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/gone_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def initialize(*args)
end

def page_title
"No longer available"
I18n.t("gone.page_title")
end
end
6 changes: 3 additions & 3 deletions app/presenters/specialist_document_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ def images
{
"protected-designation-of-origin-pdo" => {
"url" => view_context.image_url("protected-food-drink-names/protected-designation-of-origin-pdo.png"),
"alt_text" => "The scheme logo is a black stamp with the words Designated Origin UK Protected",
"alt_text" => I18n.t("specialist_document.pdo_alt_text"),
},
"protected-geographical-indication-pgi" => {
"url" => view_context.image_url("protected-food-drink-names/protected-geographical-indication-pgi.png"),
"alt_text" => "The scheme logo is a black stamp with the words Geographic Origin UK Protected",
"alt_text" => I18n.t("specialist_document.pgi_alt_text"),
},
"traditional-speciality-guaranteed-tsg" => {
"url" => view_context.image_url("protected-food-drink-names/traditional-speciality-guaranteed-tsg.png"),
"alt_text" => "The scheme logo is a black stamp with the words Traditional Speciality UK Protected",
"alt_text" => I18n.t("specialist_document.tsg_alt_text"),
},
}
end
Expand Down
6 changes: 3 additions & 3 deletions app/presenters/speech_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class SpeechPresenter < ContentItemPresenter

def delivery_type
if document_type == "authored_article"
"Written on"
I18n.t("speech.written_on")
else
"Delivered on"
I18n.t("speech.delivered_on")
end
end

Expand All @@ -27,7 +27,7 @@ def from

def important_metadata
super.tap do |m|
m.merge!("Location" => location, delivery_type => delivered_on_metadata)
m.merge!(I18n.t("speech.location") => location, delivery_type => delivered_on_metadata)
end
end

Expand Down
8 changes: 4 additions & 4 deletions app/presenters/statistics_announcement_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class StatisticsAnnouncementPresenter < ContentItemPresenter
include ContentItem::TitleAndContext
include StatisticsAnnouncementHelper

FORTHCOMING_NOTICE = "These statistics will be released".freeze
FORTHCOMING_NOTICE = I18n.t("statistics_announcement.forthcoming").freeze

def release_date
content_item["details"]["display_date"]
Expand All @@ -28,11 +28,11 @@ def important_metadata
super.tap do |m|
if cancelled?
m.merge!(
"Proposed release" => release_date,
"Cancellation date" => cancellation_date,
I18n.t("statistics_announcement.proposed_date") => release_date,
I18n.t("statistics_announcement.cancellation_date") => cancellation_date,
)
else
m.merge!("Release date" => release_date_and_status)
m.merge!(I18n.t("statistics_announcement.release_date") => release_date_and_status)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/presenters/travel_advice_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def metadata
updated_at = content_item["details"]["updated_at"]

other = {
"Still current at" => I18n.l(Time.zone.now, format: "%-d %B %Y"),
"Updated" => display_date(reviewed_at || updated_at),
I18n.t("travel_advice.still_current_at") => I18n.l(Time.zone.now, format: "%-d %B %Y"),
I18n.t("travel_advice.updated") => display_date(reviewed_at || updated_at),
}

other["Latest update"] = view_context.simple_format(latest_update) if latest_update.present?
Expand All @@ -29,7 +29,7 @@ def metadata

def title_and_context
{
context: "Foreign travel advice",
context: I18n.t("travel_advice.context"),
title: country_name,
}
end
Expand Down Expand Up @@ -111,7 +111,7 @@ def raw_parts

def summary_part
{
"title" => "Summary",
"title" => I18n.t("travel_advice.summary"),
"slug" => "",
"body" => content_item["details"]["summary"],
}
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/unpublishing_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ def initialize(*args)
end

def page_title
"No longer available"
I18n.t("unpublishing.page_title")
end
end
4 changes: 2 additions & 2 deletions app/presenters/working_group_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def title_and_context

def extra_headings
extra_headings = []
extra_headings << { id: "policies", text: "Policies" } if policies.any?
extra_headings << { id: "contact-details", text: "Contact details" } if email.present?
extra_headings << { id: "policies", text: I18n.t("working_group.policies") } if policies.any?
extra_headings << { id: "contact-details", text: I18n.t("working_group.contact_details") } if email.present?
extra_headings
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/coming_soon.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= render 'govuk_publishing_components/components/title', title: 'Coming soon' %>

<p class="summary">
This document will be published on<br />
<%= t("content_item.coming_soon") %><br />
<%= content_tag(:time, class: 'publish_time', datetime: @content_item.iso8601_publish_time) do %>
<%= @content_item.formatted_publish_date + " at " + @content_item.formatted_publish_time %>
<% end %>
Expand Down
44 changes: 22 additions & 22 deletions app/views/content_items/consultation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@

<% if @content_item.unopened? %>
<% content_item_unopened = capture do %>
This consultation opens
<% if @content_item.opening_date_midnight? %>on<% else %>at<% end %>
<%= t("consultation.opens") %>
<%= @content_item.opening_date_midnight? ? t("consultation.on") : t("consultation.at") %>
<time datetime="<%= @content_item.opening_date_time %>"><%= @content_item.opening_date %></time>
<% end %>
<%= render 'govuk_publishing_components/components/notice', {
title: "This consultation isn't open yet",
title: t("consultation.not_open_yet"),
description_text: content_item_unopened,
} %>

<% elsif @content_item.pending_final_outcome? %>
<% content_item_final_outcome = capture do %>
Visit this page again soon to download the outcome to this public&nbsp;feedback.
<%= t("consultation.visit_soon") %>
<% end %>
<%= render 'govuk_publishing_components/components/notice',
title: 'We are analysing your feedback',
Expand All @@ -44,11 +44,11 @@
<%= render 'govuk_publishing_components/components/notice', title: 'This consultation has concluded' %>

<%= render "attachments",
title: "Download the full outcome",
title: t("consultation.download_outcome"),
legacy_pre_rendered_documents: @content_item.final_outcome_documents,
attachments: @content_item.final_outcome_attachments %>

<%= render 'govuk_publishing_components/components/heading', text: "Detail of outcome", mobile_top_margin: true %>
<%= render 'govuk_publishing_components/components/heading', text: t("consultation.detail_of_outcome"), mobile_top_margin: true %>
<div class="consultation-outcome-detail">
<%= render 'govuk_publishing_components/components/govspeak', {
direction: page_text_direction,
Expand All @@ -59,14 +59,14 @@
<% end %>

<%= render "attachments",
title: "Feedback received",
title: t("consultation.feedback_received"),
legacy_pre_rendered_documents: @content_item.public_feedback_documents,
attachments: @content_item.public_feedback_attachments %>

<% if @content_item.public_feedback_detail %>
<%= render 'govuk_publishing_components/components/heading', {
mobile_top_margin: true,
text: "Detail of feedback received",
text: t("consultation.detail_of_feedback_received"),
} %>
<div class="consultation-feedback">
<%= render 'govuk_publishing_components/components/govspeak', {
Expand All @@ -84,22 +84,22 @@
heading_level: 2,
id: "original-consultation-title",
mobile_top_margin: true,
text: "Original consultation",
text: t("consultation.original_consultation"),
} %>
</header>
<% end %>

<% consultation_date = capture do %>
<% if @content_item.closed? %>
This consultation ran from<br /><span class="consultation-date"><time datetime="<%= @content_item.opening_date_time %>"><%= @content_item.opening_date %></time> to
<%= t("consultation.ran_from") %><br /><span class="consultation-date"><time datetime="<%= @content_item.opening_date_time %>"><%= @content_item.opening_date %></time> to
<time datetime="<%= @content_item.closing_date_time %>"><%= @content_item.closing_date %></time></span>
<% elsif @content_item.open? %>
This consultation closes at<br />
<%= t("consultation.closes_at") %><br />
<span class="consultation-date"><time datetime="<%= @content_item.closing_date_time %>"><%= @content_item.closing_date %></time></span>
<% elsif @content_item.unopened? %>
This consultation opens <% if @content_item.opening_date_midnight? %>on<% else %>at<% end %><br />
<%= t("consultation.opens") %> <%= @content_item.opening_date_midnight? ? t("consultation.on") : t("consultation.at") %><br />
<span class="consultation-date"><time datetime="<%= @content_item.opening_date_time %>"><%= @content_item.opening_date %></time></span><br />
It closes at<br />
<%= t("consultation.closes") %><br />
<span class="consultation-date"><time datetime="<%= @content_item.closing_date_time %>"><%= @content_item.closing_date %></time></span>
<% end %>
<% end %>
Expand All @@ -109,7 +109,7 @@
<% if @content_item.held_on_another_website? %>
<p class="govuk-!-margin-top-2">
<strong>
This consultation <% if @content_item.closed? %>was<% else %>is being<% end %> held on <a href="<%= @content_item.held_on_another_website_url %>">another website</a>.
<%= t("consultation.another_website_html", closed: @content_item.closed? ? t("consultation.was") : t("consultation.is_being"), url: @content_item.held_on_another_website_url) %>.
</strong>
</p>
<% end %>
Expand All @@ -128,26 +128,26 @@
<div class="consultation-description">
<%= render 'govuk_publishing_components/components/heading', {
mobile_top_margin: true,
text: "Consultation description",
text: t("consultation.description"),
} %>

<%= render 'govuk_publishing_components/components/govspeak', {} do %>
<%= raw(@content_item.govspeak_body[:content]) %>
<% end %>

<%= render "attachments",
title: "Documents",
title: t("consultation.documents"),
legacy_pre_rendered_documents: @content_item.documents,
attachments: @content_item.featured_attachments %>
</div>

<% if @content_item.ways_to_respond? %>
<div class="consultation-ways-to-respond">
<%= render 'govuk_publishing_components/components/heading', text: "Ways to respond", mobile_top_margin: true %>
<%= render 'govuk_publishing_components/components/heading', text: t("consultation.ways_to_respond"), mobile_top_margin: true %>
<% @ways_to_respond_body = capture do %>
<% if @content_item.respond_online_url %>
<div class="call-to-action">
<p><%= link_to 'Respond online', @content_item.respond_online_url %></p>
<p><%= link_to t("consultation.respond_online"), @content_item.respond_online_url %></p>
</div>

<% if @content_item.email || @content_item.postal_address %>
Expand All @@ -157,18 +157,18 @@

<% if @content_item.response_form? %>
<p>
Complete a <%= link_to 'response form', @content_item.attachment_url %> and
<% if @content_item.email && @content_item.postal_address %>either<% end %>
<%= t("consultation.complete_a") %> <%= link_to 'response form', @content_item.attachment_url %> <%= t("consultation.and") %>
<%= t("consultation.either") if @content_item.email && @content_item.postal_address %>
</p>
<% end %>

<% if @content_item.email %>
<h3>Email to:</h3>
<h3><%= t("consultation.email_to") %></h3>
<p><%= mail_to @content_item.email, @content_item.email %></p>
<% end %>

<% if @content_item.postal_address %>
<h3>Write to:</h3>
<h3><%= t("consultation.write_to") %></h3>
<div class="contact">
<div class="content">
<%= simple_format(@content_item.postal_address) %>
Expand Down
10 changes: 5 additions & 5 deletions app/views/content_items/contact.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<% body = capture do %>
<% if @content_item.online_form_links.any? %>
<h2 id="online-forms-title">Online</h2>
<h2 id="online-forms-title"><%= t("contact.online") %></h2>
<% @content_item.online_form_links.each do |link| %>
<p>
<%= link_to(link[:title], link[:url]) %>
Expand All @@ -28,12 +28,12 @@
<% end %>

<% if @content_item.show_webchat? %>
<h2 id="webchat-title">Webchat</h2>
<h2 id="webchat-title"><%= t("contact.webchat") %></h2>
<%= render 'shared/webchat' %>
<% end %>

<% if @content_item.email.any? %>
<h2 id="email-title">Email</h2>
<h2 id="email-title"><%= t("contact.email") %></h2>
<% @content_item.email.each do |email_group| %>
<p class="vcard">
<% email_group[:v_card].each do |v_card_part| %>
Expand All @@ -50,7 +50,7 @@
<% end %>

<% if @content_item.phone.any? %>
<h2 id="phone-title">Phone</h2>
<h2 id="phone-title"><%= t("contact.phone") %></h2>
<% @content_item.phone.each do |phone_group| %>
<% if @content_item.phone.size > 1 %>
<h3><%= phone_group[:title] %></h3>
Expand All @@ -77,7 +77,7 @@
<%= @content_item.phone_body %>

<p class="call-charges">
<%= link_to "Find out about call charges", "/call-charges" %>
<%= link_to t("contact.find_call_charges"), "/call-charges" %>
</p>
<% end %>

Expand Down
6 changes: 3 additions & 3 deletions app/views/content_items/gone.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render "govuk_publishing_components/components/title", {
title: "The page you're looking for is no longer available",
title: t("gone.title"),
} %>

<p class="summary">
The information on this page has been removed because it was published in error.
<%= t("gone.published_in_error") %>
</p>

<%= render "govuk_publishing_components/components/govspeak", {} do %>
Expand All @@ -14,7 +14,7 @@

<% if @content_item.alternative_path.present? %>
<p class="alternative">
Visit: <%= alternative_path_link(request, @content_item.alternative_path)%>
<%= t("common.visit") %> <%= alternative_path_link(request, @content_item.alternative_path)%>
</p>
<% end %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/content_items/guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

<% if @content_item.show_guide_navigation? %>
<%= render "govuk_publishing_components/components/skip_link", {
text: "Skip to contents of guide",
text: t("guide.skip_to_contents"),
href: "#guide-contents"
} %>
<aside class="part-navigation-container" role="complementary">
<%= render "govuk_publishing_components/components/contents_list", aria_label: 'Pages in this guide', contents: @content_item.part_link_elements, underline_links: true %>
<%= render "govuk_publishing_components/components/contents_list", aria_label: t("guide.pages_in_guide"), contents: @content_item.part_link_elements, underline_links: true %>
</aside>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/guide_single.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<% if @content_item.show_guide_navigation? %>
<aside class="part-navigation-container" role="complementary">
<%= render "govuk_publishing_components/components/contents_list", aria_label: 'Pages in this guide', contents: @content_item.part_link_elements, underline_links: true %>
<%= render "govuk_publishing_components/components/contents_list", aria_label: t("guide.pages_in_guide"), contents: @content_item.part_link_elements, underline_links: true %>
</aside>
<% end %>
</div>
Expand Down
Loading