Extract translation logic to helper method

This commit is contained in:
Angel Perez
2018-07-31 13:54:18 -04:00
committed by decabeza
parent 362157d56e
commit 9b19a4e956
2 changed files with 14 additions and 10 deletions

View File

@@ -7,6 +7,19 @@ module SiteCustomizationHelper
site_customization_enable_translation?(locale) ? "" : "display: none;"
end
def translation_for_locale(content, locale)
i18n_content = I18nContent.where(key: content.key).first
if i18n_content.present?
I18nContentTranslation.where(
i18n_content_id: i18n_content.id,
locale: locale
).first.try(:value)
else
false
end
end
def merge_translatable_field_options(options, locale)
options.merge(
class: "#{options[:class]} js-globalize-attribute".strip,