rails_locale_detection 2.0.0.pre4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -1
- data/.travis.yml +10 -5
- data/Appraisals +12 -4
- data/Gemfile.lock +118 -91
- data/gemfiles/{rails4.gemfile → rails3.2.gemfile} +2 -2
- data/gemfiles/rails4.0.gemfile +7 -0
- data/gemfiles/rails4.1.gemfile +7 -0
- data/gemfiles/{rails3.gemfile → rails4.2.gemfile} +2 -2
- data/lib/rails_locale_detection/detection_methods.rb +3 -3
- data/lib/rails_locale_detection/locale_detector.rb +7 -7
- data/lib/rails_locale_detection/version.rb +1 -1
- data/rails_locale_detection.gemspec +12 -11
- data/spec/controllers/callback_tests_controller_spec.rb +7 -7
- data/spec/rails_locale_detection/config_spec.rb +3 -3
- data/spec/rails_locale_detection/controller_methods_spec.rb +7 -7
- data/spec/rails_locale_detection/locale_accessors_spec.rb +4 -4
- data/spec/rails_locale_detection/locale_detector_spec.rb +50 -50
- data/spec/spec_helper.rb +3 -1
- data/spec/support/mocks.rb +4 -4
- metadata +56 -42
- data/gemfiles/rails3.gemfile.lock +0 -118
- data/gemfiles/rails4.gemfile.lock +0 -113
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c27829347e137b07d2ac81252de1d6bed5d84b
|
4
|
+
data.tar.gz: 2e16e6f84ec0cca5254e0d867dfa980f12ba4133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0253574fbf32ae79988c5f1a1ffac47944049b9f8a077b675adbb27768ed142c2af2950806a6dfc3a4fba2483c4f96496fa1a07ecea9c8f614b8c444fd9260dc
|
7
|
+
data.tar.gz: 50894ac1a4a91059133f8ef04c9cd1ee2d25f1ffff9612526847548c2aee82f10020474c8f2383abf17332c0c85c6cf66cb67c0aac1c5e99454246f8cb7459b7
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
before_install: gem install bundler --version '1.10.6'
|
2
|
+
|
3
|
+
sudo: false
|
4
|
+
|
1
5
|
gemfile:
|
2
|
-
- gemfiles/rails3.gemfile
|
3
|
-
- gemfiles/rails4.gemfile
|
4
|
-
|
6
|
+
- gemfiles/rails3.2.gemfile
|
7
|
+
- gemfiles/rails4.0.gemfile
|
8
|
+
- gemfiles/rails4.1.gemfile
|
9
|
+
- gemfiles/rails4.2.gemfile
|
10
|
+
|
5
11
|
rvm:
|
6
|
-
- "2.
|
7
|
-
- "1.9.3"
|
12
|
+
- "2.2.0"
|
data/Appraisals
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
appraise "rails3" do
|
2
|
-
gem "rails", "3.2.
|
1
|
+
appraise "rails3.2" do
|
2
|
+
gem "rails", "3.2.22"
|
3
3
|
end
|
4
4
|
|
5
|
-
appraise "rails4" do
|
6
|
-
gem "rails", "4.0.
|
5
|
+
appraise "rails4.0" do
|
6
|
+
gem "rails", "4.0.13"
|
7
|
+
end
|
8
|
+
|
9
|
+
appraise "rails4.1" do
|
10
|
+
gem "rails", "4.1.13"
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise "rails4.2" do
|
14
|
+
gem "rails", "4.2.4"
|
7
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,117 +1,144 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_locale_detection (2.0.0
|
5
|
-
http_accept_language (~>
|
4
|
+
rails_locale_detection (2.0.0)
|
5
|
+
http_accept_language (~> 2.0.5)
|
6
6
|
rails (>= 3.2.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionmailer (
|
12
|
-
actionpack (=
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
actionmailer (4.2.4)
|
12
|
+
actionpack (= 4.2.4)
|
13
|
+
actionview (= 4.2.4)
|
14
|
+
activejob (= 4.2.4)
|
15
|
+
mail (~> 2.5, >= 2.5.4)
|
16
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
17
|
+
actionpack (4.2.4)
|
18
|
+
actionview (= 4.2.4)
|
19
|
+
activesupport (= 4.2.4)
|
20
|
+
rack (~> 1.6)
|
21
|
+
rack-test (~> 0.6.2)
|
22
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
23
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
24
|
+
actionview (4.2.4)
|
25
|
+
activesupport (= 4.2.4)
|
26
|
+
builder (~> 3.1)
|
18
27
|
erubis (~> 2.7.0)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
activemodel (
|
25
|
-
activesupport (=
|
26
|
-
builder (~> 3.
|
27
|
-
activerecord (
|
28
|
-
activemodel (=
|
29
|
-
activesupport (=
|
30
|
-
arel (~>
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
appraisal (0.5.2)
|
28
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
30
|
+
activejob (4.2.4)
|
31
|
+
activesupport (= 4.2.4)
|
32
|
+
globalid (>= 0.3.0)
|
33
|
+
activemodel (4.2.4)
|
34
|
+
activesupport (= 4.2.4)
|
35
|
+
builder (~> 3.1)
|
36
|
+
activerecord (4.2.4)
|
37
|
+
activemodel (= 4.2.4)
|
38
|
+
activesupport (= 4.2.4)
|
39
|
+
arel (~> 6.0)
|
40
|
+
activesupport (4.2.4)
|
41
|
+
i18n (~> 0.7)
|
42
|
+
json (~> 1.7, >= 1.7.7)
|
43
|
+
minitest (~> 5.1)
|
44
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
45
|
+
tzinfo (~> 1.1)
|
46
|
+
appraisal (2.1.0)
|
39
47
|
bundler
|
40
48
|
rake
|
41
|
-
|
42
|
-
|
43
|
-
|
49
|
+
thor (>= 0.14.0)
|
50
|
+
arel (6.0.3)
|
51
|
+
builder (3.2.2)
|
52
|
+
diff-lcs (1.2.5)
|
44
53
|
erubis (2.7.0)
|
45
|
-
gem-release (0.5.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
json (1.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
rack-test (0.6.
|
54
|
+
gem-release (0.5.5)
|
55
|
+
globalid (0.3.6)
|
56
|
+
activesupport (>= 4.1.0)
|
57
|
+
http_accept_language (2.0.5)
|
58
|
+
i18n (0.7.0)
|
59
|
+
json (1.8.3)
|
60
|
+
loofah (2.0.3)
|
61
|
+
nokogiri (>= 1.5.9)
|
62
|
+
mail (2.6.3)
|
63
|
+
mime-types (>= 1.16, < 3)
|
64
|
+
mime-types (2.6.2)
|
65
|
+
mini_portile (0.6.2)
|
66
|
+
minitest (5.8.1)
|
67
|
+
nokogiri (1.6.6.2)
|
68
|
+
mini_portile (~> 0.6.0)
|
69
|
+
power_assert (0.2.4)
|
70
|
+
rack (1.6.4)
|
71
|
+
rack-test (0.6.3)
|
63
72
|
rack (>= 1.0)
|
64
|
-
rails (
|
65
|
-
actionmailer (=
|
66
|
-
actionpack (=
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
rails (4.2.4)
|
74
|
+
actionmailer (= 4.2.4)
|
75
|
+
actionpack (= 4.2.4)
|
76
|
+
actionview (= 4.2.4)
|
77
|
+
activejob (= 4.2.4)
|
78
|
+
activemodel (= 4.2.4)
|
79
|
+
activerecord (= 4.2.4)
|
80
|
+
activesupport (= 4.2.4)
|
81
|
+
bundler (>= 1.3.0, < 2.0)
|
82
|
+
railties (= 4.2.4)
|
83
|
+
sprockets-rails
|
84
|
+
rails-deprecated_sanitizer (1.0.3)
|
85
|
+
activesupport (>= 4.2.0.alpha)
|
86
|
+
rails-dom-testing (1.0.7)
|
87
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
88
|
+
nokogiri (~> 1.6.0)
|
89
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
90
|
+
rails-html-sanitizer (1.0.2)
|
91
|
+
loofah (~> 2.0)
|
92
|
+
railties (4.2.4)
|
93
|
+
actionpack (= 4.2.4)
|
94
|
+
activesupport (= 4.2.4)
|
76
95
|
rake (>= 0.8.7)
|
77
|
-
|
78
|
-
thor (>= 0.14.6, < 2.0)
|
96
|
+
thor (>= 0.18.1, < 2.0)
|
79
97
|
rake (10.0.4)
|
80
|
-
|
81
|
-
|
82
|
-
rspec-
|
83
|
-
|
84
|
-
|
85
|
-
rspec-mocks (
|
86
|
-
|
98
|
+
rspec-core (3.3.2)
|
99
|
+
rspec-support (~> 3.3.0)
|
100
|
+
rspec-expectations (3.3.1)
|
101
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
102
|
+
rspec-support (~> 3.3.0)
|
103
|
+
rspec-mocks (3.3.2)
|
104
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
105
|
+
rspec-support (~> 3.3.0)
|
106
|
+
rspec-rails (3.3.3)
|
107
|
+
actionpack (>= 3.0, < 4.3)
|
108
|
+
activesupport (>= 3.0, < 4.3)
|
109
|
+
railties (>= 3.0, < 4.3)
|
110
|
+
rspec-core (~> 3.3.0)
|
111
|
+
rspec-expectations (~> 3.3.0)
|
112
|
+
rspec-mocks (~> 3.3.0)
|
113
|
+
rspec-support (~> 3.3.0)
|
114
|
+
rspec-support (3.3.0)
|
115
|
+
sprockets (3.4.0)
|
116
|
+
rack (> 1, < 3)
|
117
|
+
sprockets-rails (2.3.3)
|
87
118
|
actionpack (>= 3.0)
|
88
119
|
activesupport (>= 3.0)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
tilt (~> 1.1, != 1.3.0)
|
98
|
-
thor (0.18.1)
|
99
|
-
tilt (1.3.6)
|
100
|
-
timecop (0.6.1)
|
101
|
-
treetop (1.4.14)
|
102
|
-
polyglot
|
103
|
-
polyglot (>= 0.3.1)
|
104
|
-
tzinfo (0.3.37)
|
120
|
+
sprockets (>= 2.8, < 4.0)
|
121
|
+
test-unit (3.1.5)
|
122
|
+
power_assert
|
123
|
+
thor (0.19.1)
|
124
|
+
thread_safe (0.3.5)
|
125
|
+
timecop (0.6.3)
|
126
|
+
tzinfo (1.2.2)
|
127
|
+
thread_safe (~> 0.1)
|
105
128
|
|
106
129
|
PLATFORMS
|
107
130
|
ruby
|
108
131
|
|
109
132
|
DEPENDENCIES
|
110
|
-
appraisal (~>
|
111
|
-
bundler (~> 1.
|
133
|
+
appraisal (~> 2.1.0)
|
134
|
+
bundler (~> 1.10.6)
|
112
135
|
gem-release (~> 0.5.3)
|
113
|
-
i18n (~> 0.
|
136
|
+
i18n (~> 0.7.0)
|
114
137
|
rails_locale_detection!
|
115
138
|
rake (~> 10.0.4)
|
116
|
-
rspec-rails (~>
|
139
|
+
rspec-rails (~> 3.0)
|
140
|
+
test-unit (~> 3.0)
|
117
141
|
timecop (~> 0.6.1)
|
142
|
+
|
143
|
+
BUNDLED WITH
|
144
|
+
1.10.6
|
@@ -14,7 +14,7 @@ module RailsLocaleDetection
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def locale_from_request
|
17
|
-
validate_locale(
|
17
|
+
validate_locale(http_accept_language.preferred_language_from(available_locales))
|
18
18
|
end
|
19
19
|
|
20
20
|
def locale_from_user
|
@@ -40,6 +40,6 @@ module RailsLocaleDetection
|
|
40
40
|
# returns true if the default url option should be set for this request
|
41
41
|
def set_default_url_option_for_request?
|
42
42
|
RailsLocaleDetection.set_default_url_option === true || RailsLocaleDetection.set_default_url_option == :always || RailsLocaleDetection.set_default_url_option == :explicitly && params[locale_key].present?
|
43
|
-
end
|
43
|
+
end
|
44
44
|
end
|
45
|
-
end
|
45
|
+
end
|
@@ -2,23 +2,23 @@ module RailsLocaleDetection
|
|
2
2
|
class LocaleDetector
|
3
3
|
include DetectionMethods
|
4
4
|
include LocaleAccessors
|
5
|
-
|
5
|
+
|
6
6
|
attr_reader :controller
|
7
|
-
|
8
|
-
delegate :params, :request, :default_url_options, :user_locale, :to => :controller
|
9
|
-
|
7
|
+
|
8
|
+
delegate :params, :request, :default_url_options, :user_locale, :http_accept_language, :to => :controller
|
9
|
+
|
10
10
|
def initialize(controller = nil)
|
11
11
|
@controller = controller
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def cookies
|
15
15
|
request.cookie_jar
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def locale_key
|
19
19
|
RailsLocaleDetection.locale_key
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def self.before(controller)
|
23
23
|
new(controller).set_locale
|
24
24
|
end
|
@@ -12,20 +12,21 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = "Locale setting for rails project"
|
13
13
|
gem.homepage = "https://github.com/mateomurphy/rails_locale_detection"
|
14
14
|
gem.license = 'MIT'
|
15
|
-
|
15
|
+
|
16
16
|
gem.files = `git ls-files`.split($/)
|
17
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ['lib']
|
20
|
-
|
21
|
-
gem.add_dependency('http_accept_language', '~>
|
22
|
-
gem.add_dependency('rails', '>= 3.2.0')
|
23
|
-
|
24
|
-
gem.add_development_dependency('appraisal', '~>
|
25
|
-
gem.add_development_dependency('bundler', '~> 1.
|
26
|
-
gem.add_development_dependency('i18n', '~> 0.
|
27
|
-
gem.add_development_dependency('gem-release', '~> 0.5.3')
|
28
|
-
gem.add_development_dependency('rake', '~> 10.0.4')
|
29
|
-
gem.add_development_dependency('rspec-rails', '~>
|
20
|
+
|
21
|
+
gem.add_dependency('http_accept_language', '~> 2.0.5')
|
22
|
+
gem.add_dependency('rails', '>= 3.2.0')
|
23
|
+
|
24
|
+
gem.add_development_dependency('appraisal', '~> 2.1.0')
|
25
|
+
gem.add_development_dependency('bundler', '~> 1.10.6')
|
26
|
+
gem.add_development_dependency('i18n', '~> 0.7.0')
|
27
|
+
gem.add_development_dependency('gem-release', '~> 0.5.3')
|
28
|
+
gem.add_development_dependency('rake', '~> 10.0.4')
|
29
|
+
gem.add_development_dependency('rspec-rails', '~> 3.0')
|
30
30
|
gem.add_development_dependency('timecop', '~> 0.6.1')
|
31
|
+
gem.add_development_dependency('test-unit', '~> 3.0')
|
31
32
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe CallbackTestsController do
|
4
|
-
|
3
|
+
describe CallbackTestsController, type: :controller do
|
4
|
+
|
5
5
|
it "should automatically include the callback" do
|
6
|
-
subject.class.ancestors.
|
6
|
+
expect(subject.class.ancestors).to include(RailsLocaleDetection::ControllerMethods)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should correctly detect the user locale" do
|
10
10
|
get :show
|
11
|
-
|
12
|
-
response.body.
|
11
|
+
|
12
|
+
expect(response.body).to eq('fr')
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
end
|