NativeScript / nativescript-intl

Apache License 2.0
7 stars 8 forks source link

Fix android number format #24

Open t1sh0o opened 4 years ago

t1sh0o commented 4 years ago

It seems that the currency should be set on the DecimalFormatSymbols instance before setting it to the NumberFormat instance in order to display proper currency.

With the old implementation, we had the following results, from which the first is ok, but the second is wrong:

const bgFormat = new Intl.NumberFormat('bg-BG', {
    style: 'currency',
    currency: 'BGN',
});
const usFormat = new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'BGN',
});
console.log(bgFormat.format(123.9)); // 123,90 лв.
console.log(usFormat.format(123.9)); // $123.90

And with the new one, the second call results in BGN123.90 which seems to be the correct result.

Fixes #23

cla-bot[bot] commented 4 years ago

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign the CLA at https://www.nativescript.org/cla. CLA has not been signed by users: @t1sh0o. After signing the CLA, you can ask me to recheck this PR by posting @cla-bot check as a comment to the PR.

t1sh0o commented 4 years ago

@cla-bot check

cla-bot[bot] commented 4 years ago

The cla-bot has been summoned, and re-checked this pull request!

wendt88 commented 3 years ago

@NathanWalker can you merge this PR please? thx