rails_locale_detection 2.3.0 → 3.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: da94d0ec0d03f37345a4a131ef18c8d3362824c0
4
- data.tar.gz: 57a594826fb7ce78c8834cb2bbd9e946310ffd91
2
+ SHA256:
3
+ metadata.gz: bd0f01f134b8ff0b88f622247003fc9945828c3b9f1d07e4f5c73afd9786d306
4
+ data.tar.gz: 18f8732d28ddbe79086203227bd3faec0383c00ab48f33b53c0565850e348c37
5
5
  SHA512:
6
- metadata.gz: c0a227eeb4c9a54e6cddfaf11200898b575a1513fb6d86055aa5f955118a984b685e3590f9e99f5fd36a8ef376c9090d28b476dc91a9861ce1336388b6cf8e62
7
- data.tar.gz: 690f7ddf3bd22052dce18345d6edab80b23a66c1e9be5fe81dc9c41dffd43ee835b389129757091684b3f25d878108ef15df277ba8f06c43b72c79c5b34fc14e
6
+ metadata.gz: 6895651c66586495bd1331662d021a851b92b5da076b5ce44a716ebb9e1716059a2ef7e360484a62a80ce44e8686e8b58af7c3dce7f1e5d0a495976ab5b89f40
7
+ data.tar.gz: 7cbfffca6abe40a4f4ddd2fd94a99960caa3abe908891577bd91d2717d5bfee6707120d971621bd572863abe6702e6584c5029bf2340491de71aa5c31fee53c1
@@ -0,0 +1,38 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master, main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ ruby: ["3.1", "3.2", "3.3", "3.4"]
15
+ gemfile:
16
+ - rails_6.1
17
+ - rails_7.0
18
+ - rails_7.1
19
+ - rails_7.2
20
+ - rails_8.0
21
+ exclude:
22
+ - ruby: "3.1"
23
+ gemfile: rails_7.2
24
+ - ruby: "3.1"
25
+ gemfile: rails_8.0
26
+ - ruby: "3.4"
27
+ gemfile: rails_6.1
28
+
29
+ env:
30
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
31
+
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: ${{ matrix.ruby }}
37
+ bundler-cache: true
38
+ - run: bundle exec rspec
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
+ # dev config
2
+ .vscode
3
+
1
4
  # rcov generated
2
5
  coverage
3
6
 
@@ -19,4 +22,4 @@ pkg
19
22
  .ruby-*
20
23
 
21
24
  # appraisals
22
- *.gemfile.lock
25
+ *.gemfile.lock
data/.mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ ruby = "3.4.9"
data/Appraisals CHANGED
@@ -1,27 +1,19 @@
1
- appraise "rails3.2" do
2
- gem "rails", "3.2.22"
1
+ appraise "rails-6.1" do
2
+ gem "rails", "~> 6.1.0"
3
3
  end
4
4
 
5
- appraise "rails4.0" do
6
- gem "rails", "4.0.13"
5
+ appraise "rails-7.0" do
6
+ gem "rails", "~> 7.0.0"
7
7
  end
8
8
 
9
- appraise "rails4.1" do
10
- gem "rails", "4.1.13"
9
+ appraise "rails-7.1" do
10
+ gem "rails", "~> 7.1.0"
11
11
  end
12
12
 
13
- appraise "rails4.2" do
14
- gem "rails", "4.2.4"
13
+ appraise "rails-7.2" do
14
+ gem "rails", "~> 7.2.0"
15
15
  end
16
16
 
17
- appraise "rails5.0" do
18
- gem "rails", "5.0.7"
19
- end
20
-
21
- appraise "rails5.1" do
22
- gem "rails", "5.1.6"
23
- end
24
-
25
- appraise "rails5.2" do
26
- gem "rails", "5.2.0"
17
+ appraise "rails-8.0" do
18
+ gem "rails", "~> 8.0.0"
27
19
  end
