Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forced polyfill of de-AT locale for Intl.NumberFormat is using incorrect currency group separator #4422

Closed
briavicenti opened this issue May 15, 2024 · 3 comments
Labels

Comments

@briavicenti
Copy link

briavicenti commented May 15, 2024

Which package?

@formatjs/intl-numberformat

Describe the bug

We are using the FormatJS forced polyfills in an number formatting internal library to ensure that our frontend, backend, and testing environments all have consistent behavior when calling Intl.NumberFormat and Intl.DateTimeFormat.

However, de-AT is a required locale for us and the force polyfill is resulting in incorrect output according to both real browser behavior and this CLDR spec.

I can see the correct currencyGroup in the generated de-AT.js file in my node_modules folder:

image

However, this correct separator doesn't seem to be getting applied as expected and we are seeing the non-currency group separator (a non-breaking space) applied to currency instead.

To Reproduce

  1. npm add @format-js/intl-numberformat@latest
  2. Add the following imports:
import "@formatjs/intl-numberformat/polyfill-force";
import "@formatjs/intl-numberformat/locale-data/de-AT";
  1. Run the following code, and observe the incorrect output:
console.log(
    new Intl.NumberFormat("de-AT", {
      style: "currency",
      currency: "EUR",
    }).format(1234567)
  );

Codesandbox URL

Code sandbox can be found here. You can comment out the import for the force polyfill and refresh the code sandbox browser to see that this is indeed an issue with that import.

Expected behavior

Currency formatted for the de-AT locale should use periods as a group separator. i.e.:

Current incorrect output: € 12 345 678,00
Expected correct output: € 12.345.678,00

@briavicenti
Copy link
Author

As an aside we are on a time crunch here to get a fullstack de-AT formatter working for an internationalized demo, and so I would absolutely love a workaround if anyone knows one, even if we can't get an actual fix right away!

@longlho
Copy link
Member

longlho commented May 18, 2024

Thanks for reporting. Latest version should have this fix.

@briavicenti
Copy link
Author

@longlho thanks so much for the prompt fix! Just pulled it in and I can attest that it works as expected now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants