radiant-event_calendar-extension 1.3.9 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/VERSION +1 -1
  2. data/app/controllers/events_controller.rb +19 -19
  3. data/app/models/event.rb +41 -30
  4. data/app/models/event_calendar_page.rb +5 -9
  5. data/app/views/admin/calendars/_form.html.haml +12 -12
  6. data/app/views/admin/calendars/edit.html.haml +2 -3
  7. data/app/views/admin/calendars/index.html.haml +9 -9
  8. data/app/views/admin/calendars/new.html.haml +3 -4
  9. data/app/views/admin/calendars/show.html.haml +6 -6
  10. data/app/views/admin/event_venues/_event_venue.html.haml +2 -2
  11. data/app/views/admin/event_venues/_form.html.haml +13 -13
  12. data/app/views/admin/event_venues/edit.html.haml +6 -6
  13. data/app/views/admin/event_venues/index.html.haml +9 -8
  14. data/app/views/admin/event_venues/new.html.haml +6 -6
  15. data/app/views/admin/event_venues/remove.html.haml +12 -11
  16. data/app/views/admin/events/_event.html.haml +1 -1
  17. data/app/views/admin/events/_form.html.haml +21 -20
  18. data/app/views/admin/events/edit.html.haml +2 -2
  19. data/app/views/admin/events/index.html.haml +12 -12
  20. data/app/views/admin/events/remove.html.haml +8 -9
  21. data/app/views/events/_event.html.haml +11 -8
  22. data/app/views/events/_faceting.html.haml +6 -13
  23. data/app/views/events/_minicalendar.html.haml +3 -3
  24. data/app/views/events/_views.html.haml +5 -4
  25. data/app/views/events/index.html.haml +9 -9
  26. data/config/locales/de.yml +213 -0
  27. data/config/locales/en.yml +212 -6
  28. data/event_calendar_extension.rb +12 -6
  29. data/lib/calendar_period.rb +23 -18
  30. data/lib/event_calendar_tags.rb +13 -7
  31. data/radiant-event_calendar-extension.gemspec +3 -2
  32. metadata +6 -5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.9
1
+ 1.4.0
@@ -95,8 +95,8 @@ class EventsController < SiteController
95
95
  def list_description
96
96
  return @description if @description
97
97
  parts = []
98
- parts << (period ? period.description : "coming up")
99
- parts << "in #{calendars.to_sentence}" if calendars
98
+ parts << (period ? period.description : t('event_page.coming_up'))
99
+ parts << I18n.t('event_page.in_calendars', :calendars => calendars.to_sentence) if calendars
100
100
  @description = parts.join(' ')
101
101
  end
102
102
 
@@ -154,31 +154,31 @@ class EventsController < SiteController
154
154
  [:year, :month, :mday, :category, :slug, :calendar_id]
155
155
  end
156
156
 
157
- def day_names
158
- return @day_names if @day_names
159
- @day_names ||= Date::DAYNAMES.dup
160
- @day_names.push(@day_names.shift) # Class::Date and ActiveSupport::CoreExtensions::Time::Calculations have different ideas of when is the start of the week. We've gone for the rails standard.
161
- @day_names
162
- end
163
-
164
157
  def month_name(month)
165
158
  month_names[month]
166
159
  end
167
-
168
- def month_names
169
- @month_names ||= Date::MONTHNAMES.dup
170
- end
171
-
160
+
172
161
  def short_month_name(month)
173
162
  short_month_names[month]
174
163
  end
175
-
164
+
165
+ def day_names
166
+ return @day_names if @day_names
167
+ @day_names ||= (I18n.t 'date.day_names').dup
168
+ @day_names.push(@day_names.shift) # Class::Date and ActiveSupport::CoreExtensions::Time::Calculations have different ideas of when is the start of the week. We've gone for the rails standard.
169
+ @day_names
170
+ end
171
+
172
+ protected
173
+
176
174
  def short_month_names
177
- @short_month_names ||= Date::ABBR_MONTHNAMES.dup
175
+ @short_month_names ||= (I18n.t 'date.abbr_month_names').dup
178
176
  end
179
-
180
- private
181
-
177
+
178
+ def month_names
179
+ @month_names ||= (I18n.t 'date.month_names').dup
180
+ end
181
+
182
182
  # months can be passed around either as names or numbers
