I am trying to use intl
to do some formatting but no matter what I pass in as the locale, I always get the following error message:
ReferenceError: No locale data has been provided for this object yet
I have tried the following:
new Intl.NumberFormat('en-ZA', { minimumFractionDigits: percentDecimals });
as well as
new Intl.NumberFormat(['en-ZA'], { minimumFractionDigits: percentDecimals });
and I am not sure what else do.
I have added the package to the package.json
"intl": "latest"
and I do import it
import Intl from "intl";
Depending on the enviromnent you are running this code you might need to import locale data as well to polyfill locale
import 'intl/locale-data/jsonp/en-ZA'
This import does side-effect that register en-ZA
locale IntlPolyfill.__addLocaleData({locale:"en-ZA",
when polyfill is required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With