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.
Files changed (254) hide show
  1. package/README.md +45 -19
  2. package/dist/intl-messageformat-with-locales.js +1095 -346
  3. package/dist/intl-messageformat-with-locales.js.map +1 -1
  4. package/dist/intl-messageformat-with-locales.min.js +4 -2
  5. package/dist/intl-messageformat-with-locales.min.js.map +1 -1
  6. package/dist/intl-messageformat.js +309 -186
  7. package/dist/intl-messageformat.js.map +1 -1
  8. package/dist/intl-messageformat.min.js +1 -1
  9. package/dist/intl-messageformat.min.js.map +1 -1
  10. package/dist/locale-data/af.js +2 -1
  11. package/dist/locale-data/agq.js +1 -0
  12. package/dist/locale-data/ak.js +1 -1
  13. package/dist/locale-data/am.js +1 -1
  14. package/dist/locale-data/ar.js +28 -1
  15. package/dist/locale-data/as.js +1 -1
  16. package/dist/locale-data/asa.js +1 -1
  17. package/dist/locale-data/ast.js +1 -1
  18. package/dist/locale-data/az.js +4 -1
  19. package/dist/locale-data/bas.js +1 -0
  20. package/dist/locale-data/be.js +1 -1
  21. package/dist/locale-data/bem.js +1 -1
  22. package/dist/locale-data/bez.js +1 -1
  23. package/dist/locale-data/bg.js +1 -1
  24. package/dist/locale-data/bh.js +1 -0
  25. package/dist/locale-data/bm.js +2 -1
  26. package/dist/locale-data/bn.js +2 -1
  27. package/dist/locale-data/bo.js +2 -1
  28. package/dist/locale-data/br.js +1 -1
  29. package/dist/locale-data/brx.js +1 -1
  30. package/dist/locale-data/bs.js +3 -1
  31. package/dist/locale-data/ca.js +6 -1
  32. package/dist/locale-data/ce.js +1 -0
  33. package/dist/locale-data/cgg.js +1 -1
  34. package/dist/locale-data/chr.js +1 -1
  35. package/dist/locale-data/ckb.js +2 -0
  36. package/dist/locale-data/cs.js +1 -1
  37. package/dist/locale-data/cu.js +1 -0
  38. package/dist/locale-data/cy.js +1 -1
  39. package/dist/locale-data/da.js +2 -1
  40. package/dist/locale-data/dav.js +1 -0
  41. package/dist/locale-data/de.js +6 -1
  42. package/dist/locale-data/dje.js +1 -0
  43. package/dist/locale-data/dsb.js +1 -0
  44. package/dist/locale-data/dua.js +1 -0
  45. package/dist/locale-data/dv.js +1 -0
  46. package/dist/locale-data/dyo.js +1 -0
  47. package/dist/locale-data/dz.js +1 -1
  48. package/dist/locale-data/ebu.js +1 -0
  49. package/dist/locale-data/ee.js +2 -1
  50. package/dist/locale-data/el.js +2 -1
  51. package/dist/locale-data/en.js +107 -1
  52. package/dist/locale-data/eo.js +1 -1
  53. package/dist/locale-data/es.js +26 -1
  54. package/dist/locale-data/et.js +1 -1
  55. package/dist/locale-data/eu.js +1 -1
  56. package/dist/locale-data/ewo.js +1 -0
  57. package/dist/locale-data/fa.js +2 -1
  58. package/dist/locale-data/ff.js +4 -1
  59. package/dist/locale-data/fi.js +1 -1
  60. package/dist/locale-data/fil.js +1 -1
  61. package/dist/locale-data/fo.js +2 -1
  62. package/dist/locale-data/fr.js +46 -1
  63. package/dist/locale-data/fur.js +1 -1
  64. package/dist/locale-data/fy.js +1 -1
  65. package/dist/locale-data/ga.js +1 -1
  66. package/dist/locale-data/gd.js +1 -1
  67. package/dist/locale-data/gl.js +1 -1
  68. package/dist/locale-data/gsw.js +3 -1
  69. package/dist/locale-data/gu.js +1 -1
  70. package/dist/locale-data/guw.js +1 -0
  71. package/dist/locale-data/guz.js +1 -0
  72. package/dist/locale-data/gv.js +1 -1
  73. package/dist/locale-data/ha.js +4 -1
  74. package/dist/locale-data/haw.js +1 -1
  75. package/dist/locale-data/he.js +1 -1
  76. package/dist/locale-data/hi.js +1 -1
  77. package/dist/locale-data/hr.js +2 -1
  78. package/dist/locale-data/hsb.js +1 -0
  79. package/dist/locale-data/hu.js +1 -1
  80. package/dist/locale-data/hy.js +1 -1
  81. package/dist/locale-data/id.js +1 -1
  82. package/dist/locale-data/ig.js +1 -1
  83. package/dist/locale-data/ii.js +1 -1
  84. package/dist/locale-data/in.js +1 -0
  85. package/dist/locale-data/is.js +1 -1
  86. package/dist/locale-data/it.js +3 -1
  87. package/dist/locale-data/iu.js +2 -0
  88. package/dist/locale-data/iw.js +1 -0
  89. package/dist/locale-data/ja.js +1 -1
  90. package/dist/locale-data/jbo.js +1 -0
  91. package/dist/locale-data/jgo.js +1 -1
  92. package/dist/locale-data/ji.js +1 -0
  93. package/dist/locale-data/jmc.js +1 -1
  94. package/dist/locale-data/jv.js +1 -0
  95. package/dist/locale-data/jw.js +1 -0
  96. package/dist/locale-data/ka.js +1 -1
  97. package/dist/locale-data/kab.js +1 -1
  98. package/dist/locale-data/kaj.js +1 -0
  99. package/dist/locale-data/kam.js +1 -0
  100. package/dist/locale-data/kcg.js +1 -0
  101. package/dist/locale-data/kde.js +1 -1
  102. package/dist/locale-data/kea.js +1 -1
  103. package/dist/locale-data/khq.js +1 -0
  104. package/dist/locale-data/ki.js +1 -0
  105. package/dist/locale-data/kk.js +1 -1
  106. package/dist/locale-data/kkj.js +1 -1
  107. package/dist/locale-data/kl.js +1 -1
  108. package/dist/locale-data/kln.js +1 -0
  109. package/dist/locale-data/km.js +1 -1
  110. package/dist/locale-data/kn.js +1 -1
  111. package/dist/locale-data/ko.js +2 -1
  112. package/dist/locale-data/kok.js +1 -0
  113. package/dist/locale-data/ks.js +1 -1
  114. package/dist/locale-data/ksb.js +1 -1
  115. package/dist/locale-data/ksf.js +1 -0
  116. package/dist/locale-data/ksh.js +1 -1
  117. package/dist/locale-data/ku.js +1 -0
  118. package/dist/locale-data/kw.js +1 -1
  119. package/dist/locale-data/ky.js +1 -1
  120. package/dist/locale-data/lag.js +1 -1
  121. package/dist/locale-data/lb.js +1 -0
  122. package/dist/locale-data/lg.js +1 -1
  123. package/dist/locale-data/lkt.js +1 -1
  124. package/dist/locale-data/ln.js +4 -1
  125. package/dist/locale-data/lo.js +1 -1
  126. package/dist/locale-data/lrc.js +2 -0
  127. package/dist/locale-data/lt.js +1 -1
  128. package/dist/locale-data/lu.js +1 -0
  129. package/dist/locale-data/luo.js +1 -0
  130. package/dist/locale-data/luy.js +1 -0
  131. package/dist/locale-data/lv.js +1 -1
  132. package/dist/locale-data/mas.js +2 -1
  133. package/dist/locale-data/mer.js +1 -0
  134. package/dist/locale-data/mfe.js +1 -0
  135. package/dist/locale-data/mg.js +1 -1
  136. package/dist/locale-data/mgh.js +1 -0
  137. package/dist/locale-data/mgo.js +1 -1
  138. package/dist/locale-data/mk.js +1 -1
  139. package/dist/locale-data/ml.js +1 -1
  140. package/dist/locale-data/mn.js +2 -1
  141. package/dist/locale-data/mo.js +1 -0
  142. package/dist/locale-data/mr.js +1 -1
  143. package/dist/locale-data/ms.js +4 -1
  144. package/dist/locale-data/mt.js +1 -1
  145. package/dist/locale-data/mua.js +1 -0
  146. package/dist/locale-data/my.js +1 -1
  147. package/dist/locale-data/mzn.js +1 -0
  148. package/dist/locale-data/nah.js +1 -0
  149. package/dist/locale-data/naq.js +1 -1
  150. package/dist/locale-data/nb.js +2 -1
  151. package/dist/locale-data/nd.js +1 -1
  152. package/dist/locale-data/ne.js +2 -1
  153. package/dist/locale-data/nl.js +7 -1
  154. package/dist/locale-data/nmg.js +1 -0
  155. package/dist/locale-data/nn.js +1 -1
  156. package/dist/locale-data/nnh.js +1 -1
  157. package/dist/locale-data/no.js +1 -0
  158. package/dist/locale-data/nqo.js +1 -0
  159. package/dist/locale-data/nr.js +1 -1
  160. package/dist/locale-data/nso.js +1 -1
  161. package/dist/locale-data/nus.js +1 -0
  162. package/dist/locale-data/ny.js +1 -0
  163. package/dist/locale-data/nyn.js +1 -1
  164. package/dist/locale-data/om.js +2 -1
  165. package/dist/locale-data/or.js +1 -1
  166. package/dist/locale-data/os.js +2 -1
  167. package/dist/locale-data/pa.js +3 -1
  168. package/dist/locale-data/pap.js +1 -0
  169. package/dist/locale-data/pl.js +1 -1
  170. package/dist/locale-data/prg.js +1 -0
  171. package/dist/locale-data/ps.js +1 -1
  172. package/dist/locale-data/pt.js +9 -1
  173. package/dist/locale-data/qu.js +3 -0
  174. package/dist/locale-data/rm.js +1 -1
  175. package/dist/locale-data/rn.js +1 -0
  176. package/dist/locale-data/ro.js +2 -1
  177. package/dist/locale-data/rof.js +1 -1
  178. package/dist/locale-data/ru.js +6 -1
  179. package/dist/locale-data/rw.js +1 -0
  180. package/dist/locale-data/rwk.js +1 -1
  181. package/dist/locale-data/sah.js +1 -1
  182. package/dist/locale-data/saq.js +1 -1
  183. package/dist/locale-data/sbp.js +1 -0
  184. package/dist/locale-data/sdh.js +1 -0
  185. package/dist/locale-data/se.js +3 -1
  186. package/dist/locale-data/seh.js +1 -1
  187. package/dist/locale-data/ses.js +1 -1
  188. package/dist/locale-data/sg.js +1 -1
  189. package/dist/locale-data/sh.js +1 -0
  190. package/dist/locale-data/shi.js +3 -1
  191. package/dist/locale-data/si.js +1 -1
  192. package/dist/locale-data/sk.js +1 -1
  193. package/dist/locale-data/sl.js +1 -1
  194. package/dist/locale-data/sma.js +1 -0
  195. package/dist/locale-data/smi.js +1 -0
  196. package/dist/locale-data/smj.js +1 -0
  197. package/dist/locale-data/smn.js +1 -0
  198. package/dist/locale-data/sms.js +1 -0
  199. package/dist/locale-data/sn.js +1 -1
  200. package/dist/locale-data/so.js +4 -1
  201. package/dist/locale-data/sq.js +3 -1
  202. package/dist/locale-data/sr.js +9 -1
  203. package/dist/locale-data/ss.js +1 -1
  204. package/dist/locale-data/ssy.js +1 -1
  205. package/dist/locale-data/st.js +1 -1
  206. package/dist/locale-data/sv.js +3 -1
  207. package/dist/locale-data/sw.js +4 -1
  208. package/dist/locale-data/syr.js +1 -0
  209. package/dist/locale-data/ta.js +4 -1
  210. package/dist/locale-data/te.js +1 -1
  211. package/dist/locale-data/teo.js +2 -1
  212. package/dist/locale-data/th.js +1 -1
  213. package/dist/locale-data/ti.js +2 -1
  214. package/dist/locale-data/tig.js +1 -1
  215. package/dist/locale-data/tk.js +1 -0
  216. package/dist/locale-data/tl.js +1 -0
  217. package/dist/locale-data/tn.js +1 -1
  218. package/dist/locale-data/to.js +1 -1
  219. package/dist/locale-data/tr.js +2 -1
  220. package/dist/locale-data/ts.js +1 -1
  221. package/dist/locale-data/twq.js +1 -0
  222. package/dist/locale-data/tzm.js +1 -1
  223. package/dist/locale-data/ug.js +1 -1
  224. package/dist/locale-data/uk.js +1 -1
  225. package/dist/locale-data/ur.js +2 -1
  226. package/dist/locale-data/uz.js +4 -1
  227. package/dist/locale-data/vai.js +3 -0
  228. package/dist/locale-data/ve.js +1 -1
  229. package/dist/locale-data/vi.js +1 -1
  230. package/dist/locale-data/vo.js +1 -1
  231. package/dist/locale-data/vun.js +1 -1
  232. package/dist/locale-data/wa.js +1 -0
  233. package/dist/locale-data/wae.js +1 -1
  234. package/dist/locale-data/wo.js +1 -0
  235. package/dist/locale-data/xh.js +1 -1
  236. package/dist/locale-data/xog.js +1 -1
  237. package/dist/locale-data/yav.js +1 -0
  238. package/dist/locale-data/yi.js +1 -0
  239. package/dist/locale-data/yo.js +2 -1
  240. package/dist/locale-data/zgh.js +1 -0
  241. package/dist/locale-data/zh.js +8 -1
  242. package/dist/locale-data/zu.js +1 -1
  243. package/lib/compiler.js +21 -10
  244. package/lib/core.js +54 -35
  245. package/lib/en.js +2 -1
  246. package/lib/es5.js +8 -0
  247. package/lib/locales.js +554 -161
  248. package/lib/main.js +5 -3
  249. package/lib/utils.js +8 -0
  250. package/package.json +10 -9
  251. package/src/compiler.js +13 -10
  252. package/src/core.js +44 -33
  253. package/src/en.js +1 -1
  254. package/bower.json +0 -40
