From 20171564e8e23470ad203021ecdf4ae87e13316a Mon Sep 17 00:00:00 2001 From: Max Lehmann Date: Tue, 16 Jul 2019 10:25:43 +0000 Subject: [PATCH] Force English for metadata On translated pages we are largely failing to translate the metadata, leading to messy strings where the only translated content is the month or the word "and" amongst otherwise English sentences. This change sets the locale to English for the dates, and reverts attempts to translate other sections of the page, and it marks the components as being in English. It removes classnames that aren't used from the CSS and forces the text direction to be left-to-right for these components. This marks the page up more semantically, and supports a better experience for screenreader users as they can now context switch the language appropriately. --- .../stylesheets/components/_published-dates.scss | 1 + .../components/_publisher-metadata.scss | 15 +-------------- app/presenters/content_item_presenter.rb | 2 +- app/views/components/_published-dates.html.erb | 11 +++++------ app/views/components/_publisher-metadata.html.erb | 12 +++++------- 5 files changed, 13 insertions(+), 28 deletions(-) diff --git a/app/assets/stylesheets/components/_published-dates.scss b/app/assets/stylesheets/components/_published-dates.scss index 2b96a7ea2..a07ea7658 100644 --- a/app/assets/stylesheets/components/_published-dates.scss +++ b/app/assets/stylesheets/components/_published-dates.scss @@ -1,5 +1,6 @@ .app-c-published-dates { @include core-16; + direction: ltr; } .app-c-published-dates__toggle { diff --git a/app/assets/stylesheets/components/_publisher-metadata.scss b/app/assets/stylesheets/components/_publisher-metadata.scss index d18d9afc9..168167b9e 100644 --- a/app/assets/stylesheets/components/_publisher-metadata.scss +++ b/app/assets/stylesheets/components/_publisher-metadata.scss @@ -1,6 +1,7 @@ .app-c-publisher-metadata { @include responsive-bottom-margin; @include core-16; + direction: ltr; padding-top: govuk-spacing(3); } @@ -11,20 +12,6 @@ .app-c-publisher-metadata__term { float: left; padding-right: govuk-spacing(1); - - .direction-rtl & { - float: none; - display: inline-block; - padding-right: 0; - padding-left: 5px; - } -} - -.app-c-publisher-metadata__definition { - .direction-rtl & { - float: none; - display: inline-block; - } } .app-c-publisher-metadata__toggle, diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index e2c0e1277..d9c9fd35f 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -80,7 +80,7 @@ def cache_control_public? private def display_date(timestamp, format = "%-d %B %Y") - I18n.l(Time.zone.parse(timestamp), format: format) if timestamp + I18n.l(Time.zone.parse(timestamp), format: format, locale: 'en') if timestamp end def sorted_locales(translations) diff --git a/app/views/components/_published-dates.html.erb b/app/views/components/_published-dates.html.erb index 8cb40b27a..5c3328508 100644 --- a/app/views/components/_published-dates.html.erb +++ b/app/views/components/_published-dates.html.erb @@ -7,21 +7,20 @@ history_class = "app-c-published-dates--history" if history.any? %> <% if published || last_updated %> -
id="history" data-module="toggle"<% end %>> +
id="history" data-module="toggle"<% end %> lang="en"> <% if published %> - <%= t('components.published_dates.published', date: published) %> + Published <%= published %> <% end %> <% if last_updated %> - <% if published %>
<% end %><%= t('components.published_dates.last_updated', date: last_updated) %> + <% if published %>
<% end %>Last updated <%= last_updated %> <% if link_to_history && history.empty? %> - — <%= t('components.published_dates.see_all_updates') %> + — <%= t('components.published_dates.see_all_updates', locale: :en) %> <% elsif history.any? %> + <%= t('components.published_dates.show_all_updates') - %> + data-toggled-text="- <%= t('components.published_dates.hide_all_updates', locale: :en) %>">+ <%= t('components.published_dates.show_all_updates', locale: :en) %>
    <% history.each do |change| %> diff --git a/app/views/components/_publisher-metadata.html.erb b/app/views/components/_publisher-metadata.html.erb index 2bdd34ef1..4a19bf4d1 100644 --- a/app/views/components/_publisher-metadata.html.erb +++ b/app/views/components/_publisher-metadata.html.erb @@ -7,7 +7,7 @@ metadata = [published, last_updated] %> <% if metadata.any? || other_has_values %> -