Skip to content

Commit

Permalink
Issue 2802 - Added default number values to avoid precision / delimit…
Browse files Browse the repository at this point in the history
…er bug when locale != :en
  • Loading branch information
christianblais committed Sep 6, 2011
1 parent 9f3e732 commit 8754fe4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion actionpack/lib/action_view/helpers/number_helper.rb
Expand Up @@ -17,6 +17,9 @@ module Helpers #:nodoc:
# unchanged if can't be converted into a valid number.
module NumberHelper

DEFAULT_NUMBER_VALUES = { :precision => 3, :separator => ".", :delimiter => "", :significant => false, :strip_insignificant_zeros => false }


DEFAULT_CURRENCY_VALUES = { :format => "%u%n", :negative_format => "-%u%n", :unit => "$", :separator => ".", :delimiter => ",",
:precision => 2, :significant => false, :strip_insignificant_zeros => false }

Expand Down Expand Up @@ -260,7 +263,7 @@ def number_with_precision(number, options = {})

defaults = I18n.translate(:'number.format', :locale => options[:locale], :default => {})
precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale], :default => {})
defaults = defaults.merge(precision_defaults)
defaults = DEFAULT_NUMBER_VALUES.merge(defaults).merge(precision_defaults)

options = options.reverse_merge(defaults) # Allow the user to unset default values: Eg.: :significant => false
precision = options.delete :precision
Expand Down

0 comments on commit 8754fe4

Please sign in to comment.