183
183
  # any date part can be 'now' or 'next' for ease of linking
184
184
  # and everything is converted to_i to save clutter later
data/app/models/event.rb CHANGED
@@ -65,6 +65,10 @@ class Event < ActiveRecord::Base
65
65
 
66
66
  named_scope :by_end_date, { :order => "end_date ASC" }
67
67
 
68
+ named_scope :limited_to, lambda { |limit|
69
+ { :limit => limit }
70
+ }
71
+
68
72
  named_scope :at_venue, lambda { |venue| # EventVenue object
69
73
  { :conditions => ["event_venue_id = ?", venue.id] }
70
74
  }
@@ -115,7 +119,7 @@ class Event < ActiveRecord::Base
115
119
  stack = {}
116
120
  find(:all).each_with_object({}) do |event, stack|
117
121
  y = event.start_date.year
118
- m = Date::MONTHNAMES[event.start_date.month]
122
+ m = (I18n.t 'date.month_names')[event.start_date.month]
119
123
  stack[y] ||= {}
120
124
  stack[y][m] ||= []
121
125
  stack[y][m].push event
@@ -168,15 +172,15 @@ class Event < ActiveRecord::Base
168
172
  end
169
173
 
170
174
  def date
171
- start_date.to_datetime.strftime(date_format)
175
+ I18n.l start_date, :format => date_format
172
176
  end
173
177
 
174
178
  def month
175
- Date::MONTHNAMES[start_date.month]
179
+ I18n.l start_date, :format => :calendar_month
176
180
  end
177
181
 
178
182
  def short_month
179
- Date::ABBR_MONTHNAMES[start_date.month]
183
+ I18n.l start_date, :format => :calendar_short_month
180
184
  end
181
185
 
182
186
  def year
@@ -184,31 +188,31 @@ class Event < ActiveRecord::Base
184
188
  end
185
189
 
186
190
  def day
187
- Date::DAYNAMES[start_date.day]
191
+ I18n.l start_date, :format => :calendar_day_name
188
192
  end
189
193
 
190
194
  def mday
191
- start_date.mday
195
+ I18n.l start_date, :format => :calendar_day_of_month
192
196
  end
193
197
 
194
198
  def mday_padded
195
- "%02d" % mday
199
+ mday
196
200
  end
197
201
 
198
202
  def short_date
199
- start_date.to_datetime.strftime(short_date_format)
203
+ I18n.l start_date, :format => short_date_format
200
204
  end
201
205
 
202
206
  def start_time
203
- start_date.to_datetime.strftime(start_date.min == 0 ? round_time_format : time_format).downcase
207
+ (I18n.l start_date, :format => (start_date.min == 0 ? round_time_format : time_format)).downcase
204
208
  end
205
209
 
206
210
  def end_time
207
- end_date.to_datetime.strftime(end_date.min == 0 ? round_time_format : time_format).downcase if end_date
211
+ (I18n.l end_date, :format => (end_date.min == 0 ? round_time_format : time_format)).downcase if end_date
208
212
  end
209
213
 
210
214
  def last_day
211
- end_date.to_datetime.strftime(date_format)if end_date
215
+ I18n.l end_date, :format => date_format if end_date
212
216
  end
213
217
 
214
218
  def duration
@@ -221,7 +225,7 @@ class Event < ActiveRecord::Base
221
225
 
222
226
  def starts
223
227
  if all_day?
224
- "all day"
228
+ t('event_page.all_day')
225
229
  else
226
230
  start_time
227
231
  end
@@ -229,7 +233,7 @@ class Event < ActiveRecord::Base
229
233
 
230
234
  def finishes
231
235
  if all_day?
232
- "all day"
236
+ t('event_page.all_day')
233
237
  else
234
238
  end_time
235
239
  end
@@ -237,29 +241,36 @@ class Event < ActiveRecord::Base
237
241
 
238
242
  def summarize_start
239
243
  if one_day?
240
- "all day on #{date}"
244
+ I18n.t 'event_page.all_day_on', :date => date
241
245
  elsif all_day?
242
- "from #{date}"
246
+ I18n.t 'event_page.from_date', :date => date
243
247
  else
244
- "#{start_time} on #{date}"
248
+ I18n.t 'event_page.on_date', :time => start_time, :date => date
245
249
  end
246
250
  end
247
-
251
+
248
252
  def summarize_period
