Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
792acc1
net: fix abort on bad address input
BridgeAR Jun 16, 2017
38ae5c4
doc, lib, test: do not re-require needlessly
vsemozhetbyt Jul 15, 2017
66cdcd9
build: add cpp linting to windows build
Mar 15, 2017
c9ae894
build: add lint option to vcbuild.bat help
brennemo Mar 22, 2017
14cc1ab
build: split up cpplint to avoid long cmd lines
kfarnung Jul 6, 2017
8604772
readline: remove max limit of crlfDelay
Azard Aug 17, 2017
8dfc283
test: fix test-readline-interface
Azard Aug 7, 2017
921876d
deps: backport 071b655 from V8 upstream
targos Sep 6, 2017
f8b85e1
tools: replace assert-throw-arguments custom lint
Trott Jul 30, 2017
4e1a50a
deps: backport 0353a1e from V8 upstream
jBarz Sep 8, 2017
90fcccd
doc: add documentation on ICU
TimothyGu Jun 26, 2017
362a7c0
repl: do not consider `...` as a REPL command
shivanth Jul 23, 2017
f7b6d19
tools: eslint - use `error` and `off`
refack Jul 3, 2017
86497f1
test: mark inspector-port-zero-cluster as flaky
refack Jun 1, 2017
e65c9ec
http: assert parser.consume argument's type
gireeshpunathil Apr 9, 2017
594e3c2
doc: add readline.emitKeypressEvents note
STRML Nov 3, 2016
dcdc905
doc: fix typo in stream.md
Jul 19, 2017
3a6392b
tls: fix empty issuer/subject/infoAccess parsing
bnoordhuis Jul 24, 2017
8b9a05c
test: read proper inspector message size
bzoz Aug 2, 2017
860c619
test: use ciphers supported by shared OpenSSL
kapouer Aug 1, 2017
c88f99f
test: improvements to various http tests
jasnell Jul 14, 2017
fc49cf4
test: improve multiple timers tests
jasnell Aug 4, 2017
28b77d1
test: improve check in test-os
Trott Aug 7, 2017
9d84641
test: fix conversion of microseconds in test
nickstanish Aug 9, 2017
c0e47e4
doc: fix order of AtExit callbacks in addons.md
danbev Jul 3, 2017
b5904a2
doc: remove undef NDEBUG from addons.md
danbev Jul 3, 2017
ca61f3b
tools: fix tools/addon-verify.js
danbev Jul 3, 2017
6707411
http: reset stream to unconsumed in `unconsume()`
addaleax Jul 21, 2017
4fb755c
test: set module loading error for aix
prakaashkpk Jul 27, 2017
9ed2c4c
test: add block scoping to test-readline-interface
Trott Aug 3, 2017
91649b9
test: make test-tls-connect checks more strict
Trott Aug 8, 2017
9f33025
test: remove redundant `using` in cctest
XadillaX Aug 10, 2017
d20b7bf
src: use local isolate instead of args.GetIsolate
danbev Aug 11, 2017
1aac05b
test: cover all HTTP methods that parser supports
Aug 11, 2017
caeee38
net: support passing undefined to listen()
sam-github Jul 14, 2017
5a7a49f
doc: clarify the position argument for fs.read
dcharbonnier Aug 3, 2017
f8fbac7
doc: improve fs.read() doc text
Trott Aug 4, 2017
f35f06d
test: improve multiple vm tests
jasnell Jul 24, 2017
68cf7f0
test: improve multiple zlib tests
jasnell Jul 24, 2017
32260b9
test: check crypto before requiring tls module
danbev Aug 9, 2017
a284ee6
test: invoke callback with common.mustCall()
Sep 17, 2016
4fb4fbe
test: add missing console.error to exec-maxBuffer
BethGriggs Aug 12, 2017
a63cd82
doc: fix word wrapping for api stability boxes
saadq Aug 13, 2017
debea1c
tools: delete an unused argument
phisixersai Jul 15, 2017
d75e9b7
doc: add BridgeAR to collaborators
BridgeAR Aug 16, 2017
855d7ae
benchmark: convert var to es6 const
sebasmurphy May 7, 2017
27b6737
doc: explain what to do if git push is rejected
Trott Aug 16, 2017
cac4beb
tools: fix update-eslint.sh
MylesBorins Aug 16, 2017
c76a54f
doc: add missing word
maclover7 Aug 18, 2017
7245082
test: make timers-blocking-callback more reliable
Trott Aug 14, 2017
b2112f8
src: detect nul bytes in InternalModuleReadFile()
bnoordhuis Aug 16, 2017
55dc14e
doc: remove misterdjules from the CTC members list
Aug 22, 2017
915b56b
test: remove unused arguments from function
0xparashar Aug 18, 2017
70e9a6e
doc: link to correct "OS Constants" heading in docs
jamiebuilds Aug 21, 2017
968121b
src: remove unnecessary helper function
mscdex Aug 21, 2017
7546eef
doc: rephrase text of child_process.execSync()
ayazhafiz Aug 20, 2017
168f73c
test: improve assertion fail messages
refack Aug 19, 2017
644d990
test: do not modify fixtures in test-fs-chmod
Trott Aug 18, 2017
1e231ba
test: add known issue for vm module
fhinkel Aug 7, 2017
66dd898
build: better support for python3 systems
bnoordhuis Aug 10, 2017
a8b917e
benchmark: fix dgram/bind-params.js benchmark
Trott Aug 19, 2017
29de000
doc: add note for Windows build path
Jul 18, 2017
b10bc31
doc: fix typo in Buffer.from(string, [encoding])
Aug 24, 2017
ad1d745
test: extend async addon test
addaleax Aug 18, 2017
948a7d7
meta: improve definition of a collaborator
jasnell Aug 22, 2017
605a02b
doc: environmental->environment & NodeJS->Node.js
rvagg Aug 22, 2017
6540e99
test: simplify test-tls-client-default-ciphers
maclover7 Aug 18, 2017
4c26913
doc: crypto.randomBytes does not block when async
sam-github Aug 23, 2017
f0328f6
doc,stream: remove wrong remark on readable.read
jscissr Aug 24, 2017
66187fa
stream: fix Writable instanceof for subclasses
addaleax Aug 19, 2017
25be2a3
crypto: naming anonymous functions.
solebox Oct 9, 2016
8b04574
test: pipe some error output if npm fails
Fishrock123 Apr 18, 2017
8b3ac4b
tools: add custom private key option
krydos Jul 20, 2017
4ee066e
meta: considerations for new core modules
jasnell Aug 24, 2017
e014178
meta: merge TSC and CTC back into a single body
jasnell Aug 22, 2017
5696223
doc: clarify http.get data consumption requirement
strugee Aug 26, 2017
4e71782
lib: clean up usage of threw
JacksonTian Aug 11, 2016
6a7e46e
build: add NetBSD support to opensslconf.h
rsmarples Jul 16, 2017
1b0e660
doc: /s/SHASUM256/SHASUMS256
maclover7 Aug 30, 2017
a260190
doc: instructions for generating coverage reports
ssbrewster Sep 4, 2017
2babae4
test: refactor test-fs-readfile-unlink
Trott Sep 3, 2017
33fdbb5
doc: describe what security issues are
sam-github Jul 25, 2017
feb6863
doc: document bytes to chars after setEncoding
jalafel Jun 3, 2017
8e00315
test: check zlib version for createDeflateRaw
danbev Jun 15, 2017
0c670e0
http: eliminate capture of ClientRequest in Agent
evantorrie Dec 13, 2016
73416b4
assert: refactor the code
BridgeAR Jun 27, 2017
abf6355
doc,assert: document stackStartFunction in fail
BridgeAR Jul 2, 2017
2c8fe97
test: remove envPlus, use Object.assign everywhere
gibfahn Aug 15, 2017
ecea33b
doc: add links to alternative versions of doc
Jan 23, 2017
37dd2ad
tools: fix linter error in html.js
targos Aug 28, 2017
a13ac69
doc: prevent displaying empty version picker
Sep 14, 2017
8691fdf
2017-10-03, Version 6.11.4 'Boron' (LTS)
MylesBorins Sep 20, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc: add documentation on ICU
PR-URL: #13916
Refs: #13644 (comment)
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
  • Loading branch information
