Skip to content

Commit

Permalink
Translate correctly Welsh published date
Browse files Browse the repository at this point in the history
Remove the hardcoded locale from `display_date` method
  • Loading branch information
catalinailie committed Nov 27, 2024
1 parent a80cbb3 commit 74979b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/presenters/content_item_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def voting_is_open?
end

def display_date(timestamp, format = "%-d %B %Y")
I18n.l(Time.zone.parse(timestamp), format:, locale: "en") if timestamp
I18n.l(Time.zone.parse(timestamp), format:, locale:) if timestamp
end

def sorted_locales(translations)
Expand Down
14 changes: 14 additions & 0 deletions test/integration/publication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,18 @@ class PublicationTest < ActionDispatch::IntegrationTest
setup_and_visit_content_item("publication-with-featured-attachments", overrides)
assert page.has_css?('meta[name="robots"][content="noindex"]', visible: false)
end

test "translates Welsh published date correctly" do
setup_and_visit_content_item("publication", { "locale" => "cy" })

assert_has_metadata({
published: "3 Mai 2016",
from: {
"Environment Agency": "/government/organisations/environment-agency",
"The Rt Hon Sir Eric Pickles MP": "/government/people/eric-pickles",
},
})

assert_footer_has_published_dates("Cyhoeddwyd ar 3 Mai 2016")
end
end

0 comments on commit 74979b8

Please sign in to comment.