Module: Lit::FrontendHelper::TranslationKeyWrapper

Included in:
Lit::FrontendHelper
Defined in:
app/helpers/lit/frontend_helper.rb

Instance Method Summary collapse

Instance Method Details

#pluralized_key(key, count) ⇒ Object



19
20
21
22
23
24
# File 'app/helpers/lit/frontend_helper.rb', line 19

def pluralized_key(key, count)
  pluralizer = I18n.backend.send(:pluralizer, locale)
  return unless pluralizer.respond_to?(:call)
  last = count.zero? ? :zero : pluralizer.call(count)
  format '%<key>s.%<last>s', key: key, last: last
end

#t(key, options = {}) ⇒ Object



26
27
28
# File 'app/helpers/lit/frontend_helper.rb', line 26

def t(key, options = {})
  translate(key, options)
end

#translate(key, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/lit/frontend_helper.rb', line 6

def translate(key, options = {})
  count = options[:count]
  options = options.with_indifferent_access
  key = scope_key_by_partial(key)
  key = pluralized_key(key, count) if count

  content = super(key, options.symbolize_keys)
  if !options[:skip_lit] && lit_authorized?
    content = get_translateable_span(key, content)
  end
  content
end