Rails 数字到印度货币格式转换助手
我有像 100000 这样的数字,
当我用户 number_to_currency(100000) 时
,它给出 - 100,000.00
但我怎样才能获得像 1,00,000.00 这样的格式
,因为 $ 100,000 看起来不错,但要以卢比显示它,我需要像这样的分隔符(',') - 1, 00,00,000.00
i have number like 100000
when i user number_to_currency(100000)
it give - 100,000.00
but how can i get format like 1,00,000.00
as $ 100,000 looks good but to show it in Rs i need separators (',') like this - 1,00,00,000.00
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
结账 http://www.funonrails.com/ 2011/03/number-to-indian-currency-helper-for.html
checkout http://www.funonrails.com/2011/03/number-to-indian-currency-helper-for.html
RubyMoney 有一个针对南亚的格式化选项(也可用于印度)。
RubyMoney has a formatting option for south Asia (can be used for India as well).
我建议编写您自己的函数来执行此显示格式,而不是覆盖 number_to_currency。您可以将其命名为 r_number_to_currency 或类似名称,并将其放置在您的应用程序视图助手中。
I would suggest writing your own function to perform this display formatting, rather than overwriting number_to_currency. You could call it r_number_to_currency or something like that and place it in your application view helper.
是的,潘,我为此写了一个助手......
类似这样的东西 -
通过 1000000 给我“10,00,000 卢比”
谢谢。
Yes Pan, I wrote a helper for that...
Something like this -
which on passing 1000000 gives me "Rs 10,00,000"
Thanks.
不同组合的示例输出
Sample Output for different combinations