From 7106744372abce3c00dd326d4bc5d5ce5cac9d78 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Wed, 16 Jan 2013 19:07:54 +1100 Subject: Set locale in controller test by passing parameter in get Also using I18n.locale to pass the current locale around. --- app/controllers/public_body_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index aa6980b69..9e4f7c023 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -16,7 +16,7 @@ class PublicBodyController < ApplicationController return end @locale = self.locale_from_params() - PublicBody.with_locale(@locale) do + I18n.with_locale(@locale) do @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? if @public_body.url_name.nil? -- cgit v1.2.3 From 5d22285eef67627c58320f031d03d2bffd0ba55e Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Thu, 17 Jan 2013 05:26:54 +1100 Subject: Set locale with I18n rather than through globalize Conflicts: app/controllers/general_controller.rb --- app/controllers/admin_public_body_controller.rb | 10 +++++----- app/controllers/general_controller.rb | 2 +- app/controllers/public_body_controller.rb | 4 ++-- app/controllers/request_controller.rb | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index bb5e98852..93715d364 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 f6a46458e..0783fc579 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -25,7 +25,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 9e4f7c023..1821e6725 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -69,7 +69,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) @@ -127,7 +127,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 ec5c9d055..8807d2354 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]+$/) @@ -811,7 +811,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 = { @@ -868,7 +868,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? -- cgit v1.2.3 From 884b879400f7da1e70436a42469cbfdda6e2d6c2 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 21 Jan 2013 17:24:55 +0000 Subject: Use {{}} instead of %s in url interpolation. --- app/controllers/request_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/controllers') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 49d2f35f3..cbd6543cb 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -322,9 +322,9 @@ class RequestController < ApplicationController message = "" if @outgoing_message.contains_email? if @user.nil? - message += (_("

You do not need to include your email in the request in order to get a reply, as we will ask for it on the next screen (details).

") % [help_privacy_path+"#email_address"]).html_safe; + message += _("

You do not need to include your email in the request in order to get a reply, as we will ask for it on the next screen (details).

", :url => (help_privacy_path+"#email_address").html_safe); else - message += (_("

You do not need to include your email in the request in order to get a reply (details).

") % [help_privacy_path+"#email_address"]).html_safe; + message += _("

You do not need to include your email in the request in order to get a reply (details).

", :url => (help_privacy_path+"#email_address").html_safe); end message += _("

We recommend that you edit your request and remove the email address. If you leave it, the email address will be sent to the authority, but will not be displayed on the site.

") @@ -333,7 +333,7 @@ class RequestController < ApplicationController message += _("

Your request contains a postcode. Unless it directly relates to the subject of your request, please remove any address as it will appear publicly on the Internet.

"); end if not message.empty? - flash.now[:error] = message + flash.now[:error] = message.html_safe end render :action => 'preview' return -- cgit v1.2.3 From dc0f6181e445a64cd14f6c5bb5e052dc320cd956 Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 21 Jan 2013 19:30:39 +0000 Subject: Use {{}} not %s in translation. --- app/controllers/request_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index cbd6543cb..bf9e6c689 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -625,7 +625,7 @@ class RequestController < ApplicationController if !params[:submitted_followup].nil? && !params[:reedit] if @info_request.allow_new_responses_from == 'nobody' - flash[:error] = (_('Your follow up has not been sent because this request has been stopped to prevent spam. Please contact us if you really want to send a follow up message.') % [help_contact_path]).html_safe + flash[:error] = _('Your follow up has not been sent because this request has been stopped to prevent spam. Please contact us if you really want to send a follow up message.', :url => help_contact_path.html_safe) else if @info_request.find_existing_outgoing_message(params[:outgoing_message][:body]) flash[:error] = _('You previously submitted that exact follow up message for this request.') -- cgit v1.2.3