015. I18n.t currency format - cwy007/tips-and-skills GitHub Wiki

2.config/locales/zh-CN.yml

zh-CN:
  number:
    currency:
      format:
        unit: '$US'
        precision: 2
        separator: '.'
        delimiter: ','
        format: "%n %u"

We’ve specified the unit, precision, separator, and delimiter for number.curren- cy.format. That much is pretty self-explanatory. The format is a bit more involved: %n is a placeholder for the number;   is a nonbreaking space character, preventing this value from being split across multiple lines; and %u is a placeholder for the unit.

2.views

<%= number_to_currency(cart.total_price) %>

3.结果

1,530.42 $US