Skip to content

Commit e0f9349

Browse files
joyeecheungruyadorno
authored andcommitted
doc: improve documentation about ICU data fallback
This patch: - Documents `--with-icu-default-data-dir` and its precedence - Elaborates a bit more about the format of the name of the expected data file. PR-URL: #49666 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 10a2ade commit e0f9349

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

doc/api/intl.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,47 @@ This mode provides a balance between features and binary size.
113113

114114
If the `small-icu` option is used, one can still provide additional locale data
115115
at runtime so that the JS methods would work for all ICU locales. Assuming the
116-
data file is stored at `/some/directory`, it can be made available to ICU
117-
through either:
116+
data file is stored at `/runtime/directory/with/dat/file`, it can be made
117+
available to ICU through either:
118+
119+
* The `--with-icu-default-data-dir` configure option:
120+
121+
```bash
122+
./configure --with-icu-default-data-dir=/runtime/directory/with/dat/file --with-intl=small-icu
123+
```
124+
125+
This only embeds the default data directory path into the binary.
126+
The actual data file is going to be loaded at runtime from this directory
127+
path.
118128

119129
* The [`NODE_ICU_DATA`][] environment variable:
120130

121131
```bash
122-
env NODE_ICU_DATA=/some/directory node
132+
env NODE_ICU_DATA=/runtime/directory/with/dat/file node
123133
```
124134

125135
* The [`--icu-data-dir`][] CLI parameter:
126136

127137
```bash
128-
node --icu-data-dir=/some/directory
138+
node --icu-data-dir=/runtime/directory/with/dat/file
129139
```
130140

131-
(If both are specified, the `--icu-data-dir` CLI parameter takes precedence.)
141+
When more than one of them is specified, the `--icu-data-dir` CLI parameter has
142+
the highest precedence, then the `NODE_ICU_DATA` environment variable, then
143+
the `--with-icu-default-data-dir` configure option.
132144

133145
ICU is able to automatically find and load a variety of data formats, but the
134146
data must be appropriate for the ICU version, and the file correctly named.
135-
The most common name for the data file is `icudt6X[bl].dat`, where `6X` denotes
147+
The most common name for the data file is `icudtX[bl].dat`, where `X` denotes
136148
the intended ICU version, and `b` or `l` indicates the system's endianness.
149+
Node.js would fail to load if the expected data file cannot be read from the
150+
specified directory. The name of the data file corresponding to the current
151+
Node.js version can be computed with:
152+
153+
```js
154+
`icudt${process.versions.icu.split('.')[0]}${os.endianness()[0].toLowerCase()}.dat`;
155+
```
156+
137157
Check ["ICU Data"][] article in the ICU User Guide for other supported formats
138158
and more details on ICU data in general.
139159

0 commit comments

Comments
 (0)