Skip to content

Instantly share code, notes, and snippets.

Created December 28, 2012 00:14
Show Gist options
  • Save anonymous/4393419 to your computer and use it in GitHub Desktop.
Save anonymous/4393419 to your computer and use it in GitHub Desktop.
Accounting friendly negative number formatting. By configuring the `negative_format`, Rail's `number_to_currency` helper method will display negative numbers with parenthesis.
# find this file in config/locales/en.yml
# http://guides.rubyonrails.org/i18n.html
# https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml
number:
currency:
format:
delimiter: ","
format: "%u%n"
negative_format: "(%u%n)" # <-- wrap negative numbers in parenthesis
precision: 2
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