number_to_currency 语言环境转换 [英] number_to_currency locale converting

查看:28
本文介绍了number_to_currency 语言环境转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 number_to_currency(33.50, :locale => :fr) 显示 $33.50?它应该根据区域设置以不同的货币显示.我希望结果是 33,50 €.

Why does number_to_currency(33.50, :locale => :fr) displaying $33.50? It should display it in different currency based on the locale. I would expect a result of 33,50 €.

非常感谢!

推荐答案

为此,您需要在 config/locales/fr.yml 中有一个区域设置文件.你可以从这里得到它:https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/fr.yml.

For this to work you need to have a locale file at config/locales/fr.yml. You can get it from here: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/fr.yml.

:locale 选项只向 Rails 声明你想要的语言环境.Rails 没有针对项目中每种语言的所有翻译,因此您必须自己包含这些翻译文件.

The :locale option only declares to Rails what locale you want it to be. Rails does not have all the translations for every language in the project, and so you must include these translation files yourself.

这篇关于number_to_currency 语言环境转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