我确定这是一个愚蠢的配置问题,但我似乎无法弄清楚。我在以这种方式安装的 nodejs 中使用 globalize 包:
npm install --save globalize cldr-data
查看我的 package.json 安装:
"globalize": "^1.1.1",
"cldr-data": "^29.0.1",
然后我创建了一个nodeunit测试:
var Globalize = require( "globalize" );
Globalize.load( require( "cldr-data" ).entireSupplemental() );
Globalize.load( require( "cldr-data" ).entireMainFor( "es") );
Globalize.loadMessages({
en: {
hello: "Hello, {0} {1} {2}",
hey: "Hey, {first} {middle} {last}"
}
});
exports['test message translation'] = function (test) {
var enFormatter = Globalize( "es-MX" ).messageFormatter( "hello" );
testString = enFormatter([ "Wolfgang", "Amadeus", "Mozart" ]);
test.equal(testString, "Hello, Wolfgang Amadeus Mozart");
test.done();
};
exports['test date localization'] = function (test) {
test.equals("18/4/2016", Globalize( "es-MX" ).dateFormatter()( new Date()));
test.done();
};
第一个测试通过,但第二个测试失败并出现以下错误:
Error: E_MISSING_BUNDLE: {"locale":"es-MX"}
at createError (/Users/darrin/src/tot/commons/node_modules/globalize/node_modules/cldrjs/dist/cldr.js:341:11)
at validate (/Users/darrin/src/tot/commons/node_modules/globalize/node_modules/cldrjs/dist/cldr.js:357:10)
at Cldr.main (/Users/darrin/src/tot/commons/node_modules/globalize/node_modules/cldrjs/dist/cldr.js:663:3)
at dateExpandPattern (/Users/darrin/src/tot/commons/node_modules/globalize/dist/globalize/date.js:110:18)
at Globalize.dateFormatter.Globalize.dateFormatter [as dateFormatter] (/Users/darrin/src/tot/commons/node_modules/globalize/dist/globalize/date.js:1828:12)
at Object.exports.test date localization (/Users/darrin/src/tot/commons/tests/globalize/globalize.test.js:43:40)
at Object.<anonymous> (/Users/darrin/src/tot/commons/node_modules/nodeunit/lib/core.js:236:16)
at /Users/darrin/src/tot/commons/node_modules/nodeunit/lib/core.js:236:16
at Object.exports.runTest (/Users/darrin/src/tot/commons/node_modules/nodeunit/lib/core.js:70:9)
at /Users/darrin/src/tot/commons/node_modules/nodeunit/lib/core.js:118:25
有人对我如何配置错误有任何想法吗?