Skip to content

Commit

Permalink
Add FAQ entry about ICU data in Node
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsknn committed Nov 1, 2020
1 parent 935a072 commit 72d9ef5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,36 @@ dayjs x 281,183 ops/sec ±0.57% (96 runs sampled)
```
</details>
<details>
<summary>Why doesn't <code>localeFormat</code> work correctly with some locales in Node?</summary>
Before version 13, Node is shipped with limited ICU data (= localization data).
Because of this, using certain locales with `localeFormat` may produce incorrect results in Node up to version 12.
You can either use Node 13+ or install full ICU data manually:
1. `npm install --save cross-env full-icu`
2. Update the `scripts` section of `package.json` to set the environment variable `NODE_ICU_DATA`. For example:
```js
{
"scripts": {
// Before
"start": "index.js",
"test": "react-scripts test",

// After
"start": "cross-env NODE_ICU_DATA=node_modules/full-icu index.js",
"test": "cross-env NODE_ICU_DATA=node_modules/full-icu react-scripts test"
}
}
```
This way, when you run `npm start` or `npm test`, Node will load the full ICU data from `node_modules/full-icu`, and you should get correctly formatted results.
The `cross-env` package is needed to support setting environment variables on Windows.
</details>
## License
MIT © [Antoni Kepinski](https://kepinski.me)

0 comments on commit 72d9ef5

Please sign in to comment.