r18n-core 2.2.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/.rspec +1 -1
  3. data/ChangeLog.md +6 -1
  4. data/README.md +1 -20
  5. data/Rakefile +5 -3
  6. data/lib/r18n-core.rb +55 -55
  7. data/lib/r18n-core/filter_list.rb +34 -36
  8. data/lib/r18n-core/filters.rb +68 -51
  9. data/lib/r18n-core/helpers.rb +17 -17
  10. data/lib/r18n-core/i18n.rb +46 -39
  11. data/lib/r18n-core/locale.rb +79 -70
  12. data/lib/r18n-core/translated.rb +65 -66
  13. data/lib/r18n-core/translated_string.rb +24 -24
  14. data/lib/r18n-core/translation.rb +31 -30
  15. data/lib/r18n-core/unsupported_locale.rb +22 -24
  16. data/lib/r18n-core/untranslated.rb +35 -33
  17. data/lib/r18n-core/utils.rb +26 -25
  18. data/lib/r18n-core/version.rb +4 -1
  19. data/lib/r18n-core/yaml_loader.rb +26 -25
  20. data/lib/r18n-core/yaml_methods.rb +25 -28
  21. data/locales/af.rb +15 -8
  22. data/locales/az.rb +19 -12
  23. data/locales/bg.rb +16 -9
  24. data/locales/ca.rb +16 -9
  25. data/locales/cs.rb +27 -20
  26. data/locales/da.rb +15 -8
  27. data/locales/de.rb +16 -9
  28. data/locales/en-au.rb +10 -5
  29. data/locales/en-gb.rb +12 -5
  30. data/locales/en-us.rb +12 -5
  31. data/locales/en.rb +29 -22
  32. data/locales/eo.rb +14 -7
  33. data/locales/es-us.rb +12 -5
  34. data/locales/es.rb +14 -7
  35. data/locales/fa.rb +48 -32
  36. data/locales/fi.rb +19 -12
  37. data/locales/fr.rb +22 -15
  38. data/locales/gl.rb +15 -8
  39. data/locales/hr.rb +24 -17
  40. data/locales/hu.rb +28 -21
  41. data/locales/id.rb +14 -7
  42. data/locales/it.rb +21 -14
  43. data/locales/ja.rb +15 -8
  44. data/locales/kk.rb +17 -10
  45. data/locales/ko.rb +15 -9
  46. data/locales/lv.rb +24 -17
  47. data/locales/mn.rb +10 -3
  48. data/locales/nb.rb +15 -8
  49. data/locales/nl.rb +15 -8
  50. data/locales/no.rb +11 -16
  51. data/locales/pl.rb +26 -19
  52. data/locales/pt-br.rb +12 -5
  53. data/locales/pt.rb +17 -10
  54. data/locales/ru.rb +26 -19
  55. data/locales/sk.rb +27 -20
  56. data/locales/sr-latn.rb +27 -22
  57. data/locales/sv-se.rb +15 -8
  58. data/locales/th.rb +27 -20
  59. data/locales/tr.rb +16 -9
  60. data/locales/uk.rb +19 -12
  61. data/locales/vi.rb +14 -7
  62. data/locales/zh-cn.rb +12 -5
  63. data/locales/zh-tw.rb +15 -8
  64. data/locales/zh.rb +14 -7
  65. data/r18n-core.gemspec +5 -3
  66. data/spec/filters_spec.rb +71 -67
  67. data/spec/i18n_spec.rb +73 -51
  68. data/spec/locale_spec.rb +73 -68
  69. data/spec/locales/cs_spec.rb +2 -2
  70. data/spec/locales/en-us_spec.rb +9 -9
  71. data/spec/locales/en_spec.rb +2 -2
  72. data/spec/locales/fa_spec.rb +3 -3
  73. data/spec/locales/fr_spec.rb +2 -2
  74. data/spec/locales/hu_spec.rb +7 -7
  75. data/spec/locales/it_spec.rb +3 -3
  76. data/spec/locales/no_spec.rb +9 -0
  77. data/spec/locales/pl_spec.rb +2 -2
  78. data/spec/locales/ru_spec.rb +2 -2
  79. data/spec/locales/sk_spec.rb +2 -2
  80. data/spec/locales/th_spec.rb +2 -2
  81. data/spec/locales/vi_spec.rb +2 -2
  82. data/spec/r18n_spec.rb +44 -38
  83. data/spec/spec_helper.rb +13 -9
  84. data/spec/translated_spec.rb +48 -31
  85. data/spec/translation_spec.rb +29 -27
  86. data/spec/translations/general/en.yml +0 -2
  87. data/spec/yaml_loader_spec.rb +22 -18
  88. metadata +5 -3
