i18n_date_range 1.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +118 -116
- data/README.md +8 -2
- data/config/locales/en-GB.yml +155 -17
- data/config/locales/en.yml +155 -17
- data/config/locales/fr.yml +155 -17
- data/lib/i18n_date_range/i18n_date_range_generator.rb +62 -29
- data/lib/i18n_date_range/i18n_date_range_helper.rb +3 -2
- data/lib/i18n_date_range/version.rb +1 -1
- metadata +3 -4
- data/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eccf6668937f6b5ac4859e9e93c8b7fc670148255b3770d33af7050f1ea1b759
|
4
|
+
data.tar.gz: b2a32a1b7e54919ed762c0558fa14a51faf3a8996110981f2522fd133867ad20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09789eb760b28e52537cb8adc815d8a7294b8bacf24f50220de04764f19bc69364a429b5742077cfa5dd8645b58417cbe59cf4f37e2fcf28851c49d18736bcfb'
|
7
|
+
data.tar.gz: d5ad0aaef74b2b8b522b3765500149e1f6e80ed392bebd296543dbe3cbe5348d243569baa4450822d3d11ed59b07611d3c8a88c82e3fb14f89a8972e83b91c01
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,77 +1,78 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
i18n_date_range (1.0
|
4
|
+
i18n_date_range (2.1.0)
|
5
5
|
rails
|
6
6
|
rails-i18n
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (7.1.
|
12
|
-
actionpack (= 7.1.
|
13
|
-
activesupport (= 7.1.
|
11
|
+
actioncable (7.1.3.3)
|
12
|
+
actionpack (= 7.1.3.3)
|
13
|
+
activesupport (= 7.1.3.3)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
16
|
zeitwerk (~> 2.6)
|
17
|
-
actionmailbox (7.1.
|
18
|
-
actionpack (= 7.1.
|
19
|
-
activejob (= 7.1.
|
20
|
-
activerecord (= 7.1.
|
21
|
-
activestorage (= 7.1.
|
22
|
-
activesupport (= 7.1.
|
17
|
+
actionmailbox (7.1.3.3)
|
18
|
+
actionpack (= 7.1.3.3)
|
19
|
+
activejob (= 7.1.3.3)
|
20
|
+
activerecord (= 7.1.3.3)
|
21
|
+
activestorage (= 7.1.3.3)
|
22
|
+
activesupport (= 7.1.3.3)
|
23
23
|
mail (>= 2.7.1)
|
24
24
|
net-imap
|
25
25
|
net-pop
|
26
26
|
net-smtp
|
27
|
-
actionmailer (7.1.
|
28
|
-
actionpack (= 7.1.
|
29
|
-
actionview (= 7.1.
|
30
|
-
activejob (= 7.1.
|
31
|
-
activesupport (= 7.1.
|
27
|
+
actionmailer (7.1.3.3)
|
28
|
+
actionpack (= 7.1.3.3)
|
29
|
+
actionview (= 7.1.3.3)
|
30
|
+
activejob (= 7.1.3.3)
|
31
|
+
activesupport (= 7.1.3.3)
|
32
32
|
mail (~> 2.5, >= 2.5.4)
|
33
33
|
net-imap
|
34
34
|
net-pop
|
35
35
|
net-smtp
|
36
36
|
rails-dom-testing (~> 2.2)
|
37
|
-
actionpack (7.1.
|
38
|
-
actionview (= 7.1.
|
39
|
-
activesupport (= 7.1.
|
37
|
+
actionpack (7.1.3.3)
|
38
|
+
actionview (= 7.1.3.3)
|
39
|
+
activesupport (= 7.1.3.3)
|
40
40
|
nokogiri (>= 1.8.5)
|
41
|
+
racc
|
41
42
|
rack (>= 2.2.4)
|
42
43
|
rack-session (>= 1.0.1)
|
43
44
|
rack-test (>= 0.6.3)
|
44
45
|
rails-dom-testing (~> 2.2)
|
45
46
|
rails-html-sanitizer (~> 1.6)
|
46
|
-
actiontext (7.1.
|
47
|
-
actionpack (= 7.1.
|
48
|
-
activerecord (= 7.1.
|
49
|
-
activestorage (= 7.1.
|
50
|
-
activesupport (= 7.1.
|
47
|
+
actiontext (7.1.3.3)
|
48
|
+
actionpack (= 7.1.3.3)
|
49
|
+
activerecord (= 7.1.3.3)
|
50
|
+
activestorage (= 7.1.3.3)
|
51
|
+
activesupport (= 7.1.3.3)
|
51
52
|
globalid (>= 0.6.0)
|
52
53
|
nokogiri (>= 1.8.5)
|
53
|
-
actionview (7.1.
|
54
|
-
activesupport (= 7.1.
|
54
|
+
actionview (7.1.3.3)
|
55
|
+
activesupport (= 7.1.3.3)
|
55
56
|
builder (~> 3.1)
|
56
57
|
erubi (~> 1.11)
|
57
58
|
rails-dom-testing (~> 2.2)
|
58
59
|
rails-html-sanitizer (~> 1.6)
|
59
|
-
activejob (7.1.
|
60
|
-
activesupport (= 7.1.
|
60
|
+
activejob (7.1.3.3)
|
61
|
+
activesupport (= 7.1.3.3)
|
61
62
|
globalid (>= 0.3.6)
|
62
|
-
activemodel (7.1.
|
63
|
-
activesupport (= 7.1.
|
64
|
-
activerecord (7.1.
|
65
|
-
activemodel (= 7.1.
|
66
|
-
activesupport (= 7.1.
|
63
|
+
activemodel (7.1.3.3)
|
64
|
+
activesupport (= 7.1.3.3)
|
65
|
+
activerecord (7.1.3.3)
|
66
|
+
activemodel (= 7.1.3.3)
|
67
|
+
activesupport (= 7.1.3.3)
|
67
68
|
timeout (>= 0.4.0)
|
68
|
-
activestorage (7.1.
|
69
|
-
actionpack (= 7.1.
|
70
|
-
activejob (= 7.1.
|
71
|
-
activerecord (= 7.1.
|
72
|
-
activesupport (= 7.1.
|
69
|
+
activestorage (7.1.3.3)
|
70
|
+
actionpack (= 7.1.3.3)
|
71
|
+
activejob (= 7.1.3.3)
|
72
|
+
activerecord (= 7.1.3.3)
|
73
|
+
activesupport (= 7.1.3.3)
|
73
74
|
marcel (~> 1.0)
|
74
|
-
activesupport (7.1.
|
75
|
+
activesupport (7.1.3.3)
|
75
76
|
base64
|
76
77
|
bigdecimal
|
77
78
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -82,32 +83,31 @@ GEM
|
|
82
83
|
mutex_m
|
83
84
|
tzinfo (~> 2.0)
|
84
85
|
ast (2.4.2)
|
85
|
-
base64 (0.
|
86
|
-
bigdecimal (3.1.
|
86
|
+
base64 (0.2.0)
|
87
|
+
bigdecimal (3.1.8)
|
87
88
|
builder (3.2.4)
|
88
|
-
combustion (1.
|
89
|
+
combustion (1.4.0)
|
89
90
|
activesupport (>= 3.0.0)
|
90
91
|
railties (>= 3.0.0)
|
91
92
|
thor (>= 0.14.6)
|
92
|
-
concurrent-ruby (1.2.
|
93
|
+
concurrent-ruby (1.2.3)
|
93
94
|
connection_pool (2.4.1)
|
94
95
|
crass (1.0.6)
|
95
|
-
date (3.3.
|
96
|
-
diff-lcs (1.5.
|
97
|
-
drb (2.
|
98
|
-
ruby2_keywords
|
96
|
+
date (3.3.4)
|
97
|
+
diff-lcs (1.5.1)
|
98
|
+
drb (2.2.1)
|
99
99
|
erubi (1.12.0)
|
100
100
|
globalid (1.2.1)
|
101
101
|
activesupport (>= 6.1)
|
102
|
-
i18n (1.14.
|
102
|
+
i18n (1.14.5)
|
103
103
|
concurrent-ruby (~> 1.0)
|
104
|
-
io-console (0.
|
105
|
-
irb (1.
|
106
|
-
rdoc
|
107
|
-
reline (>= 0.
|
108
|
-
json (2.
|
104
|
+
io-console (0.7.2)
|
105
|
+
irb (1.13.1)
|
106
|
+
rdoc (>= 4.0.0)
|
107
|
+
reline (>= 0.4.2)
|
108
|
+
json (2.7.2)
|
109
109
|
language_server-protocol (3.17.0.3)
|
110
|
-
loofah (2.
|
110
|
+
loofah (2.22.0)
|
111
111
|
crass (~> 1.0.2)
|
112
112
|
nokogiri (>= 1.12.0)
|
113
113
|
mail (2.8.1)
|
@@ -115,30 +115,30 @@ GEM
|
|
115
115
|
net-imap
|
116
116
|
net-pop
|
117
117
|
net-smtp
|
118
|
-
marcel (1.0.
|
118
|
+
marcel (1.0.4)
|
119
119
|
mini_mime (1.1.5)
|
120
|
-
minitest (5.
|
121
|
-
mutex_m (0.
|
122
|
-
net-imap (0.4.
|
120
|
+
minitest (5.23.1)
|
121
|
+
mutex_m (0.2.0)
|
122
|
+
net-imap (0.4.11)
|
123
123
|
date
|
124
124
|
net-protocol
|
125
125
|
net-pop (0.1.2)
|
126
126
|
net-protocol
|
127
|
-
net-protocol (0.2.
|
127
|
+
net-protocol (0.2.2)
|
128
128
|
timeout
|
129
|
-
net-smtp (0.
|
129
|
+
net-smtp (0.5.0)
|
130
130
|
net-protocol
|
131
|
-
nio4r (2.
|
132
|
-
nokogiri (1.
|
131
|
+
nio4r (2.7.3)
|
132
|
+
nokogiri (1.16.5-x86_64-darwin)
|
133
133
|
racc (~> 1.4)
|
134
|
-
parallel (1.
|
135
|
-
parser (3.
|
134
|
+
parallel (1.24.0)
|
135
|
+
parser (3.3.1.0)
|
136
136
|
ast (~> 2.4.1)
|
137
137
|
racc
|
138
|
-
psych (5.1.
|
138
|
+
psych (5.1.2)
|
139
139
|
stringio
|
140
|
-
racc (1.
|
141
|
-
rack (3.0.
|
140
|
+
racc (1.8.0)
|
141
|
+
rack (3.0.11)
|
142
142
|
rack-session (2.0.0)
|
143
143
|
rack (>= 3.0.0)
|
144
144
|
rack-test (2.1.0)
|
@@ -146,20 +146,20 @@ GEM
|
|
146
146
|
rackup (2.1.0)
|
147
147
|
rack (>= 3)
|
148
148
|
webrick (~> 1.8)
|
149
|
-
rails (7.1.
|
150
|
-
actioncable (= 7.1.
|
151
|
-
actionmailbox (= 7.1.
|
152
|
-
actionmailer (= 7.1.
|
153
|
-
actionpack (= 7.1.
|
154
|
-
actiontext (= 7.1.
|
155
|
-
actionview (= 7.1.
|
156
|
-
activejob (= 7.1.
|
157
|
-
activemodel (= 7.1.
|
158
|
-
activerecord (= 7.1.
|
159
|
-
activestorage (= 7.1.
|
160
|
-
activesupport (= 7.1.
|
149
|
+
rails (7.1.3.3)
|
150
|
+
actioncable (= 7.1.3.3)
|
151
|
+
actionmailbox (= 7.1.3.3)
|
152
|
+
actionmailer (= 7.1.3.3)
|
153
|
+
actionpack (= 7.1.3.3)
|
154
|
+
actiontext (= 7.1.3.3)
|
155
|
+
actionview (= 7.1.3.3)
|
156
|
+
activejob (= 7.1.3.3)
|
157
|
+
activemodel (= 7.1.3.3)
|
158
|
+
activerecord (= 7.1.3.3)
|
159
|
+
activestorage (= 7.1.3.3)
|
160
|
+
activesupport (= 7.1.3.3)
|
161
161
|
bundler (>= 1.15.0)
|
162
|
-
railties (= 7.1.
|
162
|
+
railties (= 7.1.3.3)
|
163
163
|
rails-dom-testing (2.2.0)
|
164
164
|
activesupport (>= 5.0.0)
|
165
165
|
minitest
|
@@ -167,68 +167,70 @@ GEM
|
|
167
167
|
rails-html-sanitizer (1.6.0)
|
168
168
|
loofah (~> 2.21)
|
169
169
|
nokogiri (~> 1.14)
|
170
|
-
rails-i18n (7.0.
|
170
|
+
rails-i18n (7.0.9)
|
171
171
|
i18n (>= 0.7, < 2)
|
172
172
|
railties (>= 6.0.0, < 8)
|
173
|
-
railties (7.1.
|
174
|
-
actionpack (= 7.1.
|
175
|
-
activesupport (= 7.1.
|
173
|
+
railties (7.1.3.3)
|
174
|
+
actionpack (= 7.1.3.3)
|
175
|
+
activesupport (= 7.1.3.3)
|
176
176
|
irb
|
177
177
|
rackup (>= 1.0.0)
|
178
178
|
rake (>= 12.2)
|
179
179
|
thor (~> 1.0, >= 1.2.2)
|
180
180
|
zeitwerk (~> 2.6)
|
181
181
|
rainbow (3.1.1)
|
182
|
-
rake (13.1
|
183
|
-
rdoc (6.
|
182
|
+
rake (13.2.1)
|
183
|
+
rdoc (6.7.0)
|
184
184
|
psych (>= 4.0.0)
|
185
|
-
regexp_parser (2.
|
186
|
-
reline (0.
|
185
|
+
regexp_parser (2.9.2)
|
186
|
+
reline (0.5.7)
|
187
187
|
io-console (~> 0.5)
|
188
|
-
rexml (3.2.
|
189
|
-
|
190
|
-
|
191
|
-
rspec-
|
192
|
-
rspec-
|
193
|
-
|
194
|
-
|
195
|
-
|
188
|
+
rexml (3.2.8)
|
189
|
+
strscan (>= 3.0.9)
|
190
|
+
rspec (3.13.0)
|
191
|
+
rspec-core (~> 3.13.0)
|
192
|
+
rspec-expectations (~> 3.13.0)
|
193
|
+
rspec-mocks (~> 3.13.0)
|
194
|
+
rspec-core (3.13.0)
|
195
|
+
rspec-support (~> 3.13.0)
|
196
|
+
rspec-expectations (3.13.0)
|
196
197
|
diff-lcs (>= 1.2.0, < 2.0)
|
197
|
-
rspec-support (~> 3.
|
198
|
-
rspec-mocks (3.
|
198
|
+
rspec-support (~> 3.13.0)
|
199
|
+
rspec-mocks (3.13.1)
|
199
200
|
diff-lcs (>= 1.2.0, < 2.0)
|
200
|
-
rspec-support (~> 3.
|
201
|
-
rspec-rails (6.
|
201
|
+
rspec-support (~> 3.13.0)
|
202
|
+
rspec-rails (6.1.2)
|
202
203
|
actionpack (>= 6.1)
|
203
204
|
activesupport (>= 6.1)
|
204
205
|
railties (>= 6.1)
|
205
|
-
rspec-core (~> 3.
|
206
|
-
rspec-expectations (~> 3.
|
207
|
-
rspec-mocks (~> 3.
|
208
|
-
rspec-support (~> 3.
|
209
|
-
rspec-support (3.
|
210
|
-
rubocop (1.
|
206
|
+
rspec-core (~> 3.13)
|
207
|
+
rspec-expectations (~> 3.13)
|
208
|
+
rspec-mocks (~> 3.13)
|
209
|
+
rspec-support (~> 3.13)
|
210
|
+
rspec-support (3.13.1)
|
211
|
+
rubocop (1.64.0)
|
211
212
|
json (~> 2.3)
|
212
213
|
language_server-protocol (>= 3.17.0)
|
213
214
|
parallel (~> 1.10)
|
214
|
-
parser (>= 3.
|
215
|
+
parser (>= 3.3.0.2)
|
215
216
|
rainbow (>= 2.2.2, < 4.0)
|
216
217
|
regexp_parser (>= 1.8, < 3.0)
|
217
218
|
rexml (>= 3.2.5, < 4.0)
|
218
|
-
rubocop-ast (>= 1.
|
219
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
219
220
|
ruby-progressbar (~> 1.7)
|
220
221
|
unicode-display_width (>= 2.4.0, < 3.0)
|
221
|
-
rubocop-ast (1.
|
222
|
-
parser (>= 3.
|
223
|
-
rubocop-rails (2.
|
222
|
+
rubocop-ast (1.31.3)
|
223
|
+
parser (>= 3.3.1.0)
|
224
|
+
rubocop-rails (2.25.0)
|
224
225
|
activesupport (>= 4.2.0)
|
225
226
|
rack (>= 1.1)
|
226
227
|
rubocop (>= 1.33.0, < 2.0)
|
228
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
227
229
|
ruby-progressbar (1.13.0)
|
228
|
-
|
229
|
-
|
230
|
-
thor (1.3.
|
231
|
-
timeout (0.4.
|
230
|
+
stringio (3.1.0)
|
231
|
+
strscan (3.1.0)
|
232
|
+
thor (1.3.1)
|
233
|
+
timeout (0.4.1)
|
232
234
|
tzinfo (2.0.6)
|
233
235
|
concurrent-ruby (~> 1.0)
|
234
236
|
unicode-display_width (2.5.0)
|
@@ -236,7 +238,7 @@ GEM
|
|
236
238
|
websocket-driver (0.7.6)
|
237
239
|
websocket-extensions (>= 0.1.0)
|
238
240
|
websocket-extensions (0.1.5)
|
239
|
-
zeitwerk (2.6.
|
241
|
+
zeitwerk (2.6.14)
|
240
242
|
|
241
243
|
PLATFORMS
|
242
244
|
x86_64-darwin-20
|
@@ -255,4 +257,4 @@ DEPENDENCIES
|
|
255
257
|
rubocop-rails
|
256
258
|
|
257
259
|
BUNDLED WITH
|
258
|
-
2.4.
|
260
|
+
2.4.22
|
data/README.md
CHANGED
@@ -10,6 +10,7 @@ Add this line to your application's Gemfile:
|
|
10
10
|
```ruby
|
11
11
|
gem 'i18n_date_range'
|
12
12
|
```
|
13
|
+
|
13
14
|
And then execute:
|
14
15
|
|
15
16
|
$ bundle install
|
@@ -19,13 +20,18 @@ And then execute:
|
|
19
20
|
This gem comes with an integrated view helper: `date_range_i18n` which takes 3 parameters:
|
20
21
|
- date_from
|
21
22
|
- date_to (optional)
|
22
|
-
-
|
23
|
+
- a hash of additional formatting options(optional)
|
23
24
|
|
24
|
-
|
25
|
+
The options hash currently support 2 arguments:
|
26
|
+
- format: can be `:short` or `:long` (default is :short)
|
27
|
+
- layout: can be `:one_line`or `:two_lines` (default is :one_line)
|
25
28
|
|
26
29
|
"Short" format means without the explicit day name (September 8, 2024).
|
27
30
|
"Long" format means with it (Friday, September 8, 2024).
|
28
31
|
|
32
|
+
"One line" layout means the string will be displayed on one line only (From September 8, 2024 to September 8, 2025)
|
33
|
+
"Two lines" layout means the result will be displayed on 2 lines,separated with `<br>` (September 8, 2024<br>September 8, 2025)
|
34
|
+
|
29
35
|
## Change texts or formats
|
30
36
|
|
31
37
|
This gem is based on I18n. Feel free to overwrite any key you want.
|
data/config/locales/en-GB.yml
CHANGED
@@ -1,19 +1,157 @@
|
|
1
1
|
en-GB:
|
2
2
|
date_range:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
no_end:
|
4
|
+
one_line:
|
5
|
+
short:
|
6
|
+
from:
|
7
|
+
sentence: "From %-d %B %Y"
|
8
|
+
upcase_first: false
|
9
|
+
to:
|
10
|
+
sentence: ""
|
11
|
+
upcase_first: false
|
12
|
+
long:
|
13
|
+
from:
|
14
|
+
sentence: "From %A %-d %B %Y"
|
15
|
+
upcase_first: false
|
16
|
+
to:
|
17
|
+
sentence: ""
|
18
|
+
upcase_first: false
|
19
|
+
two_lines:
|
20
|
+
short:
|
21
|
+
from:
|
22
|
+
sentence: "%-d %B %Y"
|
23
|
+
upcase_first: false
|
24
|
+
to:
|
25
|
+
sentence: ""
|
26
|
+
upcase_first: false
|
27
|
+
long:
|
28
|
+
from:
|
29
|
+
sentence: "%A %-d %B %Y"
|
30
|
+
upcase_first: true
|
31
|
+
to:
|
32
|
+
sentence: ""
|
33
|
+
upcase_first: false
|
34
|
+
same_day:
|
35
|
+
one_line:
|
36
|
+
short:
|
37
|
+
from:
|
38
|
+
sentence: "%-d %B %Y"
|
39
|
+
upcase_first: false
|
40
|
+
to:
|
41
|
+
sentence: ""
|
42
|
+
upcase_first: false
|
43
|
+
long:
|
44
|
+
from:
|
45
|
+
sentence: "%A %-d %B %Y"
|
46
|
+
upcase_first: true
|
47
|
+
to:
|
48
|
+
sentence: ""
|
49
|
+
upcase_first: false
|
50
|
+
two_lines:
|
51
|
+
short:
|
52
|
+
from:
|
53
|
+
sentence: "%-d %B %Y"
|
54
|
+
upcase_first: false
|
55
|
+
to:
|
56
|
+
sentence: ""
|
57
|
+
upcase_first: false
|
58
|
+
long:
|
59
|
+
from:
|
60
|
+
sentence: "%A %-d %B %Y"
|
61
|
+
upcase_first: true
|
62
|
+
to:
|
63
|
+
sentence: ""
|
64
|
+
upcase_first: false
|
65
|
+
same_month:
|
66
|
+
one_line:
|
67
|
+
short:
|
68
|
+
from:
|
69
|
+
sentence: "From %-d"
|
70
|
+
upcase_first: false
|
71
|
+
to:
|
72
|
+
sentence: " to %-d %B %Y"
|
73
|
+
upcase_first: false
|
74
|
+
long:
|
75
|
+
from:
|
76
|
+
sentence: "From %A %-d"
|
77
|
+
upcase_first: false
|
78
|
+
to:
|
79
|
+
sentence: " to %A %-d %B %Y"
|
80
|
+
upcase_first: false
|
81
|
+
two_lines:
|
82
|
+
short:
|
83
|
+
from:
|
84
|
+
sentence: "%-d %B"
|
85
|
+
upcase_first: false
|
86
|
+
to:
|
87
|
+
sentence: "%-d %B %Y"
|
88
|
+
upcase_first: false
|
89
|
+
long:
|
90
|
+
from:
|
91
|
+
sentence: "%A %-d %B"
|
92
|
+
upcase_first: true
|
93
|
+
to:
|
94
|
+
sentence: "%A %-d %B %Y"
|
95
|
+
upcase_first: true
|
96
|
+
same_year:
|
97
|
+
one_line:
|
98
|
+
short:
|
99
|
+
from:
|
100
|
+
sentence: "From %-d %B"
|
101
|
+
upcase_first: false
|
102
|
+
to:
|
103
|
+
sentence: " to %-d %B %Y"
|
104
|
+
upcase_first: false
|
105
|
+
long:
|
106
|
+
from:
|
107
|
+
sentence: "From %A %-d %B"
|
108
|
+
upcase_first: false
|
109
|
+
to:
|
110
|
+
sentence: " to %A %-d %B %Y"
|
111
|
+
upcase_first: false
|
112
|
+
two_lines:
|
113
|
+
short:
|
114
|
+
from:
|
115
|
+
sentence: "%-d %B"
|
116
|
+
upcase_first: false
|
117
|
+
to:
|
118
|
+
sentence: "%-d %B %Y"
|
119
|
+
upcase_first: false
|
120
|
+
long:
|
121
|
+
from:
|
122
|
+
sentence: "%A %-d %B"
|
123
|
+
upcase_first: true
|
124
|
+
to:
|
125
|
+
sentence: "%A %-d %B %Y"
|
126
|
+
upcase_first: true
|
127
|
+
other:
|
128
|
+
one_line:
|
129
|
+
short:
|
130
|
+
from:
|
131
|
+
sentence: "From %-d %B %Y"
|
132
|
+
upcase_first: false
|
133
|
+
to:
|
134
|
+
sentence: " to %-d %B %Y"
|
135
|
+
upcase_first: false
|
136
|
+
long:
|
137
|
+
from:
|
138
|
+
sentence: "From %A %-d %B %Y"
|
139
|
+
upcase_first: false
|
140
|
+
to:
|
141
|
+
sentence: " to %A %-d %B %Y"
|
142
|
+
upcase_first: false
|
143
|
+
two_lines:
|
144
|
+
short:
|
145
|
+
from:
|
146
|
+
sentence: "%-d %B %Y"
|
147
|
+
upcase_first: false
|
148
|
+
to:
|
149
|
+
sentence: "%-d %B %Y"
|
150
|
+
upcase_first: false
|
151
|
+
long:
|
152
|
+
from:
|
153
|
+
sentence: "%A %-d %B %Y"
|
154
|
+
upcase_first: true
|
155
|
+
to:
|
156
|
+
sentence: "%A %-d %B %Y"
|
157
|
+
upcase_first: true
|
data/config/locales/en.yml
CHANGED
@@ -1,19 +1,157 @@
|
|
1
1
|
en:
|
2
2
|
date_range:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
no_end:
|
4
|
+
one_line:
|
5
|
+
short:
|
6
|
+
from:
|
7
|
+
sentence: "From %B %-d, %Y"
|
8
|
+
upcase_first: false
|
9
|
+
to:
|
10
|
+
sentence: ""
|
11
|
+
upcase_first: false
|
12
|
+
long:
|
13
|
+
from:
|
14
|
+
sentence: "From %A %B %-d, %Y"
|
15
|
+
upcase_first: false
|
16
|
+
to:
|
17
|
+
sentence: ""
|
18
|
+
upcase_first: false
|
19
|
+
two_lines:
|
20
|
+
short:
|
21
|
+
from:
|
22
|
+
sentence: "%B %-d, %Y"
|
23
|
+
upcase_first: true
|
24
|
+
to:
|
25
|
+
sentence: ""
|
26
|
+
upcase_first: false
|
27
|
+
long:
|
28
|
+
from:
|
29
|
+
sentence: "%A %B %-d, %Y"
|
30
|
+
upcase_first: true
|
31
|
+
to:
|
32
|
+
sentence: ""
|
33
|
+
upcase_first: false
|
34
|
+
same_day:
|
35
|
+
one_line:
|
36
|
+
short:
|
37
|
+
from:
|
38
|
+
sentence: "%B %-d, %Y"
|
39
|
+
upcase_first: true
|
40
|
+
to:
|
41
|
+
sentence: ""
|
42
|
+
upcase_first: false
|
43
|
+
long:
|
44
|
+
from:
|
45
|
+
sentence: "%A %B %-d, %Y"
|
46
|
+
upcase_first: true
|
47
|
+
to:
|
48
|
+
sentence: ""
|
49
|
+
upcase_first: false
|
50
|
+
two_lines:
|
51
|
+
short:
|
52
|
+
from:
|
53
|
+
sentence: "%B %-d, %Y"
|
54
|
+
upcase_first: true
|
55
|
+
to:
|
56
|
+
sentence: ""
|
57
|
+
upcase_first: false
|
58
|
+
long:
|
59
|
+
from:
|
60
|
+
sentence: "%A %B %-d, %Y"
|
61
|
+
upcase_first: true
|
62
|
+
to:
|
63
|
+
sentence: ""
|
64
|
+
upcase_first: false
|
65
|
+
same_month:
|
66
|
+
one_line:
|
67
|
+
short:
|
68
|
+
from:
|
69
|
+
sentence: "From %B %-d"
|
70
|
+
upcase_first: false
|
71
|
+
to:
|
72
|
+
sentence: " to %-d, %Y"
|
73
|
+
upcase_first: false
|
74
|
+
long:
|
75
|
+
from:
|
76
|
+
sentence: "From %A %B %-d"
|
77
|
+
upcase_first: false
|
78
|
+
to:
|
79
|
+
sentence: " to %A %B %-d, %Y"
|
80
|
+
upcase_first: false
|
81
|
+
two_lines:
|
82
|
+
short:
|
83
|
+
from:
|
84
|
+
sentence: "%B %-d"
|
85
|
+
upcase_first: true
|
86
|
+
to:
|
87
|
+
sentence: "%B %-d, %Y"
|
88
|
+
upcase_first: true
|
89
|
+
long:
|
90
|
+
from:
|
91
|
+
sentence: "%A %B %-d"
|
92
|
+
upcase_first: true
|
93
|
+
to:
|
94
|
+
sentence: "%A %B %-d, %Y"
|
95
|
+
upcase_first: true
|
96
|
+
same_year:
|
97
|
+
one_line:
|
98
|
+
short:
|
99
|
+
from:
|
100
|
+
sentence: "From %B %-d"
|
101
|
+
upcase_first: false
|
102
|
+
to:
|
103
|
+
sentence: " to %B %-d, %Y"
|
104
|
+
upcase_first: false
|
105
|
+
long:
|
106
|
+
from:
|
107
|
+
sentence: "From %A %B %-d"
|
108
|
+
upcase_first: false
|
109
|
+
to:
|
110
|
+
sentence: " to %A %B %-d, %Y"
|
111
|
+
upcase_first: false
|
112
|
+
two_lines:
|
113
|
+
short:
|
114
|
+
from:
|
115
|
+
sentence: "%B %-d"
|
116
|
+
upcase_first: true
|
117
|
+
to:
|
118
|
+
sentence: "%B %-d, %Y"
|
119
|
+
upcase_first: true
|
120
|
+
long:
|
121
|
+
from:
|
122
|
+
sentence: "%A %B %-d"
|
123
|
+
upcase_first: true
|
124
|
+
to:
|
125
|
+
sentence: "%A %B %-d, %Y"
|
126
|
+
upcase_first: true
|
127
|
+
other:
|
128
|
+
one_line:
|
129
|
+
short:
|
130
|
+
from:
|
131
|
+
sentence: "From %B %-d, %Y"
|
132
|
+
upcase_first: false
|
133
|
+
to:
|
134
|
+
sentence: " to %B %-d, %Y"
|
135
|
+
upcase_first: false
|
136
|
+
long:
|
137
|
+
from:
|
138
|
+
sentence: "From %A %B %-d, %Y"
|
139
|
+
upcase_first: false
|
140
|
+
to:
|
141
|
+
sentence: " to %A %B %-d, %Y"
|
142
|
+
upcase_first: false
|
143
|
+
two_lines:
|
144
|
+
short:
|
145
|
+
from:
|
146
|
+
sentence: "%B %-d, %Y"
|
147
|
+
upcase_first: true
|
148
|
+
to:
|
149
|
+
sentence: "%B %-d, %Y"
|
150
|
+
upcase_first: true
|
151
|
+
long:
|
152
|
+
from:
|
153
|
+
sentence: "%A %B %-d, %Y"
|
154
|
+
upcase_first: true
|
155
|
+
to:
|
156
|
+
sentence: "%A %B %-d, %Y"
|
157
|
+
upcase_first: true
|
data/config/locales/fr.yml
CHANGED
@@ -1,19 +1,157 @@
|
|
1
1
|
fr:
|
2
2
|
date_range:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
no_end:
|
4
|
+
one_line:
|
5
|
+
short:
|
6
|
+
from:
|
7
|
+
sentence: "À partir du %-d %B %Y"
|
8
|
+
upcase_first: false
|
9
|
+
to:
|
10
|
+
sentence: ""
|
11
|
+
upcase_first: false
|
12
|
+
long:
|
13
|
+
from:
|
14
|
+
sentence: "À partir du %A %-d %B %Y"
|
15
|
+
upcase_first: false
|
16
|
+
to:
|
17
|
+
sentence: ""
|
18
|
+
upcase_first: false
|
19
|
+
two_lines:
|
20
|
+
short:
|
21
|
+
from:
|
22
|
+
sentence: "%-d %B %Y"
|
23
|
+
upcase_first: false
|
24
|
+
to:
|
25
|
+
sentence: ""
|
26
|
+
upcase_first: false
|
27
|
+
long:
|
28
|
+
from:
|
29
|
+
sentence: "%A %-d %B %Y"
|
30
|
+
upcase_first: true
|
31
|
+
to:
|
32
|
+
sentence: ""
|
33
|
+
upcase_first: false
|
34
|
+
same_day:
|
35
|
+
one_line:
|
36
|
+
short:
|
37
|
+
from:
|
38
|
+
sentence: "%-d %B %Y"
|
39
|
+
upcase_first: false
|
40
|
+
to:
|
41
|
+
sentence: ""
|
42
|
+
upcase_first: false
|
43
|
+
long:
|
44
|
+
from:
|
45
|
+
sentence: "%A %-d %B %Y"
|
46
|
+
upcase_first: true
|
47
|
+
to:
|
48
|
+
sentence: ""
|
49
|
+
upcase_first: false
|
50
|
+
two_lines:
|
51
|
+
short:
|
52
|
+
from:
|
53
|
+
sentence: "%-d %B %Y"
|
54
|
+
upcase_first: false
|
55
|
+
to:
|
56
|
+
sentence: ""
|
57
|
+
upcase_first: false
|
58
|
+
long:
|
59
|
+
from:
|
60
|
+
sentence: "%A %-d %B %Y"
|
61
|
+
upcase_first: true
|
62
|
+
to:
|
63
|
+
sentence: ""
|
64
|
+
upcase_first: false
|
65
|
+
same_month:
|
66
|
+
one_line:
|
67
|
+
short:
|
68
|
+
from:
|
69
|
+
sentence: "Du %-d"
|
70
|
+
upcase_first: false
|
71
|
+
to:
|
72
|
+
sentence: " au %-d %B %Y"
|
73
|
+
upcase_first: false
|
74
|
+
long:
|
75
|
+
from:
|
76
|
+
sentence: "Du %A %-d"
|
77
|
+
upcase_first: false
|
78
|
+
to:
|
79
|
+
sentence: " au %A %-d %B %Y"
|
80
|
+
upcase_first: false
|
81
|
+
two_lines:
|
82
|
+
short:
|
83
|
+
from:
|
84
|
+
sentence: "%-d %B"
|
85
|
+
upcase_first: false
|
86
|
+
to:
|
87
|
+
sentence: "%-d %B %Y"
|
88
|
+
upcase_first: false
|
89
|
+
long:
|
90
|
+
from:
|
91
|
+
sentence: "%A %-d %B"
|
92
|
+
upcase_first: true
|
93
|
+
to:
|
94
|
+
sentence: "%A %-d %B %Y"
|
95
|
+
upcase_first: true
|
96
|
+
same_year:
|
97
|
+
one_line:
|
98
|
+
short:
|
99
|
+
from:
|
100
|
+
sentence: "Du %-d %B"
|
101
|
+
upcase_first: false
|
102
|
+
to:
|
103
|
+
sentence: " au %-d %B %Y"
|
104
|
+
upcase_first: false
|
105
|
+
long:
|
106
|
+
from:
|
107
|
+
sentence: "Du %A %-d %B"
|
108
|
+
upcase_first: false
|
109
|
+
to:
|
110
|
+
sentence: " au %A %-d %B %Y"
|
111
|
+
upcase_first: false
|
112
|
+
two_lines:
|
113
|
+
short:
|
114
|
+
from:
|
115
|
+
sentence: "%-d %B"
|
116
|
+
upcase_first: false
|
117
|
+
to:
|
118
|
+
sentence: "%-d %B %Y"
|
119
|
+
upcase_first: false
|
120
|
+
long:
|
121
|
+
from:
|
122
|
+
sentence: "%A %-d %B"
|
123
|
+
upcase_first: true
|
124
|
+
to:
|
125
|
+
sentence: "%A %-d %B %Y"
|
126
|
+
upcase_first: true
|
127
|
+
other:
|
128
|
+
one_line:
|
129
|
+
short:
|
130
|
+
from:
|
131
|
+
sentence: "Du %-d %B %Y"
|
132
|
+
upcase_first: false
|
133
|
+
to:
|
134
|
+
sentence: " au %-d %B %Y"
|
135
|
+
upcase_first: false
|
136
|
+
long:
|
137
|
+
from:
|
138
|
+
sentence: "Du %A %-d %B %Y"
|
139
|
+
upcase_first: false
|
140
|
+
to:
|
141
|
+
sentence: " au %A %-d %B %Y"
|
142
|
+
upcase_first: false
|
143
|
+
two_lines:
|
144
|
+
short:
|
145
|
+
from:
|
146
|
+
sentence: "%-d %B %Y"
|
147
|
+
upcase_first: false
|
148
|
+
to:
|
149
|
+
sentence: "%-d %B %Y"
|
150
|
+
upcase_first: false
|
151
|
+
long:
|
152
|
+
from:
|
153
|
+
sentence: "%A %-d %B %Y"
|
154
|
+
upcase_first: true
|
155
|
+
to:
|
156
|
+
sentence: "%A %-d %B %Y"
|
157
|
+
upcase_first: true
|
@@ -2,60 +2,93 @@
|
|
2
2
|
|
3
3
|
# Computing range to choose the correct form
|
4
4
|
class I18nDateRangeGenerator
|
5
|
-
attr_reader :from_date, :to_date, :format, :layout
|
5
|
+
attr_reader :from_date, :to_date, :format, :layout, :locale
|
6
6
|
|
7
|
-
|
7
|
+
KIND_NO_END = :no_end
|
8
|
+
KIND_SAME_DAY = :same_day
|
9
|
+
KIND_SAME_MONTH = :same_month
|
10
|
+
KIND_SAME_YEAR = :same_year
|
11
|
+
KIND_OTHER = :other
|
12
|
+
|
13
|
+
# "format" can be :short or :long. "layout" can be :one_line or :two_lines
|
14
|
+
def initialize(from_date, to_date = nil, format: :short, layout: :one_line, locale: I18n.locale)
|
8
15
|
@from_date = from_date
|
9
16
|
@to_date = to_date
|
10
17
|
@format = format
|
11
18
|
@layout = layout
|
19
|
+
@locale = locale
|
12
20
|
end
|
13
21
|
|
14
22
|
def to_s
|
15
|
-
|
23
|
+
layout == :two_lines && to_formatted.present? ? from_formatted + '<br>' + to_formatted : from_formatted + to_formatted
|
16
24
|
end
|
17
25
|
|
18
26
|
protected
|
19
27
|
|
20
|
-
|
28
|
+
# Analyzing
|
29
|
+
|
30
|
+
def kind
|
31
|
+
unless @kind
|
32
|
+
@kind = KIND_OTHER
|
33
|
+
@kind = KIND_SAME_YEAR if same_year?
|
34
|
+
@kind = KIND_SAME_MONTH if same_month?
|
35
|
+
@kind = KIND_SAME_DAY if same_day?
|
36
|
+
@kind = KIND_NO_END if no_end?
|
37
|
+
end
|
38
|
+
@kind
|
39
|
+
end
|
40
|
+
|
41
|
+
def same_year?
|
42
|
+
from_date.year == to_date&.year
|
43
|
+
end
|
44
|
+
|
45
|
+
def same_month?
|
46
|
+
from_date.year == to_date&.year && from_date.month == to_date&.month
|
47
|
+
end
|
48
|
+
|
49
|
+
def same_day?
|
21
50
|
to_date == from_date
|
22
51
|
end
|
23
52
|
|
24
|
-
def
|
25
|
-
|
26
|
-
"date_range.#{layout}.without_to",
|
27
|
-
from: format_date(from_date, :day_month_year)
|
28
|
-
).capitalize
|
53
|
+
def no_end?
|
54
|
+
to_date.blank?
|
29
55
|
end
|
30
56
|
|
31
|
-
def
|
32
|
-
I18n.t(
|
33
|
-
"date_range.#{layout}.with_to",
|
34
|
-
from: format_date(from_date, from_format),
|
35
|
-
to: format_date(to_date, :day_month_year)
|
36
|
-
).capitalize
|
57
|
+
def from_sentence
|
58
|
+
I18n.t("#{composite_key}.from.sentence", locale: locale)
|
37
59
|
end
|
38
60
|
|
39
|
-
def
|
40
|
-
|
61
|
+
def from_upcase_first
|
62
|
+
I18n.t("#{composite_key}.from.upcase_first", locale: locale)
|
63
|
+
end
|
41
64
|
|
42
|
-
|
65
|
+
def to_sentence
|
66
|
+
I18n.t("#{composite_key}.to.sentence", locale: locale)
|
67
|
+
end
|
43
68
|
|
44
|
-
|
69
|
+
def to_upcase_first
|
70
|
+
I18n.t("#{composite_key}.to.upcase_first", locale: locale)
|
45
71
|
end
|
46
72
|
|
47
|
-
def
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
73
|
+
def from_formatted
|
74
|
+
@from_formatted ||= begin
|
75
|
+
from = I18n.l(from_date, format: from_sentence)
|
76
|
+
from = from.upcase_first if from_upcase_first
|
77
|
+
from
|
78
|
+
end
|
52
79
|
end
|
53
80
|
|
54
|
-
def
|
55
|
-
|
81
|
+
def to_formatted
|
82
|
+
return '' if no_end?
|
83
|
+
@to_formatted ||= begin
|
84
|
+
to = I18n.l(to_date, format: to_sentence)
|
85
|
+
to = to.upcase_first if to_upcase_first
|
86
|
+
to
|
87
|
+
end
|
56
88
|
end
|
57
89
|
|
58
|
-
def
|
59
|
-
|
90
|
+
def composite_key
|
91
|
+
"date_range.#{kind}.#{layout}.#{format}"
|
60
92
|
end
|
61
|
-
|
93
|
+
|
94
|
+
end
|
@@ -6,8 +6,9 @@
|
|
6
6
|
# Layout can be :one_line (default) or :two_lines, other might be necessary in the future
|
7
7
|
module I18nDateRangeHelper
|
8
8
|
|
9
|
-
def date_range_i18n(from_date, to_date = nil,
|
10
|
-
I18nDateRangeGenerator.new(from_date, to_date,
|
9
|
+
def date_range_i18n(from_date, to_date = nil, **options)
|
10
|
+
generator = I18nDateRangeGenerator.new(from_date, to_date, **options.slice(:format, :layout))
|
11
|
+
generator.to_s.html_safe
|
11
12
|
end
|
12
13
|
|
13
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_date_range
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pabois
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -145,7 +145,6 @@ executables: []
|
|
145
145
|
extensions: []
|
146
146
|
extra_rdoc_files: []
|
147
147
|
files:
|
148
|
-
- ".DS_Store"
|
149
148
|
- ".rspec"
|
150
149
|
- ".rubocop.yml"
|
151
150
|
- CHANGELOG.md
|
@@ -187,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
186
|
- !ruby/object:Gem::Version
|
188
187
|
version: '0'
|
189
188
|
requirements: []
|
190
|
-
rubygems_version: 3.4.
|
189
|
+
rubygems_version: 3.4.10
|
191
190
|
signing_key:
|
192
191
|
specification_version: 4
|
193
192
|
summary: Add helper to display a date range
|
data/.DS_Store
DELETED
Binary file
|