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-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
govuk_publishing_components-44.5.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.4.2 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.4.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.4.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.3.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.2.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.1.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-44.0.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.5.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.4.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.4.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.3.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.2.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.1.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.1.0 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.0.2 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.0.1 lib/govuk_publishing_components/presenters/accordion_helper.rb
govuk_publishing_components-43.0.0 lib/govuk_publishing_components/presenters/accordion_helper.rb