@@ -1,4 +1,4 @@
1
- require File.expand_path('../spec_helper', __FILE__)
1
+ # frozen_string_literal: true
2
2
 
3
3
  describe R18n::I18n do
4
4
  before do
@@ -11,67 +11,82 @@ describe R18n::I18n do
11
11
  R18n.extension_places = @extension_places
12
12
  end
13
13
 
14
- it "parses HTTP_ACCEPT_LANGUAGE" do
14
+ it 'parses HTTP_ACCEPT_LANGUAGE' do
15
15
  expect(R18n::I18n.parse_http(nil)).to eq([])
16
16
  expect(R18n::I18n.parse_http('')).to eq([])
17
- expect(R18n::I18n.parse_http('ru,en;q=0.9')).to eq(['ru', 'en'])
18
- expect(R18n::I18n.parse_http('ru;q=0.8,en;q=0.9')).to eq(['en', 'ru'])
17
+ expect(R18n::I18n.parse_http('ru,en;q=0.9')).to eq(%w[ru en])
18
+ expect(R18n::I18n.parse_http('ru;q=0.8,en;q=0.9')).to eq(%w[en ru])
19
19
  end
20
20
 
21
- it "has default locale" do
21
+ it 'has default locale' do
22
22
  R18n::I18n.default = 'ru'
23
23
  expect(R18n::I18n.default).to eq('ru')
24
24
  end
25
25
 
26
- it "loads locales" do
26
+ it 'loads locales' do
27
27
  i18n = R18n::I18n.new('en', DIR)
28
28
  expect(i18n.locales).to eq([R18n.locale('en')])
29
29
 
30
30
  i18n = R18n::I18n.new(['ru', 'nolocale-DL'], DIR)
31
- expect(i18n.locales).to eq([R18n.locale('ru'),
32
- R18n::UnsupportedLocale.new('nolocale-DL'),
33
- R18n::UnsupportedLocale.new('nolocale'),
34
- R18n.locale('en')])
31
+ expect(i18n.locales).to eq([
32
+ R18n.locale('ru'),
33
+ R18n::UnsupportedLocale.new('nolocale-DL'),
34
+ R18n::UnsupportedLocale.new('nolocale'),
35
+ R18n.locale('en')
36
+ ])
35
37
  end
36
38
 
37
- it "returns translations loaders" do
39
+ it 'returns translations loaders' do
38
40
  i18n = R18n::I18n.new('en', DIR)
39
41
  expect(i18n.translation_places).to eq([R18n::Loader::YAML.new(DIR)])
40
42
  end
41
43
 
42
- it "loads translations by loader" do
44
+ it 'loads translations by loader' do
43
45
  loader = Class.new do
44
- def available; [R18n.locale('en')]; end
45
- def load(locale); { 'custom' => 'Custom' }; end
46
+ def available
47
+ [R18n.locale('en')]
48
+ end
49
+
50
+ def load(_locale)
51
+ { 'custom' => 'Custom' }
52
+ end
46
53
  end
47
54
  expect(R18n::I18n.new('en', loader.new).custom).to eq('Custom')
48
55
  end
49
56
 
50
- it "passes parameters to default loader" do
57
+ it 'passes parameters to default loader' do
51
58
  loader = Class.new do
52
- def initialize(param); @param = param; end
53
- def available; [R18n.locale('en')]; end
54
- def load(locale); { 'custom' => @param }; end
59
+ def initialize(param)
60
+ @param = param
61
+ end
62
+
63
+ def available
64
+ [R18n.locale('en')]
65
+ end
66
+
67
+ def load(_locale)
68
+ { 'custom' => @param }
69
+ end
55
70
  end
56
71
  R18n.default_loader = loader
57
72
  expect(R18n::I18n.new('en', 'default').custom).to eq('default')
58
73
  end
59
74
 
