globalize-rpk 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +5 -0
- package/README.md +818 -0
- package/{globalize → dist/globalize}/currency.js +3 -3
- package/{globalize → dist/globalize}/date.js +3 -3
- package/{globalize → dist/globalize}/message.js +2 -2
- package/{globalize → dist/globalize}/number.js +3 -3
- package/{globalize → dist/globalize}/plural.js +3 -3
- package/{globalize → dist/globalize}/relative-time.js +3 -3
- package/{globalize → dist/globalize}/unit.js +0 -0
- package/dist/globalize-runtime/currency.js +183 -0
- package/dist/globalize-runtime/date.js +1657 -0
- package/dist/globalize-runtime/message.js +120 -0
- package/dist/globalize-runtime/number.js +919 -0
- package/dist/globalize-runtime/plural.js +90 -0
- package/dist/globalize-runtime/relative-time.js +120 -0
- package/dist/globalize-runtime/unit.js +132 -0
- package/{globalize → dist}/globalize-runtime.js +0 -0
- package/{globalize → dist}/globalize.js +2 -2
- package/{node-main.js → dist/node-main.js} +0 -0
- package/doc/api/core/constructor.md +28 -0
- package/doc/api/core/load.md +96 -0
- package/doc/api/core/locale.md +43 -0
- package/doc/api/currency/currency-formatter.md +196 -0
- package/doc/api/currency/currency-to-parts-formatter.md +117 -0
- package/doc/api/date/date-formatter.md +203 -0
- package/doc/api/date/date-parser.md +60 -0
- package/doc/api/date/date-to-parts-formatter.md +176 -0
- package/doc/api/date/load-iana-time-zone.md +29 -0
- package/doc/api/message/load-messages.md +105 -0
- package/doc/api/message/message-formatter.md +208 -0
- package/doc/api/number/number-formatter.md +202 -0
- package/doc/api/number/number-parser.md +130 -0
- package/doc/api/number/number-to-parts-formatter.md +140 -0
- package/doc/api/plural/plural-generator.md +84 -0
- package/doc/api/relative-time/relative-time-formatter.md +60 -0
- package/doc/api/unit/unit-formatter.md +72 -0
- package/doc/blog-post/2017-07-xx-1.3.0-announcement.md +177 -0
- package/doc/cldr.md +114 -0
- package/doc/error/e-default-locale-not-defined.md +9 -0
- package/doc/error/e-invalid-cldr.md +14 -0
- package/doc/error/e-invalid-par-type.md +12 -0
- package/doc/error/e-invalid-par-value.md +11 -0
- package/doc/error/e-missing-cldr.md +11 -0
- package/doc/error/e-missing-parameter.md +10 -0
- package/doc/error/e-missing-plural-module.md +9 -0
- package/doc/error/e-par-missing-key.md +11 -0
- package/doc/error/e-par-out-of-range.md +13 -0
- package/doc/error/e-unsupported.md +10 -0
- package/doc/migrating-from-0.x.md +64 -0
- package/examples/amd-bower/.bowerrc +7 -0
- package/examples/amd-bower/README.md +65 -0
- package/examples/amd-bower/bower.json +13 -0
- package/examples/amd-bower/index.html +46 -0
- package/examples/amd-bower/main.js +141 -0
- package/examples/amd-bower/messages/en.json +12 -0
- package/examples/amd-bower/package.json +14 -0
- package/examples/app-npm-webpack/README.md +74 -0
- package/examples/app-npm-webpack/app/index.js +89 -0
- package/examples/app-npm-webpack/index-template.html +71 -0
- package/examples/app-npm-webpack/messages/ar.json +25 -0
- package/examples/app-npm-webpack/messages/de.json +21 -0
- package/examples/app-npm-webpack/messages/en.json +21 -0
- package/examples/app-npm-webpack/messages/es.json +21 -0
- package/examples/app-npm-webpack/messages/pt.json +21 -0
- package/examples/app-npm-webpack/messages/ru.json +23 -0
- package/examples/app-npm-webpack/messages/zh.json +20 -0
- package/examples/app-npm-webpack/package.json +17 -0
- package/examples/app-npm-webpack/webpack-config.js +63 -0
- package/examples/globalize-compiler/README.md +45 -0
- package/examples/globalize-compiler/app.js +58 -0
- package/examples/globalize-compiler/development.html +121 -0
- package/examples/globalize-compiler/messages.json +12 -0
- package/examples/globalize-compiler/package.json +15 -0
- package/examples/globalize-compiler/production.html +75 -0
- package/examples/node-npm/README.md +57 -0
- package/examples/node-npm/main.js +65 -0
- package/examples/node-npm/messages/en.json +12 -0
- package/examples/node-npm/package.json +10 -0
- package/examples/plain-javascript/README.md +81 -0
- package/examples/plain-javascript/index.html +445 -0
- package/package.json +27 -4
@@ -16,11 +16,11 @@
|
|
16
16
|
|
17
17
|
// AMD
|
18
18
|
define([
|
19
|
-
"cldr",
|
19
|
+
"cldrjs/dist/cldr",
|
20
20
|
"../globalize",
|
21
21
|
"./number",
|
22
|
-
"cldr/event",
|
23
|
-
"cldr/supplemental"
|
22
|
+
"cldrjs/dist/cldr/event",
|
23
|
+
"cldrjs/dist/cldr/supplemental"
|
24
24
|
], factory );
|
25
25
|
} else if ( typeof exports === "object" ) {
|
26
26
|
|
@@ -20,11 +20,11 @@
|
|
20
20
|
|
21
21
|
// AMD
|
22
22
|
define([
|
23
|
-
"cldr",
|
23
|
+
"cldrjs/dist/cldr",
|
24
24
|
"../globalize",
|
25
25
|
"./number",
|
26
|
-
"cldr/event",
|
27
|
-
"cldr/supplemental"
|
26
|
+
"cldrjs/dist/cldr/event",
|
27
|
+
"cldrjs/dist/cldr/supplemental"
|
28
28
|
], factory );
|
29
29
|
} else if ( typeof exports === "object" ) {
|
30
30
|
|
@@ -20,10 +20,10 @@
|
|
20
20
|
|
21
21
|
// AMD
|
22
22
|
define([
|
23
|
-
"cldr",
|
23
|
+
"cldrjs/dist/cldr",
|
24
24
|
"../globalize",
|
25
|
-
"cldr/event",
|
26
|
-
"cldr/supplemental"
|
25
|
+
"cldrjs/dist/cldr/event",
|
26
|
+
"cldrjs/dist/cldr/supplemental"
|
27
27
|
], factory );
|
28
28
|
} else if ( typeof exports === "object" ) {
|
29
29
|
|
@@ -20,10 +20,10 @@
|
|
20
20
|
|
21
21
|
// AMD
|
22
22
|
define([
|
23
|
-
"cldr",
|
23
|
+
"cldrjs/dist/cldr",
|
24
24
|
"../globalize",
|
25
|
-
"cldr/event",
|
26
|
-
"cldr/supplemental"
|
25
|
+
"cldrjs/dist/cldr/event",
|
26
|
+
"cldrjs/dist/cldr/supplemental"
|
27
27
|
], factory );
|
28
28
|
} else if ( typeof exports === "object" ) {
|
29
29
|
|
@@ -20,12 +20,12 @@
|
|
20
20
|
|
21
21
|
// AMD
|
22
22
|
define([
|
23
|
-
"cldr",
|
23
|
+
"cldrjs/dist/cldr",
|
24
24
|
"../globalize",
|
25
25
|
"./number",
|
26
26
|
"./plural",
|
27
|
-
"cldr/event",
|
28
|
-
"cldr/supplemental"
|
27
|
+
"cldrjs/dist/cldr/event",
|
28
|
+
"cldrjs/dist/cldr/supplemental"
|
29
29
|
], factory );
|
30
30
|
} else if ( typeof exports === "object" ) {
|
31
31
|
|
File without changes
|
@@ -0,0 +1,183 @@
|
|
1
|
+
/**
|
2
|
+
* Globalize Runtime v1.7.0
|
3
|
+
*
|
4
|
+
* https://github.com/globalizejs/globalize
|
5
|
+
*
|
6
|
+
* Copyright OpenJS Foundation and other contributors
|
7
|
+
* Released under the MIT license
|
8
|
+
* https://jquery.org/license
|
9
|
+
*
|
10
|
+
* Date: 2021-08-02T11:53Z
|
11
|
+
*/
|
12
|
+
/*!
|
13
|
+
* Globalize Runtime v1.7.0 2021-08-02T11:53Z Released under the MIT license
|
14
|
+
* http://git.io/TrdQbw
|
15
|
+
*/
|
16
|
+
(function( root, factory ) {
|
17
|
+
|
18
|
+
"use strict";
|
19
|
+
|
20
|
+
// UMD returnExports
|
21
|
+
if ( typeof define === "function" && define.amd ) {
|
22
|
+
|
23
|
+
// AMD
|
24
|
+
define([
|
25
|
+
"../globalize-runtime",
|
26
|
+
"./number"
|
27
|
+
], factory );
|
28
|
+
} else if ( typeof exports === "object" ) {
|
29
|
+
|
30
|
+
// Node, CommonJS
|
31
|
+
module.exports = factory(
|
32
|
+
require( "../globalize-runtime" ),
|
33
|
+
require( "./number" )
|
34
|
+
);
|
35
|
+
} else {
|
36
|
+
|
37
|
+
// Extend global
|
38
|
+
factory( root.Globalize );
|
39
|
+
}
|
40
|
+
}(this, function( Globalize ) {
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
var formatMessageToParts = Globalize._formatMessageToParts,
|
45
|
+
partsJoin = Globalize._partsJoin,
|
46
|
+
partsPush = Globalize._partsPush,
|
47
|
+
runtimeKey = Globalize._runtimeKey,
|
48
|
+
validateParameterPresence = Globalize._validateParameterPresence,
|
49
|
+
validateParameterTypeNumber = Globalize._validateParameterTypeNumber;
|
50
|
+
|
51
|
+
|
52
|
+
var currencyFormatterFn = function( currencyToPartsFormatter ) {
|
53
|
+
return function currencyFormatter( value ) {
|
54
|
+
return partsJoin( currencyToPartsFormatter( value ));
|
55
|
+
};
|
56
|
+
};
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
/**
|
62
|
+
* nameFormat( formattedNumber, pluralForm, properties )
|
63
|
+
*
|
64
|
+
* Return the appropriate name form currency format.
|
65
|
+
*/
|
66
|
+
var currencyNameFormat = function( formattedNumber, pluralForm, properties ) {
|
67
|
+
var displayName, unitPattern,
|
68
|
+
parts = [],
|
69
|
+
displayNames = properties.displayNames || {},
|
70
|
+
unitPatterns = properties.unitPatterns;
|
71
|
+
|
72
|
+
displayName = displayNames[ "displayName-count-" + pluralForm ] ||
|
73
|
+
displayNames[ "displayName-count-other" ] ||
|
74
|
+
displayNames.displayName ||
|
75
|
+
properties.currency;
|
76
|
+
unitPattern = unitPatterns[ "unitPattern-count-" + pluralForm ] ||
|
77
|
+
unitPatterns[ "unitPattern-count-other" ];
|
78
|
+
|
79
|
+
formatMessageToParts( unitPattern, [ formattedNumber, displayName ]).forEach(function( part ) {
|
80
|
+
if ( part.type === "variable" && part.name === "0" ) {
|
81
|
+
part.value.forEach(function( part ) {
|
82
|
+
partsPush( parts, part.type, part.value );
|
83
|
+
});
|
84
|
+
} else if ( part.type === "variable" && part.name === "1" ) {
|
85
|
+
partsPush( parts, "currency", part.value );
|
86
|
+
} else {
|
87
|
+
partsPush( parts, "literal", part.value );
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
91
|
+
return parts;
|
92
|
+
};
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
/**
|
98
|
+
* symbolFormat( parts, symbol )
|
99
|
+
*
|
100
|
+
* Return the appropriate symbol/account form format.
|
101
|
+
*/
|
102
|
+
var currencySymbolFormat = function( parts, symbol ) {
|
103
|
+
parts.forEach(function( part ) {
|
104
|
+
if ( part.type === "currency" ) {
|
105
|
+
part.value = symbol;
|
106
|
+
}
|
107
|
+
});
|
108
|
+
return parts;
|
109
|
+
};
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
var currencyToPartsFormatterFn = function( numberToPartsFormatter, pluralGenerator, properties ) {
|
115
|
+
var fn;
|
116
|
+
|
117
|
+
// Return formatter when style is "name".
|
118
|
+
if ( pluralGenerator && properties ) {
|
119
|
+
fn = function currencyToPartsFormatter( value ) {
|
120
|
+
validateParameterPresence( value, "value" );
|
121
|
+
validateParameterTypeNumber( value, "value" );
|
122
|
+
return currencyNameFormat(
|
123
|
+
numberToPartsFormatter( value ),
|
124
|
+
pluralGenerator( value ),
|
125
|
+
properties
|
126
|
+
);
|
127
|
+
};
|
128
|
+
|
129
|
+
// Return formatter when style is "symbol", "accounting", or "code".
|
130
|
+
} else {
|
131
|
+
fn = function currencyToPartsFormatter( value ) {
|
132
|
+
|
133
|
+
// 1: Reusing pluralGenerator argument, but in this case it is actually `symbol`
|
134
|
+
return currencySymbolFormat( numberToPartsFormatter( value ), pluralGenerator /* 1 */ );
|
135
|
+
};
|
136
|
+
}
|
137
|
+
|
138
|
+
return fn;
|
139
|
+
};
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
Globalize._currencyFormatterFn = currencyFormatterFn;
|
145
|
+
Globalize._currencyNameFormat = currencyNameFormat;
|
146
|
+
Globalize._currencyToPartsFormatterFn = currencyToPartsFormatterFn;
|
147
|
+
|
148
|
+
Globalize.currencyFormatter =
|
149
|
+
Globalize.prototype.currencyFormatter = function( currency, options ) {
|
150
|
+
options = options || {};
|
151
|
+
return Globalize[ runtimeKey( "currencyFormatter", this._locale, [ currency, options ] ) ];
|
152
|
+
};
|
153
|
+
|
154
|
+
Globalize.currencyToPartsFormatter =
|
155
|
+
Globalize.prototype.currencyToPartsFormatter = function( currency, options ) {
|
156
|
+
options = options || {};
|
157
|
+
return Globalize[
|
158
|
+
runtimeKey( "currencyToPartsFormatter", this._locale, [ currency, options ] )
|
159
|
+
];
|
160
|
+
};
|
161
|
+
|
162
|
+
Globalize.formatCurrency =
|
163
|
+
Globalize.prototype.formatCurrency = function( value, currency, options ) {
|
164
|
+
validateParameterPresence( value, "value" );
|
165
|
+
validateParameterTypeNumber( value, "value" );
|
166
|
+
|
167
|
+
return this.currencyFormatter( currency, options )( value );
|
168
|
+
};
|
169
|
+
|
170
|
+
Globalize.formatCurrencyToParts =
|
171
|
+
Globalize.prototype.formatCurrencyToParts = function( value, currency, options ) {
|
172
|
+
validateParameterPresence( value, "value" );
|
173
|
+
validateParameterTypeNumber( value, "value" );
|
174
|
+
|
175
|
+
return this.currencyToPartsFormatter( currency, options )( value );
|
176
|
+
};
|
177
|
+
|
178
|
+
return Globalize;
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
}));
|