aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/models/about_me_validator.rb2
-rw-r--r--app/models/change_email_validator.rb22
-rw-r--r--app/models/comment.rb4
-rw-r--r--app/models/contact_validator.rb18
-rw-r--r--app/models/info_request.rb10
-rw-r--r--app/models/outgoing_message.rb12
-rw-r--r--app/models/profile_photo.rb8
-rw-r--r--app/models/public_body.rb2
-rw-r--r--app/models/user.rb12
10 files changed, 47 insertions, 45 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5420499f6..9382e077f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -12,6 +12,8 @@
class ApplicationController < ActionController::Base
# Standard headers, footers and navigation for whole site
layout "default"
+ # set locale
+ before_filter :set_gettext_locale
# scrub sensitive parameters from the logs
filter_parameter_logging :password
diff --git a/app/models/about_me_validator.rb b/app/models/about_me_validator.rb
index 7b59c1fcb..f7b88f7dd 100644
--- a/app/models/about_me_validator.rb
+++ b/app/models/about_me_validator.rb
@@ -21,7 +21,7 @@ class AboutMeValidator < ActiveRecord::BaseWithoutTable
def validate
if !self.about_me.blank? && self.about_me.size > 500
- errors.add(:about_me, "^Please keep it shorter than 500 characters")
+ errors.add(:about_me, N_("Please keep it shorter than 500 characters"))
end
end
diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb
index f11153e0d..15d2cb624 100644
--- a/app/models/change_email_validator.rb
+++ b/app/models/change_email_validator.rb
@@ -3,9 +3,9 @@
#
# Table name: change_email_validators
#
-# old_email :string
-# new_email :string
-# password :string
+# old_email :string
+# new_email :string
+# password :string
#
# models/changeemail_validator.rb:
@@ -25,27 +25,27 @@ class ChangeEmailValidator < ActiveRecord::BaseWithoutTable
attr_accessor :logged_in_user
- validates_presence_of :old_email, :message => "^Please enter your old email address"
- validates_presence_of :new_email, :message => "^Please enter your new email address"
- validates_presence_of :password, :message => "^Please enter your password"
+ validates_presence_of :old_email, :message => N_("Please enter your old email address")
+ validates_presence_of :new_email, :message => N_("Please enter your new email address")
+ validates_presence_of :password, :message => N_("Please enter your password")
def validate
if !self.old_email.blank? && !MySociety::Validate.is_valid_email(self.old_email)
- errors.add(:old_email, "doesn't look like a valid address")
+ errors.add(:old_email, "Old email doesn't look like a valid address")
end
- if !errors[:old_email]
+ if !errors[:old_email]
if self.old_email.downcase != self.logged_in_user.email.downcase
- errors.add(:old_email, "address isn't the same as the address of the account you are logged in with")
+ errors.add(:old_email, "Old email address isn't the same as the address of the account you are logged in with")
elsif !self.logged_in_user.has_this_password?(self.password)
if !errors[:password]
- errors.add(:password, "is not correct")
+ errors.add(:password, "Password is not correct")
end
end
end
if !self.new_email.blank? && !MySociety::Validate.is_valid_email(self.new_email)
- errors.add(:new_email, "doesn't look like a valid address")
+ errors.add(:new_email, "New email doesn't look like a valid address")
end
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 7aede1a48..3d69b1108 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -56,10 +56,10 @@ class Comment < ActiveRecord::Base
# Check have edited comment
def validate
if self.body.empty? || self.body =~ /^\s+$/
- errors.add(:body, "^Please enter your annotation")
+ errors.add(:body, N_("Please enter your annotation"))
end
if !MySociety::Validate.uses_mixed_capitals(self.body)
- errors.add(:body, '^Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.')
+ errors.add(:body, N_('Please write your annotation using a mixture of capital and lower case letters. This makes it easier for others to read.'))
end
end
diff --git a/app/models/contact_validator.rb b/app/models/contact_validator.rb
index 511fa1140..9d8c54095 100644
--- a/app/models/contact_validator.rb
+++ b/app/models/contact_validator.rb
@@ -3,10 +3,10 @@
#
# Table name: contact_validators
#
-# name :string
-# email :string
-# subject :text
-# message :text
+# name :string
+# email :string
+# subject :text
+# message :text
#
# models/contact_validator.rb:
@@ -25,13 +25,13 @@ class ContactValidator < ActiveRecord::BaseWithoutTable
column :subject, :text
column :message, :text
- validates_presence_of :name, :message => "^Please enter your name"
- validates_presence_of :email, :message => "^Please enter your email address"
- validates_presence_of :subject, :message => "^Please enter a subject"
- validates_presence_of :message, :message => "^Please enter the message you want to send"
+ validates_presence_of :name, :message => N_("Please enter your name")
+ validates_presence_of :email, :message => N_("Please enter your email address")
+ validates_presence_of :subject, :message => N_("Please enter a subject")
+ validates_presence_of :message, :message => N_("Please enter the message you want to send")
def validate
- errors.add(:email, "doesn't look like a valid address") unless MySociety::Validate.is_valid_email(self.email)
+ errors.add(:email, "Email doesn't look like a valid address") unless MySociety::Validate.is_valid_email(self.email)
end
end
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 23d7c78c3..3441a73f7 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -32,8 +32,8 @@ require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/li
class InfoRequest < ActiveRecord::Base
strip_attributes!
- validates_presence_of :title, :message => "^Please enter a summary of your request"
- validates_format_of :title, :with => /[a-zA-Z]/, :message => "^Please write a summary with some text in it", :if => Proc.new { |info_request| !info_request.title.nil? && !info_request.title.empty? }
+ validates_presence_of :title, :message => N_("Please enter a summary of your request")
+ validates_format_of :title, :with => /[a-zA-Z]/, :message => N_("Please write a summary with some text in it"), :if => Proc.new { |info_request| !info_request.title.nil? && !info_request.title.empty? }
belongs_to :user
#validates_presence_of :user_id # breaks during construction of new ones :(
@@ -95,13 +95,13 @@ class InfoRequest < ActiveRecord::Base
# only check on create, so existing models with mixed case are allowed
def validate_on_create
if !self.title.nil? && !MySociety::Validate.uses_mixed_capitals(self.title, 10)
- errors.add(:title, '^Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.')
+ errors.add(:title, N_('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.'))
end
if !self.title.nil? && title.size > 200
- errors.add(:title, '^Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.')
+ errors.add(:title, N_('Please keep the summary short, like in the subject of an email. You can use a phrase, rather than a full sentence.'))
end
if !self.title.nil? && self.title =~ /^(FOI|Freedom of Information)\s*requests?$/i
- errors.add(:title, '^Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.')
+ errors.add(:title, N_('Please describe more what the request is about in the subject. There is no need to say it is an FOI request, we add that on anyway.'))
end
end
diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb
index aa782df5a..220f4f0a7 100644
--- a/app/models/outgoing_message.rb
+++ b/app/models/outgoing_message.rb
@@ -142,24 +142,24 @@ class OutgoingMessage < ActiveRecord::Base
if self.body.empty? || self.body =~ /\A#{get_salutation}\s+#{get_signoff}/ || self.body =~ /#{get_internal_review_insert_here_note}/
if self.message_type == 'followup'
if self.what_doing == 'internal_review'
- errors.add(:body, "^Please give details explaining why you want a review")
+ errors.add(:body, _("Please give details explaining why you want a review"))
else
- errors.add(:body, "^Please enter your follow up message")
+ errors.add(:body, _("Please enter your follow up message"))
end
elsif
- errors.add(:body, "^Please enter your letter requesting information")
+ errors.add(:body, _("Please enter your letter requesting information"))
else
raise "Message id #{self.id} has type '#{self.message_type}' which validate can't handle"
end
end
if self.body =~ /#{get_signoff}\s*\Z/ms
- errors.add(:body, '^Please sign at the bottom with your name, or alter the "' + get_signoff + '" signature')
+ errors.add(:body, _("Please sign at the bottom with your name, or alter the \"%{signoff}\" signature" % { :signoff => get_signoff }))
end
if !MySociety::Validate.uses_mixed_capitals(self.body)
- errors.add(:body, '^Please write your message using a mixture of capital and lower case letters. This makes it easier for others to read.')
+ errors.add(:body, _('Please write your message using a mixture of capital and lower case letters. This makes it easier for others to read.'))
end
if self.what_doing.nil? || !['new_information', 'internal_review', 'normal_sort'].include?(self.what_doing)
- errors.add(:what_doing_dummy, '^Please choose what sort of reply you are making.')
+ errors.add(:what_doing_dummy, _('Please choose what sort of reply you are making.'))
end
end
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb
index 576bffc2c..b15e3e4f4 100644
--- a/app/models/profile_photo.rb
+++ b/app/models/profile_photo.rb
@@ -88,21 +88,21 @@ class ProfilePhoto < ActiveRecord::Base
def validate
if self.data.nil?
- errors.add(:data, "^Please choose a file containing your photo.")
+ errors.add(:data, N_("Please choose a file containing your photo."))
return
end
if self.image.nil?
- errors.add(:data, "^Couldn't understand the image file that you uploaded. PNG, JPEG, GIF and many other common image file formats are supported.")
+ errors.add(:data, N_("Couldn't understand the image file that you uploaded. PNG, JPEG, GIF and many other common image file formats are supported."))
return
end
if self.image.format != 'PNG'
- errors.add(:data, "^Failed to convert image to a PNG")
+ errors.add(:data, N_("Failed to convert image to a PNG"))
end
if !self.draft && (self.image.columns != WIDTH || self.image.rows != HEIGHT)
- errors.add(:data, "^Failed to convert image to the correct size: at #{self.image.columns}x#{self.image.rows}, need #{WIDTH}x#{HEIGHT}")
+ errors.add(:data, N_("Failed to convert image to the correct size: at %{cols}x%{rows}, need %{width}x%{height}" % { :cols => self.image.columns, :rows => self.image.rows, :width => WIDTH, :height => HEIGHT }))
end
if self.draft && self.user_id
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index de3ac3552..098e5e5e4 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -74,7 +74,7 @@ class PublicBody < ActiveRecord::Base
# Request_email can be blank, meaning we don't have details
if self.is_requestable?
unless MySociety::Validate.is_valid_email(self.request_email)
- errors.add(:request_email, "doesn't look like a valid email address")
+ errors.add(:request_email, "Request email doesn't look like a valid email address")
end
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 7f85a2c4f..8c53c0d05 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -31,11 +31,11 @@ require 'digest/sha1'
class User < ActiveRecord::Base
strip_attributes!
- validates_presence_of :email, :message => "^Please enter your email address"
+ validates_presence_of :email, :message => N_("Please enter your email address")
- validates_presence_of :name, :message => "^Please enter your name"
+ validates_presence_of :name, :message => N_("Please enter your name")
- validates_presence_of :hashed_password, :message => "^Please enter a password"
+ validates_presence_of :hashed_password, :message => N_("Please enter a password")
has_many :info_requests, :order => 'created_at desc'
has_many :user_info_request_sent_alerts
@@ -46,7 +46,7 @@ class User < ActiveRecord::Base
has_many :censor_rules, :order => 'created_at desc'
attr_accessor :password_confirmation, :no_xapian_reindex
- validates_confirmation_of :password, :message =>"^Please enter the same password twice"
+ validates_confirmation_of :password, :message => N_("Please enter the same password twice")
validates_inclusion_of :admin_level, :in => [
'none',
@@ -103,10 +103,10 @@ class User < ActiveRecord::Base
def validate
if self.email != "" && !MySociety::Validate.is_valid_email(self.email)
- errors.add(:email, "^Please enter a valid email address")
+ errors.add(:email, N_("Please enter a valid email address"))
end
if MySociety::Validate.is_valid_email(self.name)
- errors.add(:name, "^Please enter your name, not your email address, in the name field.")
+ errors.add(:name, N_("Please enter your name, not your email address, in the name field."))
end
end