From bbbd0820c1c59e91a1dd8965e27d6cf37e251157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sat, 5 Oct 2019 02:15:16 +0200 Subject: [PATCH] Use active record translations in votation types We need to build a votation type object in the form so translations are applied automatically. --- app/views/admin/poll/questions/_form.html.erb | 11 +++++------ app/views/admin/poll/questions/show.html.erb | 2 +- config/locales/en/activerecord.yml | 5 +++++ config/locales/en/general.yml | 4 ---- config/locales/es/activerecord.yml | 5 +++++ config/locales/es/general.yml | 4 ---- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 20687bbca..d6dc8a9ad 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -33,12 +33,12 @@
<% if !@question.persisted? %> - <%= fields_for :votation_type do |votation_f| %> + <%= fields_for :votation_type, @question.votation_type || @question.build_votation_type do |votation_f| %>
<%= votation_f.select :enum_type, options_for_select(VotationType.enum_types.map { |k, v| [t(k, scope: :enum_type), v] }, params.dig(:votation_type, :enum_type)), default: 0, - disabled: @question.persisted?, label: t("enum_type.title") %> + disabled: @question.persisted? %>
@@ -47,18 +47,17 @@
<% end %> diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 768282b02..edf693bf7 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -42,7 +42,7 @@ <% end %> <% if !@question.votation_type.prioritization_type.nil? %>

- <%= t("prioritization_type.title") %> + <%= VotationType.human_attribute_name(:prioritization_type) %>
<%= t("prioritization_type.#{@question.votation_type.prioritization_type}") %>

diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index 7d2651fac..dcc7b531a 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -333,6 +333,11 @@ en: topic: title: "Title" description: "Initial text" + votation_type: + enum_type: "Votation type" + max_groups_answers: "Maximum number of answers in the set" + max_votes: "Maximum number of votes" + prioritization_type: "Prioritization type" banner: background_color: Background color font_color: Font color diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 0c45044c6..cbb07d447 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -992,11 +992,8 @@ en: poll: take_part: Take part from %{from} to %{to} question: - max_votes: Maximum number of votes - max_group_answers: Maximum number of answers in the set votation_type: Votation type enum_type: - title: Votation type unique: Unique answer, closed multiple: Multiple answers, closed prioritized: Multiple prioritized answer, closed @@ -1007,7 +1004,6 @@ en: answer_set_open: Set of answers, open answer_set_closed: Set of answers, closed prioritization_type: - title: Prioritization type borda: Borda votation dowdall: Dowdall votation remote_translations: diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index 84ea180d6..6213b0777 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -335,6 +335,11 @@ es: topic: title: "Título" description: "Texto inicial" + votation_type: + enum_type: "Tipo de votación" + max_groups_answers: "Número máximo de respuestas en el conjunto" + max_votes: "Número máximo de votos" + prioritization_type: "Tipo de priorizacion" banner: background_color: Color del fondo font_color: Color del texto diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 26f1c8018..e0a0997b8 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -991,11 +991,8 @@ es: poll: take_part: Participa del %{from} al %{to} question: - max_votes: Número máximo de votos - max_group_answers: Número máximo de respuestas en el conjunto votation_type: Tipo de votación enum_type: - title: Tipo de votación unique: Respuesta única, cerrada multiple: Respuesta múltiple, cerrada prioritized: Respuesta múltiple priorizada, cerrada @@ -1006,7 +1003,6 @@ es: answer_set_open: Conjunto de respuestas, abiertas answer_set_closed: Conjunto de respuestas, cerradas prioritization_type: - title: Tipo de priorizacion borda: Votación con recuento Borda dowdall: Votación con recuento Dowdall remote_translations: