You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using non-precomputed compound units, in languages without a "one" property on their units, globalize throws. The following example illustrates this behavior:
Cldr.load( jaUnits );
Cldr.load( likelySubtags );
globalize = new Globalize( "ja" );
cldr = globalize.cldr;
QUnit.module( "Unit Format - Compound Form with no one property in cldr" );
function oneOrOtherPluralGenerator() {
return "other";
}
function stubNumberFormatter( number ) {
return number.toString();
}
QUnit.assert.unitFormatJa = function ( value, unit, options, expected ) {
var unitProps = unitProperties( unit, options.form, cldr );
this.equal(
formatUnit( value, options.numberFormatter || stubNumberFormatter, oneOrOtherPluralGenerator, unitProps ),
expected
);
};
QUnit.test( "Compound form (without precomputed)", function ( assert ) {
assert.unitFormatJa( 1, "length-foot-per-second", { form: "long" }, "1 フィート毎秒" );
assert.unitFormatJa( 100, "length-foot-per-second", { form: "long" }, "100 フィート毎秒" );
assert.unitFormatJa( 1, "megabyte-per-second", { form: "narrow" }, "1MB/秒" );
assert.unitFormatJa( 100, "megabyte-per-second", { form: "narrow" }, "100MB/秒" );
assert.unitFormatJa( 1.2345678910, "megabyte-per-second",
{ form: "narrow", numberFormatter: function (number) { return number.toFixed(1); }},
"1.2MB/秒" );
});
/* Throws:
>> Unit Format - Compound Form with no one property in cldr - Compound form (without precomputed)
>> Message: Died on test #1 http://localhost:9001/unit/unit/format-ja.js:37:11
>> execCb@http://localhost:9001/external/requirejs/require.js:1678:38
>> check@http://localhost:9001/external/requirejs/require.js:873:61
>> http://localhost:9001/external/requirejs/require.js:1128:39
>> http://localhost:9001/external/requirejs/require.js:131:28
>> http://localhost:9001/external/requirejs/require.js:1178:23
>> each@http://localhost:9001/external/requirejs/require.js:56:35
>> emit@http://localhost:9001/external/requirejs/require.js:1177:21
>> check@http://localhost:9001/external/requirejs/require.js:929:34
>> http://localhost:9001/external/requirejs/require.js:1128:39
>> http://localhost:9001/external/requirejs/require.js:131:28
>> http://localhost:9001/external/requirejs/require.js:1178:23
>> each@http://localhost:9001/external/requirejs/require.js:56:35
>> emit@http://localhost:9001/external/requirejs/require.js:1177:21
>> check@http://localhost:9001/external/requirejs/require.js:929:34
>> http://localhost:9001/external/requirejs/require.js:1128:39
>> http://localhost:9001/external/requirejs/require.js:131:28
>> http://localhost:9001/external/requirejs/require.js:1178:23
>> each@http://localhost:9001/external/requirejs/require.js:56:35
>> emit@http://localhost:9001/external/requirejs/require.js:1177:21
>> check@http://localhost:9001/external/requirejs/require.js:929:34
>> http://localhost:9001/external/requirejs/require.js:1128:39
>> http://localhost:9001/external/requirejs/require.js:131:28
>> http://localhost:9001/external/requirejs/require.js:1178:23
>> each@http://localhost:9001/external/requirejs/require.js:56:35
>> emit@http://localhost:9001/external/requirejs/require.js:1177:21
>> check@http://localhost:9001/external/requirejs/require.js:929:34
>> enable@http://localhost:9001/external/requirejs/require.js:1165:27
>> init@http://localhost:9001/external/requirejs/require.js:783:32
>> callGetModule@http://localhost:9001/external/requirejs/require.js:1192:67
>> completeLoad@http://localhost:9001/external/requirejs/require.js:1571:34
>> onScriptLoad@http://localhost:9001/external/requirejs/require.js:1699:41: undefined is not an object (evaluating 'message.replace')
>> Actual: null
>> Expected: undefined
>> http://localhost:9001/src/common/format-message.js:26:19
>> http://localhost:9001/src/unit/format.js:40:26
>> unitFormatJa@http://localhost:9001/unit/unit/format-ja.js:32:13
>> http://localhost:9001/unit/unit/format-ja.js:38:21
>> run@http://localhost:9001/external/qunit/qunit/qunit.js:895:32
>> http://localhost:9001/external/qunit/qunit/qunit.js:1024:14
>> process@http://localhost:9001/external/qunit/qunit/qunit.js:583:24
>> begin@http://localhost:9001/external/qunit/qunit/qunit.js:628:9
>> http://localhost:9001/external/qunit/qunit/qunit.js:644:9
*/
The text was updated successfully, but these errors were encountered:
willsp
added a commit
to willsp/globalize
that referenced
this issue
Dec 16, 2018
When using non-precomputed compound units, in languages without a "one" property on their units, globalize throws. The following example illustrates this behavior:
The text was updated successfully, but these errors were encountered: