dotiw 5.1.0 → 5.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.markdown +16 -0
- data/lib/dotiw.rb +1 -0
- data/lib/dotiw/action_view/helpers/date_helper.rb +1 -0
- data/lib/dotiw/locale/ar.yml +54 -3
- data/lib/dotiw/locale/da.yml +35 -0
- data/lib/dotiw/locale/de.yml +36 -1
- data/lib/dotiw/locale/en.yml +35 -0
- data/lib/dotiw/locale/es.yml +36 -1
- data/lib/dotiw/locale/fr.yml +35 -0
- data/lib/dotiw/locale/id.yml +35 -0
- data/lib/dotiw/locale/it.yml +35 -0
- data/lib/dotiw/locale/ja.yml +35 -0
- data/lib/dotiw/locale/ko.yml +23 -0
- data/lib/dotiw/locale/nb.yml +36 -1
- data/lib/dotiw/locale/nl.yml +35 -0
- data/lib/dotiw/locale/pl.yml +35 -0
- data/lib/dotiw/locale/pt-BR.yml +35 -0
- data/lib/dotiw/locale/ru.yml +37 -0
- data/lib/dotiw/locale/sv.yml +48 -0
- data/lib/dotiw/locale/vi.yml +23 -0
- data/lib/dotiw/locale/zh-CN.yml +23 -0
- data/lib/dotiw/locale/zh-TW.yml +60 -0
- data/lib/dotiw/methods.rb +10 -4
- data/lib/dotiw/version.rb +1 -1
- data/spec/lib/dotiw_spec.rb +11 -10
- data/spec/lib/i18n/sv.yml +2 -0
- data/spec/lib/i18n/zh-TW.yml +2 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d52199ee419e6e9effc50ae35409aa01605c4e2b05306ddf2ba4a7d5d9a627d
|
4
|
+
data.tar.gz: c069bf8d7cc9078b9091284084907f777155b2a698b9fe9067ad4ee621dd4982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9578117b3360f17e92d49ffe07b4071f805d9c8737033c5431f9ed6e6a9e75aec787d3ef22c9e156af2f1186083cb38c9b4039b9cb12b05cf4ea0dbfd7ce0d83
|
7
|
+
data.tar.gz: c463d39fdf6b1e811a850b23ab363f4a1e4bf3cd76515621d90ee347489762e4cb0c436cdca038487954af6124c60ef9b84902ccc5a9a7ffa034aabee0826b16
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 5.2.0 (2020/10/03)
|
2
|
+
|
3
|
+
* [#94](https://github.com/radar/distance_of_time_in_words/pull/94): Add :compact formatting option - [@booty](https://github.com/booty).
|
4
|
+
* [#112](https://github.com/radar/distance_of_time_in_words/pull/112): Add Swedish language support - [@davidwessman](https://github.com/davidwessman).
|
5
|
+
* [#114](https://github.com/radar/distance_of_time_in_words/pull/114): Add Traditional Chinese (Taiwan) language support - [@sibevin](https://github.com/sibevin).
|
6
|
+
|
1
7
|
## 5.1.0 (2020/08/05)
|
2
8
|
|
3
9
|
* [#111](https://github.com/radar/distance_of_time_in_words/pull/111): Fix: `NoMethodError` when calling `ActionController::Base.helpers.distance_of_time_in_words` - [@denisahearn](https://github.com/denisahearn).
|
data/README.markdown
CHANGED
@@ -235,6 +235,22 @@ This method takes the same options as [`number_with_precision`](http://api.rubyo
|
|
235
235
|
=> '15.3%'
|
236
236
|
```
|
237
237
|
|
238
|
+
## :compact
|
239
|
+
|
240
|
+
Pressed for space? Try `compact: true`.
|
241
|
+
|
242
|
+
```ruby
|
243
|
+
>> distance_of_time_in_words(Time.now, Time.now + 2.year + 1.day + 1.second, compact: true)
|
244
|
+
=> "2y1d"
|
245
|
+
```
|
246
|
+
|
247
|
+
Pairs well with `words_connector`, `last_word_connector`, and `two_words_connector` if you can spare just a little more room:
|
248
|
+
|
249
|
+
```ruby
|
250
|
+
>> distance_of_time_in_words(Time.now, Time.now + 5.years + 1.day + 23.seconds, words_connector: " ", last_word_connector: " ", two_words_connector: " ", compact: true)
|
251
|
+
=> "5y 1d 23s"
|
252
|
+
```
|
253
|
+
|
238
254
|
## Contributors
|
239
255
|
|
240
256
|
* [chendo](http://github.com/chendo) - for talking through it with me and drawing on the whiteboard
|
data/lib/dotiw.rb
CHANGED
@@ -15,6 +15,7 @@ module ActionView
|
|
15
15
|
|
16
16
|
def distance_of_time_in_percent(from_time, current_time, to_time, options = {})
|
17
17
|
options[:precision] ||= 0
|
18
|
+
options = options_with_scope(options)
|
18
19
|
distance = to_time - from_time
|
19
20
|
result = ((current_time - from_time) / distance) * 100
|
20
21
|
number_with_precision(result, options).to_s + '%'
|
data/lib/dotiw/locale/ar.yml
CHANGED
@@ -26,7 +26,7 @@ ar:
|
|
26
26
|
zero: يوم
|
27
27
|
one: يوم واحد
|
28
28
|
two: يومين
|
29
|
-
few: "%{count} أيام"
|
29
|
+
few: "%{count} أيام"
|
30
30
|
many: "%{count} يومًا"
|
31
31
|
other: "%{count} يوم"
|
32
32
|
weeks:
|
@@ -38,16 +38,67 @@ ar:
|
|
38
38
|
other: "%{count} أسيوع"
|
39
39
|
months:
|
40
40
|
zero: شهر
|
41
|
-
one: شهر واحد
|
41
|
+
one: شهر واحد
|
42
42
|
two: شهرين
|
43
43
|
few: "%{count} أشهر"
|
44
44
|
many: "%{count} شهراً"
|
45
45
|
other: "%{count} شهر"
|
46
46
|
years:
|
47
47
|
zero: عام
|
48
|
-
one: عام واحد
|
48
|
+
one: عام واحد
|
49
49
|
two: عامين
|
50
50
|
few: "%{count} أعوام"
|
51
51
|
many: "%{count} عاماً"
|
52
52
|
other: "%{count} عام"
|
53
53
|
less_than_x: "%{distance} أقل من"
|
54
|
+
dotiw_compact:
|
55
|
+
seconds:
|
56
|
+
zero: ثانية
|
57
|
+
one: ثانية واحدة
|
58
|
+
two: ثانيتين
|
59
|
+
few: "%{count}توانٍ"
|
60
|
+
many: "%{count}ثانية"
|
61
|
+
other: "%{count}ثانية"
|
62
|
+
minutes:
|
63
|
+
zero: دقيقة
|
64
|
+
one: دقيقة واحدة
|
65
|
+
two: دقيقتين
|
66
|
+
few: "%{count}دقائق"
|
67
|
+
many: "%{count}دقيقة"
|
68
|
+
other: "%{count}دقيقة"
|
69
|
+
hours:
|
70
|
+
zero: ساعة
|
71
|
+
one: ساعة واحدة
|
72
|
+
two: ساعتين
|
73
|
+
few: "%{count}ساعات"
|
74
|
+
many: "%{count}ساعة"
|
75
|
+
other: "%{count}ساعة"
|
76
|
+
days:
|
77
|
+
zero: يوم
|
78
|
+
one: يوم واحد
|
79
|
+
two: يومين
|
80
|
+
few: "%{count}أيام"
|
81
|
+
many: "%{count}يومًا"
|
82
|
+
other: "%{count}يوم"
|
83
|
+
weeks:
|
84
|
+
zero: أسبوع
|
85
|
+
one: أسبوع واحدة
|
86
|
+
two: أسبوعين
|
87
|
+
few: "%{count}أسابيع"
|
88
|
+
many: "%{count}أسابيع"
|
89
|
+
other: "%{count}أسيوع"
|
90
|
+
months:
|
91
|
+
zero: شهر
|
92
|
+
one: شهر واحد
|
93
|
+
two: شهرين
|
94
|
+
few: "%{count}أشهر"
|
95
|
+
many: "%{count}شهراً"
|
96
|
+
other: "%{count}شهر"
|
97
|
+
years:
|
98
|
+
zero: عام
|
99
|
+
one: عام واحد
|
100
|
+
two: عامين
|
101
|
+
few: "%{count}أعوام"
|
102
|
+
many: "%{count}عاماً"
|
103
|
+
other: "%{count}عام"
|
104
|
+
less_than_x: "%{distance}>"
|
data/lib/dotiw/locale/da.yml
CHANGED
@@ -21,3 +21,38 @@ da:
|
|
21
21
|
other: "%{count} måneder"
|
22
22
|
years: "%{count} år"
|
23
23
|
less_than_x: "mindre end %{distance}"
|
24
|
+
dotiw_compact:
|
25
|
+
seconds:
|
26
|
+
one: 1s
|
27
|
+
other: "%{count}s"
|
28
|
+
minutes:
|
29
|
+
one: 1m
|
30
|
+
other: "%{count}m"
|
31
|
+
hours:
|
32
|
+
one: 1t
|
33
|
+
other: "%{count}t"
|
34
|
+
days:
|
35
|
+
one: 1d
|
36
|
+
other: "%{count}d"
|
37
|
+
weeks:
|
38
|
+
one: 1u
|
39
|
+
other: "%{count}u"
|
40
|
+
months:
|
41
|
+
one: 1må
|
42
|
+
other: "%{count}må"
|
43
|
+
years:
|
44
|
+
one: 1år
|
45
|
+
other: "%{count}år"
|
46
|
+
less_than_x: "<%{distance}"
|
47
|
+
words_connector: ""
|
48
|
+
two_words_connector: ""
|
49
|
+
last_word_connector: ""
|
50
|
+
about_x_years:
|
51
|
+
one: ~1y
|
52
|
+
any: "~%{count}y"
|
53
|
+
over_x_years:
|
54
|
+
one: ">1y"
|
55
|
+
other: ">%{count}y"
|
56
|
+
almost_x_years:
|
57
|
+
one: ~1y
|
58
|
+
any: "~%{count}y"
|
data/lib/dotiw/locale/de.yml
CHANGED
@@ -22,4 +22,39 @@ de:
|
|
22
22
|
years:
|
23
23
|
one: 1 Jahr
|
24
24
|
other: "%{count} Jahre"
|
25
|
-
less_than_x: "weniger als %{distance}"
|
25
|
+
less_than_x: "weniger als %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1std
|
35
|
+
other: "%{count}std"
|
36
|
+
days:
|
37
|
+
one: 1t
|
38
|
+
other: "%{count}t"
|
39
|
+
weeks:
|
40
|
+
one: 1w
|
41
|
+
other: "%{count}w"
|
42
|
+
months:
|
43
|
+
one: 1mo
|
44
|
+
other: "%{count}mo"
|
45
|
+
years:
|
46
|
+
one: 1j
|
47
|
+
other: "%{count}j"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1y
|
54
|
+
any: "~%{count}y"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1y"
|
57
|
+
other: ">%{count}y"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1y
|
60
|
+
any: "~%{count}y"
|
data/lib/dotiw/locale/en.yml
CHANGED
@@ -23,3 +23,38 @@ en:
|
|
23
23
|
one: 1 year
|
24
24
|
other: "%{count} years"
|
25
25
|
less_than_x: "less than %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1h
|
35
|
+
other: "%{count}h"
|
36
|
+
days:
|
37
|
+
one: 1d
|
38
|
+
other: "%{count}d"
|
39
|
+
weeks:
|
40
|
+
one: 1w
|
41
|
+
other: "%{count}w"
|
42
|
+
months:
|
43
|
+
one: 1mo
|
44
|
+
other: "%{count}mo"
|
45
|
+
years:
|
46
|
+
one: 1y
|
47
|
+
other: "%{count}y"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1y
|
54
|
+
any: "~%{count}y"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1y"
|
57
|
+
other: ">%{count}y"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1y
|
60
|
+
any: "~%{count}y"
|
data/lib/dotiw/locale/es.yml
CHANGED
@@ -22,4 +22,39 @@ es:
|
|
22
22
|
years:
|
23
23
|
one: un año
|
24
24
|
other: "%{count} años"
|
25
|
-
less_than_x: "menos de %{distance}"
|
25
|
+
less_than_x: "menos de %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1h
|
35
|
+
other: "%{count}h"
|
36
|
+
days:
|
37
|
+
one: 1d
|
38
|
+
other: "%{count}d"
|
39
|
+
weeks:
|
40
|
+
one: 1s
|
41
|
+
other: "%{count}s"
|
42
|
+
months:
|
43
|
+
one: 1me
|
44
|
+
other: "%{count}me"
|
45
|
+
years:
|
46
|
+
one: 1a
|
47
|
+
other: "%{count}a"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1a
|
54
|
+
any: "~%{count}a"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1a"
|
57
|
+
other: ">%{count}a"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1a
|
60
|
+
any: "~%{count}a"
|
data/lib/dotiw/locale/fr.yml
CHANGED
@@ -23,3 +23,38 @@ fr:
|
|
23
23
|
one: 1 an
|
24
24
|
other: "%{count} ans"
|
25
25
|
less_than_x: "moins de %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1h
|
35
|
+
other: "%{count}h"
|
36
|
+
days:
|
37
|
+
one: 1j
|
38
|
+
other: "%{count}j"
|
39
|
+
weeks:
|
40
|
+
one: 1se
|
41
|
+
other: "%{count}se"
|
42
|
+
months:
|
43
|
+
one: 1mo
|
44
|
+
other: "%{count}mo"
|
45
|
+
years:
|
46
|
+
one: 1a
|
47
|
+
other: "%{count}a"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1a
|
54
|
+
any: "~%{count}a"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1a"
|
57
|
+
other: ">%{count}a"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1a
|
60
|
+
any: "~%{count}a"
|
data/lib/dotiw/locale/id.yml
CHANGED
@@ -23,3 +23,38 @@ id:
|
|
23
23
|
one: 1 tahun
|
24
24
|
other: "%{count} tahun"
|
25
25
|
less_than_x: "kurang dari %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1d
|
29
|
+
other: "%{count}d"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1j
|
35
|
+
other: "%{count}j"
|
36
|
+
days:
|
37
|
+
one: 1h
|
38
|
+
other: "%{count}h"
|
39
|
+
weeks:
|
40
|
+
one: 1mi
|
41
|
+
other: "%{count}mi"
|
42
|
+
months:
|
43
|
+
one: 1b
|
44
|
+
other: "%{count}b"
|
45
|
+
years:
|
46
|
+
one: 1t
|
47
|
+
other: "%{count}t"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1t
|
54
|
+
any: "~%{count}t"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1t"
|
57
|
+
other: ">%{count}t"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1t
|
60
|
+
any: "~%{count}t"
|
data/lib/dotiw/locale/it.yml
CHANGED
@@ -22,3 +22,38 @@ it:
|
|
22
22
|
years:
|
23
23
|
one: un anno
|
24
24
|
other: "%{count} anni"
|
25
|
+
dotiw_compact:
|
26
|
+
seconds:
|
27
|
+
one: 1s
|
28
|
+
other: "%{count}s"
|
29
|
+
minutes:
|
30
|
+
one: 1m
|
31
|
+
other: "%{count}m"
|
32
|
+
hours:
|
33
|
+
one: 1o
|
34
|
+
other: "%{count}o"
|
35
|
+
days:
|
36
|
+
one: 1g
|
37
|
+
other: "%{count}g"
|
38
|
+
weeks:
|
39
|
+
one: 1se
|
40
|
+
other: "%{count}se"
|
41
|
+
months:
|
42
|
+
one: 1me
|
43
|
+
other: "%{count}me"
|
44
|
+
years:
|
45
|
+
one: 1a
|
46
|
+
other: "%{count}a"
|
47
|
+
less_than_x: "<%{distance}"
|
48
|
+
words_connector: ""
|
49
|
+
two_words_connector: ""
|
50
|
+
last_word_connector: ""
|
51
|
+
about_x_years:
|
52
|
+
one: ~1a
|
53
|
+
any: "~%{count}a"
|
54
|
+
over_x_years:
|
55
|
+
one: ">1a"
|
56
|
+
other: ">%{count}a"
|
57
|
+
almost_x_years:
|
58
|
+
one: ~1a
|
59
|
+
any: "~%{count}a"
|
data/lib/dotiw/locale/ja.yml
CHANGED
@@ -22,3 +22,38 @@ ja:
|
|
22
22
|
years:
|
23
23
|
one: "1年間"
|
24
24
|
other: "%{count}年間"
|
25
|
+
dotiw_compact:
|
26
|
+
seconds:
|
27
|
+
one: "1秒"
|
28
|
+
other: "%{count}秒"
|
29
|
+
minutes:
|
30
|
+
one: "1分"
|
31
|
+
other: "%{count}分"
|
32
|
+
hours:
|
33
|
+
one: "1時間"
|
34
|
+
other: "%{count}時間"
|
35
|
+
days:
|
36
|
+
one: "1日間"
|
37
|
+
other: "%{count}日間"
|
38
|
+
weeks:
|
39
|
+
one: "1週間"
|
40
|
+
other: "%{count}週間"
|
41
|
+
months:
|
42
|
+
one: "1ヶ月"
|
43
|
+
other: "%{count}ヶ月"
|
44
|
+
years:
|
45
|
+
one: "1年間"
|
46
|
+
other: "%{count}年間"
|
47
|
+
less_than_x: "<%{distance}"
|
48
|
+
words_connector: ""
|
49
|
+
two_words_connector: ""
|
50
|
+
last_word_connector: ""
|
51
|
+
about_x_years:
|
52
|
+
one: ~1年間
|
53
|
+
any: "~%{count}年間"
|
54
|
+
over_x_years:
|
55
|
+
one: ">1年間"
|
56
|
+
other: ">%{count}年間"
|
57
|
+
almost_x_years:
|
58
|
+
one: ~1年間
|
59
|
+
any: "~%{count}年間"
|
data/lib/dotiw/locale/ko.yml
CHANGED
@@ -23,3 +23,26 @@ ko:
|
|
23
23
|
one: 일년
|
24
24
|
other: "%{count} 년"
|
25
25
|
less_than_x: "%{distance} 미만"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 일초
|
29
|
+
other: "%{count}초"
|
30
|
+
minutes:
|
31
|
+
one: 일분
|
32
|
+
other: "%{count}분"
|
33
|
+
hours:
|
34
|
+
one: 한시간
|
35
|
+
other: "%{count}시간"
|
36
|
+
days:
|
37
|
+
one: 하루
|
38
|
+
other: "%{count}일"
|
39
|
+
weeks:
|
40
|
+
one: 일주
|
41
|
+
other: "%{count}주"
|
42
|
+
months:
|
43
|
+
one: 한달
|
44
|
+
other: "%{count}달"
|
45
|
+
years:
|
46
|
+
one: 일년
|
47
|
+
other: "%{count}년"
|
48
|
+
less_than_x: "< %{distance}"
|
data/lib/dotiw/locale/nb.yml
CHANGED
@@ -22,4 +22,39 @@ nb:
|
|
22
22
|
years:
|
23
23
|
one: 1 år
|
24
24
|
other: "%{count} år"
|
25
|
-
less_than_x: "mindre enn %{distance}"
|
25
|
+
less_than_x: "mindre enn %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1t
|
35
|
+
other: "%{count}t"
|
36
|
+
days:
|
37
|
+
one: 1d
|
38
|
+
other: "%{count}d"
|
39
|
+
weeks:
|
40
|
+
one: 1u
|
41
|
+
other: "%{count}u"
|
42
|
+
months:
|
43
|
+
one: 1må
|
44
|
+
other: "%{count}må"
|
45
|
+
years:
|
46
|
+
one: 1å
|
47
|
+
other: "%{count}å"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1å
|
54
|
+
any: "~%{count}å"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1å"
|
57
|
+
other: ">%{count}å"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1å
|
60
|
+
any: "~%{count}å"
|
data/lib/dotiw/locale/nl.yml
CHANGED
@@ -23,3 +23,38 @@ nl:
|
|
23
23
|
one: 1 jaar
|
24
24
|
other: "%{count} jaar"
|
25
25
|
less_than_x: "minder dan %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1u
|
35
|
+
other: "%{count}u"
|
36
|
+
days:
|
37
|
+
one: 1d
|
38
|
+
other: "%{count}d"
|
39
|
+
weeks:
|
40
|
+
one: 1w
|
41
|
+
other: "%{count}w"
|
42
|
+
months:
|
43
|
+
one: 1ma
|
44
|
+
other: "%{count}ma"
|
45
|
+
years:
|
46
|
+
one: 1j
|
47
|
+
other: "%{count}j"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1j
|
54
|
+
any: "~%{count}j"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1j"
|
57
|
+
other: ">%{count}j"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1j
|
60
|
+
any: "~%{count}j"
|
data/lib/dotiw/locale/pl.yml
CHANGED
@@ -37,3 +37,38 @@ pl:
|
|
37
37
|
many: "%{count} lat"
|
38
38
|
other: "%{count} lat"
|
39
39
|
less_than_x: "mniej niż %{distance}"
|
40
|
+
dotiw_compact:
|
41
|
+
seconds:
|
42
|
+
one: 1s
|
43
|
+
other: "%{count}s"
|
44
|
+
minutes:
|
45
|
+
one: 1m
|
46
|
+
other: "%{count}m"
|
47
|
+
hours:
|
48
|
+
one: 1g
|
49
|
+
other: "%{count}g"
|
50
|
+
days:
|
51
|
+
one: 1d
|
52
|
+
other: "%{count}d"
|
53
|
+
weeks:
|
54
|
+
one: 1t
|
55
|
+
other: "%{count}t"
|
56
|
+
months:
|
57
|
+
one: 1mi
|
58
|
+
other: "%{count}mi"
|
59
|
+
years:
|
60
|
+
one: 1r
|
61
|
+
other: "%{count}l"
|
62
|
+
less_than_x: "<%{distance}"
|
63
|
+
words_connector: ""
|
64
|
+
two_words_connector: ""
|
65
|
+
last_word_connector: ""
|
66
|
+
about_x_years:
|
67
|
+
one: ~1r
|
68
|
+
any: "~%{count}r"
|
69
|
+
over_x_years:
|
70
|
+
one: ">1r"
|
71
|
+
other: ">%{count}r"
|
72
|
+
almost_x_years:
|
73
|
+
one: ~1r
|
74
|
+
any: "~%{count}r"
|
data/lib/dotiw/locale/pt-BR.yml
CHANGED
@@ -23,3 +23,38 @@ pt-BR:
|
|
23
23
|
one: 1 ano
|
24
24
|
other: "%{count} anos"
|
25
25
|
less_than_x: "menos de %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1h
|
35
|
+
other: "%{count}h"
|
36
|
+
days:
|
37
|
+
one: 1d
|
38
|
+
other: "%{count}d"
|
39
|
+
weeks:
|
40
|
+
one: 1s
|
41
|
+
other: "%{count}s"
|
42
|
+
months:
|
43
|
+
one: 1mê
|
44
|
+
other: "%{count}mê"
|
45
|
+
years:
|
46
|
+
one: 1a
|
47
|
+
other: "%{count}a"
|
48
|
+
less_than_x: "<%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: ~1a
|
54
|
+
any: "~%{count}a"
|
55
|
+
over_x_years:
|
56
|
+
one: ">1a"
|
57
|
+
other: ">%{count}a"
|
58
|
+
almost_x_years:
|
59
|
+
one: ~1a
|
60
|
+
any: "~%{count}a"
|
data/lib/dotiw/locale/ru.yml
CHANGED
@@ -37,3 +37,40 @@ ru:
|
|
37
37
|
many: "%{count} лет"
|
38
38
|
other: "%{count} года"
|
39
39
|
less_than_x: "меньше, чем %{distance}"
|
40
|
+
dotiw_compact:
|
41
|
+
seconds:
|
42
|
+
one: 1с
|
43
|
+
other: "%{count}с"
|
44
|
+
minutes:
|
45
|
+
one: 1м
|
46
|
+
other: "%{count}м"
|
47
|
+
hours:
|
48
|
+
one: 1ч
|
49
|
+
other: "%{count}ч"
|
50
|
+
days:
|
51
|
+
one: 1д
|
52
|
+
other: "%{count}д"
|
53
|
+
weeks:
|
54
|
+
one: 1н
|
55
|
+
other: "%{count}н"
|
56
|
+
months:
|
57
|
+
one: 1ме
|
58
|
+
other: "%{count}ме"
|
59
|
+
years:
|
60
|
+
one: "%{count}г"
|
61
|
+
few: "%{count}г"
|
62
|
+
many: "%{count}л"
|
63
|
+
other: "%{count}г"
|
64
|
+
less_than_x: "<%{distance}"
|
65
|
+
words_connector: ""
|
66
|
+
two_words_connector: ""
|
67
|
+
last_word_connector: ""
|
68
|
+
about_x_years:
|
69
|
+
one: ~1г
|
70
|
+
any: "~%{count}г"
|
71
|
+
over_x_years:
|
72
|
+
one: ">1г"
|
73
|
+
other: ">%{count}г"
|
74
|
+
almost_x_years:
|
75
|
+
one: ~1г
|
76
|
+
any: "~%{count}г"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
sv:
|
2
|
+
datetime:
|
3
|
+
dotiw:
|
4
|
+
seconds:
|
5
|
+
one: 1 sekund
|
6
|
+
other: "%{count} sekunder"
|
7
|
+
minutes:
|
8
|
+
one: 1 minut
|
9
|
+
other: "%{count} minuter"
|
10
|
+
hours:
|
11
|
+
one: 1 timme
|
12
|
+
other: "%{count} timmar"
|
13
|
+
days:
|
14
|
+
one: 1 dag
|
15
|
+
other: "%{count} dagar"
|
16
|
+
weeks:
|
17
|
+
one: 1 vecka
|
18
|
+
other: "%{count} veckor"
|
19
|
+
months:
|
20
|
+
one: 1 månad
|
21
|
+
other: "%{count} månader"
|
22
|
+
years:
|
23
|
+
one: 1 år
|
24
|
+
other: "%{count} år"
|
25
|
+
less_than_x: "mindre än %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1s
|
29
|
+
other: "%{count}s"
|
30
|
+
minutes:
|
31
|
+
one: 1m
|
32
|
+
other: "%{count}m"
|
33
|
+
hours:
|
34
|
+
one: 1t
|
35
|
+
other: "%{count}t"
|
36
|
+
days:
|
37
|
+
one: 1d
|
38
|
+
other: "%{count}d"
|
39
|
+
weeks:
|
40
|
+
one: 1v
|
41
|
+
other: "%{count}v"
|
42
|
+
months:
|
43
|
+
one: 1m
|
44
|
+
other: "%{count}m"
|
45
|
+
years:
|
46
|
+
one: 1å
|
47
|
+
other: "%{count}å"
|
48
|
+
less_than_x: "<%{distance}"
|
data/lib/dotiw/locale/vi.yml
CHANGED
@@ -23,3 +23,26 @@ vi:
|
|
23
23
|
one: 1 năm
|
24
24
|
other: "%{count} năm"
|
25
25
|
less_than_x: "ít hơn %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1 giây
|
29
|
+
other: "%{count}giây"
|
30
|
+
minutes:
|
31
|
+
one: 1 phút
|
32
|
+
other: "%{count}phút"
|
33
|
+
hours:
|
34
|
+
one: 1 giờ
|
35
|
+
other: "%{count}giờ"
|
36
|
+
days:
|
37
|
+
one: 1 ngày
|
38
|
+
other: "%{count}ngày"
|
39
|
+
weeks:
|
40
|
+
one: 1 tuần
|
41
|
+
other: "%{count}tuần"
|
42
|
+
months:
|
43
|
+
one: 1 tháng
|
44
|
+
other: "%{count}tháng"
|
45
|
+
years:
|
46
|
+
one: 1 năm
|
47
|
+
other: "%{count}năm"
|
48
|
+
less_than_x: "< %{distance}"
|
data/lib/dotiw/locale/zh-CN.yml
CHANGED
@@ -23,3 +23,26 @@ zh-CN:
|
|
23
23
|
one: 1 年
|
24
24
|
other: "%{count} 年"
|
25
25
|
less_than_x: "小于 %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1秒
|
29
|
+
other: "%{count}秒"
|
30
|
+
minutes:
|
31
|
+
one: 1分钟
|
32
|
+
other: "%{count}分钟"
|
33
|
+
hours:
|
34
|
+
one: 1小时
|
35
|
+
other: "%{count}小时"
|
36
|
+
days:
|
37
|
+
one: 1天
|
38
|
+
other: "%{count}天"
|
39
|
+
weeks:
|
40
|
+
one: 1周
|
41
|
+
other: "%{count}周"
|
42
|
+
months:
|
43
|
+
one: 1月
|
44
|
+
other: "%{count}月"
|
45
|
+
years:
|
46
|
+
one: 1年
|
47
|
+
other: "%{count}年"
|
48
|
+
less_than_x: "小于 %{distance}"
|
@@ -0,0 +1,60 @@
|
|
1
|
+
zh-TW:
|
2
|
+
datetime:
|
3
|
+
dotiw:
|
4
|
+
seconds:
|
5
|
+
one: 1 秒
|
6
|
+
other: "%{count} 秒"
|
7
|
+
minutes:
|
8
|
+
one: 1 分鐘
|
9
|
+
other: "%{count} 分鐘"
|
10
|
+
hours:
|
11
|
+
one: 1 小時
|
12
|
+
other: "%{count} 小時"
|
13
|
+
days:
|
14
|
+
one: 1 天
|
15
|
+
other: "%{count} 天"
|
16
|
+
weeks:
|
17
|
+
one: 1 週
|
18
|
+
other: "%{count} 週"
|
19
|
+
months:
|
20
|
+
one: 1 月
|
21
|
+
other: "%{count} 月"
|
22
|
+
years:
|
23
|
+
one: 1 年
|
24
|
+
other: "%{count} 年"
|
25
|
+
less_than_x: "小於 %{distance}"
|
26
|
+
dotiw_compact:
|
27
|
+
seconds:
|
28
|
+
one: 1秒
|
29
|
+
other: "%{count}秒"
|
30
|
+
minutes:
|
31
|
+
one: 1分鐘
|
32
|
+
other: "%{count}分鐘"
|
33
|
+
hours:
|
34
|
+
one: 1小時
|
35
|
+
other: "%{count}小時"
|
36
|
+
days:
|
37
|
+
one: 1天
|
38
|
+
other: "%{count}天"
|
39
|
+
weeks:
|
40
|
+
one: 1週
|
41
|
+
other: "%{count}週"
|
42
|
+
months:
|
43
|
+
one: 1月
|
44
|
+
other: "%{count}月"
|
45
|
+
years:
|
46
|
+
one: 1年
|
47
|
+
other: "%{count}年"
|
48
|
+
less_than_x: "小於%{distance}"
|
49
|
+
words_connector: ""
|
50
|
+
two_words_connector: ""
|
51
|
+
last_word_connector: ""
|
52
|
+
about_x_years:
|
53
|
+
one: 約1年
|
54
|
+
any: "約%{count}年"
|
55
|
+
over_x_years:
|
56
|
+
one: "大於1年"
|
57
|
+
other: "大於%{count}年"
|
58
|
+
almost_x_years:
|
59
|
+
one: 將近1年
|
60
|
+
any: "將近%{count}年"
|
data/lib/dotiw/methods.rb
CHANGED
@@ -13,7 +13,7 @@ module DOTIW
|
|
13
13
|
|
14
14
|
def distance_of_time(seconds, options = {})
|
15
15
|
options[:include_seconds] ||= true
|
16
|
-
_display_time_in_words DOTIW::TimeHash.new(seconds, nil, nil, options).to_hash, options
|
16
|
+
_display_time_in_words DOTIW::TimeHash.new(seconds, nil, nil, options_with_scope(options)).to_hash, options
|
17
17
|
end
|
18
18
|
|
19
19
|
def distance_of_time_in_words(from_time, to_time = 0, include_seconds_or_options = {}, options = {})
|
@@ -24,6 +24,7 @@ module DOTIW
|
|
24
24
|
end
|
25
25
|
return distance_of_time(from_time, options) if to_time == 0
|
26
26
|
|
27
|
+
options = options_with_scope(options)
|
27
28
|
hash = distance_of_time_in_words_hash(from_time, to_time, options)
|
28
29
|
_display_time_in_words(hash, options)
|
29
30
|
end
|
@@ -34,6 +35,11 @@ module DOTIW
|
|
34
35
|
|
35
36
|
private
|
36
37
|
|
38
|
+
def options_with_scope(options)
|
39
|
+
options.merge!({:scope => DOTIW::DEFAULT_I18N_SCOPE_COMPACT}) if options.delete(:compact)
|
40
|
+
options
|
41
|
+
end
|
42
|
+
|
37
43
|
def _display_time_in_words(hash, options = {})
|
38
44
|
options.reverse_merge!(
|
39
45
|
include_seconds: false
|
@@ -77,13 +83,13 @@ module DOTIW
|
|
77
83
|
highest_measures = 1 if options.delete(:highest_measure_only)
|
78
84
|
output = output[0...highest_measures] if highest_measures
|
79
85
|
|
80
|
-
options[:words_connector] ||= I18n.translate :
|
86
|
+
options[:words_connector] ||= I18n.translate :"#{i18n_scope}.words_connector",
|
81
87
|
default: :'support.array.words_connector',
|
82
88
|
locale: options[:locale]
|
83
|
-
options[:two_words_connector] ||= I18n.translate :
|
89
|
+
options[:two_words_connector] ||= I18n.translate :"#{i18n_scope}.two_words_connector",
|
84
90
|
default: :'support.array.two_words_connector',
|
85
91
|
locale: options[:locale]
|
86
|
-
options[:last_word_connector] ||= I18n.translate :
|
92
|
+
options[:last_word_connector] ||= I18n.translate :"#{i18n_scope}.last_word_connector",
|
87
93
|
default: :'support.array.last_word_connector',
|
88
94
|
locale: options[:locale]
|
89
95
|
|
data/lib/dotiw/version.rb
CHANGED
data/spec/lib/dotiw_spec.rb
CHANGED
@@ -23,18 +23,19 @@ describe 'A better distance_of_time_in_words' do
|
|
23
23
|
|
24
24
|
describe '#distance_of_time' do
|
25
25
|
[
|
26
|
-
[0.5.minutes,
|
27
|
-
[4.5.minutes,
|
28
|
-
[5.minutes,
|
29
|
-
[10.minutes,
|
30
|
-
[1.hour,
|
31
|
-
[1.hour + 30.seconds,
|
32
|
-
[4.weeks,
|
33
|
-
[4.weeks + 2.days,
|
34
|
-
[24.weeks,
|
35
|
-
].each do |number, result|
|
26
|
+
[0.5.minutes, "30 seconds", "30s"],
|
27
|
+
[4.5.minutes, "4 minutes and 30 seconds", "4m30s"],
|
28
|
+
[5.minutes.to_i, "5 minutes", "5m"],
|
29
|
+
[10.minutes.to_i, "10 minutes", "10m"],
|
30
|
+
[1.hour.to_i, "1 hour", "1h"],
|
31
|
+
[1.hour + 30.seconds, "1 hour and 30 seconds", "1h30s"],
|
32
|
+
[4.weeks.to_i, "4 weeks", "4w"],
|
33
|
+
[4.weeks + 2.days, "4 weeks and 2 days", "4w2d"],
|
34
|
+
[24.weeks.to_i, "5 months, 2 weeks, and 1 day", "5mo2w1d"]
|
35
|
+
].each do |number, result, compact_result|
|
36
36
|
it "#{number} == #{result}" do
|
37
37
|
expect(distance_of_time(number)).to eq(result)
|
38
|
+
expect(distance_of_time(number, compact: true)).to eq(compact_result)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotiw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -170,8 +170,10 @@ files:
|
|
170
170
|
- lib/dotiw/locale/pl.yml
|
171
171
|
- lib/dotiw/locale/pt-BR.yml
|
172
172
|
- lib/dotiw/locale/ru.yml
|
173
|
+
- lib/dotiw/locale/sv.yml
|
173
174
|
- lib/dotiw/locale/vi.yml
|
174
175
|
- lib/dotiw/locale/zh-CN.yml
|
176
|
+
- lib/dotiw/locale/zh-TW.yml
|
175
177
|
- lib/dotiw/methods.rb
|
176
178
|
- lib/dotiw/time_hash.rb
|
177
179
|
- lib/dotiw/version.rb
|
@@ -191,8 +193,10 @@ files:
|
|
191
193
|
- spec/lib/i18n/pl.yml
|
192
194
|
- spec/lib/i18n/pt-BR.yml
|
193
195
|
- spec/lib/i18n/ru.yml
|
196
|
+
- spec/lib/i18n/sv.yml
|
194
197
|
- spec/lib/i18n/vi.yml
|
195
198
|
- spec/lib/i18n/zh-CN.yml
|
199
|
+
- spec/lib/i18n/zh-TW.yml
|
196
200
|
- spec/spec_helper.rb
|
197
201
|
homepage: https://github.com/radar/distance_of_time_in_words
|
198
202
|
licenses:
|
@@ -234,6 +238,8 @@ test_files:
|
|
234
238
|
- spec/lib/i18n/pl.yml
|
235
239
|
- spec/lib/i18n/pt-BR.yml
|
236
240
|
- spec/lib/i18n/ru.yml
|
241
|
+
- spec/lib/i18n/sv.yml
|
237
242
|
- spec/lib/i18n/vi.yml
|
238
243
|
- spec/lib/i18n/zh-CN.yml
|
244
|
+
- spec/lib/i18n/zh-TW.yml
|
239
245
|
- spec/spec_helper.rb
|