Refactor method to get custom texts translations
It was a bit confusing to return `false` in the method and then handle this case in the view.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<% globalize(locale) do %>
|
||||
<%= hidden_field_tag "contents[content_#{i18n_content.key}][id]", i18n_content.key %>
|
||||
<%= text_area_tag "contents[content_#{i18n_content.key}]values[value_#{locale}]",
|
||||
text || t(i18n_content.key, locale: locale),
|
||||
text,
|
||||
rows: 5,
|
||||
class: "js-globalize-attribute",
|
||||
style: site_customization_display_translation_style(locale),
|
||||
|
||||
@@ -10,10 +10,16 @@ class Admin::SiteCustomization::InformationTexts::FormFieldComponent < Applicati
|
||||
private
|
||||
|
||||
def text
|
||||
database_text || i18n_text
|
||||
end
|
||||
|
||||
def database_text
|
||||
if i18n_content.present?
|
||||
I18nContentTranslation.find_by(i18n_content_id: i18n_content.id, locale: locale)&.value
|
||||
else
|
||||
false
|
||||
i18n_content.translations.find_by(locale: locale)&.value
|
||||
end
|
||||
end
|
||||
|
||||
def i18n_text
|
||||
t(i18n_content.key, locale: locale)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user