-
Notifications
You must be signed in to change notification settings - Fork 634
update README with customising currency symbol example #1102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
update README with customising currency symbol example #1102
Conversation
Hi @tagliala |
Hi @ptadros , sorry but I'm not a maintainer. I did a review because I was submitting a PR myself and I was interested in a "shortcut" to customize currency symbol |
@@ -455,6 +455,12 @@ m = Money.from_cents('123', :gbp) # => #<Money fractional:123 currency:GBP> | |||
m.format(symbol: m.currency.to_s + ' ') # => "GBP 1.23" | |||
``` | |||
|
|||
If you would like to customise currency symbols (e.g to avoid ambiguous between currencies), you can set custom symbol for specific currency as following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor English fixes and shortening suggestion:
If you would like to customise currency symbols (e.g to avoid ambiguous between currencies), you can set custom symbol for specific currency as following | |
If you would like to customize currency symbols to avoid ambiguity between currencies, you can: |
If you would like to customise currency symbols (e.g to avoid ambiguous between currencies), you can set custom symbol for specific currency as following | ||
|
||
```ruby | ||
Money::Currency.table[:hkd][:symbol] = 'HK$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove the indentation here.
Money::Currency.table[:hkd][:symbol] = 'HK$' | |
Money::Currency.table[:hkd][:symbol] = 'HK$' |
Context
Sometimes, there are currencies which have multiple symbols (e.g Hong Kong Dollar can be represented with
$
orHK$
. When an application supports multiple currencies, this produces ambiguous interpretation which currency is displayed (.e.g USD or HKD). This PR adds an example to the README how to do it (e.g can be placed in the gem initialiser in rails app).Changes
Tests