我需要显示不同货币的用户金额。情商。:
Your balance: $ 100 000.00
€ 70 000.00
3 000 000,00 руб.因此,我需要对不同的地区(en、eu、ru)使用number_to_currency三次。什么才是正确的方法呢?
发布于 2010-06-05 22:10:03
我不认为你真的需要不同的地区,因为你只需要不同货币的余额。您可以简单地将其他参数传递给number_to_currency。如下所示:
number_to_currency(70000.00, :unit => "€", :separator => ".", :delimiter => " ", :format => "%u %n")这将显示:欧元70 000.00
此外,您似乎可以在调用number_to_currency时设置:locale选项。它没有文档记录,但下面是number_to_currency代码的一部分:
defaults = I18n.translate('number.format''number.format', :locale => options[:locale], :raise => true) rescue {}
currency = I18n.translate('number.currency.format''number.currency.format', :locale => options[:locale], :raise => true) rescue {}因此,您应该能够执行以下操作:
number_to_currency(70000.00, :locale => :ru)https://stackoverflow.com/questions/2980077
复制相似问题