globalize-rpk 1.7.0 → 1.7.1

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.
Files changed (74) hide show
  1. package/globalize/currency.js +590 -0
  2. package/globalize/date.js +3139 -0
  3. package/globalize/globalize-runtime.js +326 -0
  4. package/globalize/globalize.js +507 -0
  5. package/globalize/message.js +2076 -0
  6. package/globalize/number.js +1727 -0
  7. package/globalize/plural.js +376 -0
  8. package/globalize/relative-time.js +203 -0
  9. package/globalize/unit.js +301 -0
  10. package/node-main.js +27 -0
  11. package/package.json +3 -26
  12. package/CONTRIBUTING.md +0 -5
  13. package/README.md +0 -818
  14. package/doc/api/core/constructor.md +0 -28
  15. package/doc/api/core/load.md +0 -96
  16. package/doc/api/core/locale.md +0 -43
  17. package/doc/api/currency/currency-formatter.md +0 -196
  18. package/doc/api/currency/currency-to-parts-formatter.md +0 -117
  19. package/doc/api/date/date-formatter.md +0 -203
  20. package/doc/api/date/date-parser.md +0 -60
  21. package/doc/api/date/date-to-parts-formatter.md +0 -176
  22. package/doc/api/date/load-iana-time-zone.md +0 -29
  23. package/doc/api/message/load-messages.md +0 -105
  24. package/doc/api/message/message-formatter.md +0 -208
  25. package/doc/api/number/number-formatter.md +0 -202
  26. package/doc/api/number/number-parser.md +0 -130
  27. package/doc/api/number/number-to-parts-formatter.md +0 -140
  28. package/doc/api/plural/plural-generator.md +0 -84
  29. package/doc/api/relative-time/relative-time-formatter.md +0 -60
  30. package/doc/api/unit/unit-formatter.md +0 -72
  31. package/doc/blog-post/2017-07-xx-1.3.0-announcement.md +0 -177
  32. package/doc/cldr.md +0 -114
  33. package/doc/error/e-default-locale-not-defined.md +0 -9
  34. package/doc/error/e-invalid-cldr.md +0 -14
  35. package/doc/error/e-invalid-par-type.md +0 -12
  36. package/doc/error/e-invalid-par-value.md +0 -11
  37. package/doc/error/e-missing-cldr.md +0 -11
  38. package/doc/error/e-missing-parameter.md +0 -10
  39. package/doc/error/e-missing-plural-module.md +0 -9
  40. package/doc/error/e-par-missing-key.md +0 -11
  41. package/doc/error/e-par-out-of-range.md +0 -13
  42. package/doc/error/e-unsupported.md +0 -10
  43. package/doc/migrating-from-0.x.md +0 -64
  44. package/examples/amd-bower/.bowerrc +0 -7
  45. package/examples/amd-bower/README.md +0 -65
  46. package/examples/amd-bower/bower.json +0 -13
  47. package/examples/amd-bower/index.html +0 -46
  48. package/examples/amd-bower/main.js +0 -141
  49. package/examples/amd-bower/messages/en.json +0 -12
  50. package/examples/amd-bower/package.json +0 -14
  51. package/examples/app-npm-webpack/README.md +0 -74
  52. package/examples/app-npm-webpack/app/index.js +0 -89
  53. package/examples/app-npm-webpack/index-template.html +0 -71
  54. package/examples/app-npm-webpack/messages/ar.json +0 -25
  55. package/examples/app-npm-webpack/messages/de.json +0 -21
  56. package/examples/app-npm-webpack/messages/en.json +0 -21
  57. package/examples/app-npm-webpack/messages/es.json +0 -21
  58. package/examples/app-npm-webpack/messages/pt.json +0 -21
  59. package/examples/app-npm-webpack/messages/ru.json +0 -23
  60. package/examples/app-npm-webpack/messages/zh.json +0 -20
  61. package/examples/app-npm-webpack/package.json +0 -17
  62. package/examples/app-npm-webpack/webpack-config.js +0 -63
  63. package/examples/globalize-compiler/README.md +0 -45
  64. package/examples/globalize-compiler/app.js +0 -58
  65. package/examples/globalize-compiler/development.html +0 -121
  66. package/examples/globalize-compiler/messages.json +0 -12
  67. package/examples/globalize-compiler/package.json +0 -15
  68. package/examples/globalize-compiler/production.html +0 -75
  69. package/examples/node-npm/README.md +0 -57
  70. package/examples/node-npm/main.js +0 -65
  71. package/examples/node-npm/messages/en.json +0 -12
  72. package/examples/node-npm/package.json +0 -10
  73. package/examples/plain-javascript/README.md +0 -81
  74. package/examples/plain-javascript/index.html +0 -445
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Globalize 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 v1.7.0 2021-08-02T11:53Z Released under the MIT license
14
+ * http://git.io/TrdQbw
15
+ */
16
+ (function( root, factory ) {
17
+
18
+ // UMD returnExports
19
+ if ( typeof define === "function" && define.amd ) {
20
+
21
+ // AMD
22
+ define([
23
+ "cldr",
24
+ "../globalize",
25
+ "./number",
26
+ "./plural"
27
+ ], factory );
28
+ } else if ( typeof exports === "object" ) {
29
+
30
+ // Node, CommonJS
31
+ module.exports = factory( require( "cldrjs" ), require( "../globalize" ) );
32
+ } else {
33
+
34
+ // Extend global
35
+ factory( root.Cldr, root.Globalize );
36
+ }
37
+ }(this, function( Cldr, Globalize ) {
38
+
39
+ var formatMessage = Globalize._formatMessage,
40
+ runtimeBind = Globalize._runtimeBind,
41
+ validateParameterPresence = Globalize._validateParameterPresence,
42
+ validateParameterTypePlainObject = Globalize._validateParameterTypePlainObject,
43
+ validateParameterTypeNumber = Globalize._validateParameterTypeNumber,
44
+ validateParameterTypeString = Globalize._validateParameterTypeString;
45
+
46
+
47
+ /**
48
+ * format( value, numberFormatter, pluralGenerator, unitProperies )
49
+ *
50
+ * @value [Number]
51
+ *
52
+ * @numberFormatter [Object]: A numberFormatter from Globalize.numberFormatter.
53
+ *
54
+ * @pluralGenerator [Object]: A pluralGenerator from Globalize.pluralGenerator.
55
+ *
56
+ * @unitProperies [Object]: localized unit data from cldr.
57
+ *
58
+ * Format units such as seconds, minutes, days, weeks, etc.
59
+ *
60
+ * OBS:
61
+ *
62
+ * Unit Sequences are not implemented.
63
+ * http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#Unit_Sequences
64
+ *
65
+ * Duration Unit (for composed time unit durations) is not implemented.
66
+ * http://www.unicode.org/reports/tr35/tr35-35/tr35-general.html#durationUnit
67
+ */
68
+ var unitFormat = function( value, numberFormatter, pluralGenerator, unitProperties ) {
69
+ var compoundUnitPattern = unitProperties.compoundUnitPattern, dividend, dividendProperties,
70
+ formattedValue, divisor, divisorProperties, message, pluralValue, oneProperty;
71
+
72
+ unitProperties = unitProperties.unitProperties;
73
+ formattedValue = numberFormatter( value );
74
+ pluralValue = pluralGenerator( value );
75
+
76
+ // computed compound unit, eg. "megabyte-per-second".
77
+ if ( unitProperties instanceof Array ) {
78
+ dividendProperties = unitProperties[ 0 ];
79
+ divisorProperties = unitProperties[ 1 ];
80
+ oneProperty = divisorProperties.hasOwnProperty( "one" ) ? "one" : "other";
81
+
82
+ dividend = formatMessage( dividendProperties[ pluralValue ], [ formattedValue ] );
83
+ divisor = formatMessage( divisorProperties[ oneProperty ], [ "" ] ).trim();
84
+
85
+ return formatMessage( compoundUnitPattern, [ dividend, divisor ] );
86
+ }
87
+
88
+ message = unitProperties[ pluralValue ];
89
+
90
+ return formatMessage( message, [ formattedValue ] );
91
+ };
92
+
93
+
94
+
95
+
96
+ var unitFormatterFn = function( numberFormatter, pluralGenerator, unitProperties ) {
97
+ return function unitFormatter( value ) {
98
+ validateParameterPresence( value, "value" );
99
+ validateParameterTypeNumber( value, "value" );
100
+
101
+ return unitFormat( value, numberFormatter, pluralGenerator, unitProperties );
102
+ };
103
+
104
+ };
105
+
106
+
107
+
108
+
109
+ /**
110
+ * categories()
111
+ *
112
+ * Return all unit categories.
113
+ */
114
+ var unitCategories = [ "acceleration", "angle", "area", "digital", "duration", "length", "mass", "power",
115
+ "pressure", "speed", "temperature", "volume" ];
116
+
117
+
118
+
119
+
120
+ function stripPluralGarbage( data ) {
121
+ var aux, pluralCount;
122
+
123
+ if ( data ) {
124
+ aux = {};
125
+ for ( pluralCount in data ) {
126
+ aux[ pluralCount.replace( /unitPattern-count-/, "" ) ] = data[ pluralCount ];
127
+ }
128
+ }
129
+
130
+ return aux;
131
+ }
132
+
133
+ /**
134
+ * get( unit, form, cldr )
135
+ *
136
+ * @unit [String] The full type-unit name (eg. duration-second), or the short unit name
137
+ * (eg. second).
138
+ *
139
+ * @form [String] A string describing the form of the unit representation (eg. long,
140
+ * short, narrow).
141
+ *
142
+ * @cldr [Cldr instance].
143
+ *
144
+ * Return the plural map of a unit, eg: "second"
145
+ * { "one": "{0} second",
146
+ * "other": "{0} seconds" }
147
+ * }
148
+ *
149
+ * Or the Array of plural maps of a compound-unit, eg: "foot-per-second"
150
+ * [ { "one": "{0} foot",
151
+ * "other": "{0} feet" },
152
+ * { "one": "{0} second",
153
+ * "other": "{0} seconds" } ]
154
+ *
155
+ * Uses the precomputed form of a compound-unit if available, eg: "mile-per-hour"
156
+ * { "displayName": "miles per hour",
157
+ * "unitPattern-count-one": "{0} mile per hour",
158
+ * "unitPattern-count-other": "{0} miles per hour"
159
+ * },
160
+ *
161
+ * Also supports "/" instead of "-per-", eg. "foot/second", using the precomputed form if
162
+ * available.
163
+ *
164
+ * Or the Array of plural maps of a compound-unit, eg: "foot-per-second"
165
+ * [ { "one": "{0} foot",
166
+ * "other": "{0} feet" },
167
+ * { "one": "{0} second",
168
+ * "other": "{0} seconds" } ]
169
+ *
170
+ * Or undefined in case the unit (or a unit of the compound-unit) doesn't exist.
171
+ */
172
+ var get = function( unit, form, cldr ) {
173
+ var ret;
174
+
175
+ // Ensure that we get the 'precomputed' form, if present.
176
+ unit = unit.replace( /\//, "-per-" );
177
+
178
+ // Get unit or <category>-unit (eg. "duration-second").
179
+ [ "" ].concat( unitCategories ).some(function( category ) {
180
+ return ret = cldr.main([
181
+ "units",
182
+ form,
183
+ category.length ? category + "-" + unit : unit
184
+ ]);
185
+ });
186
+
187
+ // Rename keys s/unitPattern-count-//g.
188
+ ret = stripPluralGarbage( ret );
189
+
190
+ // Compound Unit, eg. "foot-per-second" or "foot/second".
191
+ if ( !ret && ( /-per-/ ).test( unit ) ) {
192
+
193
+ // "Some units already have 'precomputed' forms, such as kilometer-per-hour;
194
+ // where such units exist, they should be used in preference" UTS#35.
195
+ // Note that precomputed form has already been handled above (!ret).
196
+
197
+ // Get both recursively.
198
+ unit = unit.split( "-per-" );
199
+ ret = unit.map(function( unit ) {
200
+ return get( unit, form, cldr );
201
+ });
202
+ if ( !ret[ 0 ] || !ret[ 1 ] ) {
203
+ return;
204
+ }
205
+ }
206
+
207
+ return ret;
208
+ };
209
+
210
+ var unitGet = get;
211
+
212
+
213
+
214
+
215
+ /**
216
+ * properties( unit, form, cldr )
217
+ *
218
+ * @unit [String] The full type-unit name (eg. duration-second), or the short unit name
219
+ * (eg. second).
220
+ *
221
+ * @form [String] A string describing the form of the unit representation (eg. long,
222
+ * short, narrow).
223
+ *
224
+ * @cldr [Cldr instance].
225
+ */
226
+ var unitProperties = function( unit, form, cldr ) {
227
+ var compoundUnitPattern, unitProperties;
228
+
229
+ compoundUnitPattern = cldr.main( [ "units", form, "per/compoundUnitPattern" ] );
230
+ unitProperties = unitGet( unit, form, cldr );
231
+
232
+ return {
233
+ compoundUnitPattern: compoundUnitPattern,
234
+ unitProperties: unitProperties
235
+ };
236
+ };
237
+
238
+
239
+
240
+
241
+ /**
242
+ * Globalize.formatUnit( value, unit, options )
243
+ *
244
+ * @value [Number]
245
+ *
246
+ * @unit [String]: The unit (e.g "second", "day", "year")
247
+ *
248
+ * @options [Object]
249
+ * - form: [String] "long", "short" (default), or "narrow".
250
+ *
251
+ * Format units such as seconds, minutes, days, weeks, etc.
252
+ */
253
+ Globalize.formatUnit =
254
+ Globalize.prototype.formatUnit = function( value, unit, options ) {
255
+ validateParameterPresence( value, "value" );
256
+ validateParameterTypeNumber( value, "value" );
257
+
258
+ return this.unitFormatter( unit, options )( value );
259
+ };
260
+
261
+ /**
262
+ * Globalize.unitFormatter( unit, options )
263
+ *
264
+ * @unit [String]: The unit (e.g "second", "day", "year")
265
+ *
266
+ * @options [Object]
267
+ * - form: [String] "long", "short" (default), or "narrow".
268
+ *
269
+ * - numberFormatter: [Function] a number formatter function. Defaults to Globalize
270
+ * `.numberFormatter()` for the current locale using the default options.
271
+ */
272
+ Globalize.unitFormatter =
273
+ Globalize.prototype.unitFormatter = function( unit, options ) {
274
+ var args, form, numberFormatter, pluralGenerator, returnFn, properties;
275
+
276
+ validateParameterPresence( unit, "unit" );
277
+ validateParameterTypeString( unit, "unit" );
278
+
279
+ validateParameterTypePlainObject( options, "options" );
280
+
281
+ options = options || {};
282
+
283
+ args = [ unit, options ];
284
+ form = options.form || "long";
285
+ properties = unitProperties( unit, form, this.cldr );
286
+
287
+ numberFormatter = options.numberFormatter || this.numberFormatter();
288
+ pluralGenerator = this.pluralGenerator();
289
+ returnFn = unitFormatterFn( numberFormatter, pluralGenerator, properties );
290
+
291
+ runtimeBind( args, this.cldr, returnFn, [ numberFormatter, pluralGenerator, properties ] );
292
+
293
+ return returnFn;
294
+ };
295
+
296
+ return Globalize;
297
+
298
+
299
+
300
+
301
+ }));
package/node-main.js ADDED
@@ -0,0 +1,27 @@
1
+ /*!
2
+ * Globalize 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
+ // Core
14
+ module.exports = require( "./globalize" );
15
+
16
+ // Extent core with the following modules
17
+ require( "./globalize/message" );
18
+ require( "./globalize/number" );
19
+ require( "./globalize/plural" );
20
+
21
+ // Load after globalize/number
22
+ require( "./globalize/currency" );
23
+ require( "./globalize/date" );
24
+
25
+ // Load after globalize/number and globalize/plural
26
+ require( "./globalize/relative-time" );
27
+ require( "./globalize/unit" );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "globalize-rpk",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Repackaged version of globalize to work with Angular projects without path-mapping. A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data.",
5
5
  "keywords": [
6
6
  "utility",
@@ -48,27 +48,7 @@
48
48
  "url": "http://rafael.xavier.blog.br"
49
49
  }
50
50
  ],
51
- "main": "./dist/node-main.js",
52
- "files": [
53
- "CONTRIBUTING.md",
54
- "dist/",
55
- "!dist/.build",
56
- "doc/",
57
- "examples/",
58
- "!examples/**/.tmp-globalize-webpack",
59
- "!examples/**/bower_components",
60
- "!examples/**/node_modules",
61
- "!examples/plain-javascript/cldrjs",
62
- "!examples/plain-javascript/globalize",
63
- "README.md"
64
- ],
65
- "repository": {
66
- "type": "git",
67
- "url": "git://github.com/globalizejs/globalize.git"
68
- },
69
- "bugs": {
70
- "url": "https://github.com/globalizejs/globalize/issues"
71
- },
51
+ "main": "./node-main.js",
72
52
  "dependencies": {
73
53
  "cldrjs": "^0.5.4"
74
54
  },
