Update helpers after globalize gem version update
Globalize has fixed new translations globalized_model initialization so we have to adapt existing code.
This commit is contained in:
committed by
Julian Herrero
parent
596ef8d1ed
commit
f87804aa90
@@ -12,7 +12,7 @@ module GlobalizeHelper
|
||||
|
||||
def display_translation?(resource, locale)
|
||||
if !resource || resource.translations.blank? ||
|
||||
resource.translations.map(&:locale).include?(I18n.locale)
|
||||
resource.locales_not_marked_for_destruction.include?(I18n.locale)
|
||||
locale == I18n.locale
|
||||
else
|
||||
locale == resource.translations.first.locale
|
||||
|
||||
@@ -6,7 +6,13 @@ module TranslatableFormHelper
|
||||
end
|
||||
|
||||
class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder
|
||||
attr_accessor :translations
|
||||
|
||||
def translatable_fields(&block)
|
||||
@translations = {}
|
||||
@object.globalize_locales.map do |locale|
|
||||
@translations[locale] = translation_for(locale)
|
||||
end
|
||||
@object.globalize_locales.map do |locale|
|
||||
Globalize.with_locale(locale) { fields_for_locale(locale, &block) }
|
||||
end.join.html_safe
|
||||
@@ -15,7 +21,7 @@ module TranslatableFormHelper
|
||||
private
|
||||
|
||||
def fields_for_locale(locale, &block)
|
||||
fields_for_translation(translation_for(locale)) do |translations_form|
|
||||
fields_for_translation(@translations[locale]) do |translations_form|
|
||||
@template.content_tag :div, translations_options(translations_form.object, locale) do
|
||||
@template.concat translations_form.hidden_field(
|
||||
:_destroy,
|
||||
|
||||
Reference in New Issue
Block a user