Class: Sprockets::StaticCompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/assets/sprockets.rb

Instance Method Summary collapse

Instance Method Details

#compileObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/i18n/assets/sprockets.rb', line 41

def compile
  manifest = {}
  env.each_logical_path(paths) do |logical_path|
    process = lambda do
      if asset = env.find_asset(logical_path)
        digest_path = write_asset(asset)
        manifest[asset.logical_path] = digest_path
        manifest[aliased_path_for(asset.logical_path)] = digest_path
      end
    end

    if Sprockets.localizable?(logical_path)
      (Rails.configuration.assets.locales || I18n.available_locales).each do |locale|
        I18n.locale = locale
        process.call
      end
    else
      process.call
    end
  end

  I18n.locale = I18n.default_locale

  write_manifest(manifest) if @manifest
end