嵌入有限的 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.】
仅需要 ICU 库本身的功能,例如 String.prototype.normalize() 和 WHATWG URL 解析器,在 small-icu 下完全支持。需要额外的 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.】