Class: GovukPublishingComponents::Presenters::AccordionHelper
- Inherits:
-
Object
- Object
- GovukPublishingComponents::Presenters::AccordionHelper
- Defined in:
- lib/govuk_publishing_components/presenters/accordion_helper.rb
Instance Method Summary collapse
Instance Method Details
#apply_translations ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/govuk_publishing_components/presenters/accordion_helper.rb', line 16 def apply_translations shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new({}) locales = {} data_attributes = {} translations.each do |key, translation| locales[key] = shared_helper.t_locale(translation) data_attributes[key] = I18n.translate(translation) end unique_locales = locales.values.uniq if unique_locales.length > 1 data_attributes[:locale] = locales elsif unique_locales[0] != I18n.locale data_attributes[:locale] = unique_locales[0] end data_attributes end |
#initialise ⇒ Object
4 |
# File 'lib/govuk_publishing_components/presenters/accordion_helper.rb', line 4 def initialise; end |
#translations ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/govuk_publishing_components/presenters/accordion_helper.rb', line 6 def translations { show_text: "common.show", hide_text: "common.hide", show_all_text: "components.accordion.show_all", hide_all_text: "components.accordion.hide_all", this_section_visually_hidden: "components.accordion.this_section_visually_hidden", } end |