60
- it "loads translations" do
61
- i18n = R18n::I18n.new(['ru', 'en'], DIR)
75
+ it 'loads translations' do
76
+ i18n = R18n::I18n.new(%w[ru en], DIR)
62
77
  expect(i18n.one).to eq('Один')
63
78
  expect(i18n[:one]).to eq('Один')
64
79
  expect(i18n['one']).to eq('Один')
65
80
  expect(i18n.only.english).to eq('Only in English')
66
81
  end
67
82
 
68
- it "loads translations from several dirs" do
69
- i18n = R18n::I18n.new(['nolocale', 'en'], [TWO, DIR])
83
+ it 'loads translations from several dirs' do
84
+ i18n = R18n::I18n.new(%w[nolocale en], [TWO, DIR])
70
85
  expect(i18n.in.two).to eq('Two')
71
86
  expect(i18n.in.another.level).to eq('Hierarchical')
72
87
  end
73
88
 
74
- it "uses extension places" do
89
+ it 'uses extension places' do
75
90
  R18n.extension_places << EXT
76
91
 
77
92
  i18n = R18n::I18n.new('en', DIR)
@@ -82,11 +97,11 @@ describe R18n::I18n do
82
97
  it "doesn't use extension without app translations with same locale" do
83
98
  R18n.extension_places << EXT
84
99
 
85
- i18n = R18n::I18n.new(['notransl', 'en'], DIR)
100
+ i18n = R18n::I18n.new(%w[notransl en], DIR)
86
101
  expect(i18n.ext).to eq('Extension')
87
102
  end
88
103
 
89
- it "ignores case on loading" do
104
+ it 'ignores case on loading' do
90
105
  i18n = R18n::I18n.new('nolocale', [DIR])
91
106
  expect(i18n.one).to eq('ONE')
92
107
 
@@ -94,13 +109,13 @@ describe R18n::I18n do
94
109
  expect(i18n.one).to eq('ONE')
95
110
  end
96
111
 
97
- it "loads default translation" do
112
+ it 'loads default translation' do
98
113
  i18n = R18n::I18n.new('nolocale', DIR)
99
114
  expect(i18n.one).to eq('ONE')
100
115
  expect(i18n.two).to eq('Two')
101
116
  end
102
117
 
103
- it "loads sublocales for first locale" do
118
+ it 'loads sublocales for first locale' do
104
119
  R18n::I18n.default = 'notransl'
105
120
 
106
121
  i18n = R18n::I18n.new('ru', DIR)
@@ -108,14 +123,16 @@ describe R18n::I18n do
108
123
  expect(i18n.two).to eq('Two')
109
124
  end
110
125
 
111
- it "returns available translations" do
126
+ it 'returns available translations' do
112
127
  i18n = R18n::I18n.new('en', DIR)
113
- expect(i18n.available_locales).to match_array([R18n.locale('nolocale'),
114
- R18n.locale('ru'),
115
- R18n.locale('en')])
128
+ expect(i18n.available_locales).to match_array([
129
+ R18n.locale('nolocale'),
130
+ R18n.locale('ru'),
131
+ R18n.locale('en')
132
+ ])
116
133
  end
117
134
 
118
- it "caches translations" do
135
+ it 'caches translations' do
119
136
  counter = CounterLoader.new('en')
120
137
 
121
138
  R18n::I18n.new('en', counter)
@@ -132,32 +149,34 @@ describe R18n::I18n do
132
149
  it "doesn't clear cache when custom filters are specified" do
133
150
  counter = CounterLoader.new('en')
134
151
 
135
- R18n::I18n.new('en', counter,
136
- off_filters: :untranslated, on_filters: :untranslated_html)
152
+ R18n::I18n.new(
153
+ 'en', counter, off_filters: :untranslated, on_filters: :untranslated_html
154
+ )
137
155
  expect(counter.loaded).to eq(1)
138
156
 
139
- R18n::I18n.new('en', counter,
140
- off_filters: :untranslated, on_filters: :untranslated_html)
157
+ R18n::I18n.new(
158
+ 'en', counter, off_filters: :untranslated, on_filters: :untranslated_html
159
+ )
141
160
  expect(counter.loaded).to eq(1)
142
161
  end
143
162
 
144
- it "caches translations by used locales" do
163
+ it 'caches translations by used locales' do
145
164
  counter = CounterLoader.new('en', 'ru')
146
165
 
147
166
  R18n::I18n.new('en', counter)
