Module: Lit::FrontendHelper

Includes:
ActionView::Helpers::TranslationHelper, TranslationKeyWrapper
Defined in:
app/helpers/lit/frontend_helper.rb

Defined Under Namespace

Modules: TranslationKeyWrapper

Instance Method Summary collapse

Methods included from TranslationKeyWrapper

#missing_translation, #pluralized_key, #t, #translate

Instance Method Details

#get_translateable_span(key, localization, alternative_text: nil) ⇒ Object



90
91
92
93
94
# File 'app/helpers/lit/frontend_helper.rb', line 90

def get_translateable_span(key, localization, alternative_text: nil)
   :span, class: 'lit-key-generic', data: { key: key, locale: I18n.locale } do
    localization.blank? ? alternative_text : localization
  end
end

#javascript_lit_tagObject



41
42
43
# File 'app/helpers/lit/frontend_helper.rb', line 41

def javascript_lit_tag
  javascript_include_tag 'lit/lit_frontend'
end

#lit_authorized?Boolean

Returns:

  • (Boolean)


84
85
86
87
88
# File 'app/helpers/lit/frontend_helper.rb', line 84

def lit_authorized?
  return false if Lit.authentication_verification.blank?

  send Lit.authentication_verification
end

#lit_frontend_assetsObject



49
50
51
52
53
54
# File 'app/helpers/lit/frontend_helper.rb', line 49

def lit_frontend_assets
  return unless lit_authorized?

  meta =  :meta, '', value: lit.find_localization_localization_keys_path, name: 'lit-url-base'
  safe_join [javascript_lit_tag, stylesheet_lit_tag, meta]
end

#lit_translations_infoObject



56
57
58
59
60
61
62
63
64
65
# File 'app/helpers/lit/frontend_helper.rb', line 56

def lit_translations_info
  return if Thread.current[:lit_request_keys].nil?
  return unless lit_authorized?

   :div, class: 'lit-translations-info collapsed' do
    concat (:span, 'Show translations', class: 'lit-open-button')
    concat (:span, 'X', class: 'lit-close-button')
    concat 
  end
end

#stylesheet_lit_tagObject



45
46
47
# File 'app/helpers/lit/frontend_helper.rb', line 45

def stylesheet_lit_tag
  stylesheet_link_tag 'lit/lit_frontend'
end

#translations_list_content_tagObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/helpers/lit/frontend_helper.rb', line 67

def 
   :ul, class: 'lit-translations-list' do
    Lit
      .init
      .cache
      .request_keys
      .each do |k, v|
        concat(
          (:li) do
            concat (:code, "#{k}:")
            concat get_translateable_span(k, v, alternative_text: '[empty]')
          end,
        )
      end
  end
end