sunrise-cms 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+
4
+ describe I18n do
5
+ before(:each) do
6
+ @date = Date.parse("2012-06-26")
7
+ end
8
+
9
+ context "uk" do
10
+ before(:each) do
11
+ I18n.locale = :uk
12
+ end
13
+
14
+ it "should localize month name" do
15
+ I18n.l(@date, :format => "%d.%m.%Y").should == "26.06.2012"
16
+ I18n.l(@date, :format => "%d %B %Y").should == "26 червня 2012"
17
+ end
18
+ end
19
+
20
+ context "ru" do
21
+ before(:each) do
22
+ I18n.locale = :ru
23
+ end
24
+
25
+ it "should localize month name" do
26
+ I18n.l(@date, :format => "%d.%m.%Y").should == "26.06.2012"
27
+ I18n.l(@date, :format => "%d %B %Y").should == "26 июня 2012"
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunrise-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-22 00:00:00.000000000 Z
13
+ date: 2012-06-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &75020610 !ruby/object:Gem::Requirement
17
+ requirement: &74883580 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 3.2.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *75020610
25
+ version_requirements: *74883580
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: kaminari
28
- requirement: &75020160 !ruby/object:Gem::Requirement
28
+ requirement: &74883190 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.13.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *75020160
36
+ version_requirements: *74883190
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: simple_form
39
- requirement: &75019530 !ruby/object:Gem::Requirement
39
+ requirement: &74882520 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 2.0.2
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *75019530
47
+ version_requirements: *74882520
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: jbuilder
50
- requirement: &75019240 !ruby/object:Gem::Requirement
50
+ requirement: &74882210 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 0.4.0
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *75019240
58
+ version_requirements: *74882210
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: awesome_nested_set
61
- requirement: &75018990 !ruby/object:Gem::Requirement
61
+ requirement: &74881960 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 2.1.3
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *75018990
69
+ version_requirements: *74881960
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: mime-types
72
- requirement: &75018700 !ruby/object:Gem::Requirement
72
+ requirement: &74881680 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '1.18'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *75018700
80
+ version_requirements: *74881680
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: mini_magick
83
- requirement: &75018470 !ruby/object:Gem::Requirement
83
+ requirement: &74881440 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ~>
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '3.4'
89
89
  type: :runtime
90
90
  prerelease: false
91
- version_requirements: *75018470
91
+ version_requirements: *74881440
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: carrierwave
94
- requirement: &75018210 !ruby/object:Gem::Requirement
94
+ requirement: &74881180 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 0.6.2
100
100
  type: :runtime
101
101
  prerelease: false
102
- version_requirements: *75018210
102
+ version_requirements: *74881180
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: cancan
105
- requirement: &75017930 !ruby/object:Gem::Requirement
105
+ requirement: &74880900 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ~>
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: 1.6.7
111
111
  type: :runtime
112
112
  prerelease: false
113
- version_requirements: *75017930
113
+ version_requirements: *74880900
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: cancan_namespace
116
- requirement: &75017600 !ruby/object:Gem::Requirement
116
+ requirement: &74880580 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ~>
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: 0.1.3
122
122
  type: :runtime
123
123
  prerelease: false
124
- version_requirements: *75017600
124
+ version_requirements: *74880580
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: friendly_id
127
- requirement: &75017040 !ruby/object:Gem::Requirement
127
+ requirement: &74880010 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ~>
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: 4.0.5
133
133
  type: :runtime
134
134
  prerelease: false
135
- version_requirements: *75017040
135
+ version_requirements: *74880010
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: galetahub-enum_field
138
- requirement: &75016680 !ruby/object:Gem::Requirement
138
+ requirement: &74879650 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ! '>='
@@ -143,10 +143,10 @@ dependencies:
143
143
  version: '0'
144
144
  type: :runtime
145
145
  prerelease: false
146
- version_requirements: *75016680
146
+ version_requirements: *74879650
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: page_parts
149
- requirement: &75016440 !ruby/object:Gem::Requirement
149
+ requirement: &74879410 !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
152
152
  - - ! '>='
@@ -154,10 +154,10 @@ dependencies:
154
154
  version: '0'
155
155
  type: :runtime
156
156
  prerelease: false
157
- version_requirements: *75016440
157
+ version_requirements: *74879410
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: meta_manager
160
- requirement: &75016170 !ruby/object:Gem::Requirement
160
+ requirement: &74879150 !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
163
163
  - - ! '>='
@@ -165,10 +165,10 @@ dependencies:
165
165
  version: '0'
166
166
  type: :runtime
167
167
  prerelease: false
168
- version_requirements: *75016170
168
+ version_requirements: *74879150
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: progressbar
171
- requirement: &75015900 !ruby/object:Gem::Requirement
171
+ requirement: &74878890 !ruby/object:Gem::Requirement
172
172
  none: false
173
173
  requirements:
174
174
  - - ! '>='
@@ -176,10 +176,10 @@ dependencies:
176
176
  version: '0'
177
177
  type: :runtime
178
178
  prerelease: false
179
- version_requirements: *75015900
179
+ version_requirements: *74878890
180
180
  - !ruby/object:Gem::Dependency
