26
4

2 回答 2

48

我知道这有点晚了。但只是想解释上述答案。如下使用它:

number_to_currency(aNumber, :locale => :fr)

这使用文件config/locales/fr.yml. 您可以形成自己的货币格式并在config/locales/fr.yml. 该文件将包含以下内容:

fr:
   number:
     currency:
        format:
          unit: '€'
          delimiter: ','
          separator: '.'
          precision: 2
          format: '%n%u'

unit是货币符号。您也可以使用format:. 更多关于这里

于 2014-02-21T12:07:17.853 回答
22

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.

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.

于 2011-08-30T00:47:33.610 回答