148
167
  expect(counter.loaded).to eq(1)
149
168
 
150
- R18n::I18n.new(['en', 'fr'], counter)
169
+ R18n::I18n.new(%w[en fr], counter)
151
170
  expect(counter.loaded).to eq(1)
152
171
 
153
- R18n::I18n.new(['en', 'ru'], counter)
172
+ R18n::I18n.new(%w[en ru], counter)
154
173
  expect(counter.loaded).to eq(3)
155
174
 
156
- R18n::I18n.new(['ru', 'en'], counter)
175
+ R18n::I18n.new(%w[ru en], counter)
157
176
  expect(counter.loaded).to eq(5)
158
177
  end
159
178
 
160
- it "caches translations by places" do
179
+ it 'caches translations by places' do
161
180
  counter = CounterLoader.new('en', 'ru')
162
181
 
163
182
  R18n::I18n.new('en', counter)
@@ -179,10 +198,13 @@ describe R18n::I18n do
179
198
  expect(different.loaded).to eq(1)
180
199
  end
181
200
 
182
- it "reloads translations" do
201
+ it 'reloads translations' do
183
202
  loader = Class.new do
184
- def available; [R18n.locale('en')]; end
185
- def load(locale);
203
+ def available
204
+ [R18n.locale('en')]
205
+ end
206
+
207
+ def load(_locale)
186
208
  @answer ||= 0
187
209
  @answer += 1
188
210
  { 'one' => @answer }
@@ -196,23 +218,23 @@ describe R18n::I18n do
196
218
  expect(i18n.one).to eq(2)
197
219
  end
198
220
 
199
- it "returns translations" do
221
+ it 'returns translations' do
200
222
  i18n = R18n::I18n.new('en', DIR)
201
223
  expect(i18n.t).to be_kind_of(R18n::Translation)
202
224
  expect(i18n.t.one).to eq('One')
203
225
  end
204
226
 
205
- it "returns first locale with locale file" do
206
- i18n = R18n::I18n.new(['notransl', 'nolocale', 'ru', 'en'], DIR)
227
+ it 'returns first locale with locale file' do
228
+ i18n = R18n::I18n.new(%w[notransl nolocale ru en], DIR)
207
229
  expect(i18n.locale).to eq(R18n.locale('nolocale'))
208
230
  expect(i18n.locale.base).to eq(R18n.locale('ru'))
209
231
  end
210
232
 
211
- it "localizes objects" do
233
+ it 'localizes objects' do
212
234
  i18n = R18n::I18n.new('ru')
213
235
 
214
- expect(i18n.l(-123456789)).to eq('−123 456 789')
215
- expect(i18n.l(-12345.67)).to eq('−12 345,67')
236
+ expect(i18n.l(-123_456_789)).to eq('−123 456 789')
237
+ expect(i18n.l(-12_345.67)).to eq('−12 345,67')
216
238
 
217
239
  time = Time.at(0).utc
218
240
  expect(i18n.l(time, '%A')).to eq('Четверг')
@@ -223,7 +245,7 @@ describe R18n::I18n do
223
245
  expect(i18n.l(Date.new(0))).to eq('01.01.0000')
224
246
  end
225
247
 
226
- it "returns marshalizable values" do
248
+ it 'returns marshalizable values' do
227
249
  i18n = R18n::I18n.new('en', DIR, off_filters: :untranslated,
228
250
  on_filters: :untranslated_html)
229
251
  demarsh = Marshal.load(Marshal.dump(i18n.t.one))
@@ -1,4 +1,5 @@
1
- require File.expand_path('../spec_helper', __FILE__)
1
+ # frozen_string_literal: true
2
+
2
3
  require 'bigdecimal'
3
4
 
4
5
  describe R18n::Locale do
@@ -7,17 +8,17 @@ describe R18n::Locale do
7
8
  @en = R18n.locale('en')
8
9
  end
9
10
 
10
- it "returns all available locales" do
11
+ it 'returns all available locales' do
11
12
  expect(R18n::Locale.available.class).to eq(Array)
12
13
  expect(R18n::Locale.available).not_to be_empty
13
14
  end
14
15
 
15
- it "checks is locale exists" do
16
+ it 'checks is locale exists' do
16
17
  expect(R18n::Locale.exists?('ru')).to be true