181
181
  name: rails-uploader
182
- requirement: &75015590 !ruby/object:Gem::Requirement
182
+ requirement: &74878570 !ruby/object:Gem::Requirement
183
183
  none: false
184
184
  requirements:
185
185
  - - ! '>='
@@ -187,10 +187,10 @@ dependencies:
187
187
  version: '0'
188
188
  type: :runtime
189
189
  prerelease: false
190
- version_requirements: *75015590
190
+ version_requirements: *74878570
191
191
  - !ruby/object:Gem::Dependency
192
192
  name: rspec-rails
193
- requirement: &75014750 !ruby/object:Gem::Requirement
193
+ requirement: &74877720 !ruby/object:Gem::Requirement
194
194
  none: false
195
195
  requirements:
196
196
  - - ~>
@@ -198,10 +198,10 @@ dependencies:
198
198
  version: 2.10.1
199
199
  type: :development
200
200
  prerelease: false
201
- version_requirements: *75014750
201
+ version_requirements: *74877720
202
202
  - !ruby/object:Gem::Dependency
203
203
  name: generator_spec
204
- requirement: &75014210 !ruby/object:Gem::Requirement
204
+ requirement: &74877190 !ruby/object:Gem::Requirement
205
205
  none: false
206
206
  requirements:
207
207
  - - ~>
@@ -209,10 +209,10 @@ dependencies:
209
209
  version: 0.8.5
210
210
  type: :development
211
211
  prerelease: false
212
- version_requirements: *75014210
212
+ version_requirements: *74877190
213
213
  - !ruby/object:Gem::Dependency
214
214
  name: mysql2
215
- requirement: &75013830 !ruby/object:Gem::Requirement
215
+ requirement: &74876820 !ruby/object:Gem::Requirement
216
216
  none: false
217
217
  requirements:
218
218
  - - ~>
@@ -220,10 +220,10 @@ dependencies:
220
220
  version: 0.3.11
221
221
  type: :development
222
222
  prerelease: false
223
- version_requirements: *75013830
223
+ version_requirements: *74876820
224
224
  - !ruby/object:Gem::Dependency
225
225
  name: database_cleaner
226
- requirement: &75013480 !ruby/object:Gem::Requirement
226
+ requirement: &74876460 !ruby/object:Gem::Requirement
227
227
  none: false
228
228
  requirements:
229
229
  - - ! '>='
@@ -231,10 +231,10 @@ dependencies:
231
231
  version: '0'
232
232
  type: :development
233
233
  prerelease: false
234
- version_requirements: *75013480
234
+ version_requirements: *74876460
235
235
  - !ruby/object:Gem::Dependency
236
236
  name: factory_girl
237
- requirement: &74982350 !ruby/object:Gem::Requirement
237
+ requirement: &74845210 !ruby/object:Gem::Requirement
238
238
  none: false
239
239
  requirements:
240
240
  - - ~>
@@ -242,10 +242,10 @@ dependencies:
242
242
  version: 3.3.0
243
243
  type: :development
244
244
  prerelease: false
245
- version_requirements: *74982350
245
+ version_requirements: *74845210
246
246
  - !ruby/object:Gem::Dependency
247
247
  name: capybara
248
- requirement: &74981930 !ruby/object:Gem::Requirement
248
+ requirement: &74844800 !ruby/object:Gem::Requirement
249
249
  none: false
250
250
  requirements:
251
251
  - - ~>
@@ -253,7 +253,7 @@ dependencies:
253
253
  version: 1.1.2
254
254
  type: :development
255
255
  prerelease: false
256
- version_requirements: *74981930
256
+ version_requirements: *74844800
257
257
  description: Sunrise is a Aimbulance CMS
258
258
  email: galeta.igor@gmail.com
259
259
  executables: []
@@ -334,6 +334,7 @@ files:
334
334
  - config/locales/defaults/ru.yml
335
335
  - config/locales/defaults/pluralize.rb
336
336
  - config/locales/defaults/en.yml
337
+ - config/locales/defaults/datetime.rb
337
338
  - db/migrate/20120611095315_create_settings.rb
338
339
  - db/migrate/20111216144815_create_roles.rb
339
340
  - db/migrate/20111216144915_create_structures.rb
@@ -348,7 +349,6 @@ files:
348
349
  - lib/sunrise/utils/csv_document.rb
349
350
  - lib/sunrise/utils/mysql.rb
350
351
  - lib/sunrise/utils/transliteration.rb
351
- - lib/sunrise/utils/i18n_backend.rb
352
352
  - lib/sunrise/core_ext/string.rb
353
353
  - lib/sunrise/core_ext/array.rb
354
354
  - lib/sunrise/core_ext/i18n.rb
@@ -13028,6 +13028,7 @@ files:
13028
13028
  - spec/models/sunrise/abstract_model_spec.rb
13029
13029
  - spec/models/user_spec.rb
13030
13030
  - spec/models/structure_spec.rb
13031
+ - spec/models/i18n_backend.rb
13031
13032
  - spec/dummy/public/500.html
