Sha256: d42729d83032a565a894d87048c7824f0b59e0bdb44bbb9c1f510c83b98e71c4

Contents?: true

Size: 1.06 KB

Versions: 129

Compression:

Stored size: 1.06 KB

Contents

module GovukPublishingComponents
  module Presenters
    class AccordionHelper
      def initialise; end

      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

      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
    end
  end
end

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
govuk_publishing_components-45.9.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.8.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.7.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.6.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.6.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.5.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.4.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.4.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.3.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.2.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.1.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-45.0.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.11.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.10.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.9.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.9.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.8.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.7.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.7.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.6.0 lib/govuk_publishing_components/presenters/accordion_helper.rb