adds i18n to debates' interface
This commit is contained in:
@@ -4,7 +4,7 @@ class VotesController < ApplicationController
|
||||
|
||||
def create
|
||||
register_vote
|
||||
notice = @debate.vote_registered? ? "Gracias por votar." : "Tu voto ya ha sido registrado."
|
||||
notice = @debate.vote_registered? ? I18n.t("votes.notice_thanks") : I18n.t("votes.notice_already_registered")
|
||||
redirect_to @debate, notice: notice
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class VotesController < ApplicationController
|
||||
|
||||
def set_debate
|
||||
@debate = Debate.find(params[:debate_id])
|
||||
end
|
||||
end
|
||||
|
||||
def register_vote
|
||||
@debate.vote_by voter: current_user, vote: params[:value]
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<div id="debate-<%= debate.id %>" class="small-12 medium-6 large-4 column debate">
|
||||
<div class="panel">
|
||||
<i class="fi-comment-quotes left"></i>
|
||||
<span class="label radius right">Debate</span>
|
||||
|
||||
<span class="label radius right"><%= t("debates.debate.debate") %></span>
|
||||
|
||||
<h3><%= link_to debate.title, debate %></h3>
|
||||
<p>Por <%= debate.author.name %> el <%= l debate.created_at.to_date %></p>
|
||||
<p><%= debate.description %></p>
|
||||
<p><%= debate.description %></p>
|
||||
|
||||
<p><%= render 'shared/tags', debate: debate %></p>
|
||||
|
||||
<div class="row votes">
|
||||
<div class="small-8 column">
|
||||
|
||||
|
||||
<%= link_to debate_votes_path(debate, value: 'yes'), :class => 'in-favor', method: "post" do %>
|
||||
<i class="fi-like"></i>
|
||||
<span><%= percentage('likes', debate) %></span>
|
||||
@@ -26,8 +26,8 @@
|
||||
</div>
|
||||
|
||||
<div class="small-4 column">
|
||||
<p class="total-votes right"><%= debate.total_votes %> votos</p>
|
||||
<p class="total-votes right"><%= pluralize(debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= form_for(@debate) do |f| %>
|
||||
<% if @debate.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@debate.errors.count, "error") %> prohibited this debate from being saved:</h2>
|
||||
<h2><%= pluralize(@debate.errors.count, t("debates.form.one_error"), t("debates.form.multiple_errors")) %> <%= t("debates.form.not_saved") %>:</h2>
|
||||
|
||||
<ul>
|
||||
<% @debate.errors.full_messages.each do |message| %>
|
||||
@@ -11,23 +11,23 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<p><strong>Título del debate</strong></p>
|
||||
<p>Sé claro y conciso a la hora de poner un título, pero recuerda que debe explicar bien tu idea, ¡es tu carta de entrada!</p>
|
||||
<p><strong><%= t("debates.form.debate_title") %></strong></p>
|
||||
<p><%= t("debates.form.title_instructions") %></p>
|
||||
<%= f.text_field :title %>
|
||||
|
||||
<br/>
|
||||
<p><strong>Describe tu opinión</strong></p>
|
||||
<p>Explica con todo el detalle que puedas y de una manera sencilla la idea y que crees que conseguiríamos con ella</p>
|
||||
<p><strong><%= t("debates.form.debate_text") %></strong></p>
|
||||
<p><%= t("debates.form.text_instructions") %></p>
|
||||
<%= f.text_area :description %>
|
||||
|
||||
<div>
|
||||
<%= f.label :tag_list, "Temas (separados por comas)" %><br />
|
||||
<%= f.label :tag_list, t("debates.form.tags_label") %><br />
|
||||
<%= f.text_field :tag_list, value: @debate.tag_list.to_s %>
|
||||
</div>
|
||||
|
||||
<% if @debate.new_record? %>
|
||||
<%= f.check_box :terms_of_service %>
|
||||
Acepto la política de privacidad y el aviso legal
|
||||
<%= t("debates.form.accept_terms") %>
|
||||
<% end %>
|
||||
|
||||
<%= render 'shared/captcha' %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<h1>Editing Debate</h1>
|
||||
<h1><%= t("debates.edit.editing") %></h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @debate %> |
|
||||
<%= link_to 'Back', debates_path %>
|
||||
<%= link_to t("debates.edit.show_link"), @debate %> |
|
||||
<%= link_to t("debates.edit.back_link"), debates_path %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<h1>Publicar un debate nuevo</h1>
|
||||
<h1><%= t("debates.new.publish_new") %></h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
<%= render "form" %>
|
||||
|
||||
<%= link_to 'Back', debates_path %>
|
||||
<%= link_to t("debates.new.back_link"), debates_path %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<article class="debate-show">
|
||||
|
||||
<%= link_to 'Volver', debates_path, :class => 'right' %>
|
||||
<%= link_to t("debates.show.back_link"), debates_path, :class => 'right' %>
|
||||
|
||||
<div class="row">
|
||||
<div id="debate-<%= @debate.id %>" class="small-12 medium-9 column">
|
||||
@@ -30,22 +30,22 @@
|
||||
</div>
|
||||
|
||||
<div class="small-12 column text-center">
|
||||
<p class="total-votes"><%= pluralize(@debate.total_votes, 'voto', 'votos') %> votos</p>
|
||||
<p class="total-votes"><%= pluralize(@debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="comments" class="comments">
|
||||
<h2>Comentarios</h2>
|
||||
<h2><%= t("debates.show.comments") %></h2>
|
||||
<div style="padding-bottom:60px">
|
||||
Deja tu comentario
|
||||
<%= t("debates.show.leave_comment") %>
|
||||
<%= render 'comments/form', parent: @debate %>
|
||||
</div>
|
||||
<%= render @debate.root_comments %>
|
||||
</div>
|
||||
|
||||
<% if current_user && @debate.editable_by?(current_user) %>
|
||||
<%= link_to 'Edit', edit_debate_path(@debate), :class => 'button radius right' %>
|
||||
<%= link_to t("debates.show.edit_debate_link"), edit_debate_path(@debate), :class => 'button radius right' %>
|
||||
<% end %>
|
||||
|
||||
</article>
|
||||
|
||||
31
config/locales/en.yml
Normal file
31
config/locales/en.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
en:
|
||||
debates:
|
||||
debate:
|
||||
debate: Debate
|
||||
vote: vote
|
||||
votes: votes
|
||||
form:
|
||||
one_error: error
|
||||
plural_errors: errors
|
||||
not_saved: "prohibited this debate from being saved:"
|
||||
debate_title: Debate title
|
||||
title_instructions: "SBe clear and precise with the title, but make it informative"
|
||||
debate_text: Ellaborate your opinion
|
||||
text_instructions: "Explain your opinion, go into details, tell us what's the purpose of your idea"
|
||||
tags_label: "Topics (comma separated)"
|
||||
accept_terms: I accept the privacy policy and the legal terms
|
||||
show:
|
||||
back_link: Back
|
||||
comments: Comments
|
||||
leave_comment: Write a comment
|
||||
edit_debate_link: Edit
|
||||
edit:
|
||||
editing: Edit debate
|
||||
show_link: Show debate
|
||||
back_link: Back
|
||||
new:
|
||||
publish_new: Publish new debate
|
||||
back_link: Back
|
||||
votes:
|
||||
notice_thanks: "Thanks for voting."
|
||||
notice_already_registered: "Your vote is already registered."
|
||||
31
config/locales/es.yml
Normal file
31
config/locales/es.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
es:
|
||||
debates:
|
||||
debate:
|
||||
debate: Debate
|
||||
vote: voto
|
||||
votes: votos
|
||||
form:
|
||||
one_error: error
|
||||
plural_errors: errores
|
||||
not_saved: "impidieron guardar el debate:"
|
||||
debate_title: Título del debate
|
||||
title_instructions: "Sé claro y conciso a la hora de poner un título, pero recuerda que debe explicar bien tu idea, ¡es tu carta de entrada!"
|
||||
debate_text: Describe tu opinión
|
||||
text_instructions: "Explica con todo el detalle que puedas y de una manera sencilla la idea y que crees que conseguiríamos con ella"
|
||||
tags_label: "Temas (separados por comas)"
|
||||
accept_terms: Acepto la política de privacidad y el aviso legal
|
||||
show:
|
||||
back_link: Volver
|
||||
comments: Comentarios
|
||||
leave_comment: Deja tu comentario
|
||||
edit_debate_link: Editar
|
||||
edit:
|
||||
editing: Editar debate
|
||||
show_link: Ver debate
|
||||
back_link: Volver
|
||||
new:
|
||||
publish_new: Publicar debate nuevo
|
||||
back_link: Volver
|
||||
votes:
|
||||
notice_thanks: "Gracias por votar."
|
||||
notice_already_registered: "Tu voto ya ha sido registrado."
|
||||
@@ -72,14 +72,14 @@ feature 'Debates' do
|
||||
|
||||
visit debate_path(debate)
|
||||
click_link 'Edit'
|
||||
fill_in 'debate_title', with: 'Dimisión Rajoy'
|
||||
fill_in 'debate_description', with: 'Podríamos...'
|
||||
fill_in 'debate_title', with: "Go home Rajoy"
|
||||
fill_in 'debate_description', with: "Let's..."
|
||||
|
||||
click_button 'Update Debate'
|
||||
click_button "Update Debate"
|
||||
|
||||
expect(page).to have_content 'Debate was successfully updated.'
|
||||
expect(page).to have_content 'Dimisión Rajoy'
|
||||
expect(page).to have_content 'Podríamos...'
|
||||
expect(page).to have_content "Debate was successfully updated."
|
||||
expect(page).to have_content "Go home Rajoy"
|
||||
expect(page).to have_content "Let's..."
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -17,33 +17,33 @@ feature 'Votes' do
|
||||
|
||||
visit debate_path(@debate)
|
||||
|
||||
expect(page).to have_content "2 votos"
|
||||
|
||||
within('#in_favor') do
|
||||
expect(page).to have_content "50%"
|
||||
expect(page).to have_content "2 votes"
|
||||
|
||||
within('#in_favor') do
|
||||
expect(page).to have_content "50%"
|
||||
end
|
||||
|
||||
within('#against') do
|
||||
expect(page).to have_content "50%"
|
||||
|
||||
within('#against') do
|
||||
expect(page).to have_content "50%"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
find('#in_favor a').click
|
||||
expect(page).to have_content "Gracias por votar"
|
||||
expect(page).to have_content "Thanks for voting."
|
||||
end
|
||||
|
||||
scenario 'Update' do
|
||||
find('#in_favor a').click
|
||||
find('#against a').click
|
||||
expect(page).to have_content "Gracias por votar"
|
||||
expect(page).to have_content "Thanks for voting."
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times' do
|
||||
find('#in_favor a').click
|
||||
find('#in_favor a').click
|
||||
expect(page).to have_content "Tu voto ya ha sido registrado"
|
||||
expect(page).to have_content "1 voto"
|
||||
expect(page).to have_content "Your vote is already registered."
|
||||
expect(page).to have_content "1 vote"
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user