Sha256: 100f911c480db10b3763d0465b9ef8f41ac655f8c07577f96903ae26d2bb0351
Contents?: true
Size: 941 Bytes
Versions: 1
Compression:
Stored size: 941 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. # options - Any other option to delegate to the individual I18n.t calls # # Returns a Hash with the locales as keys and the translations as values. def multi_translation(key, locales = Decidim.available_locales, *options) locales.each_with_object({}) do |locale, result| I18n.with_locale(locale) do result[locale.to_sym] = I18n.t(key, *options) end end end module_function :multi_translation end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-core-0.16.0 | app/helpers/decidim/translations_helper.rb |