]> git.openstreetmap.org Git - rails.git/commitdiff
Rework note events to avoid raw html in translations
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 29 Mar 2023 16:07:03 +0000 (17:07 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Sun, 2 Apr 2023 09:22:30 +0000 (10:22 +0100)
app/helpers/note_helper.rb
config/locales/en.yml
test/helpers/note_helper_test.rb

index 86e5c40f8d3d8bb3427814a55f93ac84d65bcb37..42fd089e47ef1105b09a4e1a0c5e024044bd4ab4 100644 (file)
@@ -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
index afc578b6940a3bc74fc20637cb4a586901f662db..8e60a9a67f540233d7ff48c545315b26564a4d84 100644 (file)
@@ -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} <abbr title='%{exact_time}'>%{when}</abbr>"
-      opened_by_anonymous_html: "Created by anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
-      commented_by_html: "Comment from %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
-      commented_by_anonymous_html: "Comment from anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
-      closed_by_html: "Resolved by %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
-      closed_by_anonymous_html: "Resolved by anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
-      reopened_by_html: "Reactivated by %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
-      reopened_by_anonymous_html: "Reactivated by anonymous <abbr title='%{exact_time}'>%{when}</abbr>"
-      hidden_by_html: "Hidden by %{user} <abbr title='%{exact_time}'>%{when}</abbr>"
+      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.
index d5f3021fbf6dc97a90920558336d4eef918fdb20..75a0e521ee88acd657aba7e01a9f1f0b3ad3edf6 100644 (file)
@@ -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 <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("opened", date, nil)
-    assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title='Wed, 05 Mar 2014 21:37:45 \+0000'><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("closed", date, user)
+    assert_match %r{^Created by anonymous <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("opened", date, nil)
+    assert_match %r{^Resolved by <a href="/user/#{ERB::Util.u(user.display_name)}">#{user.display_name}</a> <abbr title="Wed, 05 Mar 2014 21:37:45 \+0000"><span title=" 5 March 2014 at 21:37">.* ago</span></abbr>$}, note_event("closed", date, user)
   end
 
   def test_note_author