def common_headers(recipient)
recipients recipient.email
+ locale recipient.preferred_language_from(I18n.available_locales)
from "webmaster@openstreetmap.org"
headers "return-path" => "bounces@openstreetmap.org",
"Auto-Submitted" => "auto-generated"
languages.find { |l| Language.find(:first, :conditions => { :code => l }) }
end
+ def preferred_language_from(array)
+ (languages & array.collect { |i| i.to_s }).first
+ end
+
def nearby(radius = 50, num = 10)
if self.home_lon and self.home_lat
gc = OSM::GreatCircle.new(self.home_lat, self.home_lon)
end
end
end
+
+# Monkey patch to allow sending of messages in specific locales
+module ActionMailer
+ class Base
+ adv_attr_accessor :locale
+ private
+ alias_method :old_render_message, :render_message
+
+ def render_message(method_name, body)
+ old_locale= I18n.locale
+
+ begin
+ I18n.locale = @locale
+ message = old_render_message(method_name, body)
+ ensure
+ I18n.locale = old_locale
+ end
+
+ message
+ end
+ end
+end