asset_pipeline_i18n 3.2.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify any dependencies in the gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,23 @@
1
+ = AssetPipelineI18n
2
+
3
+ asset-pipeline + i18n
4
+
5
+ In your Gemfile
6
+
7
+ group :assets do
8
+ gem 'asset_pipeline_i18n'
9
+ end
10
+
11
+ In your application.rb
12
+
13
+ config.assets.localized_precompile = ['application-it.js', 'application-fr.js', 'application-de.js', 'application-en.js']
14
+
15
+ then
16
+
17
+ rake assets:precompile i18n:assets:precompile
18
+
19
+ Of course you also have to use something like:
20
+ javascript_include_tag "application-#{I18n.locale}"
21
+
22
+ Home page: https://github.com/simplificator/asset_pipeline_i18n
23
+
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
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
@@ -0,0 +1,11 @@
1
+ require 'asset_pipeline_i18n'
2
+ require 'rails'
3
+ module AssetPipelineI18n
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :asset_pipeline_i18n
6
+
7
+ rake_tasks do
8
+ load "tasks/assets_i18n.rake"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module AssetPipelineI18n
2
+ require 'asset_pipeline_i18n/railtie' if defined?(Rails)
3
+ end
@@ -0,0 +1,159 @@
1
+ # actionpack-3.2.3/lib/sprockets/assets.rake
2
+
3
+ require "fileutils"
4
+
5
+ namespace :i18n do
6
+ namespace :assets do
7
+ def ruby_rake_task(task, fork = true)
8
+ env = ENV['RAILS_ENV'] || 'production'
9
+ groups = ENV['RAILS_GROUPS'] || 'assets'
10
+ args = [$0, task,"RAILS_ENV=#{env}","RAILS_GROUPS=#{groups}"]
11
+ args << "--trace" if Rake.application.options.trace
12
+ if $0 =~ /rake\.bat\Z/i
13
+ Kernel.exec $0, *args
14
+ else
15
+ fork ? ruby(*args) : Kernel.exec(FileUtils::RUBY, *args)
16
+ end
17
+ end
18
+
19
+ # We are currently running with no explicit bundler group
20
+ # and/or no explicit environment - we have to reinvoke rake to
21
+ # execute this task.
22
+ def invoke_or_reboot_rake_task(task)
23
+ if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
24
+ ruby_rake_task task
25
+ else
26
+ Rake::Task[task].invoke
27
+ end
28
+ end
29
+
30
+ desc "Compile all the localized assets named in config.assets.localized_precompile"
31
+ task :precompile do
32
+ invoke_or_reboot_rake_task "i18n:assets:precompile:all"
33
+ end
34
+
35
+ namespace :precompile do
36
+
37
+ def internal_localized_precompile(digest = nil)
38
+ unless Rails.application.config.assets.enabled
39
+ warn "Cannot precompile assets if sprockets is disabled. Please set config.assets.enabled to true"
40
+ exit
41
+ end
42
+
43
+ # Ensure that action view is loaded and the appropriate
44
+ # sprockets hooks get executed
45
+ _ = ActionView::Base
46
+
47
+ config = Rails.application.config
48
+ config.assets.compile = true
49
+ config.assets.digest = digest unless digest.nil?
50
+ config.assets.digests = {}
51
+
52
+ # changes for i18n
53
+ env = Rails.application.assets
54
+ target = File.join(Rails.public_path, config.assets.prefix)
55
+
56
+ asset = ENV['LOCALIZED_ASSET']
57
+ # extract locale
58
+ locale = asset.match(/.*-([[:alpha:]][[:alpha:]])\..*/)[1]
59
+
60
+ I18n.locale = locale
61
+
62
+ manifest_path = config.assets.manifest ? "#{config.assets.manifest}.#{locale}" : "#{target}/manifest.#{locale}"
63
+ # end e18n
64
+
65
+ compiler = Sprockets::StaticCompiler.new(env,
66
+ target,
67
+ [asset], # i18n change
68
+ :manifest_path => manifest_path, # i18n change
69
+ :digest => config.assets.digest,
70
+ :manifest => digest.nil?)
71
+ compiler.compile
72
+ end
73
+
74
+ # i18n
75
+ def merge_manifests
76
+
77
+ config = Rails.application.config
78
+ target = File.join(Rails.public_path, config.assets.prefix)
79
+
80
+ manifest_file = config.assets.manifest ? "#{config.assets.manifest}/manifest.yml" : "#{target}/manifest.yml"
81
+
82
+ manifest = {}
83
+ if File.exist?(manifest_file)
84
+ File.open(manifest_file) do |f|
85
+ manifest = YAML::load(f)
86
+ end
87
+ else
88
+ warn "Manifest file is missing. Please run standard assets:precompile before i18n:assets:precompile"
89
+ exit 1
90
+ end
91
+
92
+ if config.assets.localized_precompile
93
+ config.assets.localized_precompile.each do |asset|
94
+ locale = asset.match(/.*-([[:alpha:]][[:alpha:]])\..*/)[1]
95
+
96
+ localized_manifest_file = config.assets.manifest ? "#{config.assets.manifest}/manifest.#{locale}/manifest.yml" : "#{target}/manifest.#{locale}/manifest.yml"
97
+ File.open(localized_manifest_file) do |f|
98
+ localized_manifest = YAML::load(f)
99
+ manifest.merge!(localized_manifest)
100
+ end
101
+ end
102
+ end
103
+
104
+ File.open(manifest_file, 'wb') do |f|
105
+ YAML.dump(manifest, f)
106
+ end
107
+ end
108
+
109
+ # i18n
110
+ task :merge_manifests do
111
+ merge_manifests
112
+ end
113
+
114
+ task :all do
115
+ ruby_rake_task "i18n:assets:precompile:localized"
116
+
117
+ merge_manifests
118
+ end
119
+
120
+ task :primary => ["assets:environment", "tmp:cache:clear"] do
121
+ internal_precompile
122
+ end
123
+
124
+ task :nondigest => ["assets:environment", "tmp:cache:clear"] do
125
+ internal_precompile(false)
126
+ end
127
+
128
+ # i18n
129
+ task :localized do
130
+ config = Rails.application.config
131
+ if config.assets.localized_precompile
132
+ config.assets.localized_precompile.each do |asset|
133
+ ENV['LOCALIZED_ASSET'] = asset
134
+ ruby_rake_task "i18n:assets:precompile:localized_asset"
135
+ end
136
+ end
137
+ end
138
+
139
+ # i18n
140
+ task :localized_asset do
141
+ Rake::Task["i18n:assets:precompile:localized_primary"].invoke
142
+ ruby_rake_task("i18n:assets:precompile:localized_nondigest", false) if Rails.application.config.assets.digest
143
+ end
144
+
145
+ # i18n
146
+ task :localized_primary => ["assets:environment", "tmp:cache:clear"] do
147
+ internal_localized_precompile
148
+ end
149
+
150
+ # i18n
151
+ task :localized_nondigest => ["assets:environment", "tmp:cache:clear"] do
152
+ internal_localized_precompile(false)
153
+ end
154
+
155
+ end
156
+
157
+ end
158
+
159
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: asset_pipeline_i18n
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.2.5.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nicola Piccinini
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: actionpack
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.5
30
+ description: Provide some additional rake task to precompile assets for any available
31
+ locale
32
+ email: nicola.piccinini@simplificator.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - lib/asset_pipeline_i18n/railtie.rb
38
+ - lib/tasks/assets_i18n.rake
39
+ - lib/asset_pipeline_i18n.rb
40
+ - MIT-LICENSE
41
+ - Rakefile
42
+ - Gemfile
43
+ - README.rdoc
44
+ homepage: https://github.com/simplificator/asset_pipeline_i18n
45
+ licenses: []
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 1.8.21
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: Localized precompiled assets for rails
68
+ test_files: []