@@ -102,8 +82,5 @@
102
82
  "commitplease": {
103
83
  "nohook": true
104
84
  },
105
- "license": "MIT",
106
- "scripts": {
107
- "test": "grunt"
108
- }
85
+ "license": "MIT"
109
86
  }
package/CONTRIBUTING.md DELETED
@@ -1,5 +0,0 @@
1
- Welcome! Thanks for your interest in contributing to Globalize. More information on how to contribute to this and all other jQuery Foundation projects is over at [contribute.jquery.org](http://contribute.jquery.org). Before writing code for this project, be sure to read [Writing Code for jQuery Foundation Projects](http://contribute.jquery.org/code/).
2
-
3
- You may also want to take a look at our [commit & pull request guide](http://contribute.jquery.org/commits-and-pull-requests/) and [style guides](http://contribute.jquery.org/style-guide/) for instructions on how to maintain your fork and submit your code. Before we can merge any pull request, we'll also need you to sign our [contributor license agreement](http://contribute.jquery.org/cla).
4
-
5
- You can find us on [Slack](https://globalizejs.slack.com/). If you're new, [join here](https://join.slack.com/t/globalizejs/shared_invite/enQtMjk4OTUwNzM1Nzk0LTk2YmY0YjY3Yzk4YzU3M2NkMDZjNThlNzcwNTkyNGJhNDhiNjdkMWUyN2Q2MjVmNTk0ZjkyNGQ3MWEyNzNmMWU). If you've never contributed to open source before, we've put together [a short guide with tips, tricks, and ideas on getting started](http://contribute.jquery.org/open-source/).