vue-i18n
vue-i18n copied to clipboard
Invalid formatting of unit when calling $n
vue & vue-i18n version
vue: 2.6.12 vue-i18n: 8.21.0
Reproduction Link
https://jsfiddle.net/hdmaxzyq/
Steps to reproduce
Calling $n
with Intl.NumberFormat
configuration:
console.log(this.$n(8, { style: 'unit', unit: 'year', unitDisplay: 'long' }));
Here, unitDisplay
is not take in account.
What is Expected?
The previous example showing: 8 yrs
What is actually happening?
The previous example shall display: 8 years
Cf. ECMAScript Internationalization API Specification > SetNumberFormatUnitOptions > 13
I think, this issue should wait that all major browsers (Chrom*, FireFox, Safari) update there implementation of the ECMAScript.
See: https://stackoverflow.com/a/60588156
Thanks for report! Can we close this issue as upstream (browser/node.js side) issue? IIUC, it seems that we could not fix this on cue-i18n side.
@exoego,
I don't know.
When it will be implemented by all major browser, this will maybe require modification in types/index.d.ts.
Hi @exoego,
According to CanIUse, the support of this feature (style: 'unit'
) seems to be supported by all major browsers, but it is very very recent (April 26 for Safari).
So I think it can be used now but cautiously (even if IMHO, is too early now 😉).
Feel free to close this issue if you consider it solved
Seems to be fixed now with upstream update.