Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ptadros
Copy link

@ptadros ptadros commented May 29, 2024

Context

Sometimes, there are currencies which have multiple symbols (e.g Hong Kong Dollar can be represented with $ or HK$. 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

  • Update ReadMe with more currency formatting instruction.

Tests

  • Tests passed

@ptadros ptadros requested a review from tagliala June 2, 2024 19:10
@ptadros
Copy link
Author

ptadros commented Jun 12, 2024

Hi @tagliala
Could you please check this PR again?

@tagliala
Copy link
Contributor

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
Copy link
Contributor

@sunny sunny Jun 26, 2025

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:

Suggested change
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$'
Copy link
Contributor

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.

Suggested change
Money::Currency.table[:hkd][:symbol] = 'HK$'
Money::Currency.table[:hkd][:symbol] = 'HK$'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants