-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Intl
- An exception is the Chromium ICU instructions which are already relevant to node.
- TODO: remove the above notice when https://github.com/joyent/node/pull/7719 is in master
- TODO: as of https://github.com/joyent/node/pull/8719 the option
--with-intl=small-icu
will be on by default, AND ICU will be downloaded automatically. Need to reword the wiki here.
The Intl
object is available when EcmaScript 402
support is enabled.
Node.js uses ICU4C to implement the Intl
object natively.
The Intl package can use an ICU which is already built.
Here are some ways to obtain a pre-built ICU:
Run one of these or similar as appropriate for your system:
apt-get install libicu-dev
yum install libicu-dev
-
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
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 --with-intl=system-icu
- Download the latest
icu4c-##.#-src.tgz (or
.zip
) - Unpack the source as
deps/icu
(you should havedeps/icu/source/...
)
First: Unpack latest ICU
icu4c-##.#-src.tgz (or .zip
)
as deps/icu
(You'll have: deps/icu/source/...
)
- ./configure ... --with-intl=full-icu
Or, to build the "small" variant (English only):
- ./configure ... --with-intl=small-icu
- vsbuild.bat ...
full-icu
Or, to build the "small" variant (English only):
- vsbuild.bat ...
small-icu
- If you didn't build with full ICU, 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
- The
- Example: If you use the path
/some/path
, then ICU 53 on Little Endian (l) finds:- individual files such as
/some/path/icudt53l/root.res
- a packaged data file
/some/path/icudt53l.dat
- individual files such as
- Notes:
- See
u_setDataDirectory()
and the ICU Users Guide for many more details. - "53l" will be "53b" on a big endian machine.
- See
- Two methods:
-
btest402.js is a very basic test of whether
Intl
is built correctly.
- See: EcmaScript 402
- Tutorial: Working with Intl
Note: 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
- none (yet!)