adds i18n to debates' interface

This commit is contained in:
Juanjo Bazán
2015-07-28 16:45:00 +02:00
parent d5710c8dc6
commit e9c1910d7d
10 changed files with 105 additions and 43 deletions

View File

@@ -4,7 +4,7 @@ class VotesController < ApplicationController
def create def create
register_vote 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 redirect_to @debate, notice: notice
end end

View File

@@ -1,7 +1,7 @@
<div id="debate-<%= debate.id %>" class="small-12 medium-6 large-4 column debate"> <div id="debate-<%= debate.id %>" class="small-12 medium-6 large-4 column debate">
<div class="panel"> <div class="panel">
<i class="fi-comment-quotes left"></i> <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> <h3><%= link_to debate.title, debate %></h3>
<p>Por <%= debate.author.name %> el <%= l debate.created_at.to_date %></p> <p>Por <%= debate.author.name %> el <%= l debate.created_at.to_date %></p>
@@ -26,7 +26,7 @@
</div> </div>
<div class="small-4 column"> <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> </div>

View File

@@ -1,7 +1,7 @@
<%= form_for(@debate) do |f| %> <%= form_for(@debate) do |f| %>
<% if @debate.errors.any? %> <% if @debate.errors.any? %>
<div id="error_explanation"> <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> <ul>
<% @debate.errors.full_messages.each do |message| %> <% @debate.errors.full_messages.each do |message| %>
@@ -11,23 +11,23 @@
</div> </div>
<% end %> <% end %>
<p><strong>Título del debate</strong></p> <p><strong><%= t("debates.form.debate_title") %></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><%= t("debates.form.title_instructions") %></p>
<%= f.text_field :title %> <%= f.text_field :title %>
<br/> <br/>
<p><strong>Describe tu opinión</strong></p> <p><strong><%= t("debates.form.debate_text") %></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><%= t("debates.form.text_instructions") %></p>
<%= f.text_area :description %> <%= f.text_area :description %>
<div> <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 %> <%= f.text_field :tag_list, value: @debate.tag_list.to_s %>
</div> </div>
<% if @debate.new_record? %> <% if @debate.new_record? %>
<%= f.check_box :terms_of_service %> <%= f.check_box :terms_of_service %>
Acepto la política de privacidad y el aviso legal <%= t("debates.form.accept_terms") %>
<% end %> <% end %>
<%= render 'shared/captcha' %> <%= render 'shared/captcha' %>

View File

@@ -1,6 +1,6 @@
<h1>Editing Debate</h1> <h1><%= t("debates.edit.editing") %></h1>
<%= render 'form' %> <%= render 'form' %>
<%= link_to 'Show', @debate %> | <%= link_to t("debates.edit.show_link"), @debate %> |
<%= link_to 'Back', debates_path %> <%= link_to t("debates.edit.back_link"), debates_path %>

View File

@@ -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 %>

View File

@@ -1,6 +1,6 @@
<article class="debate-show"> <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 class="row">
<div id="debate-<%= @debate.id %>" class="small-12 medium-9 column"> <div id="debate-<%= @debate.id %>" class="small-12 medium-9 column">
@@ -30,22 +30,22 @@
</div> </div>
<div class="small-12 column text-center"> <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>
</div> </div>
<div id="comments" class="comments"> <div id="comments" class="comments">
<h2>Comentarios</h2> <h2><%= t("debates.show.comments") %></h2>
<div style="padding-bottom:60px"> <div style="padding-bottom:60px">
Deja tu comentario <%= t("debates.show.leave_comment") %>
<%= render 'comments/form', parent: @debate %> <%= render 'comments/form', parent: @debate %>
</div> </div>
<%= render @debate.root_comments %> <%= render @debate.root_comments %>
</div> </div>
<% if current_user && @debate.editable_by?(current_user) %> <% 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 %> <% end %>
</article> </article>

31
config/locales/en.yml Normal file
View 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
View 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."

View File

@@ -72,14 +72,14 @@ feature 'Debates' do
visit debate_path(debate) visit debate_path(debate)
click_link 'Edit' click_link 'Edit'
fill_in 'debate_title', with: 'Dimisión Rajoy' fill_in 'debate_title', with: "Go home Rajoy"
fill_in 'debate_description', with: 'Podríamos...' 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 "Debate was successfully updated."
expect(page).to have_content 'Dimisión Rajoy' expect(page).to have_content "Go home Rajoy"
expect(page).to have_content 'Podríamos...' expect(page).to have_content "Let's..."
end end
end end

View File

@@ -17,7 +17,7 @@ feature 'Votes' do
visit debate_path(@debate) visit debate_path(@debate)
expect(page).to have_content "2 votos" expect(page).to have_content "2 votes"
within('#in_favor') do within('#in_favor') do
expect(page).to have_content "50%" expect(page).to have_content "50%"
@@ -30,20 +30,20 @@ feature 'Votes' do
scenario 'Create' do scenario 'Create' do
find('#in_favor a').click find('#in_favor a').click
expect(page).to have_content "Gracias por votar" expect(page).to have_content "Thanks for voting."
end end
scenario 'Update' do scenario 'Update' do
find('#in_favor a').click find('#in_favor a').click
find('#against a').click find('#against a').click
expect(page).to have_content "Gracias por votar" expect(page).to have_content "Thanks for voting."
end end
scenario 'Trying to vote multiple times' do scenario 'Trying to vote multiple times' do
find('#in_favor a').click find('#in_favor a').click
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 "Your vote is already registered."
expect(page).to have_content "1 voto" expect(page).to have_content "1 vote"
end end
end end