Decimal comma instead of decimal point (i18n issue)

Hello,

What is the easiest way which enables usage of decimal comma “,” instead
of decimal point (".") . I would like to force all RoR views to display
float numbers with comma instead of decimal point and also to allow
insertion of float numbers with comma in forms.

Thanks in advance,
Karel

I would like to know this too… I’m watching this thread!

Karel M. wrote:

What is the easiest way which enables usage of decimal comma “,” instead
of decimal point (“.”) . I would like to force all RoR views to display
float numbers with comma instead of decimal point and also to allow
insertion of float numbers with comma in forms.

Have you looked at Globalize?
http://globalize-rails.org/wiki/

I haven’t tested it yet, but it seems that it will be a good and mature
I18N solution someday.

If you just want to force all numbers to have decimal commas and you
don’t have to switch between different languages or locales, Globalize
might be overkill.

You can just use the number_to_currency helper method:

number_to_currency(1234567890.50, {:unit => ‘’, :separator => ‘,’,
:delimiter => ‘’, :precision => 2}) → 1234567890,50

or

number_to_currency(1234567890.50, {:unit => ‘’, :separator => ‘,’,
:delimiter => ‘.’, :precision => 2}) → 1.234.567.890,50

If you use this, you’ll probably want to define your own helper method
in app/helpers/application_helper.rb:

def format_number(num)
number_to_currency(num, {:unit => ‘’, :separator => ‘,’, :delimiter =>
‘.’, :precision => 2})
end

Josh
http://shnoo.gr

Gabriel B. wrote:

Karel M. wrote:

What is the easiest way which enables usage of decimal comma “,” instead
of decimal point (“.”) . I would like to force all RoR views to display
float numbers with comma instead of decimal point and also to allow
insertion of float numbers with comma in forms.

Have you looked at Globalize?
http://globalize-rails.org/wiki/

I haven’t tested it yet, but it seems that it will be a good and mature
I18N solution someday.