From: Andy Allan Date: Wed, 29 Mar 2023 16:07:03 +0000 (+0100) Subject: Rework note events to avoid raw html in translations X-Git-Tag: live~811^2 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/fad3aedbbb9f9e35a636f27da7c314900def9d67 Rework note events to avoid raw html in translations --- diff --git a/app/helpers/note_helper.rb b/app/helpers/note_helper.rb index 86e5c40f8..42fd089e4 100644 --- a/app/helpers/note_helper.rb +++ b/app/helpers/note_helper.rb @@ -3,13 +3,13 @@ module NoteHelper def note_event(event, at, by) if by.nil? - t("notes.show.#{event}_by_anonymous_html", - :when => friendly_date_ago(at), - :exact_time => l(at)) + t("notes.show.event_#{event}_by_anonymous_html", + :time_ago => tag.abbr(friendly_date_ago(at), + :title => l(at))) else - t("notes.show.#{event}_by_html", - :when => friendly_date_ago(at), - :exact_time => l(at), + t("notes.show.event_#{event}_by_html", + :time_ago => tag.abbr(friendly_date_ago(at), + :title => l(at)), :user => note_author(by)) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index afc578b69..8e60a9a67 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2880,15 +2880,15 @@ en: open_title: "Unresolved note #%{note_name}" closed_title: "Resolved note #%{note_name}" hidden_title: "Hidden note #%{note_name}" - opened_by_html: "Created by %{user} %{when}" - opened_by_anonymous_html: "Created by anonymous %{when}" - commented_by_html: "Comment from %{user} %{when}" - commented_by_anonymous_html: "Comment from anonymous %{when}" - closed_by_html: "Resolved by %{user} %{when}" - closed_by_anonymous_html: "Resolved by anonymous %{when}" - reopened_by_html: "Reactivated by %{user} %{when}" - reopened_by_anonymous_html: "Reactivated by anonymous %{when}" - hidden_by_html: "Hidden by %{user} %{when}" + event_opened_by_html: "Created by %{user} %{time_ago}" + event_opened_by_anonymous_html: "Created by anonymous %{time_ago}" + event_commented_by_html: "Comment from %{user} %{time_ago}" + event_commented_by_anonymous_html: "Comment from anonymous %{time_ago}" + event_closed_by_html: "Resolved by %{user} %{time_ago}" + event_closed_by_anonymous_html: "Resolved by anonymous %{time_ago}" + event_reopened_by_html: "Reactivated by %{user} %{time_ago}" + event_reopened_by_anonymous_html: "Reactivated by anonymous %{time_ago}" + event_hidden_by_html: "Hidden by %{user} %{time_ago}" report: report this note coordinates_html: "%{latitude}, %{longitude}" anonymous_warning: This note includes comments from anonymous users which should be independently verified. diff --git a/test/helpers/note_helper_test.rb b/test/helpers/note_helper_test.rb index d5f3021fb..75a0e521e 100644 --- a/test/helpers/note_helper_test.rb +++ b/test/helpers/note_helper_test.rb @@ -8,8 +8,8 @@ class NoteHelperTest < ActionView::TestCase date = Time.new(2014, 3, 5, 21, 37, 45, "+00:00") user = create(:user) - assert_match %r{^Created by anonymous .* ago$}, note_event("opened", date, nil) - assert_match %r{^Resolved by #{user.display_name} .* ago$}, note_event("closed", date, user) + assert_match %r{^Created by anonymous .* ago$}, note_event("opened", date, nil) + assert_match %r{^Resolved by #{user.display_name} .* ago$}, note_event("closed", date, user) end def test_note_author