intl-messageformat 1.0.3 → 1.3.0
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/README.md +45 -19
- package/dist/intl-messageformat-with-locales.js +1095 -346
- package/dist/intl-messageformat-with-locales.js.map +1 -1
- package/dist/intl-messageformat-with-locales.min.js +4 -2
- package/dist/intl-messageformat-with-locales.min.js.map +1 -1
- package/dist/intl-messageformat.js +309 -186
- package/dist/intl-messageformat.js.map +1 -1
- package/dist/intl-messageformat.min.js +1 -1
- package/dist/intl-messageformat.min.js.map +1 -1
- package/dist/locale-data/af.js +2 -1
- package/dist/locale-data/agq.js +1 -0
- package/dist/locale-data/ak.js +1 -1
- package/dist/locale-data/am.js +1 -1
- package/dist/locale-data/ar.js +28 -1
- package/dist/locale-data/as.js +1 -1
- package/dist/locale-data/asa.js +1 -1
- package/dist/locale-data/ast.js +1 -1
- package/dist/locale-data/az.js +4 -1
- package/dist/locale-data/bas.js +1 -0
- package/dist/locale-data/be.js +1 -1
- package/dist/locale-data/bem.js +1 -1
- package/dist/locale-data/bez.js +1 -1
- package/dist/locale-data/bg.js +1 -1
- package/dist/locale-data/bh.js +1 -0
- package/dist/locale-data/bm.js +2 -1
- package/dist/locale-data/bn.js +2 -1
- package/dist/locale-data/bo.js +2 -1
- package/dist/locale-data/br.js +1 -1
- package/dist/locale-data/brx.js +1 -1
- package/dist/locale-data/bs.js +3 -1
- package/dist/locale-data/ca.js +6 -1
- package/dist/locale-data/ce.js +1 -0
- package/dist/locale-data/cgg.js +1 -1
- package/dist/locale-data/chr.js +1 -1
- package/dist/locale-data/ckb.js +2 -0
- package/dist/locale-data/cs.js +1 -1
- package/dist/locale-data/cu.js +1 -0
- package/dist/locale-data/cy.js +1 -1
- package/dist/locale-data/da.js +2 -1
- package/dist/locale-data/dav.js +1 -0
- package/dist/locale-data/de.js +6 -1
- package/dist/locale-data/dje.js +1 -0
- package/dist/locale-data/dsb.js +1 -0
- package/dist/locale-data/dua.js +1 -0
- package/dist/locale-data/dv.js +1 -0
- package/dist/locale-data/dyo.js +1 -0
- package/dist/locale-data/dz.js +1 -1
- package/dist/locale-data/ebu.js +1 -0
- package/dist/locale-data/ee.js +2 -1
- package/dist/locale-data/el.js +2 -1
- package/dist/locale-data/en.js +107 -1
- package/dist/locale-data/eo.js +1 -1
- package/dist/locale-data/es.js +26 -1
- package/dist/locale-data/et.js +1 -1
- package/dist/locale-data/eu.js +1 -1
- package/dist/locale-data/ewo.js +1 -0
- package/dist/locale-data/fa.js +2 -1
- package/dist/locale-data/ff.js +4 -1
- package/dist/locale-data/fi.js +1 -1
- package/dist/locale-data/fil.js +1 -1
- package/dist/locale-data/fo.js +2 -1
- package/dist/locale-data/fr.js +46 -1
- package/dist/locale-data/fur.js +1 -1
- package/dist/locale-data/fy.js +1 -1
- package/dist/locale-data/ga.js +1 -1
- package/dist/locale-data/gd.js +1 -1
- package/dist/locale-data/gl.js +1 -1
- package/dist/locale-data/gsw.js +3 -1
- package/dist/locale-data/gu.js +1 -1
- package/dist/locale-data/guw.js +1 -0
- package/dist/locale-data/guz.js +1 -0
- package/dist/locale-data/gv.js +1 -1
- package/dist/locale-data/ha.js +4 -1
- package/dist/locale-data/haw.js +1 -1
- package/dist/locale-data/he.js +1 -1
- package/dist/locale-data/hi.js +1 -1
- package/dist/locale-data/hr.js +2 -1
- package/dist/locale-data/hsb.js +1 -0
- package/dist/locale-data/hu.js +1 -1
- package/dist/locale-data/hy.js +1 -1
- package/dist/locale-data/id.js +1 -1
- package/dist/locale-data/ig.js +1 -1
- package/dist/locale-data/ii.js +1 -1
- package/dist/locale-data/in.js +1 -0
- package/dist/locale-data/is.js +1 -1
- package/dist/locale-data/it.js +3 -1
- package/dist/locale-data/iu.js +2 -0
- package/dist/locale-data/iw.js +1 -0
- package/dist/locale-data/ja.js +1 -1
- package/dist/locale-data/jbo.js +1 -0
- package/dist/locale-data/jgo.js +1 -1
- package/dist/locale-data/ji.js +1 -0
- package/dist/locale-data/jmc.js +1 -1
- package/dist/locale-data/jv.js +1 -0
- package/dist/locale-data/jw.js +1 -0
- package/dist/locale-data/ka.js +1 -1
- package/dist/locale-data/kab.js +1 -1
- package/dist/locale-data/kaj.js +1 -0
- package/dist/locale-data/kam.js +1 -0
- package/dist/locale-data/kcg.js +1 -0
- package/dist/locale-data/kde.js +1 -1
- package/dist/locale-data/kea.js +1 -1
- package/dist/locale-data/khq.js +1 -0
- package/dist/locale-data/ki.js +1 -0
- package/dist/locale-data/kk.js +1 -1
- package/dist/locale-data/kkj.js +1 -1
- package/dist/locale-data/kl.js +1 -1
- package/dist/locale-data/kln.js +1 -0
- package/dist/locale-data/km.js +1 -1
- package/dist/locale-data/kn.js +1 -1
- package/dist/locale-data/ko.js +2 -1
- package/dist/locale-data/kok.js +1 -0
- package/dist/locale-data/ks.js +1 -1
- package/dist/locale-data/ksb.js +1 -1
- package/dist/locale-data/ksf.js +1 -0
- package/dist/locale-data/ksh.js +1 -1
- package/dist/locale-data/ku.js +1 -0
- package/dist/locale-data/kw.js +1 -1
- package/dist/locale-data/ky.js +1 -1
- package/dist/locale-data/lag.js +1 -1
- package/dist/locale-data/lb.js +1 -0
- package/dist/locale-data/lg.js +1 -1
- package/dist/locale-data/lkt.js +1 -1
- package/dist/locale-data/ln.js +4 -1
- package/dist/locale-data/lo.js +1 -1
- package/dist/locale-data/lrc.js +2 -0
- package/dist/locale-data/lt.js +1 -1
- package/dist/locale-data/lu.js +1 -0
- package/dist/locale-data/luo.js +1 -0
- package/dist/locale-data/luy.js +1 -0
- package/dist/locale-data/lv.js +1 -1
- package/dist/locale-data/mas.js +2 -1
- package/dist/locale-data/mer.js +1 -0
- package/dist/locale-data/mfe.js +1 -0
- package/dist/locale-data/mg.js +1 -1
- package/dist/locale-data/mgh.js +1 -0
- package/dist/locale-data/mgo.js +1 -1
- package/dist/locale-data/mk.js +1 -1
- package/dist/locale-data/ml.js +1 -1
- package/dist/locale-data/mn.js +2 -1
- package/dist/locale-data/mo.js +1 -0
- package/dist/locale-data/mr.js +1 -1
- package/dist/locale-data/ms.js +4 -1
- package/dist/locale-data/mt.js +1 -1
- package/dist/locale-data/mua.js +1 -0
- package/dist/locale-data/my.js +1 -1
- package/dist/locale-data/mzn.js +1 -0
- package/dist/locale-data/nah.js +1 -0
- package/dist/locale-data/naq.js +1 -1
- package/dist/locale-data/nb.js +2 -1
- package/dist/locale-data/nd.js +1 -1
- package/dist/locale-data/ne.js +2 -1
- package/dist/locale-data/nl.js +7 -1
- package/dist/locale-data/nmg.js +1 -0
- package/dist/locale-data/nn.js +1 -1
- package/dist/locale-data/nnh.js +1 -1
- package/dist/locale-data/no.js +1 -0
- package/dist/locale-data/nqo.js +1 -0
- package/dist/locale-data/nr.js +1 -1
- package/dist/locale-data/nso.js +1 -1
- package/dist/locale-data/nus.js +1 -0
- package/dist/locale-data/ny.js +1 -0
- package/dist/locale-data/nyn.js +1 -1
- package/dist/locale-data/om.js +2 -1
- package/dist/locale-data/or.js +1 -1
- package/dist/locale-data/os.js +2 -1
- package/dist/locale-data/pa.js +3 -1
- package/dist/locale-data/pap.js +1 -0
- package/dist/locale-data/pl.js +1 -1
- package/dist/locale-data/prg.js +1 -0
- package/dist/locale-data/ps.js +1 -1
- package/dist/locale-data/pt.js +9 -1
- package/dist/locale-data/qu.js +3 -0
- package/dist/locale-data/rm.js +1 -1
- package/dist/locale-data/rn.js +1 -0
- package/dist/locale-data/ro.js +2 -1
- package/dist/locale-data/rof.js +1 -1
- package/dist/locale-data/ru.js +6 -1
- package/dist/locale-data/rw.js +1 -0
- package/dist/locale-data/rwk.js +1 -1
- package/dist/locale-data/sah.js +1 -1
- package/dist/locale-data/saq.js +1 -1
- package/dist/locale-data/sbp.js +1 -0
- package/dist/locale-data/sdh.js +1 -0
- package/dist/locale-data/se.js +3 -1
- package/dist/locale-data/seh.js +1 -1
- package/dist/locale-data/ses.js +1 -1
- package/dist/locale-data/sg.js +1 -1
- package/dist/locale-data/sh.js +1 -0
- package/dist/locale-data/shi.js +3 -1
- package/dist/locale-data/si.js +1 -1
- package/dist/locale-data/sk.js +1 -1
- package/dist/locale-data/sl.js +1 -1
- package/dist/locale-data/sma.js +1 -0
- package/dist/locale-data/smi.js +1 -0
- package/dist/locale-data/smj.js +1 -0
- package/dist/locale-data/smn.js +1 -0
- package/dist/locale-data/sms.js +1 -0
- package/dist/locale-data/sn.js +1 -1
- package/dist/locale-data/so.js +4 -1
- package/dist/locale-data/sq.js +3 -1
- package/dist/locale-data/sr.js +9 -1
- package/dist/locale-data/ss.js +1 -1
- package/dist/locale-data/ssy.js +1 -1
- package/dist/locale-data/st.js +1 -1
- package/dist/locale-data/sv.js +3 -1
- package/dist/locale-data/sw.js +4 -1
- package/dist/locale-data/syr.js +1 -0
- package/dist/locale-data/ta.js +4 -1
- package/dist/locale-data/te.js +1 -1
- package/dist/locale-data/teo.js +2 -1
- package/dist/locale-data/th.js +1 -1
- package/dist/locale-data/ti.js +2 -1
- package/dist/locale-data/tig.js +1 -1
- package/dist/locale-data/tk.js +1 -0
- package/dist/locale-data/tl.js +1 -0
- package/dist/locale-data/tn.js +1 -1
- package/dist/locale-data/to.js +1 -1
- package/dist/locale-data/tr.js +2 -1
- package/dist/locale-data/ts.js +1 -1
- package/dist/locale-data/twq.js +1 -0
- package/dist/locale-data/tzm.js +1 -1
- package/dist/locale-data/ug.js +1 -1
- package/dist/locale-data/uk.js +1 -1
- package/dist/locale-data/ur.js +2 -1
- package/dist/locale-data/uz.js +4 -1
- package/dist/locale-data/vai.js +3 -0
- package/dist/locale-data/ve.js +1 -1
- package/dist/locale-data/vi.js +1 -1
- package/dist/locale-data/vo.js +1 -1
- package/dist/locale-data/vun.js +1 -1
- package/dist/locale-data/wa.js +1 -0
- package/dist/locale-data/wae.js +1 -1
- package/dist/locale-data/wo.js +1 -0
- package/dist/locale-data/xh.js +1 -1
- package/dist/locale-data/xog.js +1 -1
- package/dist/locale-data/yav.js +1 -0
- package/dist/locale-data/yi.js +1 -0
- package/dist/locale-data/yo.js +2 -1
- package/dist/locale-data/zgh.js +1 -0
- package/dist/locale-data/zh.js +8 -1
- package/dist/locale-data/zu.js +1 -1
- package/lib/compiler.js +21 -10
- package/lib/core.js +54 -35
- package/lib/en.js +2 -1
- package/lib/es5.js +8 -0
- package/lib/locales.js +554 -161
- package/lib/main.js +5 -3
- package/lib/utils.js +8 -0
- package/package.json +10 -9
- package/src/compiler.js +13 -10
- package/src/core.js +44 -33
- package/src/en.js +1 -1
- package/bower.json +0 -40
package/lib/main.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
/* jslint esnext: true */
|
|
2
|
+
|
|
1
3
|
"use strict";
|
|
2
4
|
var src$core$$ = require("./core"), src$en$$ = require("./en");
|
|
3
5
|
|
|
4
|
-
src$core
|
|
5
|
-
src$core
|
|
6
|
+
src$core$$["default"].__addLocaleData(src$en$$["default"]);
|
|
7
|
+
src$core$$["default"].defaultLocale = 'en';
|
|
6
8
|
|
|
7
|
-
exports["default"] = src$core
|
|
9
|
+
exports["default"] = src$core$$["default"];
|
|
8
10
|
|
|
9
11
|
//# sourceMappingURL=main.js.map
|
package/lib/utils.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
|
|
3
|
+
Copyrights licensed under the New BSD License.
|
|
4
|
+
See the accompanying LICENSE file for terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* jslint esnext: true */
|
|
8
|
+
|
|
1
9
|
"use strict";
|
|
2
10
|
exports.extend = extend;
|
|
3
11
|
var hop = Object.prototype.hasOwnProperty;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intl-messageformat",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -33,22 +33,23 @@
|
|
|
33
33
|
"./lib/locales.js": false
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"intl-messageformat-parser": "1.0
|
|
36
|
+
"intl-messageformat-parser": "1.2.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"benchmark": "^1.0.0",
|
|
40
40
|
"expect.js": "^0.3.1",
|
|
41
41
|
"grunt": "^0.4.5",
|
|
42
42
|
"grunt-benchmark": "^0.3.0",
|
|
43
|
-
"grunt-
|
|
43
|
+
"grunt-browserify": "^3.3.0",
|
|
44
|
+
"grunt-bundle-jsnext-lib": "^0.5.0",
|
|
44
45
|
"grunt-cli": "^0.1.13",
|
|
45
46
|
"grunt-contrib-clean": "^0.6.0",
|
|
46
47
|
"grunt-contrib-concat": "^0.5.0",
|
|
47
48
|
"grunt-contrib-connect": "^0.9.0",
|
|
48
|
-
"grunt-contrib-copy": "^0.
|
|
49
|
-
"grunt-contrib-jshint": "^0.
|
|
50
|
-
"grunt-contrib-uglify": "^0.
|
|
51
|
-
"grunt-extract-cldr-data": "^
|
|
49
|
+
"grunt-contrib-copy": "^0.8.0",
|
|
50
|
+
"grunt-contrib-jshint": "^0.11.0",
|
|
51
|
+
"grunt-contrib-uglify": "^0.8.0",
|
|
52
|
+
"grunt-extract-cldr-data": "^3.0.0",
|
|
52
53
|
"grunt-json-remove-fields": "git://github.com/ericf/grunt-json-remove-fields#improve-files-and-output",
|
|
53
54
|
"grunt-saucelabs": "^8.4.1",
|
|
54
55
|
"intl": "^0.1.4",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"xunit-file": "0.0.6"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
|
-
"test": "istanbul cover -x lib/locales.js --
|
|
61
|
+
"test": "istanbul cover -x lib/locales.js -- _mocha tests/runner.js --reporter spec",
|
|
61
62
|
"travis": "istanbul cover -x lib/locales.js -- _mocha tests/runner.js --reporter spec && tests/saucelabs.sh",
|
|
62
63
|
"prepublish": "grunt"
|
|
63
64
|
},
|
|
@@ -65,5 +66,5 @@
|
|
|
65
66
|
"directories": {
|
|
66
67
|
"test": "tests"
|
|
67
68
|
},
|
|
68
|
-
"license": "BSD"
|
|
69
|
+
"license": "BSD-3-Clause"
|
|
69
70
|
}
|
package/src/compiler.js
CHANGED
|
@@ -110,7 +110,9 @@ Compiler.prototype.compileArgument = function (element) {
|
|
|
110
110
|
|
|
111
111
|
case 'pluralFormat':
|
|
112
112
|
options = this.compileOptions(element);
|
|
113
|
-
return new PluralFormat(
|
|
113
|
+
return new PluralFormat(
|
|
114
|
+
element.id, format.ordinal, format.offset, options, pluralFn
|
|
115
|
+
);
|
|
114
116
|
|
|
115
117
|
case 'selectFormat':
|
|
116
118
|
options = this.compileOptions(element);
|
|
@@ -127,8 +129,8 @@ Compiler.prototype.compileOptions = function (element) {
|
|
|
127
129
|
optionsHash = {};
|
|
128
130
|
|
|
129
131
|
// Save the current plural element, if any, then set it to a new value when
|
|
130
|
-
// compiling the options sub-patterns. This
|
|
131
|
-
// for handling `"#"`
|
|
132
|
+
// compiling the options sub-patterns. This conforms the spec's algorithm
|
|
133
|
+
// for handling `"#"` syntax in message text.
|
|
132
134
|
this.pluralStack.push(this.currentPlural);
|
|
133
135
|
this.currentPlural = format.type === 'pluralFormat' ? element : null;
|
|
134
136
|
|
|
@@ -141,7 +143,7 @@ Compiler.prototype.compileOptions = function (element) {
|
|
|
141
143
|
optionsHash[option.selector] = this.compileMessage(option.value);
|
|
142
144
|
}
|
|
143
145
|
|
|
144
|
-
// Pop the plural stack to put back the original
|
|
146
|
+
// Pop the plural stack to put back the original current plural value.
|
|
145
147
|
this.currentPlural = this.pluralStack.pop();
|
|
146
148
|
|
|
147
149
|
return optionsHash;
|
|
@@ -161,18 +163,19 @@ StringFormat.prototype.format = function (value) {
|
|
|
161
163
|
return typeof value === 'string' ? value : String(value);
|
|
162
164
|
};
|
|
163
165
|
|
|
164
|
-
function PluralFormat(id, offset, options, pluralFn) {
|
|
165
|
-
this.id
|
|
166
|
-
this.
|
|
167
|
-
this.
|
|
168
|
-
this.
|
|
166
|
+
function PluralFormat(id, useOrdinal, offset, options, pluralFn) {
|
|
167
|
+
this.id = id;
|
|
168
|
+
this.useOrdinal = useOrdinal;
|
|
169
|
+
this.offset = offset;
|
|
170
|
+
this.options = options;
|
|
171
|
+
this.pluralFn = pluralFn;
|
|
169
172
|
}
|
|
170
173
|
|
|
171
174
|
PluralFormat.prototype.getOption = function (value) {
|
|
172
175
|
var options = this.options;
|
|
173
176
|
|
|
174
177
|
var option = options['=' + value] ||
|
|
175
|
-
options[this.pluralFn(value - this.offset)];
|
|
178
|
+
options[this.pluralFn(value - this.offset, this.useOrdinal)];
|
|
176
179
|
|
|
177
180
|
return option || options.other;
|
|
178
181
|
};
|
package/src/core.js
CHANGED
|
@@ -31,12 +31,11 @@ function MessageFormat(message, locales, formats) {
|
|
|
31
31
|
// Defined first because it's used to build the format pattern.
|
|
32
32
|
defineProperty(this, '_locale', {value: this._resolveLocale(locales)});
|
|
33
33
|
|
|
34
|
-
var pluralFn = MessageFormat.__localeData__[this._locale].pluralRuleFunction;
|
|
35
|
-
|
|
36
34
|
// Compile the `ast` to a pattern that is highly optimized for repeated
|
|
37
35
|
// `format()` invocations. **Note:** This passes the `locales` set provided
|
|
38
36
|
// to the constructor instead of just the resolved locale.
|
|
39
|
-
var
|
|
37
|
+
var pluralFn = this._findPluralRuleFunction(this._locale);
|
|
38
|
+
var pattern = this._compilePattern(ast, locales, formats, pluralFn);
|
|
40
39
|
|
|
41
40
|
// "Bind" `format()` method to `this` so it can be passed by reference like
|
|
42
41
|
// the other `Intl` APIs.
|
|
@@ -129,17 +128,7 @@ defineProperty(MessageFormat, '__addLocaleData', {value: function (data) {
|
|
|
129
128
|
);
|
|
130
129
|
}
|
|
131
130
|
|
|
132
|
-
|
|
133
|
-
throw new Error(
|
|
134
|
-
'Locale data provided to IntlMessageFormat is missing a ' +
|
|
135
|
-
'`pluralRuleFunction` property'
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Message format locale data only requires the first part of the tag.
|
|
140
|
-
var locale = data.locale.toLowerCase().split('-')[0];
|
|
141
|
-
|
|
142
|
-
MessageFormat.__localeData__[locale] = data;
|
|
131
|
+
MessageFormat.__localeData__[data.locale.toLowerCase()] = data;
|
|
143
132
|
}});
|
|
144
133
|
|
|
145
134
|
// Defines `__parse()` static method as an exposed private.
|
|
@@ -165,6 +154,26 @@ MessageFormat.prototype._compilePattern = function (ast, locales, formats, plura
|
|
|
165
154
|
return compiler.compile(ast);
|
|
166
155
|
};
|
|
167
156
|
|
|
157
|
+
MessageFormat.prototype._findPluralRuleFunction = function (locale) {
|
|
158
|
+
var localeData = MessageFormat.__localeData__;
|
|
159
|
+
var data = localeData[locale.toLowerCase()];
|
|
160
|
+
|
|
161
|
+
// The locale data is de-duplicated, so we have to traverse the locale's
|
|
162
|
+
// hierarchy until we find a `pluralRuleFunction` to return.
|
|
163
|
+
while (data) {
|
|
164
|
+
if (data.pluralRuleFunction) {
|
|
165
|
+
return data.pluralRuleFunction;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
data = data.parentLocale && localeData[data.parentLocale.toLowerCase()];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
throw new Error(
|
|
172
|
+
'Locale data added to IntlMessageFormat is missing a ' +
|
|
173
|
+
'`pluralRuleFunction` for :' + locale
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
168
177
|
MessageFormat.prototype._format = function (pattern, values) {
|
|
169
178
|
var result = '',
|
|
170
179
|
i, len, part, id, value;
|
|
@@ -218,37 +227,39 @@ MessageFormat.prototype._mergeFormats = function (defaults, formats) {
|
|
|
218
227
|
};
|
|
219
228
|
|
|
220
229
|
MessageFormat.prototype._resolveLocale = function (locales) {
|
|
221
|
-
if (!locales) {
|
|
222
|
-
locales = MessageFormat.defaultLocale;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
230
|
if (typeof locales === 'string') {
|
|
226
231
|
locales = [locales];
|
|
227
232
|
}
|
|
228
233
|
|
|
234
|
+
// Create a copy of the array so we can push on the default locale.
|
|
235
|
+
locales = (locales || []).concat(MessageFormat.defaultLocale);
|
|
236
|
+
|
|
229
237
|
var localeData = MessageFormat.__localeData__;
|
|
230
|
-
var i, len,
|
|
238
|
+
var i, len, localeParts, data;
|
|
231
239
|
|
|
240
|
+
// Using the set of locales + the default locale, we look for the first one
|
|
241
|
+
// which that has been registered. When data does not exist for a locale, we
|
|
242
|
+
// traverse its ancestors to find something that's been registered within
|
|
243
|
+
// its hierarchy of locales. Since we lack the proper `parentLocale` data
|
|
244
|
+
// here, we must take a naive approach to traversal.
|
|
232
245
|
for (i = 0, len = locales.length; i < len; i += 1) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
246
|
+
localeParts = locales[i].toLowerCase().split('-');
|
|
247
|
+
|
|
248
|
+
while (localeParts.length) {
|
|
249
|
+
data = localeData[localeParts.join('-')];
|
|
250
|
+
if (data) {
|
|
251
|
+
// Return the normalized locale string; e.g., we return "en-US",
|
|
252
|
+
// instead of "en-us".
|
|
253
|
+
return data.locale;
|
|
254
|
+
}
|
|
243
255
|
|
|
244
|
-
|
|
245
|
-
if (hop.call(localeData, locale)) {
|
|
246
|
-
return locale;
|
|
256
|
+
localeParts.pop();
|
|
247
257
|
}
|
|
248
258
|
}
|
|
249
259
|
|
|
260
|
+
var defaultLocale = locales.pop();
|
|
250
261
|
throw new Error(
|
|
251
262
|
'No locale data has been added to IntlMessageFormat for: ' +
|
|
252
|
-
locales.join(', ')
|
|
263
|
+
locales.join(', ') + ', or the default locale: ' + defaultLocale
|
|
253
264
|
);
|
|
254
265
|
};
|
package/src/en.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED FILE
|
|
2
|
-
export default {"locale":"en","pluralRuleFunction":function (n)
|
|
2
|
+
export default {"locale":"en","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1],t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2);if(ord)return n10==1&&n100!=11?"one":n10==2&&n100!=12?"two":n10==3&&n100!=13?"few":"other";return n==1&&v0?"one":"other"}};
|
package/bower.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "intl-messageformat",
|
|
3
|
-
"main": [
|
|
4
|
-
"dist/intl-messageformat.js"
|
|
5
|
-
],
|
|
6
|
-
"version": "1.0.1",
|
|
7
|
-
"homepage": "https://github.com/yahoo/intl-messageformat",
|
|
8
|
-
"authors": [
|
|
9
|
-
"Eric Ferraiuolo <eferraiuolo@gmail.com>",
|
|
10
|
-
"Drew Folta <drew@folta.net>",
|
|
11
|
-
"Caridy Patino <caridy@gmail.com>",
|
|
12
|
-
"Anthony Pipkin <a.pipkin@yahoo.com>"
|
|
13
|
-
],
|
|
14
|
-
"description": "Formats ICU Message strings with number, date, plural, and select placeholders to create localized messages.",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"i18n",
|
|
17
|
-
"intl",
|
|
18
|
-
"internationalization",
|
|
19
|
-
"localization",
|
|
20
|
-
"globalization",
|
|
21
|
-
"messageformat",
|
|
22
|
-
"parser",
|
|
23
|
-
"plural",
|
|
24
|
-
"icu"
|
|
25
|
-
],
|
|
26
|
-
"license": "BSD",
|
|
27
|
-
"ignore": [
|
|
28
|
-
"**/.*",
|
|
29
|
-
"!dist/*",
|
|
30
|
-
"node_modules",
|
|
31
|
-
"bower_components",
|
|
32
|
-
"test",
|
|
33
|
-
"tests"
|
|
34
|
-
],
|
|
35
|
-
"moduleType": [
|
|
36
|
-
"es6",
|
|
37
|
-
"commonjs",
|
|
38
|
-
"globals"
|
|
39
|
-
]
|
|
40
|
-
}
|