13032
13033
  - spec/dummy/public/404.html
13033
13034
  - spec/dummy/public/favicon.ico
@@ -13203,6 +13204,7 @@ test_files:
13203
13204
  - spec/models/sunrise/abstract_model_spec.rb
13204
13205
  - spec/models/user_spec.rb
13205
13206
  - spec/models/structure_spec.rb
13207
+ - spec/models/i18n_backend.rb
13206
13208
  - spec/dummy/public/500.html
13207
13209
  - spec/dummy/public/404.html
13208
13210
  - spec/dummy/public/favicon.ico
@@ -1,87 +0,0 @@
1
- # encoding: utf-8
2
- module Sunrise
3
- module Utils
4
-
5
- # "Продвинутый" бекэнд для I18n.
6
- #
7
- # Наследует Simple бекэнд и полностью с ним совместим. Добаляет поддержку
8
- # для отдельностоящих/контекстных названий дней недели и месяцев.
9
- # Также позволяет каждому языку использовать собственные правила плюрализации,
10
- # объявленные как Proc (<tt>lambda</tt>).
11
- #
12
- #
13
- # Advanced I18n backend.
14
- #
15
- # Extends Simple backend. Allows usage of "standalone" keys
16
- # for DateTime localization and usage of user-defined Proc (lambda) pluralization
17
- # methods in translation tables.
18
- class I18nBackend < ::I18n::Backend::Simple
19
- include ::I18n::Backend::Pluralization
20
-
21
- LOCALIZE_ABBR_MONTH_NAMES_MATCH = /(%d|%e)(.*)(%b)/
22
- LOCALIZE_MONTH_NAMES_MATCH = /(%d|%e)(.*)(%B)/
23
- LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH = /^%a/
24
- LOCALIZE_STANDALONE_DAY_NAMES_MATCH = /^%A/
25
-
26
- # Acts the same as +strftime+, but returns a localized version of the
27
- # formatted date string. Takes a key from the date/time formats
28
- # translations as a format argument (<em>e.g.</em>, <tt>:short</tt> in <tt>:'date.formats'</tt>).
29
- #
30
- #
31
- # Метод отличается от <tt>localize</tt> в Simple бекэнде поддержкой
32
- # отдельностоящих/контекстных названий дней недели и месяцев.
33
- #
34
- #
35
- # Note that it differs from <tt>localize</tt> in Simple< backend by checking for
36
- # "standalone" month name/day name keys in translation and using them if available.
37
- #
38
- # <tt>options</tt> parameter added for i18n-0.3 compliance.
39
- def localize(locale, object, format = :default, options = nil)
40
- raise ArgumentError, "Object must be a Date, DateTime or Time object. #{object.inspect} given." unless object.respond_to?(:strftime)
41
-
42
- type = object.respond_to?(:sec) ? 'time' : 'date'
43
- # TODO only translate these if format is a String?
44
- formats = translate(locale, :"#{type}.formats")
45
- format = formats[format.to_sym] if formats && formats[format.to_sym]
46
- # TODO raise exception unless format found?
47
- format = format.to_s.dup
48
-
49
- # TODO only translate these if the format string is actually present
50
- # TODO check which format strings are present, then bulk translate then, then replace them
51
-
52
- if lookup(locale, :"date.standalone_abbr_day_names")
53
- format.gsub!(LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH,
54
- translate(locale, :"date.standalone_abbr_day_names")[object.wday])
55
- end
56
- format.gsub!(/%a/, translate(locale, :"date.abbr_day_names")[object.wday])
57
-
58
- if lookup(locale, :"date.standalone_day_names")
59
- format.gsub!(LOCALIZE_STANDALONE_DAY_NAMES_MATCH,
60
- translate(locale, :"date.standalone_day_names")[object.wday])
61
- end
62
- format.gsub!(/%A/, translate(locale, :"date.day_names")[object.wday])
63
-
64
- if lookup(locale, :"date.standalone_abbr_month_names")
65
- format.gsub!(LOCALIZE_ABBR_MONTH_NAMES_MATCH) do
66
- $1 + $2 + translate(locale, :"date.abbr_month_names")[object.mon]
67
- end
68
- format.gsub!(/%b/, translate(locale, :"date.standalone_abbr_month_names")[object.mon])
69
- else
70
- format.gsub!(/%b/, translate(locale, :"date.abbr_month_names")[object.mon])
71
- end
72
-
73
- if lookup(locale, :"date.standalone_month_names")
74
- format.gsub!(LOCALIZE_MONTH_NAMES_MATCH) do
75
- $1 + $2 + translate(locale, :"date.month_names")[object.mon]
76
- end
77
- format.gsub!(/%B/, translate(locale, :"date.standalone_month_names")[object.mon])
78
- else
79
- format.gsub!(/%B/, translate(locale, :"date.month_names")[object.mon])
80
- end
81
-
82
- format.gsub!(/%p/, translate(locale, :"time.#{object.hour < 12 ? :am : :pm}")) if object.respond_to? :hour
83
- object.strftime(format)
84
- end
85
- end
86
- end
87
- end