spree_change_locale 0.3.1 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/Gemfile +22 -0
- data/Gemfile.lock +221 -0
- data/LICENSE +26 -0
- data/README.md +40 -0
- data/Rakefile +31 -0
- data/Versionfile +1 -0
- data/app/assets/javascripts/admin/spree_change_locale.js +1 -0
- data/app/assets/javascripts/locale.js +2 -0
- data/app/assets/javascripts/store/spree_change_locale.js +1 -0
- data/app/assets/stylesheets/admin/spree_change_locale.css +3 -0
- data/app/assets/stylesheets/locale.css +4 -0
- data/app/assets/stylesheets/store/spree_change_locale.css +3 -0
- data/app/controllers/base_controller_decorator.rb +28 -0
- data/app/controllers/locale_controller.rb +14 -0
- data/app/helpers/locale_helper.rb +10 -0
- data/config/routes.rb +4 -0
- data/examples/_language_bar.html.erb +5 -0
- data/lib/generators/spree_change_locale/install/install_generator.rb +29 -0
- data/lib/spree_change_locale/engine.rb +24 -0
- data/lib/spree_change_locale.rb +3 -0
- data/script/rails +7 -0
- data/spec/controllers/locale_controller_spec.rb +5 -0
- data/spec/helpers/locale_helper_spec.rb +15 -0
- data/spec/spec_helper.rb +31 -0
- data/spree_change_locale.gemspec +24 -0
- metadata +33 -5
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/Gemfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'sqlite3'
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem 'rspec-rails', '= 2.6.1'
|
7
|
+
end
|
8
|
+
|
9
|
+
group :cucumber do
|
10
|
+
gem 'cucumber-rails', '1.0.0'
|
11
|
+
gem 'database_cleaner', '= 0.6.7'
|
12
|
+
gem 'nokogiri'
|
13
|
+
gem 'capybara', '1.0.1'
|
14
|
+
end
|
15
|
+
|
16
|
+
if RUBY_VERSION < "1.9"
|
17
|
+
gem "ruby-debug"
|
18
|
+
else
|
19
|
+
gem "ruby-debug19"
|
20
|
+
end
|
21
|
+
|
22
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
spree_change_locale (0.70.1)
|
5
|
+
spree_core (>= 0.70.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionmailer (3.1.1)
|
11
|
+
actionpack (= 3.1.1)
|
12
|
+
mail (~> 2.3.0)
|
13
|
+
actionpack (3.1.1)
|
14
|
+
activemodel (= 3.1.1)
|
15
|
+
activesupport (= 3.1.1)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
i18n (~> 0.6)
|
19
|
+
rack (~> 1.3.2)
|
20
|
+
rack-cache (~> 1.1)
|
21
|
+
rack-mount (~> 0.8.2)
|
22
|
+
rack-test (~> 0.6.1)
|
23
|
+
sprockets (~> 2.0.2)
|
24
|
+
activemerchant (1.17.0)
|
25
|
+
activesupport (>= 2.3.11)
|
26
|
+
braintree (>= 2.0.0)
|
27
|
+
builder (>= 2.0.0)
|
28
|
+
json (>= 1.5.1)
|
29
|
+
activemodel (3.1.1)
|
30
|
+
activesupport (= 3.1.1)
|
31
|
+
builder (~> 3.0.0)
|
32
|
+
i18n (~> 0.6)
|
33
|
+
activerecord (3.1.1)
|
34
|
+
activemodel (= 3.1.1)
|
35
|
+
activesupport (= 3.1.1)
|
36
|
+
arel (~> 2.2.1)
|
37
|
+
tzinfo (~> 0.3.29)
|
38
|
+
activeresource (3.1.1)
|
39
|
+
activemodel (= 3.1.1)
|
40
|
+
activesupport (= 3.1.1)
|
41
|
+
activesupport (3.1.1)
|
42
|
+
multi_json (~> 1.0)
|
43
|
+
acts_as_list (0.1.4)
|
44
|
+
archive-tar-minitar (0.5.2)
|
45
|
+
arel (2.2.1)
|
46
|
+
braintree (2.13.0)
|
47
|
+
builder (>= 2.0.0)
|
48
|
+
builder (3.0.0)
|
49
|
+
capybara (1.0.1)
|
50
|
+
mime-types (>= 1.16)
|
51
|
+
nokogiri (>= 1.3.3)
|
52
|
+
rack (>= 1.0.0)
|
53
|
+
rack-test (>= 0.5.4)
|
54
|
+
selenium-webdriver (~> 2.0)
|
55
|
+
xpath (~> 0.1.4)
|
56
|
+
childprocess (0.2.2)
|
57
|
+
ffi (~> 1.0.6)
|
58
|
+
cocaine (0.2.0)
|
59
|
+
columnize (0.3.4)
|
60
|
+
cucumber (1.0.6)
|
61
|
+
builder (>= 2.1.2)
|
62
|
+
diff-lcs (>= 1.1.2)
|
63
|
+
gherkin (~> 2.4.18)
|
64
|
+
json (>= 1.4.6)
|
65
|
+
term-ansicolor (>= 1.0.6)
|
66
|
+
cucumber-rails (1.0.0)
|
67
|
+
capybara (>= 1.0.0)
|
68
|
+
cucumber (~> 1.0.0)
|
69
|
+
nokogiri (>= 1.4.4)
|
70
|
+
rack-test (>= 0.5.7)
|
71
|
+
database_cleaner (0.6.7)
|
72
|
+
deface (0.7.1)
|
73
|
+
nokogiri (~> 1.5.0)
|
74
|
+
rails (>= 3.0.9)
|
75
|
+
diff-lcs (1.1.3)
|
76
|
+
erubis (2.7.0)
|
77
|
+
faker (1.0.0)
|
78
|
+
i18n (~> 0.4)
|
79
|
+
ffi (1.0.9)
|
80
|
+
gherkin (2.4.21)
|
81
|
+
json (>= 1.4.6)
|
82
|
+
highline (1.5.1)
|
83
|
+
hike (1.2.1)
|
84
|
+
i18n (0.6.0)
|
85
|
+
jquery-rails (1.0.16)
|
86
|
+
railties (~> 3.0)
|
87
|
+
thor (~> 0.14)
|
88
|
+
json (1.6.1)
|
89
|
+
json_pure (1.6.1)
|
90
|
+
kaminari (0.12.4)
|
91
|
+
rails (>= 3.0.0)
|
92
|
+
linecache19 (0.5.12)
|
93
|
+
ruby_core_source (>= 0.1.4)
|
94
|
+
mail (2.3.0)
|
95
|
+
i18n (>= 0.4.0)
|
96
|
+
mime-types (~> 1.16)
|
97
|
+
treetop (~> 1.4.8)
|
98
|
+
meta_search (1.1.1)
|
99
|
+
actionpack (~> 3.1.0)
|
100
|
+
activerecord (~> 3.1.0)
|
101
|
+
activesupport (~> 3.1.0)
|
102
|
+
polyamorous (~> 0.5.0)
|
103
|
+
mime-types (1.17.2)
|
104
|
+
multi_json (1.0.3)
|
105
|
+
nested_set (1.6.8)
|
106
|
+
activerecord (>= 3.0.0)
|
107
|
+
railties (>= 3.0.0)
|
108
|
+
nokogiri (1.5.0)
|
109
|
+
paperclip (2.4.1)
|
110
|
+
activerecord (>= 2.3.0)
|
111
|
+
activesupport (>= 2.3.2)
|
112
|
+
cocaine (>= 0.0.2)
|
113
|
+
mime-types
|
114
|
+
polyamorous (0.5.0)
|
115
|
+
activerecord (~> 3.0)
|
116
|
+
polyglot (0.3.3)
|
117
|
+
rack (1.3.5)
|
118
|
+
rack-cache (1.1)
|
119
|
+
rack (>= 0.4)
|
120
|
+
rack-mount (0.8.3)
|
121
|
+
rack (>= 1.0.0)
|
122
|
+
rack-ssl (1.3.2)
|
123
|
+
rack
|
124
|
+
rack-test (0.6.1)
|
125
|
+
rack (>= 1.0)
|
126
|
+
rails (3.1.1)
|
127
|
+
actionmailer (= 3.1.1)
|
128
|
+
actionpack (= 3.1.1)
|
129
|
+
activerecord (= 3.1.1)
|
130
|
+
activeresource (= 3.1.1)
|
131
|
+
activesupport (= 3.1.1)
|
132
|
+
bundler (~> 1.0)
|
133
|
+
railties (= 3.1.1)
|
134
|
+
railties (3.1.1)
|
135
|
+
actionpack (= 3.1.1)
|
136
|
+
activesupport (= 3.1.1)
|
137
|
+
rack-ssl (~> 1.3.2)
|
138
|
+
rake (>= 0.8.7)
|
139
|
+
rdoc (~> 3.4)
|
140
|
+
thor (~> 0.14.6)
|
141
|
+
rake (0.9.2.2)
|
142
|
+
rd_find_by_param (0.1.1)
|
143
|
+
activerecord (~> 3.0)
|
144
|
+
activesupport (~> 3.0)
|
145
|
+
rd_resource_controller (1.0.1)
|
146
|
+
rdoc (3.11)
|
147
|
+
json (~> 1.4)
|
148
|
+
rspec (2.6.0)
|
149
|
+
rspec-core (~> 2.6.0)
|
150
|
+
rspec-expectations (~> 2.6.0)
|
151
|
+
rspec-mocks (~> 2.6.0)
|
152
|
+
rspec-core (2.6.4)
|
153
|
+
rspec-expectations (2.6.0)
|
154
|
+
diff-lcs (~> 1.1.2)
|
155
|
+
rspec-mocks (2.6.0)
|
156
|
+
rspec-rails (2.6.1)
|
157
|
+
actionpack (~> 3.0)
|
158
|
+
activesupport (~> 3.0)
|
159
|
+
railties (~> 3.0)
|
160
|
+
rspec (~> 2.6.0)
|
161
|
+
ruby-debug-base19 (0.11.25)
|
162
|
+
columnize (>= 0.3.1)
|
163
|
+
linecache19 (>= 0.5.11)
|
164
|
+
ruby_core_source (>= 0.1.4)
|
165
|
+
ruby-debug19 (0.11.6)
|
166
|
+
columnize (>= 0.3.1)
|
167
|
+
linecache19 (>= 0.5.11)
|
168
|
+
ruby-debug-base19 (>= 0.11.19)
|
169
|
+
ruby_core_source (0.1.5)
|
170
|
+
archive-tar-minitar (>= 0.5.2)
|
171
|
+
rubyzip (0.9.4)
|
172
|
+
selenium-webdriver (2.10.0)
|
173
|
+
childprocess (>= 0.2.1)
|
174
|
+
ffi (= 1.0.9)
|
175
|
+
json_pure
|
176
|
+
rubyzip
|
177
|
+
spree_core (0.70.1)
|
178
|
+
activemerchant (= 1.17.0)
|
179
|
+
acts_as_list (= 0.1.4)
|
180
|
+
deface (>= 0.7.0)
|
181
|
+
faker (= 1.0.0)
|
182
|
+
highline (= 1.5.1)
|
183
|
+
jquery-rails (>= 1.0.14)
|
184
|
+
kaminari (>= 0.12.4)
|
185
|
+
meta_search (= 1.1.1)
|
186
|
+
nested_set (= 1.6.8)
|
187
|
+
paperclip (= 2.4.1)
|
188
|
+
rails (= 3.1.1)
|
189
|
+
rd_find_by_param (= 0.1.1)
|
190
|
+
rd_resource_controller
|
191
|
+
state_machine (= 1.0.1)
|
192
|
+
stringex (= 1.0.3)
|
193
|
+
sprockets (2.0.3)
|
194
|
+
hike (~> 1.2)
|
195
|
+
rack (~> 1.0)
|
196
|
+
tilt (~> 1.1, != 1.3.0)
|
197
|
+
sqlite3 (1.3.4)
|
198
|
+
state_machine (1.0.1)
|
199
|
+
stringex (1.0.3)
|
200
|
+
term-ansicolor (1.0.7)
|
201
|
+
thor (0.14.6)
|
202
|
+
tilt (1.3.3)
|
203
|
+
treetop (1.4.10)
|
204
|
+
polyglot
|
205
|
+
polyglot (>= 0.3.1)
|
206
|
+
tzinfo (0.3.30)
|
207
|
+
xpath (0.1.4)
|
208
|
+
nokogiri (~> 1.3)
|
209
|
+
|
210
|
+
PLATFORMS
|
211
|
+
ruby
|
212
|
+
|
213
|
+
DEPENDENCIES
|
214
|
+
capybara (= 1.0.1)
|
215
|
+
cucumber-rails (= 1.0.0)
|
216
|
+
database_cleaner (= 0.6.7)
|
217
|
+
nokogiri
|
218
|
+
rspec-rails (= 2.6.1)
|
219
|
+
ruby-debug19
|
220
|
+
spree_change_locale!
|
221
|
+
sqlite3
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2011 humancopy.net
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
##Spree Change Locale
|
2
|
+
|
3
|
+
Easy locale change in Spree.
|
4
|
+
|
5
|
+
##Install
|
6
|
+
|
7
|
+
Add the following to your Gemfile
|
8
|
+
|
9
|
+
gem 'spree_change_locale', :git => 'git://github.com/humancopy/spree-change-locale.git'
|
10
|
+
|
11
|
+
Run:
|
12
|
+
|
13
|
+
bundle install
|
14
|
+
|
15
|
+
##Example
|
16
|
+
|
17
|
+
Adds a locale controller and route so then any path can be prepended with the locale.
|
18
|
+
|
19
|
+
The extension saves the locale in *session[:locale]* and redirects back to the requested page, omitting the locale from the path.
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
|
23
|
+
* /es/cart => /cart in Spanish
|
24
|
+
* /fr/account => /account in French
|
25
|
+
* /ru => / in Russian.
|
26
|
+
|
27
|
+
Look at [examples/_language_bar.html.erb](https://github.com/humancopy/spree-change-locale/blob/master/examples/_language_bar.html.erb) for a simple use in views.
|
28
|
+
|
29
|
+
By default the extension will look at config/locales for enabled locales. If none found, it will fall to *I18n.available_locales* and then to single *I18n.default_locale*.
|
30
|
+
|
31
|
+
You can setup *Spree::Config[:enabled_locales]* with an array of available locales to force a list of enabled locales. (e.g. ```Spree::Config.set(:enabled_locales, ['en','es','it'])```)
|
32
|
+
|
33
|
+
<!-- ## Testing
|
34
|
+
|
35
|
+
Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
|
36
|
+
|
37
|
+
$ bundle exec rake test app
|
38
|
+
$ bundle exec rspec spec -->
|
39
|
+
|
40
|
+
Copyright (c) 2011 humancopy.net, released under the New BSD License
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/packagetask'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
require 'spree_core/testing_support/common_rake'
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new
|
10
|
+
Cucumber::Rake::Task.new
|
11
|
+
|
12
|
+
task :default => [:spec, :cucumber ]
|
13
|
+
|
14
|
+
spec = eval(File.read('spree_change_locale.gemspec'))
|
15
|
+
|
16
|
+
Gem::PackageTask.new(spec) do |p|
|
17
|
+
p.gem_spec = spec
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Release to gemcutter"
|
21
|
+
task :release => :package do
|
22
|
+
require 'rake/gemcutter'
|
23
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
24
|
+
Rake::Task['gem:push'].invoke
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Generates a dummy app for testing"
|
28
|
+
task :test_app do
|
29
|
+
ENV['LIB_NAME'] = 'spree_change_locale'
|
30
|
+
Rake::Task['common:test_app'].invoke
|
31
|
+
end
|
data/Versionfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"0.70.x" => { :version => "0.4" }
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require store/spree_core
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Spree::BaseController.class_eval do
|
2
|
+
helper_method :enabled_locales
|
3
|
+
before_filter :set_locale, :if => proc { !session[:locale] }
|
4
|
+
|
5
|
+
protected
|
6
|
+
def enabled_locales
|
7
|
+
@enabled_locales ||= (Spree::Config.get(:enabled_locales) || get_locales || I18n.available_locales || [I18n.default_locale]).collect(&:intern)
|
8
|
+
end
|
9
|
+
|
10
|
+
# inspired by: https://github.com/greendog/spree_locales_dropdown
|
11
|
+
def get_locales
|
12
|
+
path = Rails.root.join('config', 'locales')
|
13
|
+
items = Dir.glob(Rails.root.join('config', 'locales', '*.yml')).collect { |filename| File.basename(filename.gsub(/\.yml$/, '')) }
|
14
|
+
items unless items.blank?
|
15
|
+
# Dir.glob(Rails.root.join('config', 'locales', '*.yml')).inject([]) do |mem, filename|
|
16
|
+
# locale_file = YAML.load_file(path.join(filename))
|
17
|
+
# str = File.basename(filename.gsub(/\.yml$/, ''))
|
18
|
+
# str = str.gsub("_spree", "")
|
19
|
+
# mem << str if locale_file.has_key?(str)
|
20
|
+
#
|
21
|
+
# mem
|
22
|
+
# end
|
23
|
+
end
|
24
|
+
|
25
|
+
def set_locale
|
26
|
+
session[:locale] = I18n.locale = (request.preferred_language_from(enabled_locales) || request.compatible_language_from(enabled_locales) || I18n.default_locale).intern
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class LocaleController < Spree::BaseController
|
2
|
+
def set
|
3
|
+
if request.referer && request.referer.starts_with?("http://" + request.host)
|
4
|
+
session["user_return_to"] = request.referer
|
5
|
+
end
|
6
|
+
if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
|
7
|
+
session[:locale] = I18n.locale = params[:locale].to_sym
|
8
|
+
# flash.notice = t(:locale_changed)
|
9
|
+
# else
|
10
|
+
# flash[:error] = t(:locale_not_changed)
|
11
|
+
end
|
12
|
+
redirect_back_or_default(params[:return_path] ? "/#{params[:return_path]}" : root_path)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module LocaleHelper
|
2
|
+
def link_to_locale(locale, name = nil)
|
3
|
+
link_to name || locale_name(locale), "/#{locale}#{request.path}"
|
4
|
+
end
|
5
|
+
def locale_name(locale)
|
6
|
+
I18n.t :this_file_language, :locale => locale
|
7
|
+
#
|
8
|
+
# t("locale.#{locale.to_s.sub('-', '_')}")
|
9
|
+
end
|
10
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module SpreeChangeLocale
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
#
|
5
|
+
# def add_javascripts
|
6
|
+
# append_file "app/assets/javascripts/store/all.js", "//= require store/spree_change_locale\n"
|
7
|
+
# append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_change_locale\n"
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# def add_stylesheets
|
11
|
+
# inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_change_locale\n", :before => /\*\//, :verbose => true
|
12
|
+
# inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_change_locale\n", :before => /\*\//, :verbose => true
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# def add_migrations
|
16
|
+
# run 'bundle exec rake railties:install:migrations FROM=spree_change_locale'
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# def run_migrations
|
20
|
+
# res = ask "Would you like to run the migrations now? [Y/n]"
|
21
|
+
# if res == "" || res.downcase == "y"
|
22
|
+
# run 'bundle exec rake db:migrate'
|
23
|
+
# else
|
24
|
+
# puts "Skiping rake db:migrate, don't forget to run it!"
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SpreeChangeLocale
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name 'spree_change_locale'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")).each do |c|
|
14
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")).each do |c|
|
18
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.to_prepare &method(:activate).to_proc
|
23
|
+
end
|
24
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
|
5
|
+
ENGINE_PATH = File.expand_path('../..', __FILE__)
|
6
|
+
load File.expand_path('../../spec/dummy/script/rails', __FILE__)
|
7
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the LocaleHelper. For example:
|
5
|
+
#
|
6
|
+
# describe LocaleHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# helper.concat_strings("this","that").should == "this that"
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
describe LocaleHelper do
|
14
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
|
5
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
6
|
+
|
7
|
+
|
8
|
+
require 'rspec/rails'
|
9
|
+
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
11
|
+
# in spec/support/ and its subdirectories.
|
12
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
# == Mock Framework
|
16
|
+
#
|
17
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
18
|
+
#
|
19
|
+
# config.mock_with :mocha
|
20
|
+
# config.mock_with :flexmock
|
21
|
+
# config.mock_with :rr
|
22
|
+
config.mock_with :rspec
|
23
|
+
|
24
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
25
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
26
|
+
|
27
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
28
|
+
# examples within a transaction, remove the following line or assign false
|
29
|
+
# instead of true.
|
30
|
+
config.use_transactional_fixtures = true
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = 'spree_change_locale'
|
5
|
+
s.version = '0.4'
|
6
|
+
s.summary = 'Easy locale change for Spree'
|
7
|
+
s.description = 'Easy locale change for Spree'
|
8
|
+
s.required_ruby_version = '>= 1.8.7'
|
9
|
+
|
10
|
+
s.author = 'humancopy'
|
11
|
+
s.email = 'info@humancopy.net'
|
12
|
+
s.homepage = 'https://github.com/humancopy/spree-change-locale'
|
13
|
+
# s.rubyforge_project = 'actionmailer'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.require_path = 'lib'
|
18
|
+
s.requirements << 'none'
|
19
|
+
|
20
|
+
s.add_dependency 'spree_core', '>= 0.70.0'
|
21
|
+
# s.add_dependency 'http_accept_language', '~> 1.0'
|
22
|
+
s.add_development_dependency 'rspec-rails'
|
23
|
+
end
|
24
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: spree_change_locale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: "0.4"
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- humancopy
|
@@ -42,8 +42,34 @@ extensions: []
|
|
42
42
|
|
43
43
|
extra_rdoc_files: []
|
44
44
|
|
45
|
-
files:
|
46
|
-
|
45
|
+
files:
|
46
|
+
- .gitignore
|
47
|
+
- .rspec
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- Versionfile
|
54
|
+
- app/assets/javascripts/admin/spree_change_locale.js
|
55
|
+
- app/assets/javascripts/locale.js
|
56
|
+
- app/assets/javascripts/store/spree_change_locale.js
|
57
|
+
- app/assets/stylesheets/admin/spree_change_locale.css
|
58
|
+
- app/assets/stylesheets/locale.css
|
59
|
+
- app/assets/stylesheets/store/spree_change_locale.css
|
60
|
+
- app/controllers/base_controller_decorator.rb
|
61
|
+
- app/controllers/locale_controller.rb
|
62
|
+
- app/helpers/locale_helper.rb
|
63
|
+
- config/routes.rb
|
64
|
+
- examples/_language_bar.html.erb
|
65
|
+
- lib/generators/spree_change_locale/install/install_generator.rb
|
66
|
+
- lib/spree_change_locale.rb
|
67
|
+
- lib/spree_change_locale/engine.rb
|
68
|
+
- script/rails
|
69
|
+
- spec/controllers/locale_controller_spec.rb
|
70
|
+
- spec/helpers/locale_helper_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
- spree_change_locale.gemspec
|
47
73
|
homepage: https://github.com/humancopy/spree-change-locale
|
48
74
|
licenses: []
|
49
75
|
|
@@ -71,5 +97,7 @@ rubygems_version: 1.8.11
|
|
71
97
|
signing_key:
|
72
98
|
specification_version: 3
|
73
99
|
summary: Easy locale change for Spree
|
74
|
-
test_files:
|
75
|
-
|
100
|
+
test_files:
|
101
|
+
- spec/controllers/locale_controller_spec.rb
|
102
|
+
- spec/helpers/locale_helper_spec.rb
|
103
|
+
- spec/spec_helper.rb
|