Karel Miarka
2006-Feb-23 14:24 UTC
[Rails] 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 -- Posted via http://www.ruby-forum.com/.
Harm de Laat
2006-Feb-23 19:10 UTC
[Rails] Decimal comma instead of decimal point (i18n issue)
I would like to know this too... I''m watching this thread! On 2/23/06, Karel Miarka <kajism@yahoo.com> wrote:> > 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060223/8e6b8e2e/attachment-0001.html
Gabriel Birke
2006-Feb-24 00:05 UTC
[Rails] Re: Decimal comma instead of decimal point (i18n issue)
Karel Miarka 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. -- Posted via http://www.ruby-forum.com/.
Joshua Harvey
2006-Feb-24 03:29 UTC
[Rails] Re: Decimal comma instead of decimal point (i18n issue)
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 Birke wrote:> Karel Miarka 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.-- Posted via http://www.ruby-forum.com/.