TimothyGu authored and MylesBorins committed Sep 19, 2017
commit 90fcccd7a35834780dd838eff941de188d25cb45
1 change: 1 addition & 0 deletions doc/api/_toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* [Globals](globals.html)
* [HTTP](http.html)
* [HTTPS](https.html)
* [Internationalization](intl.html)
* [Modules](modules.html)
* [Net](net.html)
* [OS](os.html)
Expand Down
1 change: 1 addition & 0 deletions doc/api/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@include globals
@include http
@include https
@include intl
@include modules
@include net
@include os
Expand Down
198 changes: 198 additions & 0 deletions doc/api/intl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
# Internationalization Support

Node.js has many features that make it easier to write internationalized
programs. Some of them are:

- Locale-sensitive or Unicode-aware functions in the [ECMAScript Language
Specification][ECMA-262]:
- [`String.prototype.normalize()`][]
- [`String.prototype.toLowerCase()`][]
- [`String.prototype.toUpperCase()`][]
- All functionality described in the [ECMAScript Internationalization API
Specification][ECMA-402] (aka ECMA-402):
- [`Intl`][] object
- Locale-sensitive methods like [`String.prototype.localeCompare()`][] and
[`Date.prototype.toLocaleString()`][]

Node.js (and its underlying V8 engine) uses [ICU][] to implement these features
in native C/C++ code. However, some of them require a very large ICU data file
in order to support all locales of the world. Because it is expected that most
Node.js users will make use of only a small portion of ICU functionality, only
a subset of the full ICU data set is provided by Node.js by default. Several
options are provided for customizing and expanding the ICU data set either when
building or running Node.js.