17
18
  expect(R18n::Locale.exists?('nolocale')).to be false
18
19
  end
19
20
 
20
- it "sets locale properties" do
21
+ it 'sets locale properties' do
21
22
  locale_class = Class.new(R18n::Locale) do
22
23
  set one: 1
23
24
  set two: 2
@@ -27,26 +28,26 @@ describe R18n::Locale do
27
28
  expect(locale.two).to eq(2)
28
29
  end
29
30
 
30
- it "loads locale" do
31
+ it 'loads locale' do
31
32
  expect(@ru.class).to eq(R18n::Locales::Ru)
32
33
  expect(@ru.code).to eq('ru')
33
34
  expect(@ru.title).to eq('Русский')
34
35
  end
35
36
 
36
- it "loads locale by Symbol" do
37
+ it 'loads locale by Symbol' do
37
38
  expect(R18n.locale(:ru)).to eq(R18n.locale('ru'))
38
39
  end
39
40
 
40
- it "equals to another locale with same code" do
41
+ it 'equals to another locale with same code' do
41
42
  expect(@en).not_to eq(@ru)
42
43
  expect(@en).to eq(R18n.locale('en'))
43
44
  end
44
45
 
45
- it "prints human readable representation" do
46
+ it 'prints human readable representation' do
46
47
  expect(@ru.inspect).to eq('Locale ru (Русский)')
47
48
  end
48
49
 
49
- it "returns pluralization type by elements count" do
50
+ it 'returns pluralization type by elements count' do
50
51
  expect(@en.pluralize(0)).to eq(0)
51
52
  expect(@en.pluralize(1)).to eq(1)
52
53
  expect(@en.pluralize(5)).to eq('n')
@@ -67,17 +68,17 @@ describe R18n::Locale do
67
68
  expect(unsupported.inspect.downcase).to eq('unsupported locale nolocale-dl')
68
69
  end
69
70
 
70
- it "formats number in local traditions" do
71
- expect(@en.localize(-123456789)).to eq("−123,456,789")
71
+ it 'formats number in local traditions' do
72
+ expect(@en.localize(-123_456_789)).to eq('−123,456,789')
72
73
  end
73
74
 
74
- it "formats float in local traditions" do
75
- expect(@en.localize(-12345.67)).to eq("−12,345.67")
76
- expect(@en.localize(BigDecimal.new("-12345.67"))).to eq("−12,345.67")
75
+ it 'formats float in local traditions' do
76
+ expect(@en.localize(-12_345.67)).to eq('−12,345.67')
77
+ expect(@en.localize(BigDecimal.new('-12345.67'))).to eq('−12,345.67')
77
78
  end
78
79
 
79
- it "translates month, week days and am/pm names in strftime" do
80
- i18n = R18n::I18n.new('ru')
80
+ it 'translates month, week days and am/pm names in strftime' do
81
+ R18n::I18n.new('ru')
81
82
  time = Time.at(0).utc
82
83
 
83
84
  expect(@ru.localize(time, '%a %A')).to eq('Чтв Четверг')
@@ -85,12 +86,12 @@ describe R18n::Locale do
85
86
  expect(@ru.localize(time, '%H:%M%p')).to eq('00:00 утра')
86
87
  end
87
88
 
88
- it "generates locale code by locale class name" do
89
+ it 'generates locale code by locale class name' do
89
90
  expect(R18n.locale('ru').code).to eq('ru')
90
91
  expect(R18n.locale('zh-CN').code).to eq('zh-CN')
91
92
  end
92
93
 
93
- it "localizes date for human" do
94
+ it 'localizes date for human' do
94
95
  i18n = R18n::I18n.new('en')
95
96
 
96
97
  expect(@en.localize(Date.today + 2, :human, i18n)).to eq('after 2 days')
@@ -100,38 +101,40 @@ describe R18n::Locale do
100
101
  expect(@en.localize(Date.today - 3, :human, i18n)).to eq('3 days ago')
101
102
 
102
103
  y2k = Date.parse('2000-05-08')
103
- expect(@en.localize(y2k, :human, i18n, y2k + 8 )).to eq('8th of May')
104
+ expect(@en.localize(y2k, :human, i18n, y2k + 8)).to eq('8th of May')
104
105
  expect(@en.localize(y2k, :human, i18n, y2k - 365)).to eq('8th of May, 2000')
