Skip to content
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

Problem with currency symbols #14

Open
uhho opened this issue Apr 16, 2015 · 11 comments
Open

Problem with currency symbols #14

uhho opened this issue Apr 16, 2015 · 11 comments

Comments

@uhho
Copy link

uhho commented Apr 16, 2015

Regarding issue #2 (number formatting in various "exotic" languages), we've got two additional problems:

Multiple currency symbols

In Japanese (and Chinese) prices can be formatted in two ways

  • ¥100 - international symbol, always as a prefix
  • 100円 - native symbol written, always as a suffix

in Chinese it's ¥ and 元 respectively
Used symbol mainly depends on context, but important thing is that both are commonly used.

Although we can choose place of currency symbol in format() function, we can't change it's style (choose symbol we prefer to use).

@BenjaminVanRyseghem had an idea we could introduce additional parameter to language configuration file called translatedSymbol. If this symbol is not defined, we fallback to currencySymbol.

Centesimal division

Several currencies in the world using separate symbol for centisimal division of the currency.
For example, in Poland main currency is called zloty and the international symbol of this currency is "zł".
1 zloty (1 zł) is divided into 100 grosz (100 gr), so prices are usually formatted in following way:
50.99 becomes 50zł 88gr.

Problem applies also to dollars & cents, punds & pennies, euro & cents and several other currencies so I think it would be nice to have such functionality.

One idea is to add additional parameter to currency symbol called "c" ("centisimal"):

numbro(50.99).format('0,0.00$'); // 50.99zł
numbro(50.99).format('0,0$ .00c'); // 50zł 99gr

I know it may looks little wierd, but on the other hand it lets user define formatting in more flexible way (to use space between currency and centisimal symbol or not).

What do you guys think about that?

@BenjaminVanRyseghem
Copy link
Owner

I 👍 both 😉

@BenjaminVanRyseghem
Copy link
Owner

maybe introducing a formatCurrencyWithCents could be a thing too 😉

@BenjaminVanRyseghem
Copy link
Owner

any progress?

@uhho
Copy link
Author

uhho commented Apr 24, 2015

Yes, I've prepared myself mentally for this task 😸

Please give me few more days, I've been extremely busy this week.

@BenjaminVanRyseghem
Copy link
Owner

ok 😄 it was just to know, no worry 😄

@BenjaminVanRyseghem
Copy link
Owner

Sorry to be pushy, but any news here? (it's just that I am super curious to read your implementation 😄 )

@BenjaminVanRyseghem
Copy link
Owner

@lukaszkrawczyk any progress?

@ArmorDarks
Copy link

I guess sames thing is for ru-RU and ru-UA.

In Russia there are two often used $ symbols:

  • Shortened version of rubles: `100 руб.'
  • Official symbol: `100 ₽'

Same in Ukraine:

  • Shortened version: `100 грн.'
  • Official symbol: `100 ₴'

Besides, in some cases users may want to display ISO 4217 code:

  • 100 RUB
  • 100 UAH

Just for the note, symbols and shortened versions in Russia and Ukraine do not depend on number in any way, it's always same.

Maybe we can have somehow more flexible way to configure possible formats for different languages?

@mnasyrov
Copy link

mnasyrov commented Apr 7, 2016

Hello!
I would be happy if custom culture settings can be passed to format methods directly and they override current settings. It will allow to control which currency symbol should be used by hand at least.

@BenjaminVanRyseghem
Copy link
Owner

sounds like a good idea 😄 I think moment has a similar feature

@ArmorDarks
Copy link

ArmorDarks commented Apr 20, 2016

Here is something more to consider http://www.gnu.org/software/libc/manual/html_node/Locale-Names.html#Locale-Names:

Most locale names follow XPG syntax and consist of up to four parts:

language[_territory[.codeset]][@modifier]

For example, the locale name ‘de_AT.iso885915@euro’ denotes a German-language locale for use in Austria, using the ISO-8859-15 (Latin-9) character set, and with the Euro as the currency symbol.

GNU locales have @modifier part. To be honest, not sure does Microsoft's culture has modifiers too or not, but it seems to be good idea to allow them.

You can see as in example they denote with @modifier type of currency. We can follow up that convention too, so that we could call different currencies:

Besides, with such helper we would be able to call certain locale/culture with not specific to it currency. Like ru-RU@euro — to call Russian locale with Euros.

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

No branches or pull requests

4 participants