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
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"sbp","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"sdh","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1,3 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"se","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";if(n===2)return"two";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"se","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":n==2?"two":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"se-FI","parentLocale":"se"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"se-SE","parentLocale":"se"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"seh","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"seh","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ses","pluralRuleFunction":function (n) {return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ses","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sg","pluralRuleFunction":function (n) {return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sg","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"sh","pluralRuleFunction":function (n,ord){var s=String(n).split("."),i=s[0],f=s[1]||"",v0=!s[1],i10=i.slice(-1),i100=i.slice(-2),f10=f.slice(-1),f100=f.slice(-2);if(ord)return"other";return v0&&i10==1&&i100!=11||f10==1&&f100!=11?"one":v0&&(i10>=2&&i10<=4)&&(i100<12||i100>14)||f10>=2&&f10<=4&&(f100<12||f100>14)?"few":"other"}});
@@ -1 +1,3 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"shi","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n));n=Math.floor(n);if(i===0||n===1)return"one";if(n===Math.floor(n)&&n>=2&&n<=10)return"few";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"shi","pluralRuleFunction":function (n,ord){var s=String(n).split("."),t0=Number(s[0])==n;if(ord)return"other";return n>=0&&n<=1?"one":t0&&n>=2&&n<=10?"few":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"shi-Latn","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
3
+ IntlMessageFormat.__addLocaleData({"locale":"shi-Tfng","parentLocale":"shi"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"si","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n)),f=parseInt(n.toString().replace(/^[^.]*\.?/,""),10);n=Math.floor(n);if(n===0||n===1||i===0&&f===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"si","pluralRuleFunction":function (n,ord){var s=String(n).split("."),i=s[0],f=s[1]||"";if(ord)return"other";return n==0||n==1||i==0&&f==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sk","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";if(i===Math.floor(i)&&i>=2&&i<=4&&v===0)return"few";if((v!==0))return"many";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sk","pluralRuleFunction":function (n,ord){var s=String(n).split("."),i=s[0],v0=!s[1];if(ord)return"other";return n==1&&v0?"one":i>=2&&i<=4&&v0?"few":!v0?"many":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sl","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n)),v=n.toString().replace(/^[^.]*\.?/,"").length;n=Math.floor(n);if(v===0&&i%100===1)return"one";if(v===0&&i%100===2)return"two";if(v===0&&(i%100===Math.floor(i%100)&&i%100>=3&&i%100<=4||(v!==0)))return"few";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sl","pluralRuleFunction":function (n,ord){var s=String(n).split("."),i=s[0],v0=!s[1],i100=i.slice(-2);if(ord)return"other";return v0&&i100==1?"one":v0&&i100==2?"two":v0&&(i100==3||i100==4)||!v0?"few":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"sma","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":n==2?"two":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"smi","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":n==2?"two":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"smj","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":n==2?"two":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"smn","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":n==2?"two":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"sms","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":n==2?"two":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sn","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sn","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1,4 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"so","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"so","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"so-DJ","parentLocale":"so"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"so-ET","parentLocale":"so"});
4
+ IntlMessageFormat.__addLocaleData({"locale":"so-KE","parentLocale":"so"});
@@ -1 +1,3 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sq","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sq","pluralRuleFunction":function (n,ord){var s=String(n).split("."),t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2);if(ord)return n==1?"one":n10==4&&n100!=14?"many":"other";return n==1?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"sq-MK","parentLocale":"sq"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"sq-XK","parentLocale":"sq"});
@@ -1 +1,9 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sr","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n)),v=n.toString().replace(/^[^.]*\.?/,"").length,f=parseInt(n.toString().replace(/^[^.]*\.?/,""),10);n=Math.floor(n);if(v===0&&i%10===1&&((i%100!==11)||f%10===1&&(f%100!==11)))return"one";if(v===0&&i%10===Math.floor(i%10)&&i%10>=2&&i%10<=4&&(!(i%100>=12&&i%100<=14)||f%10===Math.floor(f%10)&&f%10>=2&&f%10<=4&&!(f%100>=12&&f%100<=14)))return"few";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sr","pluralRuleFunction":function (n,ord){var s=String(n).split("."),i=s[0],f=s[1]||"",v0=!s[1],i10=i.slice(-1),i100=i.slice(-2),f10=f.slice(-1),f100=f.slice(-2);if(ord)return"other";return v0&&i10==1&&i100!=11||f10==1&&f100!=11?"one":v0&&(i10>=2&&i10<=4)&&(i100<12||i100>14)||f10>=2&&f10<=4&&(f100<12||f100>14)?"few":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Cyrl","parentLocale":"sr"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Cyrl-BA","parentLocale":"sr-Cyrl"});
4
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Cyrl-ME","parentLocale":"sr-Cyrl"});
5
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Cyrl-XK","parentLocale":"sr-Cyrl"});
6
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Latn","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
7
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Latn-BA","parentLocale":"sr-Latn"});
8
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Latn-ME","parentLocale":"sr-Latn"});
9
+ IntlMessageFormat.__addLocaleData({"locale":"sr-Latn-XK","parentLocale":"sr-Latn"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ss","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ss","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ssy","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ssy","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"st","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"st","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1,3 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sv","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";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sv","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||n10==2)&&n100!=11&&n100!=12?"one":"other";return n==1&&v0?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"sv-AX","parentLocale":"sv"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"sv-FI","parentLocale":"sv"});
@@ -1 +1,4 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"sw","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";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"sw","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1];if(ord)return"other";return n==1&&v0?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"sw-CD","parentLocale":"sw"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"sw-KE","parentLocale":"sw"});
4
+ IntlMessageFormat.__addLocaleData({"locale":"sw-UG","parentLocale":"sw"});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"syr","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1,4 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ta","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ta","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"ta-LK","parentLocale":"ta"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"ta-MY","parentLocale":"ta"});
4
+ IntlMessageFormat.__addLocaleData({"locale":"ta-SG","parentLocale":"ta"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"te","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"te","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1,2 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"teo","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"teo","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"teo-KE","parentLocale":"teo"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"th","pluralRuleFunction":function (n) {return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"th","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -1 +1,2 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ti","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===Math.floor(n)&&n>=0&&n<=1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ti","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==0||n==1?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"ti-ER","parentLocale":"ti"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"tig","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"tig","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"tk","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"tl","pluralRuleFunction":function (n,ord){var s=String(n).split("."),i=s[0],f=s[1]||"",v0=!s[1],i10=i.slice(-1),f10=f.slice(-1);if(ord)return n==1?"one":"other";return v0&&(i==1||i==2||i==3)||v0&&i10!=4&&i10!=6&&i10!=9||!v0&&f10!=4&&f10!=6&&f10!=9?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"tn","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"tn","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"to","pluralRuleFunction":function (n) {return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"to","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -1 +1,2 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"tr","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"tr","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"tr-CY","parentLocale":"tr"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ts","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ts","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"twq","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"tzm","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===Math.floor(n)&&n>=0&&n<=1||n===Math.floor(n)&&n>=11&&n<=99)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"tzm","pluralRuleFunction":function (n,ord){var s=String(n).split("."),t0=Number(s[0])==n;if(ord)return"other";return n==0||n==1||t0&&n>=11&&n<=99?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ug","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ug","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"uk","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n)),v=n.toString().replace(/^[^.]*\.?/,"").length;n=Math.floor(n);if(v===0&&i%10===1&&(i%100!==11))return"one";if(v===0&&i%10===Math.floor(i%10)&&i%10>=2&&i%10<=4&&!(i%100>=12&&i%100<=14))return"few";if(v===0&&(i%10===0||v===0&&(i%10===Math.floor(i%10)&&i%10>=5&&i%10<=9||v===0&&i%100===Math.floor(i%100)&&i%100>=11&&i%100<=14)))return"many";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"uk","pluralRuleFunction":function (n,ord){var s=String(n).split("."),i=s[0],v0=!s[1],t0=Number(s[0])==n,n10=t0&&s[0].slice(-1),n100=t0&&s[0].slice(-2),i10=i.slice(-1),i100=i.slice(-2);if(ord)return n10==3&&n100!=13?"few":"other";return v0&&i10==1&&i100!=11?"one":v0&&(i10>=2&&i10<=4)&&(i100<12||i100>14)?"few":v0&&i10==0||v0&&(i10>=5&&i10<=9)||v0&&(i100>=11&&i100<=14)?"many":"other"}});
@@ -1 +1,2 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ur","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";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ur","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1];if(ord)return"other";return n==1&&v0?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"ur-IN","parentLocale":"ur"});
@@ -1 +1,4 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"uz","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"uz","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"uz-Arab","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
3
+ IntlMessageFormat.__addLocaleData({"locale":"uz-Cyrl","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
4
+ IntlMessageFormat.__addLocaleData({"locale":"uz-Latn","parentLocale":"uz"});
@@ -0,0 +1,3 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"vai","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"vai-Latn","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
3
+ IntlMessageFormat.__addLocaleData({"locale":"vai-Vaii","parentLocale":"vai"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"ve","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"ve","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"vi","pluralRuleFunction":function (n) {return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"vi","pluralRuleFunction":function (n,ord){if(ord)return n==1?"one":"other";return"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"vo","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"vo","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"vun","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"vun","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"wa","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==0||n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"wae","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"wae","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"wo","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"xh","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"xh","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"xog","pluralRuleFunction":function (n) {n=Math.floor(n);if(n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"xog","pluralRuleFunction":function (n,ord){if(ord)return"other";return n==1?"one":"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"yav","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"yi","pluralRuleFunction":function (n,ord){var s=String(n).split("."),v0=!s[1];if(ord)return"other";return n==1&&v0?"one":"other"}});
@@ -1 +1,2 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"yo","pluralRuleFunction":function (n) {return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"yo","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"yo-BJ","parentLocale":"yo"});
@@ -0,0 +1 @@
1
+ IntlMessageFormat.__addLocaleData({"locale":"zgh","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
@@ -1 +1,8 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"zh","pluralRuleFunction":function (n) {return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"zh","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
2
+ IntlMessageFormat.__addLocaleData({"locale":"zh-Hans","parentLocale":"zh"});
3
+ IntlMessageFormat.__addLocaleData({"locale":"zh-Hans-HK","parentLocale":"zh-Hans"});
4
+ IntlMessageFormat.__addLocaleData({"locale":"zh-Hans-MO","parentLocale":"zh-Hans"});
5
+ IntlMessageFormat.__addLocaleData({"locale":"zh-Hans-SG","parentLocale":"zh-Hans"});
6
+ IntlMessageFormat.__addLocaleData({"locale":"zh-Hant","pluralRuleFunction":function (n,ord){if(ord)return"other";return"other"}});
7
+ IntlMessageFormat.__addLocaleData({"locale":"zh-Hant-HK","parentLocale":"zh-Hant"});
8
+ IntlMessageFormat.__addLocaleData({"locale":"zh-Hant-MO","parentLocale":"zh-Hant-HK"});
@@ -1 +1 @@
1
- IntlMessageFormat.__addLocaleData({"locale":"zu","pluralRuleFunction":function (n) {var i=Math.floor(Math.abs(n));n=Math.floor(n);if(i===0||n===1)return"one";return"other";}});
1
+ IntlMessageFormat.__addLocaleData({"locale":"zu","pluralRuleFunction":function (n,ord){if(ord)return"other";return n>=0&&n<=1?"one":"other"}});
package/lib/compiler.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["default"] = Compiler;
3
11
 
@@ -103,7 +111,9 @@ Compiler.prototype.compileArgument = function (element) {
103
111
 
104
112
  case 'pluralFormat':
105
113
  options = this.compileOptions(element);
106
- return new PluralFormat(element.id, format.offset, options, pluralFn);
114
+ return new PluralFormat(
115
+ element.id, format.ordinal, format.offset, options, pluralFn
116
+ );
107
117
 
108
118
  case 'selectFormat':
109
119
  options = this.compileOptions(element);
@@ -120,8 +130,8 @@ Compiler.prototype.compileOptions = function (element) {
120
130
  optionsHash = {};
121
131
 
122
132
  // Save the current plural element, if any, then set it to a new value when
123
- // compiling the options sub-patterns. This conform's the spec's algorithm
124
- // for handling `"#"` synax in message text.
133
+ // compiling the options sub-patterns. This conforms the spec's algorithm
134
+ // for handling `"#"` syntax in message text.
125
135
  this.pluralStack.push(this.currentPlural);
126
136
  this.currentPlural = format.type === 'pluralFormat' ? element : null;
127
137
 
@@ -134,7 +144,7 @@ Compiler.prototype.compileOptions = function (element) {
134
144
  optionsHash[option.selector] = this.compileMessage(option.value);
135
145
  }
136
146
 
137
- // Pop the plural stack to put back the original currnet plural value.
147
+ // Pop the plural stack to put back the original current plural value.
138
148
  this.currentPlural = this.pluralStack.pop();
139
149
 
140
150
  return optionsHash;
@@ -154,18 +164,19 @@ StringFormat.prototype.format = function (value) {
154
164
  return typeof value === 'string' ? value : String(value);
155
165
  };
156
166
 
157
- function PluralFormat(id, offset, options, pluralFn) {
158
- this.id = id;
159
- this.offset = offset;
160
- this.options = options;
161
- this.pluralFn = pluralFn;
167
+ function PluralFormat(id, useOrdinal, offset, options, pluralFn) {
168
+ this.id = id;
169
+ this.useOrdinal = useOrdinal;
170
+ this.offset = offset;
171
+ this.options = options;
172
+ this.pluralFn = pluralFn;
162
173
  }
163
174
 
164
175
  PluralFormat.prototype.getOption = function (value) {
165
176
  var options = this.options;
166
177
 
167
178
  var option = options['=' + value] ||
168
- options[this.pluralFn(value - this.offset)];
179
+ options[this.pluralFn(value - this.offset, this.useOrdinal)];
169
180
 
170
181
  return option || options.other;
171
182
  };
package/lib/core.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
  var src$utils$$ = require("./utils"), src$es5$$ = require("./es5"), src$compiler$$ = require("./compiler"), intl$messageformat$parser$$ = require("intl-messageformat-parser");
3
11
  exports["default"] = MessageFormat;
@@ -20,12 +28,11 @@ function MessageFormat(message, locales, formats) {
20
28
  // Defined first because it's used to build the format pattern.
21
29
  src$es5$$.defineProperty(this, '_locale', {value: this._resolveLocale(locales)});
22
30
 
23
- var pluralFn = MessageFormat.__localeData__[this._locale].pluralRuleFunction;
24
-
25
31
  // Compile the `ast` to a pattern that is highly optimized for repeated
26
32
  // `format()` invocations. **Note:** This passes the `locales` set provided
27
33
  // to the constructor instead of just the resolved locale.
28
- var pattern = this._compilePattern(ast, locales, formats, pluralFn);
34
+ var pluralFn = this._findPluralRuleFunction(this._locale);
35
+ var pattern = this._compilePattern(ast, locales, formats, pluralFn);
29
36
 
30
37
  // "Bind" `format()` method to `this` so it can be passed by reference like
31
38
  // the other `Intl` APIs.
@@ -118,21 +125,11 @@ src$es5$$.defineProperty(MessageFormat, '__addLocaleData', {value: function (dat
118
125
  );
119
126
  }
120
127
 
121
- if (!data.pluralRuleFunction) {
122
- throw new Error(
123
- 'Locale data provided to IntlMessageFormat is missing a ' +
124
- '`pluralRuleFunction` property'
125
- );
126
- }
127
-
128
- // Message format locale data only requires the first part of the tag.
129
- var locale = data.locale.toLowerCase().split('-')[0];
130
-
131
- MessageFormat.__localeData__[locale] = data;
128
+ MessageFormat.__localeData__[data.locale.toLowerCase()] = data;
132
129
  }});
133
130
 
134
131
  // Defines `__parse()` static method as an exposed private.
135
- src$es5$$.defineProperty(MessageFormat, '__parse', {value: intl$messageformat$parser$$.default.parse});
132
+ src$es5$$.defineProperty(MessageFormat, '__parse', {value: intl$messageformat$parser$$["default"].parse});
136
133
 
137
134
  // Define public `defaultLocale` property which defaults to English, but can be
138
135
  // set by the developer.
@@ -150,10 +147,30 @@ MessageFormat.prototype.resolvedOptions = function () {
150
147
  };
151
148
 
152
149
  MessageFormat.prototype._compilePattern = function (ast, locales, formats, pluralFn) {
153
- var compiler = new src$compiler$$.default(locales, formats, pluralFn);
150
+ var compiler = new src$compiler$$["default"](locales, formats, pluralFn);
154
151
  return compiler.compile(ast);
155
152
  };
156
153
 
154
+ MessageFormat.prototype._findPluralRuleFunction = function (locale) {
155
+ var localeData = MessageFormat.__localeData__;
156
+ var data = localeData[locale.toLowerCase()];
157
+
158
+ // The locale data is de-duplicated, so we have to traverse the locale's
159
+ // hierarchy until we find a `pluralRuleFunction` to return.
160
+ while (data) {
161
+ if (data.pluralRuleFunction) {
162
+ return data.pluralRuleFunction;
163
+ }
164
+
165
+ data = data.parentLocale && localeData[data.parentLocale.toLowerCase()];
166
+ }
167
+
168
+ throw new Error(
169
+ 'Locale data added to IntlMessageFormat is missing a ' +
170
+ '`pluralRuleFunction` for :' + locale
171
+ );
172
+ };
173
+
157
174
  MessageFormat.prototype._format = function (pattern, values) {
158
175
  var result = '',
159
176
  i, len, part, id, value;
@@ -207,38 +224,40 @@ MessageFormat.prototype._mergeFormats = function (defaults, formats) {
207
224
  };
208
225
 
209
226
  MessageFormat.prototype._resolveLocale = function (locales) {
210
- if (!locales) {
211
- locales = MessageFormat.defaultLocale;
212
- }
213
-
214
227
  if (typeof locales === 'string') {
215
228
  locales = [locales];
216
229
  }
217
230
 
231
+ // Create a copy of the array so we can push on the default locale.
232
+ locales = (locales || []).concat(MessageFormat.defaultLocale);
233
+
218
234
  var localeData = MessageFormat.__localeData__;
219
- var i, len, locale;
235
+ var i, len, localeParts, data;
220
236
 
237
+ // Using the set of locales + the default locale, we look for the first one
238
+ // which that has been registered. When data does not exist for a locale, we
239
+ // traverse its ancestors to find something that's been registered within
240
+ // its hierarchy of locales. Since we lack the proper `parentLocale` data
241
+ // here, we must take a naive approach to traversal.
221
242
  for (i = 0, len = locales.length; i < len; i += 1) {
222
- // We just need the root part of the langage tag.
223
- locale = locales[i].split('-')[0].toLowerCase();
224
-
225
- // Validate that the langage tag is structurally valid.
226
- if (!/[a-z]{2,3}/.test(locale)) {
227
- throw new Error(
228
- 'Language tag provided to IntlMessageFormat is not ' +
229
- 'structrually valid: ' + locale
230
- );
231
- }
243
+ localeParts = locales[i].toLowerCase().split('-');
244
+
245
+ while (localeParts.length) {
246
+ data = localeData[localeParts.join('-')];
247
+ if (data) {
248
+ // Return the normalized locale string; e.g., we return "en-US",
249
+ // instead of "en-us".
250
+ return data.locale;
251
+ }
232
252
 
233
- // Return the first locale for which we have CLDR data registered.
234
- if (src$utils$$.hop.call(localeData, locale)) {
235
- return locale;
253
+ localeParts.pop();
236
254
  }
237
255
  }
238
256
 
257
+ var defaultLocale = locales.pop();
239
258
  throw new Error(
240
259
  'No locale data has been added to IntlMessageFormat for: ' +
241
- locales.join(', ')
260
+ locales.join(', ') + ', or the default locale: ' + defaultLocale
242
261
  );
243
262
  };
244
263
 
package/lib/en.js CHANGED
@@ -1,4 +1,5 @@
1
+ // GENERATED FILE
1
2
  "use strict";
2
- exports["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";}};
3
+ exports["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"}};
3
4
 
4
5
  //# sourceMappingURL=en.js.map
package/lib/es5.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
  var src$utils$$ = require("./utils");
3
11