NativeScript / nativescript-intl

Apache License 2.0
7 stars 8 forks source link

wrong currency #23

Open wendt88 opened 4 years ago

wendt88 commented 4 years ago
new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'EUR'
}).format(1);

returns: $ 1.00 it seems that the currency option gets ignored... it takes always the currency from the locale's location

StefanNedelchev commented 4 years ago

I second that. I have the same issue. The weird thing is that for some reason the locale affects the currency (which isn't supposed to be like that). My example:

(new Intl.NumberFormat('bg-BG', { style: 'currency', currency: 'BGN' })).format(1)
// returns "1.00 лв." which is correct
(new Intl.NumberFormat('en-US', { style: 'currency', currency: 'BGN' })).format(1)
// returns "$1.00" which is incorrect - it should return "BGN 1.00"

In both cases the currency is the same (BGN) but the printed currency symbol is different.

Here, I've made a JSFiddle example so you can see the results from the same example but in vanilla JS environment

StefanNedelchev commented 4 years ago

UPDATE: I tested this on iOS and it seems to work correctly which means that the issue is probably specific to Android.

StefanNedelchev commented 4 years ago

This pull request seems to fix the issue for me

wendt88 commented 3 years ago

more than 6 months are passed and no one was able to merge this awesome bug fixing PR :see_no_evil:

StefanNedelchev commented 3 years ago

more than 6 months are passed and no one was able to merge this awesome bug fixing PR 🙈

I still use a local version with that fix because of that