@@ -159,7 +159,9 @@
159
159
 
160
160
  case 'pluralFormat':
161
161
  options = this.compileOptions(element);
162
- return new $$compiler$$PluralFormat(element.id, format.offset, options, pluralFn);
162
+ return new $$compiler$$PluralFormat(
163
+ element.id, format.ordinal, format.offset, options, pluralFn
164
+ );
163
165
 
164
166
  case 'selectFormat':
165
167
  options = this.compileOptions(element);
@@ -176,8 +178,8 @@
176
178
  optionsHash = {};
177
179
 
178
180
  // Save the current plural element, if any, then set it to a new value when
179
- // compiling the options sub-patterns. This conform's the spec's algorithm
180
- // for handling `"#"` synax in message text.
181
+ // compiling the options sub-patterns. This conforms the spec's algorithm
182
+ // for handling `"#"` syntax in message text.
181
183
  this.pluralStack.push(this.currentPlural);
182
184
  this.currentPlural = format.type === 'pluralFormat' ? element : null;
183
185
 
@@ -190,7 +192,7 @@
190
192
  optionsHash[option.selector] = this.compileMessage(option.value);
191
193
  }
192
194
 
193
- // Pop the plural stack to put back the original currnet plural value.
195
+ // Pop the plural stack to put back the original current plural value.
194
196
  this.currentPlural = this.pluralStack.pop();
