Module: Pageflow::PublicI18nHelper

Defined in:
app/helpers/pageflow/public_i18n_helper.rb

Instance Method Summary collapse

Instance Method Details

#public_i18n_javascript_tag(entry) ⇒ Object



3
4
5
6
7
# File 'app/helpers/pageflow/public_i18n_helper.rb', line 3

def public_i18n_javascript_tag(entry)
  render('pageflow/public_i18n/javascript_tag',
         entry_locale: entry.locale,
         translations: public_i18n_translations(entry))
end

#public_i18n_translations(entry) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/pageflow/public_i18n_helper.rb', line 9

def public_i18n_translations(entry)
  merge_ignoring_nil = lambda do |_, fallback, value|
    value.presence || fallback
  end

  {
    pageflow: {
      public: I18n.t('pageflow.public', locale: I18n.default_locale)
                  .dup
                  .deep_merge(I18n.t('pageflow.public', locale: entry.locale),
                              &merge_ignoring_nil)
    }
  }
end