Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11149 (closed enhancement: fixed)

Opened 3 months ago

Last modified 2 months ago

[PATCH] Add format option to number_to_currency to better facilitate localisation

Reported by: lylo Assigned to: core
Priority: normal Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: verified
Cc:

Description

It's a known issue that some currency types put the currency unit after the number (e.g. Czech Koruna). There are already a couple of submitted patches which address this issue:

http://dev.rubyonrails.org/ticket/7892
http://dev.rubyonrails.org/ticket/6351

The reason I'm submitting another is because the solution is more flexible. Simply specify a :format in the options hash to change the resulting string layout, e.g.:

number_to_currency(1234567890.50, :format => "NZ%u %n")

will result in:

NZ$ 1,234,567,890.50

Attachments

format_option_for_number_to_currency (2.6 kB) - added by lylo on 02/18/08 13:54:46.
format_option_for_number_to_currency.diff (2.7 kB) - added by lylo on 02/18/08 15:32:51.

Change History

02/18/08 13:54:46 changed by lylo

  • attachment format_option_for_number_to_currency added.

02/18/08 15:18:50 changed by djanowski

Would you mind creating your patch from the root directory? Thanks!

02/18/08 15:32:51 changed by lylo

  • attachment format_option_for_number_to_currency.diff added.

02/18/08 15:33:26 changed by lylo

Apologies. Try this updated .diff file.

02/18/08 16:10:29 changed by djanowski

Applies cleanly and sounds like the best solution for localizing this helper. +1

02/18/08 16:46:54 changed by airblade

Works perfectly. I like the flexibility and the default. +1.

02/18/08 23:10:47 changed by edmolyneux

Good idea, and it works. Definitely one for my current project as we are localizing more widely soon. +1

02/19/08 01:00:33 changed by djanowski

  • keywords set to Verified.

02/19/08 01:01:27 changed by djanowski

  • keywords changed from Verified to verified.

03/17/08 22:08:56 changed by david

  • status changed from new to closed.
  • resolution set to fixed.

Fixed by [9052]