handle non-underscored locale names for cktext_area

This commit is contained in:
Julian Herrero
2018-09-21 20:50:23 +02:00
parent 673ec075eb
commit e6762d6bca
2 changed files with 11 additions and 17 deletions

View File

@@ -35,6 +35,10 @@ module TranslatableFormHelper
translatable_field(:text_area, method, options)
end
def translatable_cktext_area(method, options = {})
translatable_field(:cktext_area, method, options)
end
private
def translatable_field(field_type, method, options = {})
@@ -47,7 +51,12 @@ module TranslatableFormHelper
final_options = @template.merge_translatable_field_options(options, locale)
.reverse_merge(label: label_without_locale)
@template.concat send(field_type, localized_attr_name, final_options)
if field_type == :cktext_area
@template.concat content_tag :span, send(field_type, localized_attr_name, final_options),
@template.merge_translatable_field_options(options, locale)
else
@template.concat send(field_type, localized_attr_name, final_options)
end
end
end
end

View File

@@ -9,22 +9,7 @@
<%= f.translatable_text_field :title %>
<div class="ckeditor">
<%= f.label :description, t("admin.shared.description") %>
<% @answer.globalize_locales.each do |locale| %>
<% globalize(locale) do %>
<%= content_tag :span, class: "js-globalize-attribute",
data: { locale: locale },
style: display_translation?(locale) do %>
<%= f.cktext_area "description_#{locale}",
maxlength: Poll::Question.description_max_length,
ckeditor: { language: locale },
class: "js-globalize-attribute",
data: { locale: locale },
label: false %>
<% end %>
<% end %>
<% end %>
<%= f.translatable_cktext_area :description, maxlength: Poll::Question.description_max_length %>
</div>
<div class="small-12 medium-4 large-2 margin-top">