data/Gemfile.lock CHANGED
@@ -1,161 +1,256 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_locale_detection (2.3.0)
5
- http_accept_language (~> 2.0.5)
6
- rails (>= 3.2.0)
4
+ rails_locale_detection (3.0.0)
5
+ http_accept_language (~> 2.1)
6
+ rails (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (5.2.0)
12
- actionpack (= 5.2.0)
11
+ actioncable (7.2.3.1)
12
+ actionpack (= 7.2.3.1)
13
+ activesupport (= 7.2.3.1)
13
14
  nio4r (~> 2.0)
14
15
  websocket-driver (>= 0.6.1)
15
- actionmailer (5.2.0)
16
- actionpack (= 5.2.0)
17
- actionview (= 5.2.0)
18
- activejob (= 5.2.0)
19
- mail (~> 2.5, >= 2.5.4)
20
- rails-dom-testing (~> 2.0)
21
- actionpack (5.2.0)
22
- actionview (= 5.2.0)
23
- activesupport (= 5.2.0)
24
- rack (~> 2.0)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (7.2.3.1)
18
+ actionpack (= 7.2.3.1)
19
+ activejob (= 7.2.3.1)
20
+ activerecord (= 7.2.3.1)
21
+ activestorage (= 7.2.3.1)
22
+ activesupport (= 7.2.3.1)
23
+ mail (>= 2.8.0)
24
+ actionmailer (7.2.3.1)
25
+ actionpack (= 7.2.3.1)
26
+ actionview (= 7.2.3.1)
27
+ activejob (= 7.2.3.1)
28
+ activesupport (= 7.2.3.1)
29
+ mail (>= 2.8.0)
30
+ rails-dom-testing (~> 2.2)
31
+ actionpack (7.2.3.1)
32
+ actionview (= 7.2.3.1)
33
+ activesupport (= 7.2.3.1)
34
+ cgi
35
+ nokogiri (>= 1.8.5)
36
+ racc
37
+ rack (>= 2.2.4, < 3.3)
38
+ rack-session (>= 1.0.1)
25
39
  rack-test (>= 0.6.3)
26
- rails-dom-testing (~> 2.0)
27
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.2.0)
29
- activesupport (= 5.2.0)
40
+ rails-dom-testing (~> 2.2)
41
+ rails-html-sanitizer (~> 1.6)
42
+ useragent (~> 0.16)
43
+ actiontext (7.2.3.1)
44
+ actionpack (= 7.2.3.1)
45
+ activerecord (= 7.2.3.1)
46
+ activestorage (= 7.2.3.1)
47
+ activesupport (= 7.2.3.1)
48
+ globalid (>= 0.6.0)
49
+ nokogiri (>= 1.8.5)
50
+ actionview (7.2.3.1)
51
+ activesupport (= 7.2.3.1)
30
52
  builder (~> 3.1)
31
- erubi (~> 1.4)
32
- rails-dom-testing (~> 2.0)
33
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.2.0)
35
- activesupport (= 5.2.0)
53
+ cgi
54
+ erubi (~> 1.11)
55
+ rails-dom-testing (~> 2.2)
56
+ rails-html-sanitizer (~> 1.6)
57
+ activejob (7.2.3.1)
58
+ activesupport (= 7.2.3.1)
36
59
  globalid (>= 0.3.6)
37
- activemodel (5.2.0)
38
- activesupport (= 5.2.0)
39
- activerecord (5.2.0)
40
- activemodel (= 5.2.0)
41
- activesupport (= 5.2.0)
42
- arel (>= 9.0)
43
- activestorage (5.2.0)
44
- actionpack (= 5.2.0)
45
- activerecord (= 5.2.0)
46
- marcel (~> 0.3.1)
47
- activesupport (5.2.0)
48
- concurrent-ruby (~> 1.0, >= 1.0.2)
49
- i18n (>= 0.7, < 2)
50
- minitest (~> 5.1)
51
- tzinfo (~> 1.1)
52
- appraisal (2.2.0)
60
+ activemodel (7.2.3.1)
61
+ activesupport (= 7.2.3.1)
62
+ activerecord (7.2.3.1)
63
+ activemodel (= 7.2.3.1)
64
+ activesupport (= 7.2.3.1)
65
+ timeout (>= 0.4.0)
66
+ activestorage (7.2.3.1)
67
+ actionpack (= 7.2.3.1)
68
+ activejob (= 7.2.3.1)
69
+ activerecord (= 7.2.3.1)
70
+ activesupport (= 7.2.3.1)
71
+ marcel (~> 1.0)
72
+ activesupport (7.2.3.1)
73
+ base64
74
+ benchmark (>= 0.3)
75
+ bigdecimal
76
+ concurrent-ruby (~> 1.0, >= 1.3.1)
77
+ connection_pool (>= 2.2.5)
78
+ drb
79
+ i18n (>= 1.6, < 2)
80
+ logger (>= 1.4.2)
81
+ minitest (>= 5.1, < 6)
82
+ securerandom (>= 0.3)
83
+ tzinfo (~> 2.0, >= 2.0.5)
84
+ appraisal (2.5.0)
53
85
  bundler
54
86
  rake
55
87
  thor (>= 0.14.0)
