How can I access or assign custom currency symbols when a method method is called using a money gem?

I have a list of currency codes that I need to display for certain currency values, and found that some of them are available in alternate_symbols from a money stone , However, I can’t understand how to access them when using the format method, and I also need to redefine a few . For example, for CAD I need to display the second character - CAD $ - but for SRD I need to display SRD $, which does not exist in the alternate_symbols array for this currency.

I want to use i18n to indicate these currencies, as some of them are more common.

+4
source share
1 answer

One option is to override the necessary languages.

josh_dollar = {
  :priority        => 1,
  :iso_code        => "USD",
  :iso_numeric     => "840",
  :name            => "United States Dollar",
  :symbol          => "Josh",
  :subunit         => "Cent",
  :subunit_to_unit => 100,
  :separator       => ".",
  :delimiter       => ","
}

Money::Currency.register(josh_dollar)
josh_dollar = Money.new(1000,"USD")
josh_dollar.format
#=> "10.00 Josh"
0
source

All Articles