Sha256: d42729d83032a565a894d87048c7824f0b59e0bdb44bbb9c1f510c83b98e71c4

Contents?: true

Size: 1.06 KB

Versions: 131

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

131 entries across 131 versions & 1 rubygems

Version Path
govuk_publishing_components-37.1.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-37.1.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-37.0.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-36.1.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-36.0.3 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-36.0.2 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-36.0.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-36.0.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.23.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.22.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.21.4 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.21.3 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.21.2 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.21.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.21.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.20.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.20.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.19.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.18.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-35.17.0 lib/govuk_publishing_components/presenters/accordion_helper.rb