-
- <%= link_to t("debates.debate.comments", count: debate.comments_count),
- debate_path(debate, anchor: "comments") %>
-
+ <%= render Shared::CommentsCountComponent.new(
+ debate.comments_count,
+ url: debate_path(debate, anchor: "comments")
+ ) %>
•
<%= l debate.created_at.to_date %>
diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb
index c7c62c0df..52f6dd160 100644
--- a/app/views/debates/show.html.erb
+++ b/app/views/debates/show.html.erb
@@ -26,9 +26,7 @@
•
<%= l @debate.created_at.to_date %>
•
-
- <%= link_to t("debates.show.comments", count: @debate.comments_count), "#comments" %>
-
+ <%= render Shared::CommentsCountComponent.new(@debate.comments_count, url: "#comments") %>
•
<%= render "shared/flag_actions", flaggable: @debate %>
diff --git a/app/views/legislation/annotations/_comment_header.html.erb b/app/views/legislation/annotations/_comment_header.html.erb
index c3ee785ec..eea52733b 100644
--- a/app/views/legislation/annotations/_comment_header.html.erb
+++ b/app/views/legislation/annotations/_comment_header.html.erb
@@ -1,6 +1,4 @@
-
- <%= t("legislation.annotations.comments.comments_count", count: annotation.comments.roots.count) %>
-
+<%= render Shared::CommentsCountComponent.new(annotation.comments.roots.count) %>
<%= render "annotation_link", annotation: annotation %>
diff --git a/app/views/legislation/annotations/_form.html.erb b/app/views/legislation/annotations/_form.html.erb
index f71606283..839c66f61 100644
--- a/app/views/legislation/annotations/_form.html.erb
+++ b/app/views/legislation/annotations/_form.html.erb
@@ -1,6 +1,6 @@
- - <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), - legislation_process_proposal_path(proposal.legislation_process_id, proposal, - anchor: "comments") %> - + <%= render Shared::CommentsCountComponent.new( + proposal.comments_count, + url: legislation_process_proposal_path( + proposal.legislation_process_id, + proposal, + anchor: "comments") + ) %> • <%= l proposal.created_at.to_date %> diff --git a/app/views/legislation/proposals/show.html.erb b/app/views/legislation/proposals/show.html.erb index cfc953d16..9be3ee3b3 100644 --- a/app/views/legislation/proposals/show.html.erb +++ b/app/views/legislation/proposals/show.html.erb @@ -44,9 +44,7 @@ • <%= l @proposal.created_at.to_date %> • - - <%= link_to t("proposals.show.comments", count: @proposal.comments_count), "#comments" %> - + <%= render Shared::CommentsCountComponent.new(@proposal.comments_count, url: "#comments") %> <% if current_user %> • diff --git a/app/views/legislation/questions/_question.html.erb b/app/views/legislation/questions/_question.html.erb index 49a92fcba..7c91b52ca 100644 --- a/app/views/legislation/questions/_question.html.erb +++ b/app/views/legislation/questions/_question.html.erb @@ -6,9 +6,10 @@
- - <%= link_to t("proposals.proposal.comments", count: proposal.comments_count), - namespaced_proposal_path(proposal, anchor: "comments") %> - - + <%= render Shared::CommentsCountComponent.new( + proposal.comments_count, + url: namespaced_proposal_path(proposal, anchor: "comments") + ) %> • <%= l proposal.created_at.to_date %> diff --git a/app/views/topics/_topic.html.erb b/app/views/topics/_topic.html.erb index a2afb656f..ddd6ce6d8 100644 --- a/app/views/topics/_topic.html.erb +++ b/app/views/topics/_topic.html.erb @@ -5,10 +5,10 @@
-
- <%= link_to t("community.show.topic.comments", count: topic.comments_count),
- community_topic_path(@community, topic, anchor: "comments") %>
-
+ <%= render Shared::CommentsCountComponent.new(
+ topic.comments_count,
+ url: community_topic_path(@community, topic, anchor: "comments")
+ ) %>
•
<%= I18n.l topic.created_at.to_date %>
•
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb
index a20e8815a..51242bd0a 100644
--- a/app/views/topics/show.html.erb
+++ b/app/views/topics/show.html.erb
@@ -14,10 +14,10 @@
•
<%= l(@topic.created_at.to_date) %>
•
-
- <%= link_to t("community.show.topic.comments", count: @topic.comments_count),
- community_topic_path(@community, @topic, anchor: "comments") %>
-
+ <%= render Shared::CommentsCountComponent.new(
+ @topic.comments_count,
+ url: community_topic_path(@community, @topic, anchor: "comments")
+ ) %>
<%= @topic.description %>
diff --git a/config/locales/en/community.yml b/config/locales/en/community.yml index 49ee30fa6..3c6a440dc 100644 --- a/config/locales/en/community.yml +++ b/config/locales/en/community.yml @@ -25,10 +25,6 @@ en: topic: edit: Edit topic destroy: Delete topic - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments author: Author back: Back to %{community} %{proposal} topic: diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index db573e42b..96b0655c9 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -69,10 +69,6 @@ en: form: submit_button: Start a debate debate: - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments votes: one: 1 vote other: "%{count} votes" @@ -128,10 +124,6 @@ en: start_new: Start a debate show: author_deleted: User deleted - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments comments_title: Comments edit_debate_link: Edit flag: This debate has been flagged as inappropriate by several users. @@ -396,10 +388,6 @@ en: edit: "Before it gets shared you'll be able to change the text as you like." view_proposal: Not now, go to my proposal already_supported: You have already supported this proposal. Share it! - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments support: Support support_label: "Support %{proposal}" support_title: Support this proposal @@ -420,10 +408,6 @@ en: show: author_deleted: User deleted code: "Proposal code:" - comments: - one: 1 comment - other: "%{count} comments" - zero: No comments comments_tab: Comments dashboard_proposal_link: Dashboard flag: This proposal has been flagged as inappropriate by several users. diff --git a/config/locales/en/legislation.yml b/config/locales/en/legislation.yml index 8fd58bc28..ea6ad838f 100644 --- a/config/locales/en/legislation.yml +++ b/config/locales/en/legislation.yml @@ -4,9 +4,6 @@ en: comments: see_all: See all see_complete: See complete - comments_count: - one: "%{count} comment" - other: "%{count} comments" replies_count: one: "%{count} reply" other: "%{count} replies" @@ -18,9 +15,6 @@ en: title: Comments comments_about: Comments about see_in_context: See in context - comments_count: - one: "%{count} comment" - other: "%{count} comments" show: title: Comment version_chooser: @@ -92,10 +86,6 @@ en: form: leave_comment: Leave your answer question: - comments: - zero: No comments - one: "%{count} comment" - other: "%{count} comments" debate: Debate show: answer_question: Submit answer @@ -134,10 +124,6 @@ en: zero: "No proposals" one: "%{count} proposal" other: "%{count} proposals" - comments: - zero: "No comments" - one: "%{count} comment" - other: "%{count} comments" download: "Download summary" top_comments: zero: "No comments" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 82ea3bbd7..ebfbd6749 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -69,10 +69,6 @@ es: form: submit_button: Empieza un debate debate: - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" votes: zero: Sin votos one: 1 voto @@ -128,10 +124,6 @@ es: start_new: Empezar un debate show: author_deleted: Usuario eliminado - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" comments_title: Comentarios edit_debate_link: Editar debate flag: Este debate ha sido marcado como inapropiado por varios usuarios. @@ -396,10 +388,6 @@ es: edit: "Antes de que se publique podrás modificar el texto a tu gusto." view_proposal: Ahora no, ir a mi propuesta already_supported: '¡Ya has apoyado esta propuesta, compártela!' - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" support: Apoyar support_label: "Apoyar %{proposal}" support_title: Apoyar esta propuesta @@ -420,10 +408,6 @@ es: show: author_deleted: Usuario eliminado code: "Código de la propuesta:" - comments: - zero: Sin comentarios - one: 1 Comentario - other: "%{count} Comentarios" comments_tab: Comentarios dashboard_proposal_link: Panel de control flag: Esta propuesta ha sido marcada como inapropiada por varios usuarios. diff --git a/config/locales/es/legislation.yml b/config/locales/es/legislation.yml index 33693570e..575c6e8af 100644 --- a/config/locales/es/legislation.yml +++ b/config/locales/es/legislation.yml @@ -4,9 +4,6 @@ es: comments: see_all: Ver todos see_complete: Ver completo - comments_count: - one: "%{count} comentario" - other: "%{count} comentarios" replies_count: one: "%{count} respuesta" other: "%{count} respuestas" @@ -18,9 +15,6 @@ es: title: Comentarios comments_about: Comentarios sobre see_in_context: Ver en contexto - comments_count: - one: "%{count} comentario" - other: "%{count} comentarios" show: title: Comentario version_chooser: @@ -92,10 +86,6 @@ es: form: leave_comment: Deja tu respuesta question: - comments: - zero: Sin comentarios - one: "%{count} comentario" - other: "%{count} comentarios" debate: Debate show: answer_question: Enviar respuesta @@ -134,10 +124,6 @@ es: zero: "No hay propuestas" one: "%{count} propuesta" other: "%{count} propuestas" - comments: - zero: "No hay comentarios" - one: "%{count} comentario" - other: "%{count} comentarios" download: "Descargar resumen" top_comments: zero: "No hay comentarios" diff --git a/spec/components/shared/comments_count_component_spec.rb b/spec/components/shared/comments_count_component_spec.rb new file mode 100644 index 000000000..15451363f --- /dev/null +++ b/spec/components/shared/comments_count_component_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +describe Shared::CommentsCountComponent do + it "renders a link when a URL is given" do + render_inline Shared::CommentsCountComponent.new(0, url: "http://www.url.com") + + expect(page.find(".comments-count")).to have_content "No comments" + expect(page.find(".comments-count")).to have_link "No comments", href: "http://www.url.com" + end + + it "renders plain text when no URL is given" do + render_inline Shared::CommentsCountComponent.new(1) + + expect(page.find(".comments-count")).to have_content "1 comment" + expect(page.find(".comments-count")).not_to have_link "1 comment" + end +end