105
106
  end
106
107
 
107
- it "localizes times for human" do
108
+ it 'localizes times for human' do
108
109
  minute = 60
109
110
  hour = 60 * minute
110
111
  day = 24 * hour
111
112
  zero = Time.at(0).utc
112
113
  p = [:human, R18n::I18n.new('en'), zero]
113
114
 
114
- expect(@en.localize( zero + 7 * day, *p)).to eq('8th of January 00:00')
115
- expect(@en.localize( zero + 50 * hour, *p)).to eq('after 2 days 02:00')
116
- expect(@en.localize( zero + 25 * hour, *p)).to eq('tomorrow 01:00')
117
- expect(@en.localize( zero + 70 * minute, *p)).to eq('after 1 hour')
118
- expect(@en.localize( zero + hour, *p)).to eq('after 1 hour')
119
- expect(@en.localize( zero + 38 * minute, *p)).to eq('after 38 minutes')
120
- expect(@en.localize( zero + 5, *p)).to eq('now')
121
- expect(@en.localize( zero - 15, *p)).to eq('now')
122
- expect(@en.localize( zero - minute, *p)).to eq('1 minute ago')
123
- expect(@en.localize( zero - hour + 59, *p)).to eq('59 minutes ago')
124
- expect(@en.localize( zero - 2 * hour, *p)).to eq('2 hours ago')
125
- expect(@en.localize( zero - 13 * hour, *p)).to eq('yesterday 11:00')
126
- expect(@en.localize( zero - 50 * hour, *p)).to eq('3 days ago 22:00')
127
-
128
- expect(@en.localize( zero - 9 * day, *p)).to eq(
129
- '23rd of December, 1969 00:00')
130
- expect(@en.localize( zero - 365 * day, *p)).to eq(
131
- '1st of January, 1969 00:00')
132
- end
133
-
134
- it "localizes date-times for human" do
115
+ expect(@en.localize(zero + 7 * day, *p)).to eq('8th of January 00:00')
116
+ expect(@en.localize(zero + 50 * hour, *p)).to eq('after 2 days 02:00')
117
+ expect(@en.localize(zero + 25 * hour, *p)).to eq('tomorrow 01:00')
118
+ expect(@en.localize(zero + 70 * minute, *p)).to eq('after 1 hour')
119
+ expect(@en.localize(zero + hour, *p)).to eq('after 1 hour')
120
+ expect(@en.localize(zero + 38 * minute, *p)).to eq('after 38 minutes')
121
+ expect(@en.localize(zero + 5, *p)).to eq('now')
122
+ expect(@en.localize(zero - 15, *p)).to eq('now')
123
+ expect(@en.localize(zero - minute, *p)).to eq('1 minute ago')
124
+ expect(@en.localize(zero - hour + 59, *p)).to eq('59 minutes ago')
125
+ expect(@en.localize(zero - 2 * hour, *p)).to eq('2 hours ago')
126
+ expect(@en.localize(zero - 13 * hour, *p)).to eq('yesterday 11:00')
127
+ expect(@en.localize(zero - 50 * hour, *p)).to eq('3 days ago 22:00')
128
+
129
+ expect(@en.localize(zero - 9 * day, *p)).to eq(
130
+ '23rd of December, 1969 00:00'
131
+ )
132
+ expect(@en.localize(zero - 365 * day, *p)).to eq(
133
+ '1st of January, 1969 00:00'
134
+ )
135
+ end
136
+
137
+ it 'localizes date-times for human' do
135
138
  day = 1.0
136
139
  hour = day / 24
137
140
  minute = hour / 60
@@ -139,27 +142,29 @@ describe R18n::Locale do
139
142
  zero = DateTime.new(1970)
140
143
  p = [:human, R18n::I18n.new('en'), zero]
141
144
 
