嵌入一组有限的 ICU 数据 (small-icu)


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

此选项静态地生成针对 ICU 库的二进制链接,并在 node 可执行文件中包含 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.

small-icu 完全支持仅需要 ICU 库本身的功能,例如 String.prototype.normalize()WHATWG URL 解析器。另外需要 ICU 语言环境数据的特性,比如 Intl.DateTimeFormat,一般只适用于英文语言环境:

¥Functionalities that only require the ICU library itself, such as String.prototype.normalize() and the WHATWG URL parser, 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:

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 either "M01" or "January" on small-icu, depending on the user’s default locale
// Should print "enero" 

此模式提供了特性和二进制大小之间的平衡。

¥This mode provides a balance between features and binary size.