money icon indicating copy to clipboard operation
money copied to clipboard

Improve Serbian Dinar formatting

Open s-mage opened this issue 10 months ago • 0 comments

Hey, thanks for the gem!

I noticed that you want to move to the formatting based on locale by default, and it's a good thing. You still want to support formatting based on the currency, so I thought I'd fix that for RSD.

So, basically the currency formatting is number formatting, currency symbol, and if we want to put the symbol before or after the currency.

Number formatting guidelines are easy to find. Two from the first page of google:

  • https://www.381info.com/pravopis-srpskog-jezika/nedoumice-oko-brojeva
  • https://kakosepise.net/srpski-jezik/pravopis/brojevi/

This gives us decimal mark , and separator . (though space is a valid separator as well).

The internet agrees that the symbol should be placed after the number:

Screenshot 2025-03-22 at 14 05 15

As for the symbol, I couldn't be sure and had to find an authority. Found two, Unicode CLDR (that ECMA 402 spec for internationalization API mentions) and my Serbian teacher Borislava who is also a philologist. I also wrote an email to the Institute or Serbian Language, but it's protesting at the moment and won't reply. What's better, Borislava and Unicode agree that your best bet on the symbol is RSD. If the rest of the text is in Serbian and is cyrillic, you will probably be better off using РСД but RSD is still fine since it's also the ISO code, while РСД in latin is wrong.

There is also the amount of digits after the decimal mark. It's correct here and incorrect in the Unicode repo. I wrote to People's bank of Serbia to be sure, they replied (for a change) and yes, there are no coins for Para but they are still used for cashless operations.

All in all, RSD currency-based formatting should be

12.345,42 RSD

This PR changes the currency_iso dataset to make it so.

> Money.locale_backend = :currency
=> :currency
> Money.from_amount(12345.42, "RSD").format
=> "12.345,42 RSD"

Thanks!

s-mage avatar Mar 22 '25 13:03 s-mage