## Options for building Node.js

To control how ICU is used in Node.js, four `configure` options are available
during compilation. Additional details on how to compile Node.js are documented
in [BUILDING.md][].

- `--with-intl=none` / `--without-intl`
- `--with-intl=system-icu`
- `--with-intl=small-icu` (default)
- `--with-intl=full-icu`

An overview of available Node.js and JavaScript features for each `configure`
option:

| | `none` | `system-icu` | `small-icu` | `full-icu`
|-----------------------------------------|-----------------------------------|------------------------------|------------------------|------------
| [`String.prototype.normalize()`][] | none (function is no-op) | full | full | full
| `String.prototype.to*Case()` | full | full | full | full
| [`Intl`][] | none (object does not exist) | partial/full (depends on OS) | partial (English-only) | full
| [`String.prototype.localeCompare()`][] | partial (not locale-aware) | full | full | full
| `String.prototype.toLocale*Case()` | partial (not locale-aware) | full | full | full
| [`Number.prototype.toLocaleString()`][] | partial (not locale-aware) | partial/full (depends on OS) | partial (English-only) | full
| `Date.prototype.toLocale*String()` | partial (not locale-aware) | partial/full (depends on OS) | partial (English-only) | full

*Note*: The "(not locale-aware)" designation denotes that the function carries
out its operation just like the non-`Locale` version of the function, if one
exists. For example, under `none` mode, `Date.prototype.toLocaleString()`'s
operation is identical to that of `Date.prototype.toString()`.

### Disable all internationalization features (`none`)

If this option is chosen, most internationalization features mentioned above
will be **unavailable** in the resulting `node` binary.

### Build with a pre-installed ICU (`system-icu`)

Node.js can link against an ICU build already installed on the system. In fact,
most Linux distributions already come with ICU installed, and this option would
make it possible to reuse the same set of data used by other components in the
OS.

Functionalities that only require the ICU library itself, such as
[`String.prototype.normalize()`][], are fully supported under `system-icu`.
Features that require ICU locale data in addition, such as
[`Intl.DateTimeFormat`][] *may* be fully or partially supported, depending on
the completeness of the ICU data installed on the system.

### Embed a limited set of ICU data (`small-icu`)

This option makes the resulting binary link against the ICU library statically,
and includes a subset of ICU data (typically only the English locale) within
the `node` executable.

Functionalities that only require the ICU library itself, such as
[`String.prototype.normalize()`][], are fully supported under `small-icu`.
Features that require ICU locale data in addition, such as
[`Intl.DateTimeFormat`][], generally only work with the English locale:

