lib/bobot/page.rb in bobot-4.7.0 vs lib/bobot/page.rb in bobot-4.8.0

- old
+ new

@@ -316,11 +316,13 @@ def set_greeting_text! raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present? greeting_texts = [] if self.language.nil? # Default text + short_slug = slug.gsub(/_\w+$/, "") greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: I18n.default_locale, default: nil) + greeting_text = I18n.t("bobot.#{short_slug}.config.greeting_text", locale: I18n.default_locale, default: nil) if greeting_text.nil? greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present? # Each languages I18n.available_locales.each do |locale| greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: locale, default: nil) next unless greeting_text.present? @@ -328,11 +330,13 @@ facebook_locales.to_a.each do |locale_long| greeting_texts << { locale: locale_long, text: greeting_text } end end else + short_slug = slug.gsub(/_#{language}$/, "") greeting_text = I18n.t("bobot.#{slug}.config.greeting_text", locale: language, default: nil) + greeting_text = I18n.t("bobot.#{short_slug}.config.greeting_text", locale: language, default: nil) if greeting_text.nil? greeting_texts << { locale: 'default', text: greeting_text } if greeting_text.present? end if greeting_texts.present? greeting_texts.each do |row| if row[:text].present? && row[:text].size > 160 @@ -421,32 +425,38 @@ def set_persistent_menu! raise Bobot::FieldFormat.new("access_token is required") unless page_access_token.present? persistent_menus = [] # Default text if language.nil? + short_slug = slug.gsub(/_\w+$/, "") persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: I18n.default_locale, default: nil) + persistent_menu = I18n.t("bobot.#{short_slug}.config.persistent_menu", locale: I18n.default_locale, default: nil) if persistent_menu.nil? if persistent_menu.present? persistent_menus << { locale: 'default', composer_input_disabled: persistent_menu[:composer_input_disabled], call_to_actions: persistent_menu[:call_to_actions], } end # Each languages I18n.available_locales.each do |locale| persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: locale, default: nil) + persistent_menu = I18n.t("bobot.#{short_slug}.config.persistent_menu", locale: locale, default: nil) if persistent_menu.nil? facebook_locales = I18n.t("bobot.#{slug}.config.facebook_locales", locale: locale, default: nil) + facebook_locales = I18n.t("bobot.#{short_slug}.config.facebook_locales", locale: locale, default: nil) if facebook_locales.nil? next unless persistent_menu.present? facebook_locales.to_a.each do |locale_long| persistent_menus << { locale: locale_long, composer_input_disabled: persistent_menu[:composer_input_disabled], call_to_actions: persistent_menu[:call_to_actions], } end end else + short_slug = slug.gsub(/_#{language}$/, "") persistent_menu = I18n.t("bobot.#{slug}.config.persistent_menu", locale: language, default: nil) + persistent_menu = I18n.t("bobot.#{short_slug}.config.persistent_menu", locale: language, default: nil) if persistent_menu.nil? if persistent_menu.present? persistent_menus << { locale: 'default', composer_input_disabled: persistent_menu[:composer_input_disabled], call_to_actions: persistent_menu[:call_to_actions],