Sha256: 7ed916d2559c08a0be2aff6209f0a689045c69630f8eaacb48b8689328662ca2
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require 'rails' require 'sprockets/rails/task' module AssetPipelineI18n class Railtie < Rails::Railtie initializer "asset_pipeline_i18n.initialization" do Sprockets::Rails::Task.new(Rails.application) do |t| # # predefined methods we need to customize # def t.assets Rails.configuration.localized_assets.map{ |name| name % {:locale => I18n.locale} } end def t.define # This implementation gets called in addition to the original implementation # when executing the rake task namespace :assets do desc "Compile all the assets named in config.assets.precompile" task :precompile => :environment do I18n.available_locales.each do |locale| Rails.logger.info "Compiling assets for locale #{locale}..." I18n.locale = locale with_logger do clean_cache manifest.compile(assets) end end I18n.locale = I18n.default_locale Rails.logger.info "Reset locale to default of #{I18n.locale}..." end end end # # new methods for better code structure on our side # def t.clean_cache env = manifest.environment def env.expire_index! @assets.clear end manifest.environment.send(:expire_index!) rm_rf(cache_path) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
asset_pipeline_i18n-4.0.1.1 | lib/asset_pipeline_i18n/railtie.rb |
asset_pipeline_i18n-4.0.1.0 | lib/asset_pipeline_i18n/railtie.rb |