Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
Steven R. Loomis edited this page Jan 9, 2015 · 25 revisions

This page applies to v0.12 and following.

What is Intl?

The Intl object is available when EcmaScript 402 support is enabled. Node.js uses ICU4C to implement the Intl object natively.

There are multiple ways to build Node with ICU. Most of this page discusses different ways to build ICU.

Build with a specific ICU:

You can find other ICU releases at the ICU homepage. Download the file named something like icu4c-**##.#**-src.tgz (or .zip).

Unix/Macintosh: from an already-unpacked ICU

./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu

Unix/Macintosh: from a local ICU tarball

./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu.tgz

Unix/Macintosh: from a tarball URL

./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz

Windows: first unpack latest ICU to deps/icu icu4c-##.#-src.tgz (or .zip) as deps/icu (You'll have: deps/icu/source/...)

vcbuild full-icu

Unix/Macintosh: Using a pre-built ICU (system-icu)

The Intl package can use an ICU which is already built.

Installing a pre-built ICU

Here are some ways to obtain a pre-built ICU:

From a package manager

Run one of these or similar as appropriate for your system:

 apt-get install libicu-dev
 yum install libicu-dev

Building ICU yourself

  • Download ICU source http://icu-project.org/download

  • Follow the enclosed readme.html to build ICU, particularly paying attention to the --prefix argument

  • build ICU and then:

    make install

Verify an installed ICU

 pkg-config --modversion icu-i18n

If this command fails, node will not be able to find the installed ICU. Verify that the PKG_CONFIG_PATH points to the newly installed icu-i18n.pc file

Configure node

 ./configure --with-intl=system-icu
  • Download the latest icu4c-##.#-src.tgz (or .zip)
  • Unpack the source as deps/icu (you should have deps/icu/source/...)

Building node with an embedded ICU

Download ICU source

First: Unpack latest ICU icu4c-##.#-src.tgz (or .zip) as deps/icu (You'll have: deps/icu/source/...)

Unix/Macintosh

  • ./configure ... --with-intl=full-icu

Or, to build the "small" variant (English only):

  • ./configure ... --with-intl=small-icu

Windows

  • vsbuild.bat ... full-icu

Or, to build the "small" variant (English only):

  • vsbuild.bat ... small-icu

Using the "small" build

  • If you use the "small-icu" option, you can provide additional data at runtime.
    • Two methods:
      • The NODE_ICU_DATA env variable: env NODE_ICU_DATA=/some/path node
      • The --icu-data-dir parameter: node --icu-data-dir=/some/path
    • Example: If you use the path /some/path, then ICU 53 on Little Endian (l) finds:
    • Notes:
      • See u_setDataDirectory() and the ICU Users Guide for many more details.
      • "53l" will be "53b" on a big endian machine.
  • With the small-icu mode, you can also choose different locales than "English only". For example, --with-icu-locales=de,zh,fr will include only German, Chinese and French but not English. The http://apps.icu-project.org/datacustom/ page will list currently available locale IDs.
  • Note that this option is also useful for updating ICU's time zone data.

Verifying an Intl build

  • node test/simple/test-intl.js
  • btest402.js is a very basic but verbose test of whether Intl is built correctly.

Using Intl build

Building using Chromium's ICU

Note: not recommended. This build is missing some locales, is an older revision, and has a larger output size. It is included here for completeness.

svn checkout --force --revision 214189 \
    http://src.chromium.org/svn/trunk/deps/third_party/icu46 \
    deps/v8/third_party/icu46
./configure --with-icu-path=deps/v8/third_party/icu46/icu.gyp
make
make install