Sha256: 034944d1f47822ca0fc4fb340f5f996cc7317c418e5e9a2e193aa6caacc18b13
Contents?: true
Size: 1018 Bytes
Versions: 34
Compression:
Stored size: 1018 Bytes
Contents
# frozen_string_literal: true module Decidim module Features # This class automatically names features for the given organization. # In order to do so, it uses the i18n keys of the feature, fallback to English, # searching for the key `"decidim.features.<feature name>.name"` # # This is intended to be used from the feature seeds section. # # Examples: # # Decidim::Feature.create!( # participatory_space: process, # name: Decidim::Feature::Namer.new(organization.available_locales, :my_feature_name).i18n_name # manifest_name: :my_feature_name # ) class Namer def initialize(locales, feature_name) @locales = locales @feature_name = feature_name end def i18n_name locales.inject({}) do |names, locale| names.update(locale => I18n.t("decidim.features.#{feature_name}.name", locale: locale)) end end private attr_reader :locales, :feature_name end end end
Version data entries
34 entries across 34 versions & 2 rubygems