aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Landauer <matthew@openaustralia.org>2013-01-17 05:26:54 +1100
committerMatthew Landauer <matthew@openaustralia.org>2013-01-17 05:26:54 +1100
commit5f6a7a29bc1ea3784728a9c57edfa4be73d4196f (patch)
tree5a1fffb45716a2383e589d2d55bc12fa2b0ca8d7
parenta44431056ae75f1b2d83cb27971456d307180042 (diff)
Set locale with I18n rather than through globalize
-rw-r--r--app/controllers/admin_public_body_controller.rb10
-rw-r--r--app/controllers/general_controller.rb2
-rw-r--r--app/controllers/public_body_controller.rb4
-rw-r--r--app/controllers/request_controller.rb6
-rw-r--r--app/models/public_body.rb8
-rw-r--r--spec/controllers/admin_public_body_controller_spec.rb10
-rw-r--r--spec/controllers/public_body_controller_spec.rb4
-rw-r--r--spec/models/public_body_spec.rb6
-rw-r--r--vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb2
9 files changed, 26 insertions, 26 deletions
diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb
index ac12e97b2..c41d05c8d 100644
--- a/app/controllers/admin_public_body_controller.rb
+++ b/app/controllers/admin_public_body_controller.rb
@@ -14,7 +14,7 @@ class AdminPublicBodyController < AdminController
def _lookup_query_internal
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@query = params[:query]
if @query == ""
@query = nil
@@ -75,7 +75,7 @@ class AdminPublicBodyController < AdminController
def show
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@public_body = PublicBody.find(params[:id])
render
end
@@ -87,7 +87,7 @@ class AdminPublicBodyController < AdminController
end
def create
- PublicBody.with_locale(I18n.default_locale) do
+ I18n.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
@@ -106,7 +106,7 @@ class AdminPublicBodyController < AdminController
end
def update
- PublicBody.with_locale(I18n.default_locale) do
+ I18n.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
@@ -120,7 +120,7 @@ class AdminPublicBodyController < AdminController
def destroy
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
public_body = PublicBody.find(params[:id])
if public_body.info_requests.size > 0
diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb
index 3ba636e29..e9d51a59d 100644
--- a/app/controllers/general_controller.rb
+++ b/app/controllers/general_controller.rb
@@ -26,7 +26,7 @@ class GeneralController < ApplicationController
@locale = self.locale_from_params()
locale_condition = 'public_body_translations.locale = ?'
conditions = [locale_condition, @locale]
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
if body_short_names.empty?
# This is too slow
@popular_bodies = PublicBody.visible.find(:all,
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 5391f62b2..5265706bf 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -71,7 +71,7 @@ class PublicBodyController < ApplicationController
@public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil?
- PublicBody.with_locale(self.locale_from_params()) do
+ I18n.with_locale(self.locale_from_params()) do
if params[:submitted_view_email]
if verify_recaptcha
flash.discard(:error)
@@ -129,7 +129,7 @@ class PublicBodyController < ApplicationController
@description = _("in the category ‘{{category_name}}’", :category_name=>category_name)
end
end
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@public_bodies = PublicBody.paginate(
:order => "public_body_translations.name", :page => params[:page], :per_page => 100,
:conditions => conditions,
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 970dfca45..b9a57c340 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -52,7 +52,7 @@ class RequestController < ApplicationController
medium_cache
end
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
# Look up by old style numeric identifiers
if params[:url_title].match(/^[0-9]+$/)
@@ -817,7 +817,7 @@ class RequestController < ApplicationController
# FOI officers can upload a response
def upload_response
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
@reason_params = {
@@ -874,7 +874,7 @@ class RequestController < ApplicationController
def download_entire_request
@locale = self.locale_from_params()
- PublicBody.with_locale(@locale) do
+ I18n.with_locale(@locale) do
@info_request = InfoRequest.find_by_url_title!(params[:url_title])
# Test for whole request being hidden or requester-only
if !@info_request.all_can_view?
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 8bc9b9c8d..cf1327c11 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -333,7 +333,7 @@ class PublicBody < ActiveRecord::Base
# The "internal admin" is a special body for internal use.
def PublicBody.internal_admin_body
- PublicBody.with_locale(I18n.default_locale) do
+ I18n.with_locale(I18n.default_locale) do
pb = PublicBody.find_by_url_name("internal_admin_authority")
if pb.nil?
pb = PublicBody.new(
@@ -371,7 +371,7 @@ class PublicBody < ActiveRecord::Base
# of updating them
bodies_by_name = {}
set_of_existing = Set.new()
- PublicBody.with_locale(I18n.default_locale) do
+ I18n.with_locale(I18n.default_locale) do
bodies = (tag.nil? || tag.empty?) ? PublicBody.find(:all) : PublicBody.find_by_tag(tag)
for existing_body in bodies
# Hide InternalAdminBody from import notes
@@ -414,7 +414,7 @@ class PublicBody < ActiveRecord::Base
if public_body = bodies_by_name[name] # Existing public body
available_locales.each do |locale|
- PublicBody.with_locale(locale) do
+ I18n.with_locale(locale) do
changed = ActiveSupport::OrderedHash.new
field_list.each do |field_name|
localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}"
@@ -449,7 +449,7 @@ class PublicBody < ActiveRecord::Base
else # New public body
public_body = PublicBody.new(:name=>"", :short_name=>"", :request_email=>"")
available_locales.each do |locale|
- PublicBody.with_locale(locale) do
+ I18n.with_locale(locale) do
changed = ActiveSupport::OrderedHash.new
field_list.each do |field_name|
localized_field_name = (locale.to_s == I18n.default_locale.to_s) ? field_name : "#{field_name}.#{locale}"
diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb
index 504ddc5cc..255eacbd0 100644
--- a/spec/controllers/admin_public_body_controller_spec.rb
+++ b/spec/controllers/admin_public_body_controller_spec.rb
@@ -288,7 +288,7 @@ describe AdminPublicBodyController, "when administering public bodies with i18n"
end
it "saves edits to a public body" do
- PublicBody.with_locale(:es) do
+ I18n.with_locale(:es) do
pb = PublicBody.find(id=3)
pb.name.should == "El Department for Humpadinking"
post :update, {
@@ -308,10 +308,10 @@ describe AdminPublicBodyController, "when administering public bodies with i18n"
end
pb = PublicBody.find(public_bodies(:humpadink_public_body).id)
- PublicBody.with_locale(:es) do
+ I18n.with_locale(:es) do
pb.name.should == "Renamed"
end
- PublicBody.with_locale(:en) do
+ I18n.with_locale(:en) do
pb.name.should == "Department for Humpadinking"
end
end
@@ -357,12 +357,12 @@ describe AdminPublicBodyController, "when creating public bodies with i18n" do
body = PublicBody.find_by_name("New Quango")
body.translations.map {|t| t.locale.to_s}.sort.should == ["en", "es"]
- PublicBody.with_locale(:en) do
+ I18n.with_locale(:en) do
body.name.should == "New Quango"
body.url_name.should == "new_quango"
body.first_letter.should == "N"
end
- PublicBody.with_locale(:es) do
+ I18n.with_locale(:es) do
body.name.should == "Mi Nuevo Quango"
body.url_name.should == "mi_nuevo_quango"
body.first_letter.should == "M"
diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb
index 14d32f303..267a854cd 100644
--- a/spec/controllers/public_body_controller_spec.rb
+++ b/spec/controllers/public_body_controller_spec.rb
@@ -83,7 +83,7 @@ describe PublicBodyController, "when listing bodies" do
end
it "should list all bodies from default locale, even when there are no translations for selected locale" do
- PublicBody.with_locale(:en) do
+ I18n.with_locale(:en) do
@english_only = PublicBody.new(:name => 'English only',
:short_name => 'EO',
:request_email => 'english@flourish.org',
@@ -91,7 +91,7 @@ describe PublicBodyController, "when listing bodies" do
:last_edit_comment => '')
@english_only.save
end
- PublicBody.with_locale(:es) do
+ I18n.with_locale(:es) do
get :list
assigns[:public_bodies].include?(@english_only).should == true
end
diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb
index c2e0a6353..0b1bfccd7 100644
--- a/spec/models/public_body_spec.rb
+++ b/spec/models/public_body_spec.rb
@@ -210,7 +210,7 @@ describe PublicBody, "when searching" do
end
it "should cope with same url_name across multiple locales" do
- PublicBody.with_locale(:es) do
+ I18n.with_locale(:es) do
# use the unique spanish name to retrieve and edit
body = PublicBody.find_by_url_name_with_historic('etgq')
body.short_name = 'tgq' # Same as english version
@@ -231,7 +231,7 @@ end
describe PublicBody, " when dealing public body locales" do
it "shouldn't fail if it internal_admin_body was created in a locale other than the default" do
# first time, do it with the non-default locale
- PublicBody.with_locale(:es) do
+ I18n.with_locale(:es) do
PublicBody.internal_admin_body
end
@@ -378,7 +378,7 @@ describe PublicBody, " when loading CSV files" do
PublicBody.count.should == original_count + 3
- # XXX Not sure why trying to do a PublicBody.with_locale fails here. Seems related to
+ # XXX Not sure why trying to do a I18n.with_locale fails here. Seems related to
# the way categories are loaded every time from the PublicBody class. For now we just
# test some translation was done.
body = PublicBody.find_by_name('North West Fake Authority')
diff --git a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
index 374fcd65b..67d6f3258 100644
--- a/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
+++ b/vendor/plugins/acts_as_xapian/lib/acts_as_xapian.rb
@@ -758,7 +758,7 @@ module ActsAsXapian
else
values = []
for locale in self.translations.map{|x| x.locale}
- self.class.with_locale(locale) do
+ I18n.with_locale(locale) do
values << single_xapian_value(field, type=type)
end
end