Sha256: a7cd626241734e6a4aabb5cf1c0668bb99c5827f1781da42c114a20e2ca72500

Contents?: true

Size: 542 Bytes

Versions: 7

Compression:

Stored size: 542 Bytes

Contents

# frozen_string_literal: true
module Decidim
  # Helper that provides convenient methods to deal with translated attributes.
  module TranslationsHelper
    # Public: Returns the translation of an attribute using the current locale,
    # if available.
    #
    # attribute - A Hash where keys (strings) are locales, and their values are
    #             the translation for each locale.
    #
    # Returns a String with the translation.
    def translated_attribute(attribute)
      attribute.try(:[], I18n.locale.to_s)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
decidim-core-0.0.1.alpha9 app/helpers/decidim/translations_helper.rb
decidim-core-0.0.1.alpha8 app/helpers/decidim/translations_helper.rb
decidim-core-0.0.1.alpha7 app/helpers/decidim/translations_helper.rb
decidim-core-0.0.1.alpha6 app/helpers/decidim/translations_helper.rb
decidim-core-0.0.1.alpha5 app/helpers/decidim/translations_helper.rb
decidim-core-0.0.1.alpha4 app/helpers/decidim/translations_helper.rb
decidim-core-0.0.1.alpha3 app/helpers/decidim/translations_helper.rb