Send notification messages in the target user's language.
This commit is contained in:
parent
f4f0c4b155
commit
5294e4d989
3 changed files with 27 additions and 0 deletions
|
@ -108,6 +108,7 @@ private
|
||||||
|
|
||||||
def common_headers(recipient)
|
def common_headers(recipient)
|
||||||
recipients recipient.email
|
recipients recipient.email
|
||||||
|
locale recipient.preferred_language_from(I18n.available_locales)
|
||||||
from "webmaster@openstreetmap.org"
|
from "webmaster@openstreetmap.org"
|
||||||
headers "return-path" => "bounces@openstreetmap.org",
|
headers "return-path" => "bounces@openstreetmap.org",
|
||||||
"Auto-Submitted" => "auto-generated"
|
"Auto-Submitted" => "auto-generated"
|
||||||
|
|
|
@ -90,6 +90,10 @@ class User < ActiveRecord::Base
|
||||||
languages.find { |l| Language.find(:first, :conditions => { :code => l }) }
|
languages.find { |l| Language.find(:first, :conditions => { :code => l }) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def preferred_language_from(array)
|
||||||
|
(languages & array.collect { |i| i.to_s }).first
|
||||||
|
end
|
||||||
|
|
||||||
def nearby(radius = 50, num = 10)
|
def nearby(radius = 50, num = 10)
|
||||||
if self.home_lon and self.home_lat
|
if self.home_lon and self.home_lat
|
||||||
gc = OSM::GreatCircle.new(self.home_lat, self.home_lon)
|
gc = OSM::GreatCircle.new(self.home_lat, self.home_lon)
|
||||||
|
|
|
@ -14,3 +14,25 @@ module Net
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue