Display needed translations when translation interface is disabled

Display only current locale translation when translation interface is disabled.

Co-Authored-By: javierm <javim@elretirao.net>
This commit is contained in:
Senén Rodero Rodríguez
2018-12-23 19:28:06 +01:00
committed by voodoorai2000
parent b5663a7c17
commit 73563e5d86

View File

@@ -19,10 +19,10 @@ module TranslatableFormHelper
def translatable_fields(&block)
@translations = {}
@object.globalize_locales.map do |locale|
visible_locales.map do |locale|
@translations[locale] = translation_for(locale)
end
@object.globalize_locales.map do |locale|
visible_locales.map do |locale|
Globalize.with_locale(locale) { fields_for_locale(locale, &block) }
end.join.html_safe
end
@@ -77,6 +77,14 @@ module TranslatableFormHelper
def no_other_translations?(translation)
(@object.translations - [translation]).reject(&:_destroy).empty?
end
def visible_locales
if @template.translations_interface_enabled?
@object.globalize_locales
else
[I18n.locale]
end
end
end
class TranslationsFieldsBuilder < FoundationRailsHelper::FormBuilder