Sha256: 1aabd72f38c0befc85f31ee6f55b979851fd33ed48f8b02614f53c62dd4cc40d
Contents?: true
Size: 845 Bytes
Versions: 20
Compression:
Stored size: 845 Bytes
Contents
# frozen_string_literal: true module Decidim # Helper that provides convenient methods to deal with translated attributes. module TranslationsHelper include Decidim::TranslatableAttributes # Public: Creates a translation for each available language in the list # given a translation key. # # key - The key to translate. # locales - A list of locales to scope the translations to. Picks up all the # available locales by default. # # Returns a Hash with the locales as keys and the translations as values. def multi_translation(key, locales = Decidim.available_locales) locales.each_with_object({}) do |locale, result| I18n.with_locale(locale) do result[locale.to_sym] = I18n.t(key) end end end module_function :multi_translation end end
Version data entries
20 entries across 20 versions & 1 rubygems