249
- period = []
253
+ period = ""
250
254
  if one_day?
251
- period << "all day on #{date}"
255
+ period = (I18n.t 'event_page.summarize_period_one_day', :date => date)
252
256
  elsif all_day?
253
- period << "from #{date} to #{end_date.to_datetime.strftime(date_format)}"
257
+ period = (I18n.t 'event_page.summarize_period_all_day',
258
+ :from_date => date,
259
+ :to_date => (I18n.l end_date, :format => date_format))
254
260
  elsif within_day?
255
- period << "#{start_time}"
256
- period << "to #{end_time}" if end_time
257
- period << "on #{date}"
261
+ if end_time
262
+ period = (I18n.t 'event_page.summarize_period_within_day_with_end_time',
263
+ :start_time => start_time, :end_time => end_time, :date => date)
264
+ else
265
+ period = (I18n.t 'event_page.summarize_period_within_day',
266
+ :start_time => start_time, :date => date)
267
+ end
258
268
  else
259
- period << "#{start_time} on #{date}"
260
- period << "to #{end_time} on #{end_date.to_datetime.strftime(date_format)}"
269
+ period = (I18n.t 'event_page.summarize_period_spanning_days',
270
+ :start_time => start_time, :end_time => end_time, :date => date,
271
+ :end_date => (I18n.l end_date, :format => date_format))
261
272
  end
262
- period.join(' ')
273
+ period
263
274
  end
264
275
 
265
276
  def url
@@ -415,19 +426,19 @@ protected
415
426
  end
416
427
 
417
428
  def date_format
418
- Radiant::Config['event_calendar.date_format'] || "%-1d %B"
429
+ Radiant::Config['event_calendar.date_format'] || (I18n.t 'date.formats.event_calendar_date_format')
419
430
  end
420
431
 
421
432
  def short_date_format
422
- Radiant::Config['event_calendar.short_date_format'] || "%-1d/%m/%Y"
433
+ Radiant::Config['event_calendar.short_date_format'] || (I18n.t 'date.formats.event_calendar_short_date_format')
423
434
  end
424
435
 
425
436
  def time_format
426
- Radiant::Config['event_calendar.time_format'] || "%-1I:%M%p"
437
+ Radiant::Config['event_calendar.time_format'] || (I18n.t 'time.formats.event_calendar_time_format')
427
438
  end
428
439
 
429
440
  def round_time_format
430
- Radiant::Config['event_calendar.round_time_format'] || "%-1I%p"
441
+ Radiant::Config['event_calendar.round_time_format'] || (I18n.t 'time.formats.event_calendar_round_time_format')
431
442
  end
432
443
 
433
444
  end
@@ -5,11 +5,7 @@ class EventCalendarPage < Page
5
5
 
6
6
  attr_accessor :filters, :calendar_parameters, :calendar_filters, :calendar_year, :calendar_month, :calendar_page, :calendar_category, :calendar_slug, :calendar_period
7
7
 
8
- description %{ Create a viewer for calendar data. }
9
-
10
- def self.sphinx_indexes
11
- []
12
- end
8
+ description I18n.t 'event_page.description'
13
9
 
14
10
  def cache?
15
11
  true
@@ -37,8 +33,8 @@ class EventCalendarPage < Page
37
33
  @calendar_year = part
38
34
  elsif part.match(/^\d+$/)
39
35
  @calendar_day = part
40
- elsif Date::MONTHNAMES.include?(part.titlecase)
41
- @calendar_month = Date::MONTHNAMES.index(part.titlecase)
36
+ elsif (I18n.t 'date.month_names').include?(part.titlecase)
37
+ @calendar_month = (I18n.t 'date.month_names').index(part.titlecase)
42
38
  elsif Calendar.categories.include?(part)
43
39
  @calendar_category = part
44
40
  elsif Calendar.slugs.include?(part)
@@ -87,12 +83,12 @@ class EventCalendarPage < Page
87
83
  alias_method_chain :url, :parts
88
84
 
89
85
  def month_names
90
- @month_names ||= Date::MONTHNAMES.dup
86
+ @month_names ||= (I18n.t 'date.month_names').dup
91
87
  end
92
88
 
93
89
  def day_names
94
90
  unless @day_names
