Open darrachequesne opened 5 months ago
Hi!
If I'm not mistaken, the currency is currently tied to the locale:
const i18n = new VueI18n({ numberFormats: { 'en-US': { currency: { style: 'currency', currency: 'USD' } }, 'fr-FR': { currency: { style: 'currency', currency: 'EUR' } } } });
So $n(100, 'currency') will print 100 € if the locale is set to fr-FR and $100 if it's en-US.
$n(100, 'currency')
100 €
fr-FR
$100
en-US
Which is problematic if a American wants to do some business in euro in France.
Reference: https://kazupon.github.io/vue-i18n/guide/number.html
I'd like to be able to set the current currency:
i18n.currency = "EUR";
So that $n(100, 'currency') returns the correct label.
If I understand correctly, there are currently two alternatives:
$n(100, { style: "currency", currency: theCurrentCurrency })
But that requires including the theCurrentCurrency variable everywhere.
theCurrentCurrency
mergeNumberFormat()
i18n.mergeNumberFormat(i18n.locale, { currency: { style: 'currency', currency: 'EUR' } });
But this requires calling mergeNumberFormat() every time the locale or the currency is updated.
Reference: https://kazupon.github.io/vue-i18n/api/#mergenumberformat-locale-format
Possibly related:
Clear and concise description of the problem
Hi!
If I'm not mistaken, the currency is currently tied to the locale:
So
$n(100, 'currency')
will print100 €
if the locale is set tofr-FR
and$100
if it'sen-US
.Which is problematic if a American wants to do some business in euro in France.
Reference: https://kazupon.github.io/vue-i18n/guide/number.html
Suggested solution
I'd like to be able to set the current currency:
So that
$n(100, 'currency')
returns the correct label.Alternative
If I understand correctly, there are currently two alternatives:
But that requires including the
theCurrentCurrency
variable everywhere.mergeNumberFormat()
But this requires calling
mergeNumberFormat()
every time the locale or the currency is updated.Reference: https://kazupon.github.io/vue-i18n/api/#mergenumberformat-locale-format
Additional context
Possibly related:
Validations