Module: Decidim::Toggle::ModuleConfigI18n
- Defined in:
- lib/decidim/toggle/module_config_i18n.rb
Overview
I18n scope helpers for ModuleConfigForm tab fields.
Class Method Summary collapse
- .helptext_key(module_name, attribute) ⇒ Object
- .label_key(module_name, attribute) ⇒ Object
- .scope_for(module_name) ⇒ Object
- .translate_helptext(module_name, attribute) ⇒ Object
- .translate_label(module_name, attribute) ⇒ Object
Class Method Details
.helptext_key(module_name, attribute) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/decidim/toggle/module_config_i18n.rb', line 22 def helptext_key(module_name, attribute) base = scope_for(module_name) return unless base "#{base}.helptext.#{attribute}" end |
.label_key(module_name, attribute) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/decidim/toggle/module_config_i18n.rb', line 15 def label_key(module_name, attribute) base = scope_for(module_name) return unless base "#{base}.#{attribute}" end |
.scope_for(module_name) ⇒ Object
9 10 11 12 13 |
# File 'lib/decidim/toggle/module_config_i18n.rb', line 9 def scope_for(module_name) return if module_name.blank? "decidim_toggle.system.#{module_name}" end |
.translate_helptext(module_name, attribute) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/decidim/toggle/module_config_i18n.rb', line 36 def translate_helptext(module_name, attribute) key = helptext_key(module_name, attribute) return unless key && I18n.exists?(key) I18n.t(key) end |
.translate_label(module_name, attribute) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/decidim/toggle/module_config_i18n.rb', line 29 def translate_label(module_name, attribute) key = label_key(module_name, attribute) return unless key && I18n.exists?(key) I18n.t(key) end |