95
- @day_names = Date::DAYNAMES.dup
91
+ @day_names = (I18n.t 'date.day_names').dup
96
92
  @day_names.push(@day_names.shift) # Class::Date and ActiveSupport::CoreExtensions::Time::Calculations have different ideas of when is the start of the week. we've gone for the rails standard.
97
93
  end
98
94
  @day_names
@@ -9,54 +9,54 @@
9
9
  - form.edit_name do
10
10
  .title
11
11
  %p.title
12
- = f.label :name
12
+ = f.label :name, t('calendar_admin.form.name')
13
13
  = f.text_field :name, :class => "textbox"
14
14
 
15
15
  - form.edit_ical do
16
16
  - f.fields_for :ical do |ical_f|
17
17
  %p.url
18
- = ical_f.label :url, "Subscription url (optional)"
18
+ = ical_f.label :url, t('calendar_admin.form.subscription_url')
19
19
  = ical_f.text_field :url, :class => "textbox"
20
20
 
21
21
  .drawer
22
22
  .drawer_contents#subscription
23
23
 
24
24
  %div.username
25
- = ical_f.label :username, 'Username', :class => 'minor'
25
+ = ical_f.label :username, t('calendar_admin.form.username'), :class => 'minor'
26
26
  = ical_f.text_field :username, :class => "textbox"
27
27
 
28
28
  %div.password
29
- = ical_f.label :password, 'Password', :class => 'minor'
29
+ = ical_f.label :password, t('calendar_admin.form.password'), :class => 'minor'
30
30
  = ical_f.text_field :password, :class => "textbox"
31
31
 
32
32
  %div.refreshment
33
33
  = ical_f.check_box :refresh_interval
34
- = ical_f.label :refresh_interval, 'Refresh automatically?', :class => 'minor'
34
+ = ical_f.label :refresh_interval, t('calendar_admin.form.auto_refresh'), :class => 'minor'
35
35
 
36
36
  .drawer_handle
37
37
  %a.toggle{:href=>'#subscription', :rel=>"toggle[subscription]", :class=>"more"}
38
- more
38
+ = t('calendar_admin.form.more')
39
39
 
40
40
  - form.edit_filing do
41
41
  .filing
42
42
  %p.calendar_category
43
- = f.label :category
43
+ = f.label :category, t('calendar_admin.form.category')
44
44
  = f.text_field :category, :class => "textbox"
45
45
  %p.calendar_slug
46
- = f.label :slug
46
+ = f.label :slug, t('calendar_admin.form.slug')
47
47
  = f.text_field :slug, :class => "textbox"
48
48
 
49
49
  - form.edit_description do
50
50
  .description
51
51
  %p.description
52
- = f.label :description, "Description"
52
+ = f.label :description, t('calendar_admin.form.description')
53
53
  = f.text_area 'description', :size => '40x6', :class => "textarea"
54
54
 
55
55
  - render_region :form_bottom do |form_bottom|
56
56
  - form_bottom.edit_metadata do
57
57
  .metadata
58
58
  %p.keywords
59
- = f.label :keywords
59
+ = f.label :keywords, t('calendar_admin.form.keywords')
60
60
  = f.text_field :keywords, :class => "textbox"
61
61
 
62
62
  - form_bottom.edit_timestamp do
@@ -66,5 +66,5 @@
66
66
  %p.buttons
67
67
  = save_model_button @calendar
68
68
  = save_model_and_continue_editing_button @calendar
69
- or
70
- = link_to "Cancel", admin_calendars_url
69
+ = t('defaults.or')
70
+ = link_to t('defaults.cancel'), admin_calendars_url
@@ -1,12 +1,11 @@
1
1
  - @page_title = @calendar.name
2
- - @page_title += ' - Calendar - ' + default_page_title
2
+ - @page_title += ' - ' + t('calendar_admin.defaults.title') + ' - ' + default_page_title
3
3
 
4
4
  - include_stylesheet('admin/event_calendar')
5
5
 
6
6
  - render_region :main do |main|
7
7
  - main.edit_header do
8
- %h1
9
- Edit Calendar
8
+ %h1= t('calendar_admin.edit.header')
10
9
 
11
10
  - main.edit_form do
12
11
  - form_for :calendar, @calendar, :url => admin_calendar_path(@calendar), :html => { :method => "put", :multipart => true } do |f|