56
- arel (9.0.0)
57
- builder (3.2.3)
58
- concurrent-ruby (1.0.5)
59
- crass (1.0.4)
60
- diff-lcs (1.3)
61
- erubi (1.7.1)
62
- gem-release (0.5.5)
63
- globalid (0.4.1)
64
- activesupport (>= 4.2.0)
65
- http_accept_language (2.0.5)
66
- i18n (0.7.0)
67
- loofah (2.2.2)
88
+ base64 (0.3.0)
89
+ benchmark (0.5.0)
90
+ bigdecimal (4.1.2)
91
+ builder (3.3.0)
92
+ cgi (0.5.1)
93
+ concurrent-ruby (1.3.6)
94
+ connection_pool (2.5.5)
95
+ crass (1.0.6)
96
+ date (3.5.1)
97
+ diff-lcs (1.6.2)
98
+ drb (2.2.3)
99
+ erb (4.0.4.1)
100
+ cgi (>= 0.3.3)
101
+ erubi (1.13.1)
102
+ gem-release (2.2.4)
103
+ globalid (1.3.0)
104
+ activesupport (>= 6.1)
105
+ http_accept_language (2.1.1)
106
+ i18n (1.14.8)
107
+ concurrent-ruby (~> 1.0)
108
+ io-console (0.8.2)
109
+ irb (1.18.0)
110
+ pp (>= 0.6.0)
111
+ prism (>= 1.3.0)
112
+ rdoc (>= 4.0.0)
113
+ reline (>= 0.4.2)
114
+ logger (1.7.0)
115
+ loofah (2.25.1)
68
116
  crass (~> 1.0.2)
69
- nokogiri (>= 1.5.9)
70
- mail (2.7.0)
117
+ nokogiri (>= 1.12.0)
118
+ mail (2.9.0)
119
+ logger
71
120
  mini_mime (>= 0.1.1)
72
- marcel (0.3.2)
73
- mimemagic (~> 0.3.2)
74
- method_source (0.9.0)
75
- mimemagic (0.3.2)
76
- mini_mime (1.0.0)
77
- mini_portile2 (2.3.0)
78
- minitest (5.11.3)
79
- nio4r (2.3.1)
80
- nokogiri (1.8.3)
81
- mini_portile2 (~> 2.3.0)
82
- power_assert (1.1.2)
83
- rack (2.0.5)
84
- rack-test (1.0.0)
85
- rack (>= 1.0, < 3)
86
- rails (5.2.0)
87
- actioncable (= 5.2.0)
88
- actionmailer (= 5.2.0)
89
- actionpack (= 5.2.0)
90
- actionview (= 5.2.0)
91
- activejob (= 5.2.0)
92
- activemodel (= 5.2.0)
93
- activerecord (= 5.2.0)
94
- activestorage (= 5.2.0)
95
- activesupport (= 5.2.0)
96
- bundler (>= 1.3.0)
97
- railties (= 5.2.0)
98
- sprockets-rails (>= 2.0.0)
99
- rails-dom-testing (2.0.3)
100
- activesupport (>= 4.2.0)
121
+ net-imap
122
+ net-pop
123
+ net-smtp
124
+ marcel (1.1.0)
125
+ mini_mime (1.1.5)
126
+ minitest (5.27.0)
127
+ net-imap (0.5.14)
128
+ date
129
+ net-protocol
130
+ net-pop (0.1.2)
131
+ net-protocol
132
+ net-protocol (0.2.2)
133
+ timeout
134
+ net-smtp (0.5.1)
135
+ net-protocol
136
+ nio4r (2.7.5)
137
+ nokogiri (1.18.10-aarch64-linux-gnu)
138
+ racc (~> 1.4)
139
+ nokogiri (1.18.10-aarch64-linux-musl)
140
+ racc (~> 1.4)
141
+ nokogiri (1.18.10-arm-linux-gnu)
142
+ racc (~> 1.4)
143
+ nokogiri (1.18.10-arm-linux-musl)
144
+ racc (~> 1.4)
145
+ nokogiri (1.18.10-arm64-darwin)
146
+ racc (~> 1.4)
147
+ nokogiri (1.18.10-x86_64-darwin)
148
+ racc (~> 1.4)
149
+ nokogiri (1.18.10-x86_64-linux-gnu)
150
+ racc (~> 1.4)
151
+ nokogiri (1.18.10-x86_64-linux-musl)
152
+ racc (~> 1.4)
153
+ pp (0.6.3)
154
+ prettyprint
155
+ prettyprint (0.2.0)
156
+ prism (1.9.0)
157
+ psych (5.3.1)
158
+ date
159
+ stringio
160
+ racc (1.8.1)
161
+ rack (3.2.6)
162
+ rack-session (2.1.2)
163
+ base64 (>= 0.1.0)
164
+ rack (>= 3.0.0)
165
+ rack-test (2.2.0)
166
+ rack (>= 1.3)
167
+ rackup (2.3.1)
168
+ rack (>= 3)
169
+ rails (7.2.3.1)
170
+ actioncable (= 7.2.3.1)
171
+ actionmailbox (= 7.2.3.1)
172
+ actionmailer (= 7.2.3.1)
173
+ actionpack (= 7.2.3.1)
174
+ actiontext (= 7.2.3.1)
175
+ actionview (= 7.2.3.1)
176
+ activejob (= 7.2.3.1)
177
+ activemodel (= 7.2.3.1)
178
+ activerecord (= 7.2.3.1)
179
+ activestorage (= 7.2.3.1)
180
+ activesupport (= 7.2.3.1)
181
+ bundler (>= 1.15.0)
182
+ railties (= 7.2.3.1)
183
+ rails-dom-testing (2.3.0)
184
+ activesupport (>= 5.0.0)
185
+ minitest
101
186
  nokogiri (>= 1.6)