142
- expect(@en.localize( zero + 7 * day, *p)).to eq('8th of January 00:00')
143
- expect(@en.localize( zero + 50 * hour, *p)).to eq('after 2 days 02:00')
144
- expect(@en.localize( zero + 25 * hour, *p)).to eq('tomorrow 01:00')
145
- expect(@en.localize( zero + 70 * minute, *p)).to eq('after 1 hour')
146
- expect(@en.localize( zero + hour, *p)).to eq('after 1 hour')
147
- expect(@en.localize( zero + 38 * minute, *p)).to eq('after 38 minutes')
148
- expect(@en.localize( zero + 5 * second, *p)).to eq('now')
149
- expect(@en.localize( zero - 15 * second, *p)).to eq('now')
150
- expect(@en.localize( zero - minute, *p)).to eq('1 minute ago')
151
- expect(@en.localize( zero - hour + 59 * second, *p)).to eq('59 minutes ago')
152
- expect(@en.localize( zero - 2 * hour, *p)).to eq('2 hours ago')
153
- expect(@en.localize( zero - 13 * hour, *p)).to eq('yesterday 11:00')
154
- expect(@en.localize( zero - 50 * hour, *p)).to eq('3 days ago 22:00')
155
-
156
- expect(@en.localize( zero - 9 * day, *p)).to eq(
157
- '23rd of December, 1969 00:00')
158
- expect(@en.localize( zero - 365 * day, *p)).to eq(
159
- '1st of January, 1969 00:00')
160
- end
161
-
162
- it "uses standard formatter by default" do
145
+ expect(@en.localize(zero + 7 * day, *p)).to eq('8th of January 00:00')
146
+ expect(@en.localize(zero + 50 * hour, *p)).to eq('after 2 days 02:00')
147
+ expect(@en.localize(zero + 25 * hour, *p)).to eq('tomorrow 01:00')
148
+ expect(@en.localize(zero + 70 * minute, *p)).to eq('after 1 hour')
149
+ expect(@en.localize(zero + hour, *p)).to eq('after 1 hour')
150
+ expect(@en.localize(zero + 38 * minute, *p)).to eq('after 38 minutes')
151
+ expect(@en.localize(zero + 5 * second, *p)).to eq('now')
152
+ expect(@en.localize(zero - 15 * second, *p)).to eq('now')
153
+ expect(@en.localize(zero - minute, *p)).to eq('1 minute ago')
154
+ expect(@en.localize(zero - hour + 59 * second, *p)).to eq('59 minutes ago')
155
+ expect(@en.localize(zero - 2 * hour, *p)).to eq('2 hours ago')
156
+ expect(@en.localize(zero - 13 * hour, *p)).to eq('yesterday 11:00')
157
+ expect(@en.localize(zero - 50 * hour, *p)).to eq('3 days ago 22:00')
158
+
159
+ expect(@en.localize(zero - 9 * day, *p)).to eq(
160
+ '23rd of December, 1969 00:00'
161
+ )
162
+ expect(@en.localize(zero - 365 * day, *p)).to eq(
163
+ '1st of January, 1969 00:00'
164
+ )
165
+ end
166
+
167
+ it 'uses standard formatter by default' do
163
168
  expect(@ru.localize(Time.at(0).utc)).to eq('01.01.1970 00:00')
164
169
  end
165
170
 
@@ -170,18 +175,18 @@ describe R18n::Locale do
170
175
  expect(@ru.localize(Time.at(0), :human)).to eq(Time.at(0).to_s)
171
176
  end
172
177
 
173
- it "raises error on unknown formatter" do
174
- expect {
178
+ it 'raises error on unknown formatter' do
179
+ expect do
175
180
  @ru.localize(Time.at(0).utc, R18n::I18n.new('ru'), :unknown)
176
- }.to raise_error(ArgumentError, /formatter/)
181
+ end.to raise_error(ArgumentError, /formatter/)
177
182
  end
178
183
 
179
- it "deletes slashed from locale for security reasons" do
184
+ it 'deletes slashed from locale for security reasons' do
180
185
  locale = R18n.locale('../spec/translations/general/en')
181
186
  expect(locale).to be_kind_of(R18n::UnsupportedLocale)
182
187
  end
183
188
 
184
- it "ignores code case in locales" do
189
+ it 'ignores code case in locales' do
185
190
  upcase = R18n.locale('RU')
186
191
  downcase = R18n.locale('ru')
187
192
  expect(upcase).to eq(downcase)
@@ -195,7 +200,7 @@ describe R18n::Locale do
195
200
  expect(downcase.code).to eq('nolocale')
196
201
  end
197
202
 
198
- it "loads locale with underscore" do
203
+ it 'loads locale with underscore' do
199
204
  expect(R18n.locale('nolocale-DL').code).to eq('nolocale-dl')
200
205
  end
201
206
  end