@@ -1,5 +1,5 @@
1
- - @page_title = 'Calendars'
2
- - @page_title += ' - Calendar - ' + default_page_title
1
+ - @page_title = t('calendar_admin.index.title')
2
+ - @page_title += ' - ' + t('calendar_admin.defaults.title') + ' - ' + default_page_title
3
3
 
4
4
  - include_stylesheet 'admin/event_calendar'
5
5
  = render_region :top
@@ -10,14 +10,14 @@
10
10
  %tr
11
11
  - render_region :thead do |thead|
12
12
  - thead.name_header do
13
- %th Name
13
+ %th.key= t('calendar_admin.index.name')
14
14
 
15
15
  - thead.url_header do
16
- %th URL (category/slug)
16
+ %th.key= t('calendar_admin.index.url')
17
17
 
18
18
  - thead.refresh_header do
19
- %th Last Refresh
20
- %th Refresh automatically?
19
+ %th.key= t('calendar_admin.index.last_refresh')
20
+ %th.key= t('calendar_admin.index.auto_refresh')
21
21
 
22
22
  - thead.action_header do
23
23
  %th
@@ -30,7 +30,7 @@
30
30
  %td.subscription-title
31
31
  = link_to image('calendar', :alt => ''), admin_calendar_url(calendar)
32
32
  = link_to calendar.name, admin_calendar_url(calendar)
33
- = "(#{calendar.events.count || '0'} events)"
33
+ = "(#{calendar.events.count || '0'} " + t('calendar_admin.index.events') + ")"
34
34
 
35
35
  - tbody.url_cell do
36
36
  %td.url
@@ -46,7 +46,7 @@
46
46
  n/a
47
47
  %td.autorefresh
48
48
  - if calendar.ical
49
- = calendar.ical.refresh_automatically? ? "yes" : "no"
49
+ = calendar.ical.refresh_automatically? ? t('calendar_admin.index.yes') : t('calendar_admin.index.no')
50
50
  - else
51
51
  n/a
52
52
  - tbody.action_cell do
@@ -65,4 +65,4 @@
65
65
  #actions
66
66
  = pagination_for @calendars
67
67
  %ul
68
- %li= link_to image('plus') + " " + "new calendar", new_admin_calendar_url
68
+ %li= link_to image('plus') + " " + t('calendar_admin.index.new'), new_admin_calendar_url
@@ -1,12 +1,11 @@
1
- - @page_title = 'New calendar'
2
- - @page_title += ' - Calendar - ' + default_page_title
1
+ - @page_title = t('calendar_admin.new.title')
2
+ - @page_title += ' - ' + t('calendar_admin.defaults.title') + ' - ' + default_page_title
3
3
 
4
4
  - include_stylesheet('admin/event_calendar')
5
5
 
6
6
  - render_region :main do |main|
7
7
  - main.edit_header do
8
- %h1
9
- New Calendar
8
+ %h1= t('calendar_admin.new.header')
10
9
 
11
10
  - main.edit_form do
12
11
  - form_for :calendar, @calendar, :url => admin_calendars_path do |f|
@@ -7,22 +7,22 @@
7
7
 
8
8
  %div#calendar_help
9
9
  %h3
10
- subscribe to this calendar
10
+ t('calendar_admin.show.subscribe')subscribe to this calendar
11
11
  %ul
12
12
  %li
13
13
  %strong
14
- address:
14
+ t('calendar_admin.show.address'):
15
15
  = link_to @calendar.ical.url
16
16
  %li
17
17
  %strong
18
- username:
18
+ t('calendar_admin.show.username'):
19
19
  = link_to @calendar.ical.username
20
20
  %li
21
21
  %strong
22
- password:
22
+ t('calendar_admin.show.password'):
23
23
  = link_to @calendar.ical.password
24
24
  %p
25
- This may be part of a master calendar with several individual calendars. In that case there will be a different address that lets you access all the calendars at once. Consult your site administrator if unsure.
25
+ t('calendar.show.detail_text')
26
26
 
27
27
  %table#events.index{:cellspacing=>"0", :border=>"0", :cellpadding=>"0"}
28
28
  = render :partial => 'events/list_head'
@@ -33,4 +33,4 @@
33
33
  - else
34
34
  %tr
35
35
  %td.note{:colspan => admin.event.index.tbody.length}
36
- No Events
36
+ t('calendar_admin.show.no_events')