102
- rails-html-sanitizer (1.0.4)
103
- loofah (~> 2.2, >= 2.2.2)
104
- railties (5.2.0)
105
- actionpack (= 5.2.0)
106
- activesupport (= 5.2.0)
107
- method_source
108
- rake (>= 0.8.7)
109
- thor (>= 0.18.1, < 2.0)
110
- rake (11.2.2)
111
- rspec-core (3.7.1)
112
- rspec-support (~> 3.7.0)
113
- rspec-expectations (3.7.0)
187
+ rails-html-sanitizer (1.7.0)
188
+ loofah (~> 2.25)
189
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
190
+ railties (7.2.3.1)
191
+ actionpack (= 7.2.3.1)
192
+ activesupport (= 7.2.3.1)
193
+ cgi
194
+ irb (~> 1.13)
195
+ rackup (>= 1.0.0)
196
+ rake (>= 12.2)
197
+ thor (~> 1.0, >= 1.2.2)
198
+ tsort (>= 0.2)
199
+ zeitwerk (~> 2.6)
200
+ rake (13.4.2)
201
+ rdoc (7.2.0)
202
+ erb
203
+ psych (>= 4.0.0)
204
+ tsort
205
+ reline (0.6.3)
206
+ io-console (~> 0.5)
207
+ rspec-core (3.13.6)
208
+ rspec-support (~> 3.13.0)
209
+ rspec-expectations (3.13.5)
114
210
  diff-lcs (>= 1.2.0, < 2.0)
115
- rspec-support (~> 3.7.0)
116
- rspec-mocks (3.7.0)
211
+ rspec-support (~> 3.13.0)
212
+ rspec-mocks (3.13.8)
117
213
  diff-lcs (>= 1.2.0, < 2.0)
118
- rspec-support (~> 3.7.0)
119
- rspec-rails (3.7.2)
120
- actionpack (>= 3.0)
121
- activesupport (>= 3.0)
122
- railties (>= 3.0)
123
- rspec-core (~> 3.7.0)
124
- rspec-expectations (~> 3.7.0)
125
- rspec-mocks (~> 3.7.0)
126
- rspec-support (~> 3.7.0)
127
- rspec-support (3.7.1)
128
- sprockets (3.7.1)
214
+ rspec-support (~> 3.13.0)
215
+ rspec-rails (6.1.5)
216
+ actionpack (>= 6.1)
217
+ activesupport (>= 6.1)
218
+ railties (>= 6.1)
219
+ rspec-core (~> 3.13)
220
+ rspec-expectations (~> 3.13)
221
+ rspec-mocks (~> 3.13)
222
+ rspec-support (~> 3.13)
223
+ rspec-support (3.13.7)
224
+ securerandom (0.4.1)
225
+ stringio (3.2.0)
226
+ thor (1.5.0)
227
+ timeout (0.6.1)
228
+ tsort (0.2.0)
229
+ tzinfo (2.0.6)
129
230
  concurrent-ruby (~> 1.0)
130
- rack (> 1, < 3)
131
- sprockets-rails (3.2.1)
132
- actionpack (>= 4.0)
133
- activesupport (>= 4.0)
134
- sprockets (>= 3.0.0)
135
- test-unit (3.2.8)
136
- power_assert
137
- thor (0.20.0)
138
- thread_safe (0.3.6)
139
- timecop (0.6.3)
140
- tzinfo (1.2.5)
141
- thread_safe (~> 0.1)
142
- websocket-driver (0.7.0)
231
+ useragent (0.16.11)
232
+ websocket-driver (0.8.0)
233
+ base64
143
234
  websocket-extensions (>= 0.1.0)
144
- websocket-extensions (0.1.3)
235
+ websocket-extensions (0.1.5)
236
+ zeitwerk (2.6.18)
145
237
 
146
238
  PLATFORMS
