Hacker News new | ask | show | jobs
by bojanz 622 days ago
I like the support for custom currencies, as that is an edge case that often pops up.

On the other hand, be careful about tying the symbol to the currency, as symbols are locale specific. For example, the symbol for USD is $ in eu-US but US$ in en-CA and en-AU (Canada and Australia), and then $US in French locales.

https://cldr.unicode.org/ is the magical dataset behind most good implementations that deal with currency display. Updated twice a year, available in JSON, providing currency symbols and formatting rules for all locales, as well as country => currency mappings and other useful information.

Disclaimer: I maintain a Go solution in this problem space: https://github.com/bojanz/currency

3 comments

I know this is a mere quibble as a rider on a helpful post, but a disclosure is not a disclaimer.

Disclaimers separate you from the comment, examples:

> Disclaimer: I am not a lawyer and this is not legal advice

> [says things about $company] Disclaimer: I don't work for $company, I heard this from someone who does but I can't link to a primary source

Disclosures are additional information which you think it's proper to add, to be open about your interest or stake in the topic:

> Disclosure: I wrote a similar library

> [replies to thing about $company] Disclosure: I used to work for $company

Disclaimer is more often used for humblebrag, not to disclose any information.
Right, indeed!
I'm curious, is there a standard practice of library developers in a certain space collaborating across languages, sharing issues and corner cases and solutions? Is this a common practice with a name? Or is it up to you to look through issues and release notes on projects in the same space to glean useful information?
Not sure there’s a particular name beyond ‘working group’ or ‘technical committee’.

CLDR a really interesting one though, their list of users is quite something too.

I'll introduce l10n support in a future release. My starting point was to make currency names and symbols unaware of the locale as I embedded cryptocurrency data in the mix.

Anyway, the library uses the CLDR dataset through ICU: https://github.com/eriksencosta/money/blob/trunk/docs/append...