Skip to content

Commit

Permalink
Move text into locale files
Browse files Browse the repository at this point in the history
- english only at this point
- simplify brexit_hub_page presenter
  • Loading branch information
hannako committed May 28, 2021
1 parent 7a43806 commit d526d58
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
29 changes: 13 additions & 16 deletions app/presenters/content_item/brexit_hub_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,21 @@ module BrexitHubPage
BREXIT_BUSINESS_PAGE_PATH = "/guidance/brexit-guidance-for-businesses".freeze
BREXIT_CITIZEN_PAGE_PATH = "/guidance/brexit-guidance-for-individuals-and-families".freeze

def brexit_hub_page?
BREXIT_HUB_PAGE_CONTENT_IDS.include?(content_item.dig("content_id"))
def brexit_links
{
ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_CONTENT_ID => {
text: I18n.t("brexit.citizen_link"),
path: BREXIT_CITIZEN_PAGE_PATH,
},
ContentItem::BrexitHubPage::BREXIT_CITIZEN_PAGE_CONTENT_ID => {
text: I18n.t("brexit.business_link"),
path: BREXIT_BUSINESS_PAGE_PATH,
},
}
end

def brexit_business_page?
BREXIT_BUSINESS_PAGE_CONTENT_ID == content_item.dig("content_id")
end

def brexit_citizen_page?
BREXIT_CITIZEN_PAGE_CONTENT_ID == content_item.dig("content_id")
end

def brexit_citizen_page
BREXIT_CITIZEN_PAGE_PATH
end

def brexit_business_page
BREXIT_BUSINESS_PAGE_PATH
def brexit_link
brexit_links[content_item.dig("content_id")]
end
end
end
16 changes: 7 additions & 9 deletions app/views/content_items/detailed_guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<% title_and_context = @content_item.brexit_hub_page? ? { title: @content_item.title } : @content_item.title_and_context %>
<% title_and_context = @content_item.brexit_link ? { title: @content_item.title } : @content_item.title_and_context %>
<%= render 'govuk_publishing_components/components/title', title_and_context %>
</div>
<%= render 'shared/translations' %>
<div class="govuk-grid-column-two-thirds">
<% if @content_item.brexit_hub_page? %>
<% if @content_item.brexit_link %>
<div class="govuk-body-l govuk-!-margin-bottom-7">
<% link_text = @content_item.brexit_citizen_page? ? "Brexit guidance for businesses" : "Brexit guidance for individuals and families" %>
<% link_path = @content_item.brexit_citizen_page? ? @content_item.brexit_business_page : @content_item.brexit_citizen_page %>
<p class="govuk-body">
There's different <%= link_to link_text, link_path %>.
<%= I18n.t("brexit.heading_prefix") %> <%= link_to @content_item.brexit_link[:text], @content_item.brexit_link[:path] %>.
</p>
</div>
<% else %>
Expand All @@ -25,7 +23,7 @@
</div>
</div>

<%= render 'shared/publisher_metadata_with_logo' unless @content_item.brexit_hub_page? %>
<%= render 'shared/publisher_metadata_with_logo' unless @content_item.brexit_link %>
<%= render 'shared/history_notice', content_item: @content_item %>
<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>

Expand All @@ -37,7 +35,7 @@
<%= render "govuk_publishing_components/components/print_link", {
margin_top: 0,
margin_bottom: 6,
} unless @content_item.brexit_hub_page? %>
} unless @content_item.brexit_link %>

<%= render 'govuk_publishing_components/components/govspeak', {} do %>
<%= raw(@content_item.govspeak_body[:content]) %>
Expand All @@ -48,13 +46,13 @@
published: @content_item.published,
last_updated: @content_item.updated,
history: @content_item.history
} unless @content_item.brexit_hub_page? %>
} unless @content_item.brexit_link %>
</div>
<% end %>
<%= render "govuk_publishing_components/components/print_link", {
margin_top: 0,
margin_bottom: 6,
} unless @content_item.brexit_hub_page? %>
} unless @content_item.brexit_link %>
</div>
<%= render 'shared/sidebar_navigation' %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<% unless @do_not_show_breadcrumbs %>
<% if @content_item.try(:back_link) %>
<%= render 'govuk_publishing_components/components/back_link', href: @content_item.back_link %>
<% elsif @content_item.brexit_hub_page? %>
<% elsif @content_item.brexit_link %>
<%= render 'govuk_publishing_components/components/breadcrumbs', breadcrumbs: [ { url: "/", title: "Home" } , { url: "/transition", title: "Brexit" } ] %>
<% else %>
<%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.content_item.parsed_content %>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ en:
written_statement:
one: Written statement to Parliament
other: Written statements to Parliament
brexit:
heading_prefix: There’s different
business_link: Brexit guidance for businesses
citizen_link: Brexit guidance for individuals and families
corporate_information_page:
about_our_services_html: Find out %{link}.
corporate_information: Corporate information
Expand Down

0 comments on commit d526d58

Please sign in to comment.