vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Invalid formatting of unit when calling $n

Open Heziode opened this issue 3 years ago • 4 comments

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

Heziode avatar Aug 22 '20 14:08 Heziode

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

Heziode avatar Aug 22 '20 15:08 Heziode

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 avatar Sep 08 '20 11:09 exoego

@exoego,

I don't know.

When it will be implemented by all major browser, this will maybe require modification in types/index.d.ts.

Heziode avatar Sep 08 '20 13:09 Heziode

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

Heziode avatar May 10 '21 06:05 Heziode

Seems to be fixed now with upstream update.

Heziode avatar Feb 05 '23 18:02 Heziode