From 1a20a3ce463bfea9d304e403bdedaf40c9f28693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Wed, 7 Dec 2016 14:49:56 +0100 Subject: [PATCH] refactors i18n for polls --- app/helpers/polls_helper.rb | 10 ++++++- app/views/admin/_menu.html.erb | 2 +- .../admin/poll/polls/_questions.html.erb | 4 ++- .../admin/poll/questions/_filter.html.erb | 2 +- app/views/admin/poll/questions/_form.html.erb | 2 +- app/views/polls/index.html.erb | 2 +- app/views/polls/questions/show.html.erb | 18 +++++++---- app/views/polls/show.html.erb | 3 +- config/i18n-tasks.yml | 1 + config/locales/admin.en.yml | 7 +++-- config/locales/admin.es.yml | 7 +++-- config/locales/en.yml | 26 +++++++--------- config/locales/es.yml | 30 +++++++++++-------- 13 files changed, 71 insertions(+), 43 deletions(-) diff --git a/app/helpers/polls_helper.rb b/app/helpers/polls_helper.rb index 09303b68f..594a20efe 100644 --- a/app/helpers/polls_helper.rb +++ b/app/helpers/polls_helper.rb @@ -9,7 +9,15 @@ module PollsHelper end def all_polls - ["Todas", admin_questions_path] + [I18n.t("polls.all"), admin_questions_path] + end + + def poll_dates(poll) + if poll.starts_at.blank? || poll.ends_at.blank? + I18n.t("polls.no_dates") + else + I18n.t("polls.dates", open_at: l(poll.starts_at.to_date), closed_at: l(poll.ends_at.to_date)) + end end end \ No newline at end of file diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index f38c7e9db..45608b5ee 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -73,7 +73,7 @@
  • > - <%= link_to t('admin.menu.booths'), admin_booths_path %> + <%= link_to t('admin.menu.poll_booths'), admin_booths_path %>
  • diff --git a/app/views/admin/poll/polls/_questions.html.erb b/app/views/admin/poll/polls/_questions.html.erb index f258f8b5a..91f33196c 100644 --- a/app/views/admin/poll/polls/_questions.html.erb +++ b/app/views/admin/poll/polls/_questions.html.erb @@ -1,11 +1,13 @@
    - <% if @poll.questions.empty? %>
    <%= t('admin.polls.show.no_questions') %>
    <% else %> + +

    <%= t("admin.polls.show.questions_title") %>

    + <% @poll.questions.each do |question| %> diff --git a/app/views/admin/poll/questions/_filter.html.erb b/app/views/admin/poll/questions/_filter.html.erb index 0c9e17695..c12c62f2d 100644 --- a/app/views/admin/poll/questions/_filter.html.erb +++ b/app/views/admin/poll/questions/_filter.html.erb @@ -2,7 +2,7 @@ <%= form_tag '', method: :get do %> <%= select_tag "poll_id", poll_select_options(true), - prompt: t("admin.booths.index.select_poll"), + prompt: t("admin.questions.index.select_poll"), class: "js-location-changer" %> <% end %> \ No newline at end of file diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index b9986f98c..f9362995b 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -10,7 +10,7 @@
    <%= f.select :poll_id, options_for_select(Poll.pluck(:name, :id)), - prompt: t("admin.booths.index.select_poll") %> + prompt: t("admin.questions.index.select_poll") %>
    <%= f.text_field :title, maxlength: Poll::Question.title_max_length %> diff --git a/app/views/polls/index.html.erb b/app/views/polls/index.html.erb index 4b39e09af..b5d98e00f 100644 --- a/app/views/polls/index.html.erb +++ b/app/views/polls/index.html.erb @@ -1,7 +1,7 @@ <%= render 'shared/filter_subnav', i18n_namespace: "polls.index" %> <% @polls.each do |poll| %> - <%= link_to poll.name, poll %> + <%= link_to poll.name, poll %> (<%= poll_dates(poll) %>) <% end %> <%= paginate @polls %> diff --git a/app/views/polls/questions/show.html.erb b/app/views/polls/questions/show.html.erb index 26cb465b7..ea6c39c8f 100644 --- a/app/views/polls/questions/show.html.erb +++ b/app/views/polls/questions/show.html.erb @@ -7,7 +7,7 @@ <% if @question.proposal.present? %>
    - <%= link_to t('questions.show.original_proposal'), @question.proposal %> + <%= link_to t('poll_questions.show.original_proposal'), @question.proposal %>
    <% end %> @@ -22,28 +22,36 @@

    - <%= t('questions.show.author') %>
    + <%= t('poll_questions.show.author') %>
    <%= link_to @question.author.name, @question.author %>

    - <%= t('questions.show.external_url') %>
    - <%# link_to @question.external_url, @question.external_url %> + <%= t('poll_questions.show.dates_title') %>
    + <%= poll_dates(@question.poll) %>

    +<% if @question.poll.current? %>
    + <%= render "answers", question: @question %>
    +<% elsif @question.poll.incoming? %> + <%= t('poll_questions.show.cant_answer_expired') %> +<% elsif @question.poll.expired? %> + <%= t('poll_questions.show.cant_answer_incoming') %> +<% end %>
    -

    <%= t('questions.show.more_info') %>

    +

    <%= t('poll_questions.show.more_info') %>

    <%= @question.description %>
    + <%= render "comments" %> diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index 7cfd02f99..3006ebc71 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -1,4 +1,5 @@ -<%= @poll.name %> +

    <%= @poll.name %>

    +

    <%= t("polls.show.dates_title") %>: <%= poll_dates(@poll) %>

    <% unless can?(:answer, @poll) %>
    diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 5bbbb3042..bafa42d63 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -131,6 +131,7 @@ ignore_unused: - 'moderation.debates.index.order*' - 'valuation.spending_proposals.index.filter*' - 'users.show.filters.*' + - 'polls.index.filters.*' - 'debates.index.select_order' - 'debates.index.orders.*' - 'debates.index.search_form.*' diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index a82a2f61d..4c498a280 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -106,6 +106,7 @@ en: valuators: Valuators poll_officers: Poll officers polls: Polls + poll_booths: Booths officials: Officials organizations: Organisations settings: Configuration settings @@ -181,9 +182,10 @@ en: no_booths: "There are no booths in this poll." no_questions: "There are no questions assigned to this poll yet." no_officers: "There are no officers assigned to this poll." - add_booth: "Add booth" remove_booth: "Remove booth from poll" booths_title: "List of booths" + officers_title: "List of officers" + questions_title: "List of questions" name: "Name" location: "Location" email: "Email" @@ -191,7 +193,8 @@ en: index: title: "Questions" create: "Create question" - no_enquiries: "There are no questions." + no_questions: "There are no questions." + select_poll: Select Poll edit: title: "Edit Question" new: diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index fb01e6548..2e294147a 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -106,6 +106,7 @@ es: valuators: Evaluadores poll_officers: Presidentes de mesa polls: Votaciones + poll_booths: Urnas officials: Cargos públicos organizations: Organizaciones settings: Configuración global @@ -181,9 +182,10 @@ es: no_booths: "No hay urnas en esta votación." no_questions: "No hay preguntas asignadas a esta votación todavía." no_officers: "No hay presidentes de mesa asignados." - add_booth: "Añadir urna" remove_booth: "Deasignar urna" booths_title: "Listado de urnas" + officers_title: "Listado de presidentes de mesa" + questions_title: "Listado de preguntas" name: "Nombre" location: "Ubicación" email: "Email" @@ -191,7 +193,8 @@ es: index: title: "Preguntas ciudadanas" create: "Crear pregunta ciudadana" - no_enquiries: "No hay ninguna pregunta ciudadana." + no_questions: "No hay ninguna pregunta ciudadana." + select_poll: Seleccionar votación edit: title: "Editar pregunta ciudadana" new: diff --git a/config/locales/en.yml b/config/locales/en.yml index 24f83bdaa..f90dac037 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -378,7 +378,16 @@ en: form: submit_button: Save changes polls: + all: "All" + no_dates: "no date assigned" + dates: "From %{open_at} to %{closed_at}" + index: + filters: + current: "Open" + incoming: "Incoming" + expired: "Expired" show: + dates_title: "Participation dates" cant_answer_not_logged_in: "You must %{signin} or %{signup} to participate." signin: Sign in signup: Sign up @@ -390,31 +399,18 @@ en: poll_questions: create_question: "Create question" default_valid_answers: "Yes, No" - index: - filters: - opened: "Open" - incoming: "Incoming" - expired: "Expired" - title: "Enquiries" - description_html: "The following citizen proposals that have reached the required supports and will be voted." - dates: "From %{open_at} to %{closed_at}" - no_enquiries_opened: "There aren't opened enquiries." - no_enquiries_expired: "There aren't expired enquiries." - no_enquiries_incoming: "There aren't incoming enquiries." show: original_proposal: "Original proposal" author: "Created by" dates_title: "Participation dates" - dates: "From %{open_at} to %{closed_at}" - external_url: "Additional documentation" more_info: "More information" not_logged_in: "You must %{signin} or %{signup} to participate." signin: Sign in signup: Sign up cant_answer_verify_html: "You must %{verify_link} in order to answer." verify_link: "verify your account" - cant_answer_incoming: "This question has not yet started." - cant_answer_expired: "This question has finished." + cant_answer_incoming: "This poll has not yet started." + cant_answer_expired: "This poll has finished." cant_answer_wrong_geozone: "This question is not available on your geozone." vote_answer: "Vote %{answer}" voted: "You have voted %{answer}" diff --git a/config/locales/es.yml b/config/locales/es.yml index 4e8ac8149..fa90809ff 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -377,26 +377,32 @@ es: update: form: submit_button: Guardar cambios - poll_questions: - create_question: "Crear votación" - default_valid_answers: "Sí, No" + polls: + all: "Todas" + no_dates: "sin fecha asignada" + dates: "Desde el %{open_at} hasta el %{closed_at}" index: filters: - opened: "Abiertas" + current: "Abiertas" incoming: "Próximamente" expired: "Terminadas" - title: "Votaciones" - description_html: "Las siguientes propuestas ciudadanas han alcanzado el número de apoyos necesarios y pasarán a votación." - dates: "Desde el %{open_at} hasta el %{closed_at}" - no_enquiries_opened: "No hay votaciones abiertas." - no_enquiries_expired: "No hay votaciones terminadas." - no_enquiries_incoming: "No hay votaciones próximamente." + show: + dates_title: "Fechas de participación" + cant_answer_not_logged_in: "Necesitas %{signin} o %{signup} para participar." + signin: iniciar sesión + signup: registrarte + cant_answer_verify_html: "Por favor %{verify_link} para poder responder." + verify_link: "verifica tu cuenta" + cant_answer_incoming: "Esta votación todavía no ha comenzado." + cant_answer_expired: "Esta votación ha terminado." + cant_answer_wrong_geozone: "Esta votación no está disponible en tu zona." + poll_questions: + create_question: "Crear pregunta para votación" + default_valid_answers: "Sí, No" show: original_proposal: "Propuesta original" author: "Creado por" dates_title: "Fechas de participación" - dates: "Desde el %{open_at} hasta el %{closed_at}" - external_url: "Documentación adicional" more_info: "Más información" not_logged_in: "Necesitas %{signin} o %{signup} para participar." signin: iniciar sesión