i18n_date_range 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +111 -81
- data/config/locales/en-GB.yml +9 -5
- data/config/locales/en.yml +9 -5
- data/config/locales/fr.yml +9 -5
- data/lib/i18n_date_range/i18n_date_range_generator.rb +8 -7
- data/lib/i18n_date_range/i18n_date_range_helper.rb +5 -2
- data/lib/i18n_date_range/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71784441c2eaf62622c2fd142dcc74d914aaa6dd1661d08f776b879ec2edd450
|
4
|
+
data.tar.gz: 43baa011e8b558a3ee54b76047a629516d63369682a4b07c4085faa36398de56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55cb4cecd209292ecc54b396c6416677244ede78d94229a169b230f914bca24234aa85bb8e2b5ad03ac933970f4f2987c0e5c99289e251d4406cbd3e8e10238b
|
7
|
+
data.tar.gz: cc4f9ff20aa67d77018bf7b9065cd9c45c6c265138a578a90f12f47fcebd775495a485cdc837804b8cc502eda089e6f0c089d5cf4e16322e7009f1e7860e7a51
|
data/Gemfile.lock
CHANGED
@@ -1,97 +1,113 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
i18n_date_range (0.
|
4
|
+
i18n_date_range (1.0.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.
|
12
|
-
actionpack (= 7.
|
13
|
-
activesupport (= 7.
|
11
|
+
actioncable (7.1.1)
|
12
|
+
actionpack (= 7.1.1)
|
13
|
+
activesupport (= 7.1.1)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
zeitwerk (~> 2.6)
|
17
|
+
actionmailbox (7.1.1)
|
18
|
+
actionpack (= 7.1.1)
|
19
|
+
activejob (= 7.1.1)
|
20
|
+
activerecord (= 7.1.1)
|
21
|
+
activestorage (= 7.1.1)
|
22
|
+
activesupport (= 7.1.1)
|
22
23
|
mail (>= 2.7.1)
|
23
24
|
net-imap
|
24
25
|
net-pop
|
25
26
|
net-smtp
|
26
|
-
actionmailer (7.
|
27
|
-
actionpack (= 7.
|
28
|
-
actionview (= 7.
|
29
|
-
activejob (= 7.
|
30
|
-
activesupport (= 7.
|
27
|
+
actionmailer (7.1.1)
|
28
|
+
actionpack (= 7.1.1)
|
29
|
+
actionview (= 7.1.1)
|
30
|
+
activejob (= 7.1.1)
|
31
|
+
activesupport (= 7.1.1)
|
31
32
|
mail (~> 2.5, >= 2.5.4)
|
32
33
|
net-imap
|
33
34
|
net-pop
|
34
35
|
net-smtp
|
35
|
-
rails-dom-testing (~> 2.
|
36
|
-
actionpack (7.
|
37
|
-
actionview (= 7.
|
38
|
-
activesupport (= 7.
|
39
|
-
|
36
|
+
rails-dom-testing (~> 2.2)
|
37
|
+
actionpack (7.1.1)
|
38
|
+
actionview (= 7.1.1)
|
39
|
+
activesupport (= 7.1.1)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
rack (>= 2.2.4)
|
42
|
+
rack-session (>= 1.0.1)
|
40
43
|
rack-test (>= 0.6.3)
|
41
|
-
rails-dom-testing (~> 2.
|
42
|
-
rails-html-sanitizer (~> 1.
|
43
|
-
actiontext (7.
|
44
|
-
actionpack (= 7.
|
45
|
-
activerecord (= 7.
|
46
|
-
activestorage (= 7.
|
47
|
-
activesupport (= 7.
|
44
|
+
rails-dom-testing (~> 2.2)
|
45
|
+
rails-html-sanitizer (~> 1.6)
|
46
|
+
actiontext (7.1.1)
|
47
|
+
actionpack (= 7.1.1)
|
48
|
+
activerecord (= 7.1.1)
|
49
|
+
activestorage (= 7.1.1)
|
50
|
+
activesupport (= 7.1.1)
|
48
51
|
globalid (>= 0.6.0)
|
49
52
|
nokogiri (>= 1.8.5)
|
50
|
-
actionview (7.
|
51
|
-
activesupport (= 7.
|
53
|
+
actionview (7.1.1)
|
54
|
+
activesupport (= 7.1.1)
|
52
55
|
builder (~> 3.1)
|
53
|
-
erubi (~> 1.
|
54
|
-
rails-dom-testing (~> 2.
|
55
|
-
rails-html-sanitizer (~> 1.
|
56
|
-
activejob (7.
|
57
|
-
activesupport (= 7.
|
56
|
+
erubi (~> 1.11)
|
57
|
+
rails-dom-testing (~> 2.2)
|
58
|
+
rails-html-sanitizer (~> 1.6)
|
59
|
+
activejob (7.1.1)
|
60
|
+
activesupport (= 7.1.1)
|
58
61
|
globalid (>= 0.3.6)
|
59
|
-
activemodel (7.
|
60
|
-
activesupport (= 7.
|
61
|
-
activerecord (7.
|
62
|
-
activemodel (= 7.
|
63
|
-
activesupport (= 7.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
activemodel (7.1.1)
|
63
|
+
activesupport (= 7.1.1)
|
64
|
+
activerecord (7.1.1)
|
65
|
+
activemodel (= 7.1.1)
|
66
|
+
activesupport (= 7.1.1)
|
67
|
+
timeout (>= 0.4.0)
|
68
|
+
activestorage (7.1.1)
|
69
|
+
actionpack (= 7.1.1)
|
70
|
+
activejob (= 7.1.1)
|
71
|
+
activerecord (= 7.1.1)
|
72
|
+
activesupport (= 7.1.1)
|
69
73
|
marcel (~> 1.0)
|
70
|
-
|
71
|
-
|
74
|
+
activesupport (7.1.1)
|
75
|
+
base64
|
76
|
+
bigdecimal
|
72
77
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
78
|
+
connection_pool (>= 2.2.5)
|
79
|
+
drb
|
73
80
|
i18n (>= 1.6, < 2)
|
74
81
|
minitest (>= 5.1)
|
82
|
+
mutex_m
|
75
83
|
tzinfo (~> 2.0)
|
76
84
|
ast (2.4.2)
|
77
85
|
base64 (0.1.1)
|
86
|
+
bigdecimal (3.1.4)
|
78
87
|
builder (3.2.4)
|
79
88
|
combustion (1.3.7)
|
80
89
|
activesupport (>= 3.0.0)
|
81
90
|
railties (>= 3.0.0)
|
82
91
|
thor (>= 0.14.6)
|
83
92
|
concurrent-ruby (1.2.2)
|
93
|
+
connection_pool (2.4.1)
|
84
94
|
crass (1.0.6)
|
85
95
|
date (3.3.3)
|
86
96
|
diff-lcs (1.5.0)
|
97
|
+
drb (2.1.1)
|
98
|
+
ruby2_keywords
|
87
99
|
erubi (1.12.0)
|
88
100
|
globalid (1.2.1)
|
89
101
|
activesupport (>= 6.1)
|
90
102
|
i18n (1.14.1)
|
91
103
|
concurrent-ruby (~> 1.0)
|
104
|
+
io-console (0.6.0)
|
105
|
+
irb (1.8.3)
|
106
|
+
rdoc
|
107
|
+
reline (>= 0.3.8)
|
92
108
|
json (2.6.3)
|
93
109
|
language_server-protocol (3.17.0.3)
|
94
|
-
loofah (2.21.
|
110
|
+
loofah (2.21.4)
|
95
111
|
crass (~> 1.0.2)
|
96
112
|
nokogiri (>= 1.12.0)
|
97
113
|
mail (2.8.1)
|
@@ -100,43 +116,50 @@ GEM
|
|
100
116
|
net-pop
|
101
117
|
net-smtp
|
102
118
|
marcel (1.0.2)
|
103
|
-
method_source (1.0.0)
|
104
119
|
mini_mime (1.1.5)
|
105
120
|
minitest (5.20.0)
|
106
|
-
|
121
|
+
mutex_m (0.1.2)
|
122
|
+
net-imap (0.4.3)
|
107
123
|
date
|
108
124
|
net-protocol
|
109
125
|
net-pop (0.1.2)
|
110
126
|
net-protocol
|
111
127
|
net-protocol (0.2.1)
|
112
128
|
timeout
|
113
|
-
net-smtp (0.
|
129
|
+
net-smtp (0.4.0)
|
114
130
|
net-protocol
|
115
131
|
nio4r (2.5.9)
|
116
132
|
nokogiri (1.15.4-x86_64-darwin)
|
117
133
|
racc (~> 1.4)
|
118
134
|
parallel (1.23.0)
|
119
|
-
parser (3.2.2.
|
135
|
+
parser (3.2.2.4)
|
120
136
|
ast (~> 2.4.1)
|
121
137
|
racc
|
138
|
+
psych (5.1.1.1)
|
139
|
+
stringio
|
122
140
|
racc (1.7.1)
|
123
|
-
rack (
|
141
|
+
rack (3.0.8)
|
142
|
+
rack-session (2.0.0)
|
143
|
+
rack (>= 3.0.0)
|
124
144
|
rack-test (2.1.0)
|
125
145
|
rack (>= 1.3)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
146
|
+
rackup (2.1.0)
|
147
|
+
rack (>= 3)
|
148
|
+
webrick (~> 1.8)
|
149
|
+
rails (7.1.1)
|
150
|
+
actioncable (= 7.1.1)
|
151
|
+
actionmailbox (= 7.1.1)
|
152
|
+
actionmailer (= 7.1.1)
|
153
|
+
actionpack (= 7.1.1)
|
154
|
+
actiontext (= 7.1.1)
|
155
|
+
actionview (= 7.1.1)
|
156
|
+
activejob (= 7.1.1)
|
157
|
+
activemodel (= 7.1.1)
|
158
|
+
activerecord (= 7.1.1)
|
159
|
+
activestorage (= 7.1.1)
|
160
|
+
activesupport (= 7.1.1)
|
138
161
|
bundler (>= 1.15.0)
|
139
|
-
railties (= 7.
|
162
|
+
railties (= 7.1.1)
|
140
163
|
rails-dom-testing (2.2.0)
|
141
164
|
activesupport (>= 5.0.0)
|
142
165
|
minitest
|
@@ -147,16 +170,21 @@ GEM
|
|
147
170
|
rails-i18n (7.0.8)
|
148
171
|
i18n (>= 0.7, < 2)
|
149
172
|
railties (>= 6.0.0, < 8)
|
150
|
-
railties (7.
|
151
|
-
actionpack (= 7.
|
152
|
-
activesupport (= 7.
|
153
|
-
|
173
|
+
railties (7.1.1)
|
174
|
+
actionpack (= 7.1.1)
|
175
|
+
activesupport (= 7.1.1)
|
176
|
+
irb
|
177
|
+
rackup (>= 1.0.0)
|
154
178
|
rake (>= 12.2)
|
155
|
-
thor (~> 1.0)
|
156
|
-
zeitwerk (~> 2.
|
179
|
+
thor (~> 1.0, >= 1.2.2)
|
180
|
+
zeitwerk (~> 2.6)
|
157
181
|
rainbow (3.1.1)
|
158
|
-
rake (13.0
|
159
|
-
|
182
|
+
rake (13.1.0)
|
183
|
+
rdoc (6.5.0)
|
184
|
+
psych (>= 4.0.0)
|
185
|
+
regexp_parser (2.8.2)
|
186
|
+
reline (0.3.9)
|
187
|
+
io-console (~> 0.5)
|
160
188
|
rexml (3.2.6)
|
161
189
|
rspec (3.12.0)
|
162
190
|
rspec-core (~> 3.12.0)
|
@@ -179,34 +207,36 @@ GEM
|
|
179
207
|
rspec-mocks (~> 3.12)
|
180
208
|
rspec-support (~> 3.12)
|
181
209
|
rspec-support (3.12.1)
|
182
|
-
rubocop (1.
|
183
|
-
base64 (~> 0.1.1)
|
210
|
+
rubocop (1.57.2)
|
184
211
|
json (~> 2.3)
|
185
212
|
language_server-protocol (>= 3.17.0)
|
186
213
|
parallel (~> 1.10)
|
187
|
-
parser (>= 3.2.2.
|
214
|
+
parser (>= 3.2.2.4)
|
188
215
|
rainbow (>= 2.2.2, < 4.0)
|
189
216
|
regexp_parser (>= 1.8, < 3.0)
|
190
217
|
rexml (>= 3.2.5, < 4.0)
|
191
218
|
rubocop-ast (>= 1.28.1, < 2.0)
|
192
219
|
ruby-progressbar (~> 1.7)
|
193
220
|
unicode-display_width (>= 2.4.0, < 3.0)
|
194
|
-
rubocop-ast (1.
|
221
|
+
rubocop-ast (1.30.0)
|
195
222
|
parser (>= 3.2.1.0)
|
196
|
-
rubocop-rails (2.
|
223
|
+
rubocop-rails (2.22.1)
|
197
224
|
activesupport (>= 4.2.0)
|
198
225
|
rack (>= 1.1)
|
199
226
|
rubocop (>= 1.33.0, < 2.0)
|
200
227
|
ruby-progressbar (1.13.0)
|
201
|
-
|
228
|
+
ruby2_keywords (0.0.5)
|
229
|
+
stringio (3.0.8)
|
230
|
+
thor (1.3.0)
|
202
231
|
timeout (0.4.0)
|
203
232
|
tzinfo (2.0.6)
|
204
233
|
concurrent-ruby (~> 1.0)
|
205
|
-
unicode-display_width (2.
|
234
|
+
unicode-display_width (2.5.0)
|
235
|
+
webrick (1.8.1)
|
206
236
|
websocket-driver (0.7.6)
|
207
237
|
websocket-extensions (>= 0.1.0)
|
208
238
|
websocket-extensions (0.1.5)
|
209
|
-
zeitwerk (2.6.
|
239
|
+
zeitwerk (2.6.12)
|
210
240
|
|
211
241
|
PLATFORMS
|
212
242
|
x86_64-darwin-20
|
data/config/locales/en-GB.yml
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
en-GB:
|
2
2
|
date_range:
|
3
|
-
|
4
|
-
|
3
|
+
one_line:
|
4
|
+
with_to: "From %{from} to %{to}"
|
5
|
+
without_to: "%{from}"
|
6
|
+
two_lines:
|
7
|
+
with_to: "%{from}<br>%{to}"
|
8
|
+
without_to: "%{from}"
|
5
9
|
|
6
10
|
date:
|
7
11
|
formats:
|
8
|
-
|
12
|
+
range_short:
|
9
13
|
day: "%-d"
|
10
14
|
day_month: "%-d %B"
|
11
15
|
day_month_year: "%-d %B %Y"
|
12
|
-
|
16
|
+
range_long:
|
13
17
|
day: "%A %-d"
|
14
18
|
day_month: "%A, %-d %B"
|
15
|
-
day_month_year: "%A, %-d %B %Y"
|
19
|
+
day_month_year: "%A, %-d %B %Y"
|
data/config/locales/en.yml
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
en:
|
2
2
|
date_range:
|
3
|
-
|
4
|
-
|
3
|
+
one_line:
|
4
|
+
with_to: "From %{from} to %{to}"
|
5
|
+
without_to: "%{from}"
|
6
|
+
two_lines:
|
7
|
+
with_to: "%{from}<br>%{to}"
|
8
|
+
without_to: "%{from}"
|
5
9
|
|
6
10
|
date:
|
7
11
|
formats:
|
8
|
-
|
12
|
+
range_short:
|
9
13
|
day: "%-d"
|
10
14
|
day_month: "%B %-d"
|
11
15
|
day_month_year: "%B %-d, %Y"
|
12
|
-
|
16
|
+
range_long:
|
13
17
|
day: "%A %-d"
|
14
18
|
day_month: "%A, %B %-d"
|
15
|
-
day_month_year: "%A, %B %-d, %Y"
|
19
|
+
day_month_year: "%A, %B %-d, %Y"
|
data/config/locales/fr.yml
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
fr:
|
2
2
|
date_range:
|
3
|
-
|
4
|
-
|
3
|
+
one_line:
|
4
|
+
with_to: "Du %{from} au %{to}"
|
5
|
+
without_to: "%{from}"
|
6
|
+
two_lines:
|
7
|
+
with_to: "%{from}<br>%{to}"
|
8
|
+
without_to: "%{from}"
|
5
9
|
|
6
10
|
date:
|
7
11
|
formats:
|
8
|
-
|
12
|
+
range_short:
|
9
13
|
day: "%-d"
|
10
14
|
day_month: "%-d %B"
|
11
15
|
day_month_year: "%-d %B %Y"
|
12
|
-
|
16
|
+
range_long:
|
13
17
|
day: "%A %-d"
|
14
18
|
day_month: "%A %-d %B"
|
15
|
-
day_month_year: "%A %-d %B %Y"
|
19
|
+
day_month_year: "%A %-d %B %Y"
|
@@ -2,16 +2,17 @@
|
|
2
2
|
|
3
3
|
# Computing range to choose the correct form
|
4
4
|
class I18nDateRangeGenerator
|
5
|
-
attr_reader :from_date, :to_date, :format
|
5
|
+
attr_reader :from_date, :to_date, :format, :layout
|
6
6
|
|
7
|
-
def self.generate(from_date, to_date, format
|
8
|
-
new(from_date, to_date, format).to_s
|
7
|
+
def self.generate(from_date, to_date, format: :short, layout: :one_line)
|
8
|
+
new(from_date, to_date, format: format, layout: layout).to_s
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize(from_date, to_date, format
|
11
|
+
def initialize(from_date, to_date, format: :short, layout: :one_line)
|
12
12
|
@from_date = from_date
|
13
13
|
@to_date = to_date
|
14
14
|
@format = format
|
15
|
+
@layout = layout
|
15
16
|
end
|
16
17
|
|
17
18
|
def to_s
|
@@ -26,14 +27,14 @@ class I18nDateRangeGenerator
|
|
26
27
|
|
27
28
|
def without_to
|
28
29
|
I18n.t(
|
29
|
-
"date_range.without_to",
|
30
|
+
"date_range.#{layout}.without_to",
|
30
31
|
from: format_date(from_date, :day_month_year)
|
31
32
|
).capitalize
|
32
33
|
end
|
33
34
|
|
34
35
|
def with_to
|
35
36
|
I18n.t(
|
36
|
-
"date_range.with_to",
|
37
|
+
"date_range.#{layout}.with_to",
|
37
38
|
from: format_date(from_date, from_format),
|
38
39
|
to: format_date(to_date, :day_month_year)
|
39
40
|
).capitalize
|
@@ -50,7 +51,7 @@ class I18nDateRangeGenerator
|
|
50
51
|
def format_date(date, key)
|
51
52
|
I18n.l(
|
52
53
|
date,
|
53
|
-
format: "#{format}.#{key}".to_sym
|
54
|
+
format: "range_#{format}.#{key}".to_sym
|
54
55
|
)
|
55
56
|
end
|
56
57
|
|
@@ -3,8 +3,11 @@
|
|
3
3
|
# Rails helper
|
4
4
|
# Format can be :short (default) or :long
|
5
5
|
# <%= date_range_i18n(start, end, :long)
|
6
|
+
# Layout can be :one_line (default) or :two_lines, other might be necessary in the future
|
6
7
|
module I18nDateRangeHelper
|
7
|
-
|
8
|
-
|
8
|
+
|
9
|
+
def date_range_i18n(from, to = nil, format: nil, layout: nil)
|
10
|
+
I18nDateRangeGenerator.generate(*args)
|
9
11
|
end
|
12
|
+
|
10
13
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_date_range
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pabois
|
8
8
|
- arnaudlevy
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -172,7 +172,7 @@ metadata:
|
|
172
172
|
homepage_uri: https://github.com/noesya/i18n_date_range
|
173
173
|
source_code_uri: https://github.com/noesya/i18n_date_range
|
174
174
|
changelog_uri: https://github.com/noesya/i18n_date_range/CHANGELOG.md
|
175
|
-
post_install_message:
|
175
|
+
post_install_message:
|
176
176
|
rdoc_options: []
|
177
177
|
require_paths:
|
178
178
|
- lib
|
@@ -187,8 +187,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: '0'
|
189
189
|
requirements: []
|
190
|
-
rubygems_version: 3.
|
191
|
-
signing_key:
|
190
|
+
rubygems_version: 3.4.6
|
191
|
+
signing_key:
|
192
192
|
specification_version: 4
|
193
193
|
summary: Add helper to display a date range
|
194
194
|
test_files: []
|