asset_pipeline_i18n 3.2.13 → 3.2.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +2 -4
- data/Gemfile.lock +91 -0
- data/README.rdoc +9 -9
- data/Rakefile +1 -29
- data/asset_pipeline_i18n.gemspec +23 -0
- data/changelog.txt +17 -0
- data/lib/asset_pipeline_i18n.rb +2 -0
- data/lib/asset_pipeline_i18n/version.rb +3 -0
- data/lib/tasks/assets_i18n.rake +75 -136
- metadata +19 -12
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
asset_pipeline_i18n (3.2.13.2)
|
5
|
+
rails (~> 3.2.13)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.2.14)
|
11
|
+
actionpack (= 3.2.14)
|
12
|
+
mail (~> 2.5.4)
|
13
|
+
actionpack (3.2.14)
|
14
|
+
activemodel (= 3.2.14)
|
15
|
+
activesupport (= 3.2.14)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.4)
|
19
|
+
rack (~> 1.4.5)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.2.1)
|
23
|
+
activemodel (3.2.14)
|
24
|
+
activesupport (= 3.2.14)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activerecord (3.2.14)
|
27
|
+
activemodel (= 3.2.14)
|
28
|
+
activesupport (= 3.2.14)
|
29
|
+
arel (~> 3.0.2)
|
30
|
+
tzinfo (~> 0.3.29)
|
31
|
+
activeresource (3.2.14)
|
32
|
+
activemodel (= 3.2.14)
|
33
|
+
activesupport (= 3.2.14)
|
34
|
+
activesupport (3.2.14)
|
35
|
+
i18n (~> 0.6, >= 0.6.4)
|
36
|
+
multi_json (~> 1.0)
|
37
|
+
arel (3.0.2)
|
38
|
+
builder (3.0.4)
|
39
|
+
erubis (2.7.0)
|
40
|
+
hike (1.2.3)
|
41
|
+
i18n (0.6.5)
|
42
|
+
journey (1.0.4)
|
43
|
+
json (1.8.0)
|
44
|
+
mail (2.5.4)
|
45
|
+
mime-types (~> 1.16)
|
46
|
+
treetop (~> 1.4.8)
|
47
|
+
mime-types (1.25)
|
48
|
+
multi_json (1.7.9)
|
49
|
+
polyglot (0.3.3)
|
50
|
+
rack (1.4.5)
|
51
|
+
rack-cache (1.2)
|
52
|
+
rack (>= 0.4)
|
53
|
+
rack-ssl (1.3.3)
|
54
|
+
rack
|
55
|
+
rack-test (0.6.2)
|
56
|
+
rack (>= 1.0)
|
57
|
+
rails (3.2.14)
|
58
|
+
actionmailer (= 3.2.14)
|
59
|
+
actionpack (= 3.2.14)
|
60
|
+
activerecord (= 3.2.14)
|
61
|
+
activeresource (= 3.2.14)
|
62
|
+
activesupport (= 3.2.14)
|
63
|
+
bundler (~> 1.0)
|
64
|
+
railties (= 3.2.14)
|
65
|
+
railties (3.2.14)
|
66
|
+
actionpack (= 3.2.14)
|
67
|
+
activesupport (= 3.2.14)
|
68
|
+
rack-ssl (~> 1.3.2)
|
69
|
+
rake (>= 0.8.7)
|
70
|
+
rdoc (~> 3.4)
|
71
|
+
thor (>= 0.14.6, < 2.0)
|
72
|
+
rake (10.1.0)
|
73
|
+
rdoc (3.12.2)
|
74
|
+
json (~> 1.4)
|
75
|
+
sprockets (2.2.2)
|
76
|
+
hike (~> 1.2)
|
77
|
+
multi_json (~> 1.0)
|
78
|
+
rack (~> 1.0)
|
79
|
+
tilt (~> 1.1, != 1.3.0)
|
80
|
+
thor (0.18.1)
|
81
|
+
tilt (1.4.1)
|
82
|
+
treetop (1.4.15)
|
83
|
+
polyglot
|
84
|
+
polyglot (>= 0.3.1)
|
85
|
+
tzinfo (0.3.37)
|
86
|
+
|
87
|
+
PLATFORMS
|
88
|
+
ruby
|
89
|
+
|
90
|
+
DEPENDENCIES
|
91
|
+
asset_pipeline_i18n!
|
data/README.rdoc
CHANGED
@@ -33,25 +33,25 @@ and of course, in your layout, you also have to use something like:
|
|
33
33
|
|
34
34
|
Finally:
|
35
35
|
|
36
|
-
rake assets:precompile
|
37
|
-
|
36
|
+
rake assets:precompile
|
37
|
+
|
38
38
|
Sample application: https://github.com/pic/rails_asset_pipeline_i18n (thanks to Morgan Hallgren)
|
39
39
|
|
40
40
|
== Known problems
|
41
41
|
|
42
|
-
=== Remove "require_tree ."
|
42
|
+
=== Remove "require_tree ."
|
43
43
|
|
44
44
|
It is no more possible to write
|
45
|
-
|
45
|
+
|
46
46
|
//= require_tree .
|
47
|
-
|
48
|
-
in application.js because this will create a circular dependency now. One easy workaround is to move all the js files
|
47
|
+
|
48
|
+
in application.js because this will create a circular dependency now. One easy workaround is to move all the js files
|
49
49
|
in a subdirectory (e.g. lib) and then:
|
50
50
|
|
51
51
|
//= require_tree ./lib
|
52
|
-
|
53
|
-
=== No proper i18n in development environment
|
54
|
-
|
52
|
+
|
53
|
+
=== No proper i18n in development environment
|
54
|
+
|
55
55
|
This gem is intended for compiling translated assets for production environment.
|
56
56
|
Unfortunately it does not provide proper translations when running in development environment due to assets caching.
|
57
57
|
|
data/Rakefile
CHANGED
@@ -1,29 +1 @@
|
|
1
|
-
|
2
|
-
require 'rubygems'
|
3
|
-
begin
|
4
|
-
require 'bundler/setup'
|
5
|
-
rescue LoadError
|
6
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'rake'
|
10
|
-
require 'rake/rdoctask'
|
11
|
-
|
12
|
-
#require 'rake/testtask'
|
13
|
-
|
14
|
-
#Rake::TestTask.new(:test) do |t|
|
15
|
-
# t.libs << 'lib'
|
16
|
-
# t.libs << 'test'
|
17
|
-
# t.pattern = 'test/**/*_test.rb'
|
18
|
-
# t.verbose = false
|
19
|
-
#end
|
20
|
-
|
21
|
-
task :default => :test
|
22
|
-
|
23
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
|
-
rdoc.rdoc_dir = 'rdoc'
|
25
|
-
rdoc.title = 'AssetPipelineI18n'
|
26
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
-
rdoc.rdoc_files.include('README.rdoc')
|
28
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "asset_pipeline_i18n/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "asset_pipeline_i18n"
|
7
|
+
s.version = AssetPipelineI18n::VERSION
|
8
|
+
s.authors = ["Nicola Piccinini", "Corin Langosch"]
|
9
|
+
s.email = ["nicola.piccinini@simplificator.com", "info@corinlangosch.com"]
|
10
|
+
s.homepage = "https://github.com/simplificator/asset_pipeline_i18n"
|
11
|
+
s.summary = %q{Localized precompiled assets for Rails}
|
12
|
+
s.description = %q{Localized precompiled assets for Rails}
|
13
|
+
|
14
|
+
s.rubyforge_project = "asset_pipeline_i18n"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_runtime_dependency "rails", "~> 3.2.13"
|
23
|
+
end
|
data/changelog.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
* version 3.2.13.2
|
2
|
+
- updated gemspec
|
3
|
+
|
4
|
+
* version 3.2.13.1
|
5
|
+
- complete rewrite for better performance
|
6
|
+
- fixes some known limitations/ bugs
|
7
|
+
- no more need to run "rake i18n:assets:precompile", just run "rake assets:precompile" as before
|
8
|
+
|
9
|
+
* version 3.2.8
|
10
|
+
should work unchanged with rails 3.2.8
|
11
|
+
relaxed dependencies
|
12
|
+
|
13
|
+
* version 3.2.6
|
14
|
+
should work unchanged with rails 3.2.6
|
15
|
+
|
16
|
+
* version 3.2.5
|
17
|
+
it works with rails 3.2.5
|
data/lib/asset_pipeline_i18n.rb
CHANGED
data/lib/tasks/assets_i18n.rake
CHANGED
@@ -1,160 +1,99 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
namespace :
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
1
|
+
# https://github.com/rails/rails/blob/v3.2.14/actionpack/lib/sprockets/assets.rake
|
2
|
+
namespace :assets do
|
3
|
+
namespace :precompile do
|
4
|
+
def internal_precompile(digest = nil)
|
5
|
+
# we have to reinvoke the rask task as we need a clean sprockets env
|
6
|
+
# this sucks, but well, cannot be changed due to design flaws in rails/ sprockets...
|
7
|
+
i18n_assets_grouped_by_locale.keys.each do |locale|
|
8
|
+
ENV['DIGEST'] = digest.nil? ? "true" : "false"
|
9
|
+
ENV['LOCALE'] = locale
|
10
|
+
ruby_rake_task "assets:precompile:localized"
|
11
|
+
end
|
12
|
+
|
13
|
+
# merge manifests on second (last) precompile run
|
14
|
+
merge_precompiled_assets if digest == false
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def invoke_or_reboot_rake_task(task)
|
21
|
-
if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
|
22
|
-
ruby_rake_task task
|
23
|
-
else
|
24
|
-
Rake::Task[task].invoke
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
desc "Compile all the localized assets named in config.assets.localized_precompile"
|
29
|
-
task :precompile do
|
30
|
-
invoke_or_reboot_rake_task "i18n:assets:precompile:all"
|
31
|
-
end
|
32
|
-
|
33
|
-
namespace :precompile do
|
34
|
-
def internal_localized_precompile(digest = nil)
|
35
|
-
unless Rails.application.config.assets.enabled
|
36
|
-
warn "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true"
|
37
|
-
exit
|
38
|
-
end
|
39
|
-
|
40
|
-
# Ensure that action view is loaded and the appropriate
|
41
|
-
# sprockets hooks get executed
|
42
|
-
_ = ActionView::Base
|
43
|
-
|
44
|
-
config = Rails.application.config
|
45
|
-
config.assets.compile = true
|
46
|
-
config.assets.digest = digest unless digest.nil?
|
47
|
-
config.assets.digests = {}
|
48
|
-
|
49
|
-
# changes for i18n
|
50
|
-
env = Rails.application.assets
|
51
|
-
target = File.join(Rails.public_path, config.assets.prefix)
|
52
|
-
|
53
|
-
asset = ENV['LOCALIZED_ASSET']
|
54
|
-
I18n.locale = manifest_locale(asset)
|
55
|
-
|
56
|
-
compiler = Sprockets::StaticCompiler.new(env,
|
57
|
-
target,
|
58
|
-
[asset], # i18n change
|
59
|
-
:manifest_path => manifest_path(asset), # i18n change
|
60
|
-
:digest => config.assets.digest,
|
61
|
-
:manifest => digest.nil?)
|
62
|
-
compiler.compile
|
63
|
-
end
|
64
|
-
|
65
|
-
def manifest_locale(localized_asset)
|
66
|
-
localized_asset.match(/-([^.]+)/)[1]
|
67
|
-
end
|
17
|
+
def internal_precompile_i18n(assets, locale, digest = nil)
|
18
|
+
puts "Precompiling assets with locale #{locale}..."
|
19
|
+
I18n.locale = locale
|
68
20
|
|
69
|
-
|
70
|
-
|
21
|
+
unless Rails.application.config.assets.enabled
|
22
|
+
warn "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true"
|
23
|
+
exit
|
71
24
|
end
|
72
25
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
config.assets.manifest ? "#{config.assets.manifest}/manifest.yml" : "#{target}/manifest.yml"
|
77
|
-
end
|
26
|
+
# Ensure that action view is loaded and the appropriate
|
27
|
+
# sprockets hooks get executed
|
28
|
+
_ = ActionView::Base
|
78
29
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
unless File.exist?(manifest_file)
|
84
|
-
warn "Manifest file is missing. Please run standard assets:precompile before i18n:assets:precompile"
|
85
|
-
exit 1
|
86
|
-
end
|
30
|
+
config = Rails.application.config
|
31
|
+
config.assets.compile = true
|
32
|
+
config.assets.digest = digest unless digest.nil?
|
33
|
+
config.assets.digests = {}
|
87
34
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
Array(Rails.application.config.assets.localized_precompile).each do |asset|
|
94
|
-
File.open(manifest_path(asset) + "/manifest.yml") do |f|
|
95
|
-
localized_manifest = YAML::load(f)
|
96
|
-
manifest.merge!(localized_manifest)
|
97
|
-
end
|
98
|
-
end
|
35
|
+
env = Rails.application.assets
|
36
|
+
target = File.join(tmp_path, locale)
|
37
|
+
Sprockets::StaticCompiler.new(env, target, assets, :manifest_path => config.assets.manifest, :digest => config.assets.digest, :manifest => digest.nil?).compile
|
38
|
+
end
|
99
39
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
40
|
+
def i18n_assets_grouped_by_locale
|
41
|
+
Rails.application.config.assets.localized_precompile.map{ |name| {:name => name, :locale => name.match(/-([a-z]+)\./)[1]} }.group_by{ |v| v[:locale] }.each_value{ |g| g.map!{ |i| i[:name] } }
|
42
|
+
end
|
104
43
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
end
|
44
|
+
def precompile_assets(locale, digest)
|
45
|
+
assets = i18n_assets_grouped_by_locale[locale]
|
46
|
+
assets.concat(Rails.application.config.assets.precompile) if I18n.default_locale.to_s == locale
|
47
|
+
internal_precompile_i18n(assets, locale, digest)
|
48
|
+
end
|
111
49
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
50
|
+
def manifest_filename
|
51
|
+
Rails.application.config.assets.manifest || "manifest.yml"
|
52
|
+
end
|
116
53
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
fixup_assets_manifest
|
121
|
-
end
|
54
|
+
def real_path
|
55
|
+
File.join(Rails.public_path, Rails.application.config.assets.prefix)
|
56
|
+
end
|
122
57
|
|
123
|
-
|
124
|
-
|
125
|
-
|
58
|
+
def tmp_path
|
59
|
+
File.join(real_path, "tmp")
|
60
|
+
end
|
126
61
|
|
127
|
-
|
128
|
-
|
129
|
-
|
62
|
+
def merge_precompiled_assets
|
63
|
+
puts "Building manifest..."
|
64
|
+
manifest = {}
|
65
|
+
|
66
|
+
i18n_assets_grouped_by_locale.keys.each do |locale|
|
67
|
+
root_path = File.join(tmp_path, locale)
|
68
|
+
Dir[File.join(root_path, *(["/**"]*10))].each do |src_path|
|
69
|
+
dst_path = File.join(real_path, src_path[(root_path.length + 1)..-1])
|
70
|
+
|
71
|
+
name = File.basename(src_path)
|
72
|
+
folder = File.dirname(src_path)
|
73
|
+
if name == manifest_filename
|
74
|
+
File.open(src_path, "rb") do |f|
|
75
|
+
manifest.merge!(YAML::load(f))
|
76
|
+
end
|
77
|
+
next
|
78
|
+
end
|
130
79
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
config.assets.localized_precompile.each do |asset|
|
136
|
-
puts "Invoking assets precompile task for localized asset #{asset}..."
|
137
|
-
ENV['LOCALIZED_ASSET'] = asset
|
138
|
-
ruby_rake_task "i18n:assets:precompile:localized_asset"
|
80
|
+
if File.directory?(src_path)
|
81
|
+
FileUtils.mkdir(dst_path) unless File.exists?(dst_path)
|
82
|
+
else
|
83
|
+
FileUtils.cp(src_path, dst_path)
|
139
84
|
end
|
140
85
|
end
|
141
86
|
end
|
142
87
|
|
143
|
-
|
144
|
-
|
145
|
-
Rake::Task["i18n:assets:precompile:localized_primary"].invoke
|
146
|
-
ruby_rake_task("i18n:assets:precompile:localized_nondigest", false) if Rails.application.config.assets.digest
|
88
|
+
File.open(File.join(real_path, manifest_filename), "wb") do |f|
|
89
|
+
YAML.dump(manifest, f)
|
147
90
|
end
|
148
91
|
|
149
|
-
|
150
|
-
|
151
|
-
internal_localized_precompile
|
152
|
-
end
|
92
|
+
FileUtils.rm_r(tmp_path)
|
93
|
+
end
|
153
94
|
|
154
|
-
|
155
|
-
|
156
|
-
internal_localized_precompile(false)
|
157
|
-
end
|
95
|
+
task :localized => ["assets:environment", "tmp:cache:clear"] do
|
96
|
+
precompile_assets(ENV['LOCALE'], (ENV['DIGEST'] == "true") ? nil : false)
|
158
97
|
end
|
159
98
|
end
|
160
99
|
end
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset_pipeline_i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.13
|
4
|
+
version: 3.2.13.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nicola Piccinini
|
9
|
+
- Corin Langosch
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
+
date: 2013-09-03 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
+
name: rails
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
@@ -27,20 +28,26 @@ dependencies:
|
|
27
28
|
- - ~>
|
28
29
|
- !ruby/object:Gem::Version
|
29
30
|
version: 3.2.13
|
30
|
-
description:
|
31
|
-
|
32
|
-
|
31
|
+
description: Localized precompiled assets for Rails
|
32
|
+
email:
|
33
|
+
- nicola.piccinini@simplificator.com
|
34
|
+
- info@corinlangosch.com
|
33
35
|
executables: []
|
34
36
|
extensions: []
|
35
37
|
extra_rdoc_files: []
|
36
38
|
files:
|
39
|
+
- .gitignore
|
40
|
+
- Gemfile
|
41
|
+
- Gemfile.lock
|
42
|
+
- MIT-LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
- Rakefile
|
45
|
+
- asset_pipeline_i18n.gemspec
|
46
|
+
- changelog.txt
|
37
47
|
- lib/asset_pipeline_i18n.rb
|
38
48
|
- lib/asset_pipeline_i18n/railtie.rb
|
49
|
+
- lib/asset_pipeline_i18n/version.rb
|
39
50
|
- lib/tasks/assets_i18n.rake
|
40
|
-
- MIT-LICENSE
|
41
|
-
- Rakefile
|
42
|
-
- Gemfile
|
43
|
-
- README.rdoc
|
44
51
|
homepage: https://github.com/simplificator/asset_pipeline_i18n
|
45
52
|
licenses: []
|
46
53
|
post_install_message:
|
@@ -60,9 +67,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
67
|
- !ruby/object:Gem::Version
|
61
68
|
version: '0'
|
62
69
|
requirements: []
|
63
|
-
rubyforge_project:
|
70
|
+
rubyforge_project: asset_pipeline_i18n
|
64
71
|
rubygems_version: 1.8.25
|
65
72
|
signing_key:
|
66
73
|
specification_version: 3
|
67
|
-
summary: Localized precompiled assets for
|
74
|
+
summary: Localized precompiled assets for Rails
|
68
75
|
test_files: []
|