Browse files

Updated all number helpers with :locale option.

  • Loading branch information...
1 parent 2148e2c commit 5a745575be25588cdfc064099bd0d376946e32c3 @basti basti committed Jun 11, 2010
Showing with 9 additions and 1 deletion.
  1. +9 −1 actionpack/lib/action_view/helpers/number_helper.rb
View
10 actionpack/lib/action_view/helpers/number_helper.rb
@@ -96,7 +96,7 @@ def number_to_phone(number, options = {})
# number_to_currency(1234567890.50) # => $1,234,567,890.50
# number_to_currency(1234567890.506) # => $1,234,567,890.51
# number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506
- # number_to_currency(1234567890.506, :locale => :fr) # => 1,234,567,890.506 €
+ # number_to_currency(1234567890.506, :locale => :fr) # => 1 234 567 890,506 €
#
# number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "")
# # => £1234567890,50
@@ -134,6 +134,7 @@ def number_to_currency(number, options = {})
# format in the +options+ hash.
#
# ==== Options
+ # * <tt>:locale</tt> - Sets the locale to be used for formatting (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number (defaults to 3).
# * <tt>:significant</tt> - If +true+, precision will be the # of significant_digits. If +false+, the # of fractional digits (defaults to +false+)
# * <tt>:separator</tt> - Sets the separator between the fractional and integer digits (defaults to ".").
@@ -145,6 +146,7 @@ def number_to_currency(number, options = {})
# number_to_percentage(100, :precision => 0) # => 100%
# number_to_percentage(1000, :delimiter => '.', :separator => ',') # => 1.000,000%
# number_to_percentage(302.24398923423, :precision => 5) # => 302.24399%
+ # number_to_percentage(1000, :locale => :fr) # => 1 000,000%
def number_to_percentage(number, options = {})
return nil if number.nil?
@@ -171,6 +173,7 @@ def number_to_percentage(number, options = {})
# customize the format in the +options+ hash.
#
# ==== Options
+ # * <tt>:locale</tt> - Sets the locale to be used for formatting (defaults to current locale).
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to ",").
# * <tt>:separator</tt> - Sets the separator between the fractional and integer digits (defaults to ".").
#
@@ -179,6 +182,7 @@ def number_to_percentage(number, options = {})
# number_with_delimiter(12345678.05) # => 12,345,678.05
# number_with_delimiter(12345678, :delimiter => ".") # => 12.345.678
# number_with_delimiter(12345678, :separator => ",") # => 12,345,678
+ # number_with_delimiter(12345678.05, :locale => :fr) # => 12 345 678,05
# number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",")
# # => 98 765 432,98
#
@@ -223,6 +227,7 @@ def number_with_delimiter(number, *args)
# You can customize the format in the +options+ hash.
#
# ==== Options
+ # * <tt>:locale</tt> - Sets the locale to be used for formatting (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number (defaults to 3).
# * <tt>:significant</tt> - If +true+, precision will be the # of significant_digits. If +false+, the # of fractional digits (defaults to +false+)
# * <tt>:separator</tt> - Sets the separator between the fractional and integer digits (defaults to ".").
@@ -237,6 +242,7 @@ def number_with_delimiter(number, *args)
# number_with_precision(111.2345, :significant => true) # => 111
# number_with_precision(111.2345, :precision => 1, :significant => true) # => 100
# number_with_precision(13, :precision => 5, :significant => true) # => 13.000
+ # number_with_precision(111.234, :locale => :fr) # => 111,234
# number_with_precision(13, :precision => 5, :significant => true, strip_insignificant_zeros => true)
# # => 13
# number_with_precision(389.32314, :precision => 4, :significant => true) # => 389.3
@@ -309,6 +315,7 @@ def number_with_precision(number, *args)
# See <tt>number_to_human</tt> if you want to pretty-print a generic number.
#
# ==== Options
+ # * <tt>:locale</tt> - Sets the locale to be used for formatting (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number (defaults to 3).
# * <tt>:significant</tt> - If +true+, precision will be the # of significant_digits. If +false+, the # of fractional digits (defaults to +true+)
# * <tt>:separator</tt> - Sets the separator between the fractional and integer digits (defaults to ".").
@@ -395,6 +402,7 @@ def number_to_human_size(number, *args)
# a wide range of unit quantifiers, even fractional ones (centi, deci, mili, etc).
#
# ==== Options
+ # * <tt>:locale</tt> - Sets the locale to be used for formatting (defaults to current locale).
# * <tt>:precision</tt> - Sets the precision of the number (defaults to 3).
# * <tt>:significant</tt> - If +true+, precision will be the # of significant_digits. If +false+, the # of fractional digits (defaults to +true+)
# * <tt>:separator</tt> - Sets the separator between the fractional and integer digits (defaults to ".").

0 comments on commit 5a74557

Please sign in to comment.