```js
const january = new Date(9e8);
const english = new Intl.DateTimeFormat('en', { month: 'long' });
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });

console.log(english.format(january));
// Prints "January"
console.log(spanish.format(january));
// Prints "January" or "M01" on small-icu
// Should print "enero"
```

This mode provides a good balance between features and binary size, and it is
the default behavior if no `--with-intl` flag is passed. The official binaries
are also built in this mode.

#### Providing ICU data at runtime

If the `small-icu` option is used, one can still provide additional locale data
at runtime so that the JS methods would work for all ICU locales. Assuming the
data file is stored at `/some/directory`, it can be made available to ICU
through either:

* The [`NODE_ICU_DATA`][] environmental variable:

```shell
env NODE_ICU_DATA=/some/directory node
```

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

```shell
node --icu-data-dir=/some/directory
```

(If both are specified, the `--icu-data-dir` CLI parameter takes precedence.)

ICU is able to automatically find and load a variety of data formats, but the
data must be appropriate for the ICU version, and the file correctly named.
The most common name for the data file is `icudt5X[bl].dat`, where `5X` denotes
the intended ICU version, and `b` or `l` indicates the system's endianness.
Check ["ICU Data"][] article in the ICU User Guide for other supported formats
and more details on ICU data in general.

The [full-icu][] npm module can greatly simplify ICU data installation by
detecting the ICU version of the running `node` executable and downloading the
appropriate data file. After installing the module through `npm i full-icu`,
the data file will be available at `./node_modules/full-icu`. This path can be
then passed either to `NODE_ICU_DATA` or `--icu-data-dir` as shown above to
enable full `Intl` support.

### Embed the entire ICU (`full-icu`)

This option makes the resulting binary link against ICU statically and include
a full set of ICU data. A binary created this way has no further external
dependencies and supports all locales, but might be rather large. See
[BUILDING.md][BUILDING.md#full-icu] on how to compile a binary using this mode.

## Detecting internationalization support

To verify that ICU is enabled at all (`system-icu`, `small-icu`, or
`full-icu`), simply checking the existence of `Intl` should suffice:

```js
const hasICU = typeof Intl === 'object';
```

Alternatively, checking for `process.versions.icu`, a property defined only
when ICU is enabled, works too:

```js
const hasICU = typeof process.versions.icu === 'string';
```

To check for support for a non-English locale (i.e. `full-icu` or
`system-icu`), [`Intl.DateTimeFormat`][] can be a good distinguishing factor:

```js
const hasFullICU = (() => {
try {
const january = new Date(9e8);
const spanish = new Intl.DateTimeFormat('es', { month: 'long' });
return spanish.format(january) === 'enero';
} catch (err) {
return false;
}
})();
```

For more verbose tests for `Intl` support, the following resources may be found
to be helpful:

- [btest402][]: Generally used to check whether Node.js with `Intl` support is
built correctly.
- [Test262][]: ECMAScript's official conformance test suite includes a section
dedicated to ECMA-402.

[btest402]: https://github.com/srl295/btest402
[BUILDING.md]: https://github.com/nodejs/node/blob/master/BUILDING.md
[BUILDING.md#full-icu]: https://github.com/nodejs/node/blob/master/BUILDING.md#build-with-full-icu-support-all-locales-supported-by-icu
[`Date.prototype.toLocaleString()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
[ECMA-262]: https://tc39.github.io/ecma262/
[ECMA-402]: https://tc39.github.io/ecma402/
[full-icu]: https://www.npmjs.com/package/full-icu
[ICU]: http://icu-project.org/
["ICU Data"]: http://userguide.icu-project.org/icudata
[`--icu-data-dir`]: cli.html#cli_icu_data_dir_file
[`Intl`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Intl
[`Intl.DateTimeFormat`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
[`NODE_ICU_DATA`]: cli.html#cli_node_icu_data_file
[`Number.prototype.toLocaleString()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString
[`String.prototype.localeCompare()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
[`String.prototype.normalize()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
[`String.prototype.toLowerCase()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase
[`String.prototype.toUpperCase()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
[Test262]: https://github.com/tc39/test262/tree/master/test/intl402