147
- ruby
239
+ aarch64-linux-gnu
240
+ aarch64-linux-musl
241
+ arm-linux-gnu
242
+ arm-linux-musl
243
+ arm64-darwin
244
+ x86_64-darwin
245
+ x86_64-linux-gnu
246
+ x86_64-linux-musl
148
247
 
149
248
  DEPENDENCIES
150
- appraisal (~> 2.2.0)
151
- bundler (~> 1.16.2)
152
- gem-release (~> 0.5.3)
153
- i18n (~> 0.7.0)
249
+ appraisal (~> 2.5)
250
+ gem-release (~> 2.2)
154
251
  rails_locale_detection!
155
- rake (~> 11.2.2)
156
- rspec-rails (~> 3.0)
157
- test-unit (~> 3.0)
158
- timecop (~> 0.6.1)
252
+ rake (~> 13.0)
253
+ rspec-rails (~> 6.1)
159
254
 
160
255
  BUNDLED WITH
161
- 1.16.2
256
+ 2.7.2
data/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # rails_locale_detection
2
2
 
3
- [![Build Status](https://travis-ci.org/mateomurphy/rails_locale_detection.png?branch=master)](https://travis-ci.org/mateomurphy/rails_locale_detection)
4
- [![Dependency Status](https://gemnasium.com/mateomurphy/rails_locale_detection.png)](https://gemnasium.com/mateomurphy/rails_locale_detection)
3
+ [![CI](https://github.com/mateomurphy/rails_locale_detection/actions/workflows/ci.yml/badge.svg)](https://github.com/mateomurphy/rails_locale_detection/actions/workflows/ci.yml)
5
4
 
6
5
  Sets the current locale of a request using a combination of params, cookies, http headers, and an optional user object.
7
6
 
@@ -36,7 +35,7 @@ Configuration is done via a block that can be added as an initializer:
36
35
 
37
36
  RailsLocaleDetection.config do |config|
38
37
  config.locale_expiry = 3.months
39
- config.set_default_url_option = :always # valid values are true, false, :always, :never and :explicity
38
+ config.set_default_url_option = :always # valid values are true, false, :always, :never and :explicitly
40
39
  config.detection_order = [:param, :user, :cookie, :request]
41
40
  config.automatically_detect = true
42
41
  config.locale_key = :locale
@@ -48,7 +47,7 @@ The configuration options:
48
47
  * `set_default_url_option` determines under which conditions the `default_url_option` is set
49
48
  * `true` or `:always` sets the option on all requests
50
49
  * `false` or `:never` never sets the option
51
- * `:explicity` sets the option only when a param[:locale] is present
50
+ * `:explicitly` sets the option only when a `params[:locale]` is present
52
51
  * `detection_order` set the order in which locale detection occurs. Omit values to skip those sources
53
52
  * `automatically_detect` configures automatic inclusion of the detection callback.
54
53
  You can set this to false and include the callback yourself by calling `detect_locale` in your controller as required.
@@ -56,6 +55,14 @@ The configuration options:
56
55
 
57
56
  ## Changelog
58
57
 
58
+ ### 3.0 (2026-05-15)
59
+
60
+ * Rails 6.1, 7.0, 7.1, 7.2, and 8.0 compatibility
61
+ * Dropped support for Rails < 6.1 and Ruby < 2.7
62
+ * `ActionController::API` controllers are now supported alongside `ActionController::Base`
63
+ * Replaced Travis CI with GitHub Actions
64
+ * Internal cleanup: removed legacy version conditionals, modernized syntax, dropped the `timecop` dev dependency in favor of ActiveSupport's `freeze_time`
65
+
59
66
  ### 2.3 (2018-06-16)
60
67
 
61
68
  * Update dependencies
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "4.2.4"
5
+ gem "rails", "~> 6.1.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "3.2.22"
5
+ gem "rails", "~> 7.0.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "4.0.13"
5
+ gem "rails", "~> 7.1.0"
6
6
 
7
7
  gemspec path: "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "4.1.13"
5
+ gem "rails", "~> 7.2.0"
6
6
 
7
7
  gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 8.0.0"
6
+
7
+ gemspec path: "../"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsLocaleDetection
2
4
  module ControllerMethods
3
5
  extend ActiveSupport::Concern
@@ -8,14 +10,8 @@ module RailsLocaleDetection
8
10
  end
9
11
 
10
12
  module ClassMethods
11
- if ::Rails.version.to_s < "4.0"
12
- def detect_locale
13
- append_before_filter LocaleDetector
14
- end
15
- else
16
- def detect_locale
17
- append_before_action LocaleDetector
18
- end
13
+ def detect_locale
14
+ append_before_action LocaleDetector
19
15
  end
20
16
  end
21
17
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsLocaleDetection
2
4
  module DetectionMethods
3
5
  # returns the (symbolized) value passed if it's in the available_locales
@@ -40,15 +42,21 @@ module RailsLocaleDetection
40
42
 
41
43
  if locale_from_cookie != current_locale
42
44
  cookies[locale_key] = {
43
- :value => current_locale,
44
- :expires => RailsLocaleDetection.locale_expiry.from_now
45
+ value: current_locale,
46
+ expires: RailsLocaleDetection.locale_expiry.from_now
45
47
  }
46
48
  end
47
49
  end
48
50
 
49
- # returns true if the default url option should be set for this request
50
51
  def set_default_url_option_for_request?
51
- RailsLocaleDetection.set_default_url_option === true || RailsLocaleDetection.set_default_url_option == :always || RailsLocaleDetection.set_default_url_option == :explicitly && params[locale_key].present?
52
+ case RailsLocaleDetection.set_default_url_option
53
+ when true, :always
54
+ true
55
+ when :explicitly
56
+ params[locale_key].present?
57
+ else
58
+ false
59
+ end
52
60
  end
53
61
  end
54
62
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsLocaleDetection
2
4
  module LocaleAccessors
3
5
  def alternate_locales
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsLocaleDetection
2
4
  class LocaleDetector
3
5
  include DetectionMethods
@@ -5,7 +7,7 @@ module RailsLocaleDetection
5
7
 
6
8
  attr_reader :controller
7
9
 
8
- delegate :params, :request, :default_url_options, :user_locale, :http_accept_language, :to => :controller
10
+ delegate :params, :request, :default_url_options, :user_locale, :http_accept_language, to: :controller
9
11
 
10
12
  def initialize(controller = nil)
11
13
  @controller = controller
@@ -1,13 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsLocaleDetection
2
4
  class Railtie < Rails::Railtie
3
- initializer "rails_locale_detection.append_before_filter" do
4
- ActiveSupport.on_load(:action_controller) do
5
- ActionController::Base.send :include, RailsLocaleDetection::ControllerMethods
5
+ initializer "rails_locale_detection.include_controller_methods" do
6
+ ActiveSupport.on_load(:action_controller_base) do
7
+ include RailsLocaleDetection::ControllerMethods
6
8
  end
7
-
9
+
10
+ ActiveSupport.on_load(:action_controller_api) do
11
+ include RailsLocaleDetection::ControllerMethods
12
+ end
13
+
8
14
  ActiveSupport.on_load(:action_view) do
9
- ActionView::Base.send :include, Rails::LocaleDetection::LocaleAccessors
10
- end
15
+ include RailsLocaleDetection::LocaleAccessors
16
+ end
11
17
  end
12
18
  end
13
- end
19
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RailsLocaleDetection
2
- VERSION = "2.3.0"
4
+ VERSION = "3.0.0"
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rails'
2
4
  require 'i18n'
3
5
  require 'http_accept_language'
@@ -13,20 +13,17 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = "https://github.com/mateomurphy/rails_locale_detection"
14
14
  gem.license = 'MIT'
15
15
 
16
+ gem.required_ruby_version = '>= 2.7'
17
+
16
18
  gem.files = `git ls-files`.split($/)
17
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
20
  gem.require_paths = ['lib']
20
21
 
21
- gem.add_dependency('http_accept_language', '~> 2.0.5')
22
- gem.add_dependency('rails', '>= 3.2.0')
22
+ gem.add_dependency('http_accept_language', '~> 2.1')
23
+ gem.add_dependency('rails', '>= 6.1')
23
24
 
24
- gem.add_development_dependency('appraisal', '~> 2.2.0')
25
- gem.add_development_dependency('bundler', '~> 1.16.2')
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', '~> 11.2.2')
29
- gem.add_development_dependency('rspec-rails', '~> 3.0')
30
- gem.add_development_dependency('timecop', '~> 0.6.1')
31
- gem.add_development_dependency('test-unit', '~> 3.0')
25
+ gem.add_development_dependency('appraisal', '~> 2.5')
26
+ gem.add_development_dependency('gem-release', '~> 2.2')
27
+ gem.add_development_dependency('rake', '~> 13.0')
28
+ gem.add_development_dependency('rspec-rails', '~> 6.1')
32
29
  end
@@ -12,23 +12,7 @@ describe RailsLocaleDetection::ControllerMethods do
12
12
  expect(controller.class).to respond_to(:detect_locale)
13
13
  end
14
14
 
15
- context 'when the rails is 4.0 or later' do
16
- before do
17
- skip "Rails version is #{::Rails.version.to_s}" unless ::Rails.version.to_s >= '4.0'
18
- end
19
-
20
- it 'adds the detector as a before action' do
21
- expect(controller.class.before_actions).to eq([[RailsLocaleDetection::LocaleDetector]])
22
- end
23
- end
24
-
25
- context 'when the rails is less than 4.0' do
26
- before do
27
- skip "Rails version is #{::Rails.version.to_s}" unless ::Rails.version.to_s < '4.0'
28
- end
29
-
30
- it 'adds the detector as a before filter' do
31
- expect(controller.class.before_filters).to eq([[RailsLocaleDetection::LocaleDetector]])
32
- end
15
+ it 'adds the detector as a before action' do
16
+ expect(controller.class.before_actions).to eq([[RailsLocaleDetection::LocaleDetector]])
33
17
  end
34
18
  end
data/spec/spec_helper.rb CHANGED
@@ -1,14 +1,20 @@
1
+ require 'logger'
1
2
  require 'abstract_controller'
2
3
  require 'action_controller'
3
4
  require 'active_support/core_ext/integer/time'
4
5
  require 'active_support/core_ext/numeric/time'
6
+ require 'active_support/testing/time_helpers'
5
7
  require 'action_view'
6
8
  require 'rspec/rails'
7
- require 'timecop'
8
9
  require 'rails_locale_detection'
9
10
 
10
11
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
12
 
12
13
  I18n.default_locale = :en
13
14
  I18n.available_locales = [:en, :fr]
14
- Timecop.freeze
15
+
16
+ RSpec.configure do |config|
17
+ config.include ActiveSupport::Testing::TimeHelpers
18
+ config.before(:each) { freeze_time }
19
+ config.after(:each) { travel_back }
20
+ end
@@ -6,11 +6,7 @@ class MockRequest
6
6
  def initialize
7
7
  @env = {'HTTP_ACCEPT_LANGUAGE' => ''}
8
8
  @cookies = {}
9
- @cookie_jar = if ::Rails.version.to_s < "5.0"
10
- ActionDispatch::Cookies::CookieJar.build(self)
11
- else
12
- ActionDispatch::Cookies::CookieJar.build(self, @cookies)
13
- end
9
+ @cookie_jar = ActionDispatch::Cookies::CookieJar.build(self, @cookies)
14
10
  end
15
11
 
16
12
  def host
@@ -20,6 +16,10 @@ class MockRequest
20
16
  def ssl?
21
17
  false
22
18
  end
19
+
20
+ def cookies_same_site_protection
21
+ proc { nil }
22
+ end
23
23
  end
24
24
 
25
25
  class MockUser
@@ -44,20 +44,9 @@ class MockController
44
44
  end
45
45
 
46
46
  class << self
47
- attr_reader :before_filters
48
47
  attr_reader :before_actions
49
48
  end
50
49
 
51
- def self.before_filter(*args)
52
- @before_filters ||= []
53
- @before_filters << args
54
- end
55
-
56
- def self.append_before_filter(*args)
57
- @before_filters ||= []
58
- @before_filters << args
59
- end
60
-
61
50
  def self.append_before_action(*args)
62
51
  @before_actions ||= []
63
52
  @before_actions << args
@@ -24,12 +24,7 @@ class CallbackTestsController < ActionController::Base
24
24
  end
25
25
 
26
26
  def show
27
- if ::Rails.version.to_s < "4.1"
28
- render text: current_locale
29
- else
30
- render plain: current_locale
31
- end
32
-
27
+ render plain: current_locale
33
28
  end
34
29
 
35
30
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_locale_detection
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateo Murphy
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2018-06-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: http_accept_language
@@ -16,140 +15,84 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: 2.0.5
18
+ version: '2.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: 2.0.5
25
+ version: '2.1'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rails
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: 3.2.0
32
+ version: '6.1'
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: 3.2.0
39
+ version: '6.1'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: appraisal
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: 2.2.0
46
+ version: '2.5'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: 2.2.0
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 1.16.2
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 1.16.2
69
- - !ruby/object:Gem::Dependency
70
- name: i18n
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.7.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.7.0
53
+ version: '2.5'
83
54
  - !ruby/object:Gem::Dependency
84
55
  name: gem-release
85
56
  requirement: !ruby/object:Gem::Requirement
86
57
  requirements:
87
58
  - - "~>"
88
59
  - !ruby/object:Gem::Version
89
- version: 0.5.3
60
+ version: '2.2'
90
61
  type: :development
91
62
  prerelease: false
92
63
  version_requirements: !ruby/object:Gem::Requirement
93
64
  requirements:
94
65
  - - "~>"
95
66
  - !ruby/object:Gem::Version
96
- version: 0.5.3
67
+ version: '2.2'
97
68
  - !ruby/object:Gem::Dependency
98
69
  name: rake
99
70
  requirement: !ruby/object:Gem::Requirement
100
71
  requirements:
101
72
  - - "~>"
102
73
  - !ruby/object:Gem::Version
103
- version: 11.2.2
74
+ version: '13.0'
104
75
  type: :development
105
76
  prerelease: false
106
77
  version_requirements: !ruby/object:Gem::Requirement
107
78
  requirements:
108
79
  - - "~>"
109
80
  - !ruby/object:Gem::Version
110
- version: 11.2.2
81
+ version: '13.0'
111
82
  - !ruby/object:Gem::Dependency
112
83
  name: rspec-rails
113
84
  requirement: !ruby/object:Gem::Requirement
114
85
  requirements:
115
86
  - - "~>"
116
87
  - !ruby/object:Gem::Version
117
- version: '3.0'
88
+ version: '6.1'
118
89
  type: :development
119
90
  prerelease: false
120
91
  version_requirements: !ruby/object:Gem::Requirement
121
92
  requirements:
122
93
  - - "~>"
123
94
  - !ruby/object:Gem::Version
124
- version: '3.0'
125
- - !ruby/object:Gem::Dependency
126
- name: timecop
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: 0.6.1
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 0.6.1
139
- - !ruby/object:Gem::Dependency
140
- name: test-unit
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '3.0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '3.0'
95
+ version: '6.1'
153
96
  description: Sets the current locale of a request using a combination of params, cookies,
154
97
  and http headers
155
98
  email:
@@ -159,22 +102,21 @@ extensions: []
159
102
  extra_rdoc_files: []
160
103
  files:
161
104
  - ".document"
105
+ - ".github/workflows/ci.yml"
162
106
  - ".gitignore"
107
+ - ".mise.toml"
163
108
  - ".rspec"
164
- - ".travis.yml"
165
109
  - Appraisals
166
110
  - Gemfile
167
111
  - Gemfile.lock
168
112
  - LICENSE
169
113
  - README.md
170
114
  - Rakefile
171
- - gemfiles/rails3.2.gemfile
172
- - gemfiles/rails4.0.gemfile
173
- - gemfiles/rails4.1.gemfile
174
- - gemfiles/rails4.2.gemfile
175
- - gemfiles/rails5.0.gemfile
176
- - gemfiles/rails5.1.gemfile
177
- - gemfiles/rails5.2.gemfile
115
+ - gemfiles/rails_6.1.gemfile
116
+ - gemfiles/rails_7.0.gemfile
117
+ - gemfiles/rails_7.1.gemfile
118
+ - gemfiles/rails_7.2.gemfile
119
+ - gemfiles/rails_8.0.gemfile
178
120
  - lib/rails_locale_detection.rb
179
121
  - lib/rails_locale_detection/controller_methods.rb
180
122
  - lib/rails_locale_detection/detection_methods.rb
@@ -195,7 +137,6 @@ homepage: https://github.com/mateomurphy/rails_locale_detection
195
137
  licenses:
196
138
  - MIT
197
139
  metadata: {}
198
- post_install_message:
199
140
  rdoc_options: []
200
141
  require_paths:
201
142
  - lib
@@ -203,24 +144,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
144
  requirements:
204
145
  - - ">="
205
146
  - !ruby/object:Gem::Version
206
- version: '0'
147
+ version: '2.7'
207
148
  required_rubygems_version: !ruby/object:Gem::Requirement
208
149
  requirements:
209
150
  - - ">="
210
151
  - !ruby/object:Gem::Version
211
152
  version: '0'
212
153
  requirements: []
213
- rubyforge_project:
214
- rubygems_version: 2.6.8
215
- signing_key:
154
+ rubygems_version: 3.6.9
216
155
  specification_version: 4
217
156
  summary: Locale setting for rails projects
218
- test_files:
219
- - spec/controllers/callback_tests_controller_spec.rb
220
- - spec/rails_locale_detection/config_spec.rb
221
- - spec/rails_locale_detection/controller_methods_spec.rb
222
- - spec/rails_locale_detection/locale_accessors_spec.rb
223
- - spec/rails_locale_detection/locale_detector_spec.rb
224
- - spec/spec_helper.rb
225
- - spec/support/mocks.rb
226
- - spec/support/rails.rb
157
+ test_files: []
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- before_install: gem install bundler --version '1.16.2'
2
-
3
- sudo: false
4
-
5
- gemfile:
6
- - gemfiles/rails3.2.gemfile
7
- - gemfiles/rails4.0.gemfile
8
- - gemfiles/rails4.1.gemfile
9
- - gemfiles/rails4.2.gemfile
10
- - gemfiles/rails5.0.gemfile
11
- - gemfiles/rails5.1.gemfile
12
- - gemfiles/rails5.2.gemfile
13
-
14
- rvm:
15
- - "2.3.0"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "5.0.7"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "5.1.6"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", "5.2.0"
6
-
7
- gemspec path: "../"