195
197
 
196
198
  return optionsHash;
@@ -210,18 +212,19 @@
210
212
  return typeof value === 'string' ? value : String(value);
211
213
  };
212
214
 
213
- function $$compiler$$PluralFormat(id, offset, options, pluralFn) {
214
- this.id = id;
215
- this.offset = offset;
216
- this.options = options;
217
- this.pluralFn = pluralFn;
215
+ function $$compiler$$PluralFormat(id, useOrdinal, offset, options, pluralFn) {
216
+ this.id = id;
217
+ this.useOrdinal = useOrdinal;
218
+ this.offset = offset;
219
+ this.options = options;
220
+ this.pluralFn = pluralFn;
218
221
  }
219
222
 
220
223
  $$compiler$$PluralFormat.prototype.getOption = function (value) {
221
224
  var options = this.options;
222
225
 
223
226
  var option = options['=' + value] ||
224
- options[this.pluralFn(value - this.offset)];
227
+ options[this.pluralFn(value - this.offset, this.useOrdinal)];
225
228
 
226
229
  return option || options.other;
227
230
  };
@@ -343,67 +346,88 @@
343
346
  },
344
347
  peg$c22 = "plural",
345
348
  peg$c23 = { type: "literal", value: "plural", description: "\"plural\"" },
346
- peg$c24 = function(offset, options) {
349
+ peg$c24 = function(pluralStyle) {
347
350
  return {
348
- type : 'pluralFormat',
349
- offset : offset || 0,
350
- options: options
351
+ type : pluralStyle.type,
352
+ ordinal: false,
353
+ offset : pluralStyle.offset || 0,
354
+ options: pluralStyle.options
355
+ };
356
+ },
357
+ peg$c25 = "selectordinal",
358
+ peg$c26 = { type: "literal", value: "selectordinal", description: "\"selectordinal\"" },
359
+ peg$c27 = function(pluralStyle) {
360
+ return {
361
+ type : pluralStyle.type,
362
+ ordinal: true,
363
+ offset : pluralStyle.offset || 0,
364
+ options: pluralStyle.options
351
365
  }
352
366
  },
353
- peg$c25 = "select",
354
- peg$c26 = { type: "literal", value: "select", description: "\"select\"" },
355
- peg$c27 = function(options) {
367
+ peg$c28 = "select",
368
+ peg$c29 = { type: "literal", value: "select", description: "\"select\"" },
369
+ peg$c30 = function(options) {
356
370
  return {
357
371
  type : 'selectFormat',
358
372
  options: options
359
- }
373
+ };
360
374
  },
361
- peg$c28 = "=",
362
- peg$c29 = { type: "literal", value: "=", description: "\"=\"" },
363
- peg$c30 = function(selector, pattern) {
375
+ peg$c31 = "=",
376
+ peg$c32 = { type: "literal", value: "=", description: "\"=\"" },
377
+ peg$c33 = function(selector, pattern) {
364
378
  return {
365
379
  type : 'optionalFormatPattern',
366
380
  selector: selector,
367
381
  value : pattern
368
382
  };
369
383
  },
370
- peg$c31 = "offset:",
371
- peg$c32 = { type: "literal", value: "offset:", description: "\"offset:\"" },
372
- peg$c33 = function(number) {
384
+ peg$c34 = "offset:",
385
+ peg$c35 = { type: "literal", value: "offset:", description: "\"offset:\"" },
386
+ peg$c36 = function(number) {
373
387
  return number;
374
388
  },
375
- peg$c34 = { type: "other", description: "whitespace" },
376
- peg$c35 = /^[ \t\n\r]/,
377
- peg$c36 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
378
- peg$c37 = { type: "other", description: "optionalWhitespace" },
379
- peg$c38 = /^[0-9]/,
380
- peg$c39 = { type: "class", value: "[0-9]", description: "[0-9]" },
381
- peg$c40 = /^[0-9a-f]/i,
382
- peg$c41 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
383
- peg$c42 = "0",
384
- peg$c43 = { type: "literal", value: "0", description: "\"0\"" },
385
- peg$c44 = /^[1-9]/,
386
- peg$c45 = { type: "class", value: "[1-9]", description: "[1-9]" },
387
- peg$c46 = function(digits) {
389
+ peg$c37 = function(offset, options) {
390
+ return {
391
+ type : 'pluralFormat',
392
+ offset : offset,
393
+ options: options
394
+ };
395
+ },
396
+ peg$c38 = { type: "other", description: "whitespace" },
397
+ peg$c39 = /^[ \t\n\r]/,
398
+ peg$c40 = { type: "class", value: "[ \\t\\n\\r]", description: "[ \\t\\n\\r]" },
399
+ peg$c41 = { type: "other", description: "optionalWhitespace" },
400
+ peg$c42 = /^[0-9]/,
401
+ peg$c43 = { type: "class", value: "[0-9]", description: "[0-9]" },
402
+ peg$c44 = /^[0-9a-f]/i,
403
+ peg$c45 = { type: "class", value: "[0-9a-f]i", description: "[0-9a-f]i" },
404
+ peg$c46 = "0",
405
+ peg$c47 = { type: "literal", value: "0", description: "\"0\"" },
406
+ peg$c48 = /^[1-9]/,
407
+ peg$c49 = { type: "class", value: "[1-9]", description: "[1-9]" },
408
+ peg$c50 = function(digits) {
388
409
  return parseInt(digits, 10);
389
410
  },
390
- peg$c47 = /^[^{}\\\0-\x1F \t\n\r]/,
391
- peg$c48 = { type: "class", value: "[^{}\\\\\\0-\\x1F \\t\\n\\r]", description: "[^{}\\\\\\0-\\x1F \\t\\n\\r]" },
392
- peg$c49 = "\\#",
393
- peg$c50 = { type: "literal", value: "\\#", description: "\"\\\\#\"" },
394
- peg$c51 = function() { return '\\#'; },
395
- peg$c52 = "\\{",
396
- peg$c53 = { type: "literal", value: "\\{", description: "\"\\\\{\"" },
397
- peg$c54 = function() { return '\u007B'; },
398
- peg$c55 = "\\}",
399
- peg$c56 = { type: "literal", value: "\\}", description: "\"\\\\}\"" },
400
- peg$c57 = function() { return '\u007D'; },
401
- peg$c58 = "\\u",
402
- peg$c59 = { type: "literal", value: "\\u", description: "\"\\\\u\"" },
403
- peg$c60 = function(digits) {
411
+ peg$c51 = /^[^{}\\\0-\x1F \t\n\r]/,
412
+ peg$c52 = { type: "class", value: "[^{}\\\\\\0-\\x1F \\t\\n\\r]", description: "[^{}\\\\\\0-\\x1F \\t\\n\\r]" },
413
+ peg$c53 = "\\\\",
414
+ peg$c54 = { type: "literal", value: "\\\\", description: "\"\\\\\\\\\"" },
415
+ peg$c55 = function() { return '\\'; },
416
+ peg$c56 = "\\#",
417
+ peg$c57 = { type: "literal", value: "\\#", description: "\"\\\\#\"" },
418
+ peg$c58 = function() { return '\\#'; },
419
+ peg$c59 = "\\{",
420
+ peg$c60 = { type: "literal", value: "\\{", description: "\"\\\\{\"" },
421
+ peg$c61 = function() { return '\u007B'; },
422
+ peg$c62 = "\\}",
423
+ peg$c63 = { type: "literal", value: "\\}", description: "\"\\\\}\"" },
424
+ peg$c64 = function() { return '\u007D'; },
425
+ peg$c65 = "\\u",
426
+ peg$c66 = { type: "literal", value: "\\u", description: "\"\\\\u\"" },
427
+ peg$c67 = function(digits) {
404
428
  return String.fromCharCode(parseInt(digits, 16));
405
429
  },
406
- peg$c61 = function(chars) { return chars.join(''); },
430
+ peg$c68 = function(chars) { return chars.join(''); },
407
431
 
408
432
  peg$currPos = 0,
409
433
  peg$reportedPos = 0,
@@ -832,7 +856,10 @@
832
856
  if (s0 === peg$FAILED) {
833
857
  s0 = peg$parsepluralFormat();
834
858
  if (s0 === peg$FAILED) {
835
- s0 = peg$parseselectFormat();
859
+ s0 = peg$parseselectOrdinalFormat();
860
+ if (s0 === peg$FAILED) {
861
+ s0 = peg$parseselectFormat();
862
+ }
836
863
  }
837
864
  }
838
865
 
@@ -922,7 +949,7 @@
922
949
  }
923
950
 
924
951
  function peg$parsepluralFormat() {
925
- var s0, s1, s2, s3, s4, s5, s6, s7, s8;
952
+ var s0, s1, s2, s3, s4, s5;
926
953
 
927
954
  s0 = peg$currPos;
928
955
  if (input.substr(peg$currPos, 6) === peg$c22) {
@@ -945,35 +972,64 @@
945
972
  if (s3 !== peg$FAILED) {
946
973
  s4 = peg$parse_();
947
974
  if (s4 !== peg$FAILED) {
948
- s5 = peg$parseoffset();
949
- if (s5 === peg$FAILED) {
950
- s5 = peg$c9;
975
+ s5 = peg$parsepluralStyle();
976
+ if (s5 !== peg$FAILED) {
977
+ peg$reportedPos = s0;
978
+ s1 = peg$c24(s5);
979
+ s0 = s1;
980
+ } else {
981
+ peg$currPos = s0;
982
+ s0 = peg$c2;
951
983
  }
984
+ } else {
985
+ peg$currPos = s0;
986
+ s0 = peg$c2;
987
+ }
988
+ } else {
989
+ peg$currPos = s0;
990
+ s0 = peg$c2;
991
+ }
992
+ } else {
993
+ peg$currPos = s0;
994
+ s0 = peg$c2;
995
+ }
996
+ } else {
997
+ peg$currPos = s0;
998
+ s0 = peg$c2;
999
+ }
1000
+
1001
+ return s0;
1002
+ }
1003
+
1004
+ function peg$parseselectOrdinalFormat() {
1005
+ var s0, s1, s2, s3, s4, s5;
1006
+
1007
+ s0 = peg$currPos;
1008
+ if (input.substr(peg$currPos, 13) === peg$c25) {
1009
+ s1 = peg$c25;
1010
+ peg$currPos += 13;
1011
+ } else {
1012
+ s1 = peg$FAILED;
1013
+ if (peg$silentFails === 0) { peg$fail(peg$c26); }
1014
+ }
1015
+ if (s1 !== peg$FAILED) {
1016
+ s2 = peg$parse_();
1017
+ if (s2 !== peg$FAILED) {
1018
+ if (input.charCodeAt(peg$currPos) === 44) {
1019
+ s3 = peg$c10;
1020
+ peg$currPos++;
1021
+ } else {
1022
+ s3 = peg$FAILED;
1023
+ if (peg$silentFails === 0) { peg$fail(peg$c11); }
1024
+ }
1025
+ if (s3 !== peg$FAILED) {
1026
+ s4 = peg$parse_();
1027
+ if (s4 !== peg$FAILED) {
1028
+ s5 = peg$parsepluralStyle();
952
1029
  if (s5 !== peg$FAILED) {
953
- s6 = peg$parse_();
954
- if (s6 !== peg$FAILED) {
955
- s7 = [];
956
- s8 = peg$parseoptionalFormatPattern();
957
- if (s8 !== peg$FAILED) {
958
- while (s8 !== peg$FAILED) {
959
- s7.push(s8);
960
- s8 = peg$parseoptionalFormatPattern();
961
- }
962
- } else {
963
- s7 = peg$c2;
964
- }
965
- if (s7 !== peg$FAILED) {
966
- peg$reportedPos = s0;
967
- s1 = peg$c24(s5, s7);
968
- s0 = s1;
969
- } else {
970
- peg$currPos = s0;
971
- s0 = peg$c2;
972
- }
973
- } else {
974
- peg$currPos = s0;
975
- s0 = peg$c2;
976
- }
1030
+ peg$reportedPos = s0;
1031
+ s1 = peg$c27(s5);
1032
+ s0 = s1;
977
1033
  } else {
978
1034
  peg$currPos = s0;
979
1035
  s0 = peg$c2;
@@ -1002,12 +1058,12 @@
1002
1058
  var s0, s1, s2, s3, s4, s5, s6;
1003
1059
 
1004
1060
  s0 = peg$currPos;
1005
- if (input.substr(peg$currPos, 6) === peg$c25) {
1006
- s1 = peg$c25;
1061
+ if (input.substr(peg$currPos, 6) === peg$c28) {
1062
+ s1 = peg$c28;
1007
1063
  peg$currPos += 6;
1008
1064
  } else {
1009
1065
  s1 = peg$FAILED;
1010
- if (peg$silentFails === 0) { peg$fail(peg$c26); }
1066
+ if (peg$silentFails === 0) { peg$fail(peg$c29); }
1011
1067
  }
1012
1068
  if (s1 !== peg$FAILED) {
1013
1069
  s2 = peg$parse_();
@@ -1034,7 +1090,7 @@
1034
1090
  }
1035
1091
  if (s5 !== peg$FAILED) {
1036
1092
  peg$reportedPos = s0;
1037
- s1 = peg$c27(s5);
1093
+ s1 = peg$c30(s5);
1038
1094
  s0 = s1;
1039
1095
  } else {
1040
1096
  peg$currPos = s0;
@@ -1066,11 +1122,11 @@
1066
1122
  s0 = peg$currPos;
1067
1123
  s1 = peg$currPos;
1068
1124
  if (input.charCodeAt(peg$currPos) === 61) {
1069
- s2 = peg$c28;
1125
+ s2 = peg$c31;
1070
1126
  peg$currPos++;
1071
1127
  } else {
1072
1128
  s2 = peg$FAILED;
1073
- if (peg$silentFails === 0) { peg$fail(peg$c29); }
1129
+ if (peg$silentFails === 0) { peg$fail(peg$c32); }
1074
1130
  }
1075
1131
  if (s2 !== peg$FAILED) {
1076
1132
  s3 = peg$parsenumber();
@@ -1129,7 +1185,7 @@
1129
1185
  }
1130
1186
  if (s8 !== peg$FAILED) {
1131
1187
  peg$reportedPos = s0;
1132
- s1 = peg$c30(s2, s6);
1188
+ s1 = peg$c33(s2, s6);
1133
1189
  s0 = s1;
1134
1190
  } else {
1135
1191
  peg$currPos = s0;
@@ -1171,12 +1227,12 @@
1171
1227
  var s0, s1, s2, s3;
1172
1228
 
1173
1229
  s0 = peg$currPos;
1174
- if (input.substr(peg$currPos, 7) === peg$c31) {
1175
- s1 = peg$c31;
1230
+ if (input.substr(peg$currPos, 7) === peg$c34) {
1231
+ s1 = peg$c34;
1176
1232
  peg$currPos += 7;
1177
1233
  } else {
1178
1234
  s1 = peg$FAILED;
1179
- if (peg$silentFails === 0) { peg$fail(peg$c32); }
1235
+ if (peg$silentFails === 0) { peg$fail(peg$c35); }
1180
1236
  }
1181
1237
  if (s1 !== peg$FAILED) {
1182
1238
  s2 = peg$parse_();
@@ -1184,7 +1240,48 @@
1184
1240
  s3 = peg$parsenumber();
1185
1241
  if (s3 !== peg$FAILED) {
1186
1242
  peg$reportedPos = s0;
1187
- s1 = peg$c33(s3);
1243
+ s1 = peg$c36(s3);
1244
+ s0 = s1;
1245
+ } else {
1246
+ peg$currPos = s0;
1247
+ s0 = peg$c2;
1248
+ }
1249
+ } else {
1250
+ peg$currPos = s0;
1251
+ s0 = peg$c2;
1252
+ }
1253
+ } else {
1254
+ peg$currPos = s0;
1255
+ s0 = peg$c2;
1256
+ }
1257
+
1258
+ return s0;
1259
+ }
1260
+
1261
+ function peg$parsepluralStyle() {
1262
+ var s0, s1, s2, s3, s4;
1263
+
1264
+ s0 = peg$currPos;
1265
+ s1 = peg$parseoffset();
1266
+ if (s1 === peg$FAILED) {
1267
+ s1 = peg$c9;
1268
+ }
1269
+ if (s1 !== peg$FAILED) {
1270
+ s2 = peg$parse_();
1271
+ if (s2 !== peg$FAILED) {
1272
+ s3 = [];
1273
+ s4 = peg$parseoptionalFormatPattern();
1274
+ if (s4 !== peg$FAILED) {
1275
+ while (s4 !== peg$FAILED) {
1276
+ s3.push(s4);
1277
+ s4 = peg$parseoptionalFormatPattern();
1278
+ }
1279
+ } else {
1280
+ s3 = peg$c2;
1281
+ }
1282
+ if (s3 !== peg$FAILED) {
1283
+ peg$reportedPos = s0;
1284
+ s1 = peg$c37(s1, s3);
1188
1285
  s0 = s1;
1189
1286
  } else {
1190
1287
  peg$currPos = s0;
@@ -1207,22 +1304,22 @@
1207
1304
 
1208
1305
  peg$silentFails++;
1209
1306
  s0 = [];
1210
- if (peg$c35.test(input.charAt(peg$currPos))) {
1307
+ if (peg$c39.test(input.charAt(peg$currPos))) {
1211
1308
  s1 = input.charAt(peg$currPos);
1212
1309
  peg$currPos++;
1213
1310
  } else {
1214
1311
  s1 = peg$FAILED;
1215
- if (peg$silentFails === 0) { peg$fail(peg$c36); }
1312
+ if (peg$silentFails === 0) { peg$fail(peg$c40); }
1216
1313
  }
1217
1314
  if (s1 !== peg$FAILED) {
1218
1315
  while (s1 !== peg$FAILED) {
1219
1316
  s0.push(s1);
1220
- if (peg$c35.test(input.charAt(peg$currPos))) {
1317
+ if (peg$c39.test(input.charAt(peg$currPos))) {
1221
1318
  s1 = input.charAt(peg$currPos);
1222
1319
  peg$currPos++;
1223
1320
  } else {
1224
1321
  s1 = peg$FAILED;
1225
- if (peg$silentFails === 0) { peg$fail(peg$c36); }
1322
+ if (peg$silentFails === 0) { peg$fail(peg$c40); }
1226
1323
  }
1227
1324
  }
1228
1325
  } else {
@@ -1231,7 +1328,7 @@
1231
1328
  peg$silentFails--;
1232
1329
  if (s0 === peg$FAILED) {
1233
1330
  s1 = peg$FAILED;
1234
- if (peg$silentFails === 0) { peg$fail(peg$c34); }
1331
+ if (peg$silentFails === 0) { peg$fail(peg$c38); }
1235
1332
  }
1236
1333
 
1237
1334
  return s0;
@@ -1255,7 +1352,7 @@
1255
1352
  peg$silentFails--;
1256
1353
  if (s0 === peg$FAILED) {
1257
1354
  s1 = peg$FAILED;
1258
- if (peg$silentFails === 0) { peg$fail(peg$c37); }
1355
+ if (peg$silentFails === 0) { peg$fail(peg$c41); }
1259
1356
  }
1260
1357
 
1261
1358
  return s0;
@@ -1264,12 +1361,12 @@
1264
1361
  function peg$parsedigit() {
1265
1362
  var s0;
1266
1363
 
1267
- if (peg$c38.test(input.charAt(peg$currPos))) {
1364
+ if (peg$c42.test(input.charAt(peg$currPos))) {
1268
1365
  s0 = input.charAt(peg$currPos);
1269
1366
  peg$currPos++;
1270
1367
  } else {
1271
1368
  s0 = peg$FAILED;
1272
- if (peg$silentFails === 0) { peg$fail(peg$c39); }
1369
+ if (peg$silentFails === 0) { peg$fail(peg$c43); }
1273
1370
  }
1274
1371
 
1275
1372
  return s0;
@@ -1278,12 +1375,12 @@
1278
1375
  function peg$parsehexDigit() {
1279
1376
  var s0;
1280
1377
 
1281
- if (peg$c40.test(input.charAt(peg$currPos))) {
1378
+ if (peg$c44.test(input.charAt(peg$currPos))) {
1282
1379
  s0 = input.charAt(peg$currPos);
1283
1380
  peg$currPos++;
1284
1381
  } else {
1285
1382
  s0 = peg$FAILED;
1286
- if (peg$silentFails === 0) { peg$fail(peg$c41); }
1383
+ if (peg$silentFails === 0) { peg$fail(peg$c45); }
1287
1384
  }
1288
1385
 
1289
1386
  return s0;
@@ -1294,21 +1391,21 @@
1294
1391
 
1295
1392
  s0 = peg$currPos;
1296
1393
  if (input.charCodeAt(peg$currPos) === 48) {
1297
- s1 = peg$c42;
1394
+ s1 = peg$c46;
1298
1395
  peg$currPos++;
1299
1396
  } else {
1300
1397
  s1 = peg$FAILED;
1301
- if (peg$silentFails === 0) { peg$fail(peg$c43); }
1398
+ if (peg$silentFails === 0) { peg$fail(peg$c47); }
1302
1399
  }
1303
1400
  if (s1 === peg$FAILED) {
1304
1401
  s1 = peg$currPos;
1305
1402
  s2 = peg$currPos;
1306
- if (peg$c44.test(input.charAt(peg$currPos))) {
1403
+ if (peg$c48.test(input.charAt(peg$currPos))) {
1307
1404
  s3 = input.charAt(peg$currPos);
1308
1405
  peg$currPos++;
1309
1406
  } else {
1310
1407
  s3 = peg$FAILED;
1311
- if (peg$silentFails === 0) { peg$fail(peg$c45); }
1408
+ if (peg$silentFails === 0) { peg$fail(peg$c49); }
1312
1409
  }
1313
1410
  if (s3 !== peg$FAILED) {
1314
1411
  s4 = [];
@@ -1335,7 +1432,7 @@
1335
1432
  }
1336
1433
  if (s1 !== peg$FAILED) {
1337
1434
  peg$reportedPos = s0;
1338
- s1 = peg$c46(s1);
1435
+ s1 = peg$c50(s1);
1339
1436
  }
1340
1437
  s0 = s1;
1341
1438
 
@@ -1345,77 +1442,95 @@
1345
1442
  function peg$parsechar() {
1346
1443
  var s0, s1, s2, s3, s4, s5, s6, s7;
1347
1444
 
1348
- if (peg$c47.test(input.charAt(peg$currPos))) {
1445
+ if (peg$c51.test(input.charAt(peg$currPos))) {
1349
1446
  s0 = input.charAt(peg$currPos);
1350
1447
  peg$currPos++;
1351
1448
  } else {
1352
1449
  s0 = peg$FAILED;
1353
- if (peg$silentFails === 0) { peg$fail(peg$c48); }
1450
+ if (peg$silentFails === 0) { peg$fail(peg$c52); }
1354
1451
  }
1355
1452
  if (s0 === peg$FAILED) {
1356
1453
  s0 = peg$currPos;
1357
- if (input.substr(peg$currPos, 2) === peg$c49) {
1358
- s1 = peg$c49;
1454
+ if (input.substr(peg$currPos, 2) === peg$c53) {
1455
+ s1 = peg$c53;
1359
1456
  peg$currPos += 2;
1360
1457
  } else {
1361
1458
  s1 = peg$FAILED;
1362
- if (peg$silentFails === 0) { peg$fail(peg$c50); }
1459
+ if (peg$silentFails === 0) { peg$fail(peg$c54); }
1363
1460
  }
1364
1461
  if (s1 !== peg$FAILED) {
1365
1462
  peg$reportedPos = s0;
1366
- s1 = peg$c51();
1463
+ s1 = peg$c55();
1367
1464
  }
1368
1465
  s0 = s1;
1369
1466
  if (s0 === peg$FAILED) {
1370
1467
  s0 = peg$currPos;
1371
- if (input.substr(peg$currPos, 2) === peg$c52) {
1372
- s1 = peg$c52;
1468
+ if (input.substr(peg$currPos, 2) === peg$c56) {
1469
+ s1 = peg$c56;
1373
1470
  peg$currPos += 2;
1374
1471
  } else {
1375
1472
  s1 = peg$FAILED;
1376
- if (peg$silentFails === 0) { peg$fail(peg$c53); }
1473
+ if (peg$silentFails === 0) { peg$fail(peg$c57); }
1377
1474
  }
1378
1475
  if (s1 !== peg$FAILED) {
1379
1476
  peg$reportedPos = s0;
1380
- s1 = peg$c54();
1477
+ s1 = peg$c58();
1381
1478
  }
1382
1479
  s0 = s1;
1383
1480
  if (s0 === peg$FAILED) {
1384
1481
  s0 = peg$currPos;
1385
- if (input.substr(peg$currPos, 2) === peg$c55) {
1386
- s1 = peg$c55;
1482
+ if (input.substr(peg$currPos, 2) === peg$c59) {
1483
+ s1 = peg$c59;
1387
1484
  peg$currPos += 2;
1388
1485
  } else {
1389
1486
  s1 = peg$FAILED;
1390
- if (peg$silentFails === 0) { peg$fail(peg$c56); }
1487
+ if (peg$silentFails === 0) { peg$fail(peg$c60); }
1391
1488
  }
1392
1489
  if (s1 !== peg$FAILED) {
1393
1490
  peg$reportedPos = s0;
1394
- s1 = peg$c57();
1491
+ s1 = peg$c61();
1395
1492
  }
1396
1493
  s0 = s1;
1397
1494
  if (s0 === peg$FAILED) {
1398
1495
  s0 = peg$currPos;
1399
- if (input.substr(peg$currPos, 2) === peg$c58) {
1400
- s1 = peg$c58;
1496
+ if (input.substr(peg$currPos, 2) === peg$c62) {
1497
+ s1 = peg$c62;
1401
1498
  peg$currPos += 2;
1402
1499
  } else {
1403
1500
  s1 = peg$FAILED;
1404
- if (peg$silentFails === 0) { peg$fail(peg$c59); }
1501
+ if (peg$silentFails === 0) { peg$fail(peg$c63); }
1405
1502
  }
1406
1503
  if (s1 !== peg$FAILED) {
1407
- s2 = peg$currPos;
1408
- s3 = peg$currPos;
1409
- s4 = peg$parsehexDigit();
1410
- if (s4 !== peg$FAILED) {
1411
- s5 = peg$parsehexDigit();
1412
- if (s5 !== peg$FAILED) {
1413
- s6 = peg$parsehexDigit();
1414
- if (s6 !== peg$FAILED) {
1415
- s7 = peg$parsehexDigit();
1416
- if (s7 !== peg$FAILED) {
1417
- s4 = [s4, s5, s6, s7];
1418
- s3 = s4;
1504
+ peg$reportedPos = s0;
1505
+ s1 = peg$c64();
1506
+ }
1507
+ s0 = s1;
1508
+ if (s0 === peg$FAILED) {
1509
+ s0 = peg$currPos;
1510
+ if (input.substr(peg$currPos, 2) === peg$c65) {
1511
+ s1 = peg$c65;
1512
+ peg$currPos += 2;
1513
+ } else {
1514
+ s1 = peg$FAILED;
1515
+ if (peg$silentFails === 0) { peg$fail(peg$c66); }
1516
+ }
1517
+ if (s1 !== peg$FAILED) {
1518
+ s2 = peg$currPos;
1519
+ s3 = peg$currPos;
1520
+ s4 = peg$parsehexDigit();
1521
+ if (s4 !== peg$FAILED) {
1522
+ s5 = peg$parsehexDigit();
1523
+ if (s5 !== peg$FAILED) {
1524
+ s6 = peg$parsehexDigit();
1525
+ if (s6 !== peg$FAILED) {
1526
+ s7 = peg$parsehexDigit();
1527
+ if (s7 !== peg$FAILED) {
1528
+ s4 = [s4, s5, s6, s7];
1529
+ s3 = s4;
1530
+ } else {
1531
+ peg$currPos = s3;
1532
+ s3 = peg$c2;
1533
+ }
1419
1534
  } else {
1420
1535
  peg$currPos = s3;
1421
1536
  s3 = peg$c2;
@@ -1428,25 +1543,22 @@
1428
1543
  peg$currPos = s3;
1429
1544
  s3 = peg$c2;
1430
1545
  }
1431
- } else {
1432
- peg$currPos = s3;
1433
- s3 = peg$c2;
1434
- }
1435
- if (s3 !== peg$FAILED) {
1436
- s3 = input.substring(s2, peg$currPos);
1437
- }
1438
- s2 = s3;
1439
- if (s2 !== peg$FAILED) {
1440
- peg$reportedPos = s0;
1441
- s1 = peg$c60(s2);
1442
- s0 = s1;
1546
+ if (s3 !== peg$FAILED) {
1547
+ s3 = input.substring(s2, peg$currPos);
1548
+ }
1549
+ s2 = s3;
1550
+ if (s2 !== peg$FAILED) {
1551
+ peg$reportedPos = s0;
1552
+ s1 = peg$c67(s2);
1553
+ s0 = s1;
1554
+ } else {
1555
+ peg$currPos = s0;
1556
+ s0 = peg$c2;
1557
+ }
1443
1558
  } else {
1444
1559
  peg$currPos = s0;
1445
1560
  s0 = peg$c2;
1446
1561
  }
1447
- } else {
1448
- peg$currPos = s0;
1449
- s0 = peg$c2;
1450
1562
  }
1451
1563
  }
1452
1564
  }
@@ -1472,7 +1584,7 @@
1472
1584
  }
1473
1585
  if (s1 !== peg$FAILED) {
1474
1586
  peg$reportedPos = s0;
1475
- s1 = peg$c61(s1);
1587
+ s1 = peg$c68(s1);
1476
1588
  }
1477
1589
  s0 = s1;
1478
1590
 
@@ -1518,12 +1630,11 @@
1518
1630
  // Defined first because it's used to build the format pattern.
1519
1631
  $$es5$$defineProperty(this, '_locale', {value: this._resolveLocale(locales)});
1520
1632
 
1521
- var pluralFn = $$core$$MessageFormat.__localeData__[this._locale].pluralRuleFunction;
1522
-
1523
1633
  // Compile the `ast` to a pattern that is highly optimized for repeated
1524
1634
  // `format()` invocations. **Note:** This passes the `locales` set provided
1525
1635
  // to the constructor instead of just the resolved locale.
1526
- var pattern = this._compilePattern(ast, locales, formats, pluralFn);
1636
+ var pluralFn = this._findPluralRuleFunction(this._locale);
1637
+ var pattern = this._compilePattern(ast, locales, formats, pluralFn);
1527
1638
 
1528
1639
  // "Bind" `format()` method to `this` so it can be passed by reference like
1529
1640
  // the other `Intl` APIs.
@@ -1616,17 +1727,7 @@
1616
1727
  );
1617
1728
  }
1618
1729
 
1619
- if (!data.pluralRuleFunction) {
1620
- throw new Error(
1621
- 'Locale data provided to IntlMessageFormat is missing a ' +
1622
- '`pluralRuleFunction` property'
1623
- );
1624
- }
1625
-
1626
- // Message format locale data only requires the first part of the tag.
1627
- var locale = data.locale.toLowerCase().split('-')[0];
1628
-
1629
- $$core$$MessageFormat.__localeData__[locale] = data;
1730
+ $$core$$MessageFormat.__localeData__[data.locale.toLowerCase()] = data;
1630
1731
  }});
1631
1732
 
1632
1733
  // Defines `__parse()` static method as an exposed private.
@@ -1652,6 +1753,26 @@
1652
1753
  return compiler.compile(ast);
1653
1754
  };
1654
1755
 
1756
+ $$core$$MessageFormat.prototype._findPluralRuleFunction = function (locale) {
1757
+ var localeData = $$core$$MessageFormat.__localeData__;
1758
+ var data = localeData[locale.toLowerCase()];
1759
+
1760
+ // The locale data is de-duplicated, so we have to traverse the locale's
1761
+ // hierarchy until we find a `pluralRuleFunction` to return.
1762
+ while (data) {
1763
+ if (data.pluralRuleFunction) {
1764
+ return data.pluralRuleFunction;
1765
+ }
1766
+
1767
+ data = data.parentLocale && localeData[data.parentLocale.toLowerCase()];
1768
+ }
1769
+
1770
+ throw new Error(
1771
+ 'Locale data added to IntlMessageFormat is missing a ' +
1772
+ '`pluralRuleFunction` for :' + locale
1773
+ );
1774
+ };
1775
+
1655
1776
  $$core$$MessageFormat.prototype._format = function (pattern, values) {
1656
1777
  var result = '',
1657
1778
  i, len, part, id, value;
@@ -1705,41 +1826,43 @@
1705
1826
  };
1706
1827
 
1707
1828
  $$core$$MessageFormat.prototype._resolveLocale = function (locales) {
1708
- if (!locales) {
1709
- locales = $$core$$MessageFormat.defaultLocale;
1710
- }
1711
-
1712
1829
  if (typeof locales === 'string') {
1713
1830
  locales = [locales];
1714
1831
  }
1715
1832
 
1833
+ // Create a copy of the array so we can push on the default locale.
1834
+ locales = (locales || []).concat($$core$$MessageFormat.defaultLocale);
1835
+
1716
1836
  var localeData = $$core$$MessageFormat.__localeData__;
1717
- var i, len, locale;
1837
+ var i, len, localeParts, data;
1718
1838
 
1839
+ // Using the set of locales + the default locale, we look for the first one
1840
+ // which that has been registered. When data does not exist for a locale, we
1841
+ // traverse its ancestors to find something that's been registered within
1842
+ // its hierarchy of locales. Since we lack the proper `parentLocale` data
1843
+ // here, we must take a naive approach to traversal.
1719
1844
  for (i = 0, len = locales.length; i < len; i += 1) {
1720
- // We just need the root part of the langage tag.
1721
- locale = locales[i].split('-')[0].toLowerCase();
1722
-
1723
- // Validate that the langage tag is structurally valid.
1724
- if (!/[a-z]{2,3}/.test(locale)) {
1725
- throw new Error(
1726
- 'Language tag provided to IntlMessageFormat is not ' +
1727
- 'structrually valid: ' + locale
1728
- );
1729
- }
1845
+ localeParts = locales[i].toLowerCase().split('-');
1846
+
1847
+ while (localeParts.length) {
1848
+ data = localeData[localeParts.join('-')];
1849
+ if (data) {
1850
+ // Return the normalized locale string; e.g., we return "en-US",
1851
+ // instead of "en-us".
1852
+ return data.locale;
1853
+ }
1730
1854
 
1731
- // Return the first locale for which we have CLDR data registered.
1732
- if ($$utils$$hop.call(localeData, locale)) {
1733
- return locale;
1855
+ localeParts.pop();
1734
1856
  }
1735
1857
  }
1736
1858
 
1859
+ var defaultLocale = locales.pop();
1737
1860
  throw new Error(
1738
1861
  'No locale data has been added to IntlMessageFormat for: ' +
1739
- locales.join(', ')
1862
+ locales.join(', ') + ', or the default locale: ' + defaultLocale
1740
1863
  );
1741
1864
  };
1742
- var $$en$$default = {"locale":"en","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n)),v=n.toString().replace(/^[^.]*\.?/,"").length;n=Math.floor(n);if(i===1&&v===0)return"one";return"other";}};
1865
+ var $$en$$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"}};
1743
1866
 
1744
1867
  $$core$$default.__addLocaleData($$en$$default);
1745
1868
  $$core$$default.defaultLocale = 'en';