Sha256: bfc6cab29bae8e581b4278f6efd2b58b2f8a45bde6e4403741e6ef59a39e32f9

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

require "rails"
require "i18n"
require "exvo_globalize"

module ExvoGlobalize
  class Engine < Rails::Engine
    initializer "exvo_globalize.configure_i18n" do |app|
      # make pluralization rules available for both backends
      I18n::Backend::GlobalizeStore.send(:include, I18n::Backend::Pluralization)
      I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)

      # fallback for missing translations (will search for translations using I18n.default_locale if not found in requested locale)
      I18n::Backend::Chain.send(:include, I18n::Backend::Fallback)

      # caching layer
      I18n::Backend::GlobalizeStore.send(:include, I18n::Backend::Cache)
      I18n.cache_store = ActiveSupport::Cache.lookup_store(:memory_store)

      # chained backends (fall back from first backend to the second if translation is not found in the first)
      # GlobalizeStore first (database backed), YAML files second (Simple backend, the default one)
      I18n.backend = I18n::Backend::Chain.new(I18n::Backend::GlobalizeStore.new, I18n.backend)
    end

    initializer "exvo_globalize.configure_helpers" do |app|
      ActiveSupport.on_load(:action_view) do
        ActionView::Base.send :include, ExvoGlobalize::Helpers
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
exvo_globalize-0.5.3 lib/exvo_globalize/engine.rb
exvo_globalize-0.5.2 lib/exvo_globalize/engine.rb
exvo_globalize-0.5.1 lib/exvo_globalize/engine.rb
exvo_globalize-0.5.0 lib/exvo_globalize/engine.rb
exvo_globalize-0.4.0 lib/exvo_globalize/engine.rb
exvo_globalize-0.3.2 lib/exvo_globalize/engine.rb