From c178a87b4326edd491922136c0a55bf4b889473d Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Mon, 23 Jun 2008 14:37:50 +0200 Subject: remove call to self.locale from helpers --- actionpack/lib/action_view/helpers/active_record_helper.rb | 5 +---- actionpack/lib/action_view/helpers/date_helper.rb | 5 +---- actionpack/lib/action_view/helpers/number_helper.rb | 9 +++------ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb index 716e303a5d..4ff16cd70c 100644 --- a/actionpack/lib/action_view/helpers/active_record_helper.rb +++ b/actionpack/lib/action_view/helpers/active_record_helper.rb @@ -159,9 +159,6 @@ module ActionView end count = objects.inject(0) {|sum, object| sum + object.errors.count } - locale = options[:locale] - locale ||= self.locale if respond_to?(:locale) - unless count.zero? html = {} [:id, :class].each do |key| @@ -174,7 +171,7 @@ module ActionView end options[:object_name] ||= params.first - I18n.with_options :locale => locale, :scope => [:active_record, :error] do |locale| + I18n.with_options :locale => options[:locale], :scope => [:active_record, :error] do |locale| header_message = if options.include?(:header_message) options[:header_message] else diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index dbb5d458bf..6ac4171fd5 100755 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -59,15 +59,12 @@ module ActionView # distance_of_time_in_words(Time.now, Time.now) # => less than a minute # def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {}) - locale = options[:locale] - locale ||= self.locale if respond_to?(:locale) - from_time = from_time.to_time if from_time.respond_to?(:to_time) to_time = to_time.to_time if to_time.respond_to?(:to_time) distance_in_minutes = (((to_time - from_time).abs)/60).round distance_in_seconds = ((to_time - from_time).abs).round - I18n.with_options :locale => locale, :scope => :'datetime.distance_in_words' do |locale| + I18n.with_options :locale => options[:locale], :scope => :'datetime.distance_in_words' do |locale| case distance_in_minutes when 0..1 return distance_in_minutes == 0 ? diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 4373d063bb..3e0d5b1db4 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -69,12 +69,9 @@ module ActionView # number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "", :format => "%n %u") # # => 1234567890,50 £ def number_to_currency(number, options = {}) - options = options.symbolize_keys - - locale = options[:locale] - locale ||= self.locale if respond_to?(:locale) - - defaults = :'currency.format'.t(locale) || {} + options = options.symbolize_keys + defaults = :'currency.format'.t(options[:locale]) || {} + precision = options[:precision] || defaults[:precision] unit = options[:unit] || defaults[:unit] separator = options[:separator] || defaults[:separator] -- cgit v1.2.3