diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/track_mailer.rb | 4 | ||||
-rw-r--r-- | app/models/track_thing.rb | 16 | ||||
-rw-r--r-- | app/models/user.rb | 9 | ||||
-rw-r--r-- | app/models/user_mailer.rb | 2 |
4 files changed, 21 insertions, 10 deletions
diff --git a/app/models/track_mailer.rb b/app/models/track_mailer.rb index 4b7c603a7..f8bef4d61 100644 --- a/app/models/track_mailer.rb +++ b/app/models/track_mailer.rb @@ -85,7 +85,11 @@ class TrackMailer < ApplicationMailer # If we have anything to send, then send everything for the user in one mail if email_about_things.size > 0 # Send the email + + previous_locale = I18n.locale + I18n.locale = user.get_locale TrackMailer.deliver_event_digest(user, email_about_things) + I18n.locale = previous_locale end # Record that we've now sent those alerts to that user diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index 06514dd4e..b74f7dad5 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -192,16 +192,16 @@ class TrackThing < ActiveRecord::Base if self.track_type == 'request_updates' @params = { # Website - :list_description => "'<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>', a request", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_request}}', a request", :link_to_request => "<a href=\"/request/" + CGI.escapeHTML(self.info_request.url_title) + "\">" + CGI.escapeHTML(self.info_request.title) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Track this request by email"), :verb_on_page_already => _("You are already tracking this request by email"), # Email - :title_in_email => "New updates for the request '" + self.info_request.title + "'", - :title_in_rss => "New updates for the request '" + self.info_request.title + "'", + :title_in_email => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title), + :title_in_rss => _("New updates for the request '{{request_title}}'", :request_title => self.info_request.title), # Authentication - :web => "To follow updates to the request '" + CGI.escapeHTML(self.info_request.title) + "'", - :email => "Then you will be emailed whenever the request '" + CGI.escapeHTML(self.info_request.title) + "' is updated.", - :email_subject => "Confirm you want to follow updates to the request '" + self.info_request.title + "'", + :web => _("To follow updates to the request '{{request_title}}'", :request_title => CGI.escapeHTML(self.info_request.title)), + :email => _("Then you will be emailed whenever the request '{{request_title}}' is updated.", :request_title => CGI.escapeHTML(self.info_request.title)), + :email_subject => _("Confirm you want to follow updates to the request '{{request_title}}'", :request_title => self.info_request.title), # RSS sorting :feed_sortby => 'newest' } @@ -243,7 +243,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'public_body_updates' @params = { # Website - :list_description => "'<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>', a public authority", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_authority}}', a public authority", :link_to_authority => "<a href=\"/body/" + CGI.escapeHTML(self.public_body.url_name) + "\">" + CGI.escapeHTML(self.public_body.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Track requests to {{public_body_name}} by email",:public_body_name=>CGI.escapeHTML(self.public_body.name)), :verb_on_page_already => _("You are already tracking requests to {{public_body_name}} by email", :public_body_name=>CGI.escapeHTML(self.public_body.name)), # Email @@ -259,7 +259,7 @@ class TrackThing < ActiveRecord::Base elsif self.track_type == 'user_updates' @params = { # Website - :list_description => "'<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>', a person", # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how + :list_description => _("'{{link_to_user}}', a person", :link_to_user => "<a href=\"/user/" + CGI.escapeHTML(self.tracked_user.url_name) + "\">" + CGI.escapeHTML(self.tracked_user.name) + "</a>"), # XXX yeuch, sometimes I just want to call view helpers from the model, sorry! can't work out how :verb_on_page => _("Track this person by email"), :verb_on_page_already => _("You are already tracking this person by email"), # Email diff --git a/app/models/user.rb b/app/models/user.rb index fddb6b035..c3c3da6f7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -96,6 +96,15 @@ class User < ActiveRecord::Base end end end + + def get_locale + if !self.locale.nil? + locale = self.locale + else + locale = I18n.locale + end + return locale.to_s + end def visible_comments self.comments.find(:all, :conditions => 'visible') diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb index 0972e167d..7adf5b63c 100644 --- a/app/models/user_mailer.rb +++ b/app/models/user_mailer.rb @@ -46,7 +46,5 @@ class UserMailer < ApplicationMailer @body[:old_email] = old_email @body[:new_email] = new_email end - - end |