Module: Lit::FrontendHelper::TranslationKeyWrapper
- Included in:
- Lit::FrontendHelper
- Defined in:
- app/helpers/lit/frontend_helper.rb
Instance Method Summary collapse
- #pluralized_key(key, count) ⇒ Object
- #t(key, options = {}) ⇒ Object
- #translate(key, options = {}) ⇒ Object
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, = {}) translate(key, ) 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, = {}) count = [:count] = .with_indifferent_access key = scope_key_by_partial(key) key = pluralized_key(key, count) if count content = super(key, .symbolize_keys) if ![:skip_lit] && content = get_translateable_span(key, content) end content end |