Skip to content

Instantly share code, notes, and snippets.

@mattsnyder
Created June 11, 2013 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattsnyder/5756434 to your computer and use it in GitHub Desktop.
Save mattsnyder/5756434 to your computer and use it in GitHub Desktop.
Examples of configuring currency for different locales and leveraging Rails ActionView::Helpers to format currency.
include ActionView::Helpers # If you want to test from a Rails console
number_to_currency(12.34, :locale => :en) # => "$12.34"
number_to_currency(12.34, :locale => :ja) # => "12円"
number_to_currency(12.34, :locale => 'en-GB') # => "£12.34"
en-GB:
number:
currency:
format:
delimiter: ! ','
format: ! '%u%n'
precision: 2
separator: .
significant: false
strip_insignificant_zeros: false
unit: £
en:
number:
currency:
format:
delimiter: ! ','
format: ! '%u%n'
precision: 2
separator: .
significant: false
strip_insignificant_zeros: false
unit: $
ja:
number:
currency:
format:
delimiter: ! ','
format: ! '%n%u'
precision: 0
separator: .
significant: false
strip_insignificant_zeros: false
unit: 円
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment