@formatjs/intl-pluralrules 5.0.1 → 5.1.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/BUILD +465 -0
- package/CHANGELOG.md +659 -0
- package/LICENSE.md +0 -0
- package/README.md +0 -0
- package/abstract/GetOperands.ts +75 -0
- package/abstract/InitializePluralRules.ts +61 -0
- package/abstract/ResolvePlural.ts +47 -0
- package/get_internal_slots.ts +14 -0
- package/index.ts +174 -0
- package/package.json +8 -4
- package/polyfill-force.ts +8 -0
- package/polyfill.ts +11 -0
- package/scripts/cldr-raw.ts +70 -0
- package/scripts/cldr.ts +29 -0
- package/scripts/test262-main-gen.ts +28 -0
- package/should-polyfill.ts +21 -0
- package/supported-locales.generated.ts +1 -0
- package/test262-main.ts +1071 -0
- package/tests/index.test.ts +57 -0
- package/{locale-data/en.js → tests/locale-data/en.ts} +3 -4
- package/{locale-data/fr.js → tests/locale-data/fr.ts} +3 -4
- package/tests/locale-data/zh.ts +6 -0
- package/tests/supported-locales-of.test.ts +23 -0
- package/tsconfig.json +5 -0
- package/abstract/GetOperands.d.ts +0 -32
- package/abstract/GetOperands.d.ts.map +0 -1
- package/abstract/GetOperands.js +0 -50
- package/abstract/InitializePluralRules.d.ts +0 -9
- package/abstract/InitializePluralRules.d.ts.map +0 -1
- package/abstract/InitializePluralRules.js +0 -21
- package/abstract/ResolvePlural.d.ts +0 -13
- package/abstract/ResolvePlural.d.ts.map +0 -1
- package/abstract/ResolvePlural.js +0 -27
- package/get_internal_slots.d.ts +0 -3
- package/get_internal_slots.d.ts.map +0 -1
- package/get_internal_slots.js +0 -12
- package/index.d.ts +0 -21
- package/index.d.ts.map +0 -1
- package/index.js +0 -141
- package/lib/abstract/GetOperands.d.ts +0 -32
- package/lib/abstract/GetOperands.d.ts.map +0 -1
- package/lib/abstract/GetOperands.js +0 -46
- package/lib/abstract/InitializePluralRules.d.ts +0 -9
- package/lib/abstract/InitializePluralRules.d.ts.map +0 -1
- package/lib/abstract/InitializePluralRules.js +0 -17
- package/lib/abstract/ResolvePlural.d.ts +0 -13
- package/lib/abstract/ResolvePlural.d.ts.map +0 -1
- package/lib/abstract/ResolvePlural.js +0 -23
- package/lib/get_internal_slots.d.ts +0 -3
- package/lib/get_internal_slots.d.ts.map +0 -1
- package/lib/get_internal_slots.js +0 -9
- package/lib/index.d.ts +0 -21
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -138
- package/lib/polyfill-force.d.ts +0 -2
- package/lib/polyfill-force.d.ts.map +0 -1
- package/lib/polyfill-force.js +0 -7
- package/lib/polyfill.d.ts +0 -2
- package/lib/polyfill.d.ts.map +0 -1
- package/lib/polyfill.js +0 -10
- package/lib/should-polyfill.d.ts +0 -2
- package/lib/should-polyfill.d.ts.map +0 -1
- package/lib/should-polyfill.js +0 -18
- package/lib/supported-locales.d.ts +0 -2
- package/lib/supported-locales.d.ts.map +0 -1
- package/lib/supported-locales.js +0 -2
- package/locale-data/af.d.ts +0 -1
- package/locale-data/af.js +0 -8
- package/locale-data/ak.d.ts +0 -1
- package/locale-data/ak.js +0 -8
- package/locale-data/am.d.ts +0 -1
- package/locale-data/am.js +0 -8
- package/locale-data/an.d.ts +0 -1
- package/locale-data/an.js +0 -8
- package/locale-data/ar.d.ts +0 -1
- package/locale-data/ar.js +0 -14
- package/locale-data/ars.d.ts +0 -1
- package/locale-data/ars.js +0 -14
- package/locale-data/as.d.ts +0 -1
- package/locale-data/as.js +0 -12
- package/locale-data/asa.d.ts +0 -1
- package/locale-data/asa.js +0 -8
- package/locale-data/ast.d.ts +0 -1
- package/locale-data/ast.js +0 -9
- package/locale-data/az.d.ts +0 -1
- package/locale-data/az.js +0 -12
- package/locale-data/bal.d.ts +0 -1
- package/locale-data/bal.js +0 -7
- package/locale-data/be.d.ts +0 -1
- package/locale-data/be.js +0 -12
- package/locale-data/bem.d.ts +0 -1
- package/locale-data/bem.js +0 -8
- package/locale-data/bez.d.ts +0 -1
- package/locale-data/bez.js +0 -8
- package/locale-data/bg.d.ts +0 -1
- package/locale-data/bg.js +0 -8
- package/locale-data/bho.d.ts +0 -1
- package/locale-data/bho.js +0 -8
- package/locale-data/bm.d.ts +0 -1
- package/locale-data/bm.js +0 -7
- package/locale-data/bn.d.ts +0 -1
- package/locale-data/bn.js +0 -12
- package/locale-data/bo.d.ts +0 -1
- package/locale-data/bo.js +0 -7
- package/locale-data/br.d.ts +0 -1
- package/locale-data/br.js +0 -13
- package/locale-data/brx.d.ts +0 -1
- package/locale-data/brx.js +0 -8
- package/locale-data/bs.d.ts +0 -1
- package/locale-data/bs.js +0 -11
- package/locale-data/ca.d.ts +0 -1
- package/locale-data/ca.js +0 -12
- package/locale-data/ce.d.ts +0 -1
- package/locale-data/ce.js +0 -8
- package/locale-data/ceb.d.ts +0 -1
- package/locale-data/ceb.js +0 -9
- package/locale-data/cgg.d.ts +0 -1
- package/locale-data/cgg.js +0 -8
- package/locale-data/chr.d.ts +0 -1
- package/locale-data/chr.js +0 -8
- package/locale-data/ckb.d.ts +0 -1
- package/locale-data/ckb.js +0 -8
- package/locale-data/cs.d.ts +0 -1
- package/locale-data/cs.js +0 -12
- package/locale-data/cy.d.ts +0 -1
- package/locale-data/cy.js +0 -18
- package/locale-data/da.d.ts +0 -1
- package/locale-data/da.js +0 -9
- package/locale-data/de.d.ts +0 -1
- package/locale-data/de.js +0 -9
- package/locale-data/doi.d.ts +0 -1
- package/locale-data/doi.js +0 -8
- package/locale-data/dsb.d.ts +0 -1
- package/locale-data/dsb.js +0 -12
- package/locale-data/dv.d.ts +0 -1
- package/locale-data/dv.js +0 -8
- package/locale-data/dz.d.ts +0 -1
- package/locale-data/dz.js +0 -7
- package/locale-data/ee.d.ts +0 -1
- package/locale-data/ee.js +0 -8
- package/locale-data/el.d.ts +0 -1
- package/locale-data/el.js +0 -8
- package/locale-data/en.d.ts +0 -1
- package/locale-data/eo.d.ts +0 -1
- package/locale-data/eo.js +0 -8
- package/locale-data/es.d.ts +0 -1
- package/locale-data/es.js +0 -11
- package/locale-data/et.d.ts +0 -1
- package/locale-data/et.js +0 -9
- package/locale-data/eu.d.ts +0 -1
- package/locale-data/eu.js +0 -8
- package/locale-data/fa.d.ts +0 -1
- package/locale-data/fa.js +0 -8
- package/locale-data/ff.d.ts +0 -1
- package/locale-data/ff.js +0 -8
- package/locale-data/fi.d.ts +0 -1
- package/locale-data/fi.js +0 -9
- package/locale-data/fil.d.ts +0 -1
- package/locale-data/fil.js +0 -9
- package/locale-data/fo.d.ts +0 -1
- package/locale-data/fo.js +0 -8
- package/locale-data/fr.d.ts +0 -1
- package/locale-data/fur.d.ts +0 -1
- package/locale-data/fur.js +0 -8
- package/locale-data/fy.d.ts +0 -1
- package/locale-data/fy.js +0 -9
- package/locale-data/ga.d.ts +0 -1
- package/locale-data/ga.js +0 -13
- package/locale-data/gd.d.ts +0 -1
- package/locale-data/gd.js +0 -15
- package/locale-data/gl.d.ts +0 -1
- package/locale-data/gl.js +0 -9
- package/locale-data/gsw.d.ts +0 -1
- package/locale-data/gsw.js +0 -8
- package/locale-data/gu.d.ts +0 -1
- package/locale-data/gu.js +0 -12
- package/locale-data/guw.d.ts +0 -1
- package/locale-data/guw.js +0 -8
- package/locale-data/gv.d.ts +0 -1
- package/locale-data/gv.js +0 -13
- package/locale-data/ha.d.ts +0 -1
- package/locale-data/ha.js +0 -8
- package/locale-data/haw.d.ts +0 -1
- package/locale-data/haw.js +0 -8
- package/locale-data/he.d.ts +0 -1
- package/locale-data/he.js +0 -12
- package/locale-data/hi.d.ts +0 -1
- package/locale-data/hi.js +0 -12
- package/locale-data/hnj.d.ts +0 -1
- package/locale-data/hnj.js +0 -7
- package/locale-data/hr.d.ts +0 -1
- package/locale-data/hr.js +0 -11
- package/locale-data/hsb.d.ts +0 -1
- package/locale-data/hsb.js +0 -12
- package/locale-data/hu.d.ts +0 -1
- package/locale-data/hu.js +0 -8
- package/locale-data/hy.d.ts +0 -1
- package/locale-data/hy.js +0 -8
- package/locale-data/ia.d.ts +0 -1
- package/locale-data/ia.js +0 -9
- package/locale-data/id.d.ts +0 -1
- package/locale-data/id.js +0 -7
- package/locale-data/ig.d.ts +0 -1
- package/locale-data/ig.js +0 -7
- package/locale-data/ii.d.ts +0 -1
- package/locale-data/ii.js +0 -7
- package/locale-data/io.d.ts +0 -1
- package/locale-data/io.js +0 -9
- package/locale-data/is.d.ts +0 -1
- package/locale-data/is.js +0 -9
- package/locale-data/it.d.ts +0 -1
- package/locale-data/it.js +0 -11
- package/locale-data/iu.d.ts +0 -1
- package/locale-data/iu.js +0 -10
- package/locale-data/ja.d.ts +0 -1
- package/locale-data/ja.js +0 -7
- package/locale-data/jbo.d.ts +0 -1
- package/locale-data/jbo.js +0 -7
- package/locale-data/jgo.d.ts +0 -1
- package/locale-data/jgo.js +0 -8
- package/locale-data/jmc.d.ts +0 -1
- package/locale-data/jmc.js +0 -8
- package/locale-data/jv.d.ts +0 -1
- package/locale-data/jv.js +0 -7
- package/locale-data/jw.d.ts +0 -1
- package/locale-data/jw.js +0 -7
- package/locale-data/ka.d.ts +0 -1
- package/locale-data/ka.js +0 -11
- package/locale-data/kab.d.ts +0 -1
- package/locale-data/kab.js +0 -8
- package/locale-data/kaj.d.ts +0 -1
- package/locale-data/kaj.js +0 -8
- package/locale-data/kcg.d.ts +0 -1
- package/locale-data/kcg.js +0 -8
- package/locale-data/kde.d.ts +0 -1
- package/locale-data/kde.js +0 -7
- package/locale-data/kea.d.ts +0 -1
- package/locale-data/kea.js +0 -7
- package/locale-data/kk.d.ts +0 -1
- package/locale-data/kk.js +0 -9
- package/locale-data/kkj.d.ts +0 -1
- package/locale-data/kkj.js +0 -8
- package/locale-data/kl.d.ts +0 -1
- package/locale-data/kl.js +0 -8
- package/locale-data/km.d.ts +0 -1
- package/locale-data/km.js +0 -7
- package/locale-data/kn.d.ts +0 -1
- package/locale-data/kn.js +0 -8
- package/locale-data/ko.d.ts +0 -1
- package/locale-data/ko.js +0 -7
- package/locale-data/ks.d.ts +0 -1
- package/locale-data/ks.js +0 -8
- package/locale-data/ksb.d.ts +0 -1
- package/locale-data/ksb.js +0 -8
- package/locale-data/ksh.d.ts +0 -1
- package/locale-data/ksh.js +0 -10
- package/locale-data/ku.d.ts +0 -1
- package/locale-data/ku.js +0 -8
- package/locale-data/kw.d.ts +0 -1
- package/locale-data/kw.js +0 -16
- package/locale-data/ky.d.ts +0 -1
- package/locale-data/ky.js +0 -8
- package/locale-data/lag.d.ts +0 -1
- package/locale-data/lag.js +0 -11
- package/locale-data/lb.d.ts +0 -1
- package/locale-data/lb.js +0 -8
- package/locale-data/lg.d.ts +0 -1
- package/locale-data/lg.js +0 -8
- package/locale-data/lij.d.ts +0 -1
- package/locale-data/lij.js +0 -9
- package/locale-data/lkt.d.ts +0 -1
- package/locale-data/lkt.js +0 -7
- package/locale-data/ln.d.ts +0 -1
- package/locale-data/ln.js +0 -8
- package/locale-data/lo.d.ts +0 -1
- package/locale-data/lo.js +0 -8
- package/locale-data/lt.d.ts +0 -1
- package/locale-data/lt.js +0 -12
- package/locale-data/lv.d.ts +0 -1
- package/locale-data/lv.js +0 -11
- package/locale-data/mas.d.ts +0 -1
- package/locale-data/mas.js +0 -8
- package/locale-data/mg.d.ts +0 -1
- package/locale-data/mg.js +0 -8
- package/locale-data/mgo.d.ts +0 -1
- package/locale-data/mgo.js +0 -8
- package/locale-data/mk.d.ts +0 -1
- package/locale-data/mk.js +0 -12
- package/locale-data/ml.d.ts +0 -1
- package/locale-data/ml.js +0 -8
- package/locale-data/mn.d.ts +0 -1
- package/locale-data/mn.js +0 -8
- package/locale-data/mo.d.ts +0 -1
- package/locale-data/mo.js +0 -11
- package/locale-data/mr.d.ts +0 -1
- package/locale-data/mr.js +0 -11
- package/locale-data/ms.d.ts +0 -1
- package/locale-data/ms.js +0 -8
- package/locale-data/mt.d.ts +0 -1
- package/locale-data/mt.js +0 -12
- package/locale-data/my.d.ts +0 -1
- package/locale-data/my.js +0 -7
- package/locale-data/nah.d.ts +0 -1
- package/locale-data/nah.js +0 -8
- package/locale-data/naq.d.ts +0 -1
- package/locale-data/naq.js +0 -10
- package/locale-data/nb.d.ts +0 -1
- package/locale-data/nb.js +0 -8
- package/locale-data/nd.d.ts +0 -1
- package/locale-data/nd.js +0 -8
- package/locale-data/ne.d.ts +0 -1
- package/locale-data/ne.js +0 -9
- package/locale-data/nl.d.ts +0 -1
- package/locale-data/nl.js +0 -9
- package/locale-data/nn.d.ts +0 -1
- package/locale-data/nn.js +0 -8
- package/locale-data/nnh.d.ts +0 -1
- package/locale-data/nnh.js +0 -8
- package/locale-data/no.d.ts +0 -1
- package/locale-data/no.js +0 -8
- package/locale-data/nqo.d.ts +0 -1
- package/locale-data/nqo.js +0 -7
- package/locale-data/nr.d.ts +0 -1
- package/locale-data/nr.js +0 -8
- package/locale-data/nso.d.ts +0 -1
- package/locale-data/nso.js +0 -8
- package/locale-data/ny.d.ts +0 -1
- package/locale-data/ny.js +0 -8
- package/locale-data/nyn.d.ts +0 -1
- package/locale-data/nyn.js +0 -8
- package/locale-data/om.d.ts +0 -1
- package/locale-data/om.js +0 -8
- package/locale-data/or.d.ts +0 -1
- package/locale-data/or.js +0 -13
- package/locale-data/os.d.ts +0 -1
- package/locale-data/os.js +0 -8
- package/locale-data/osa.d.ts +0 -1
- package/locale-data/osa.js +0 -7
- package/locale-data/pa.d.ts +0 -1
- package/locale-data/pa.js +0 -8
- package/locale-data/pap.d.ts +0 -1
- package/locale-data/pap.js +0 -8
- package/locale-data/pcm.d.ts +0 -1
- package/locale-data/pcm.js +0 -8
- package/locale-data/pl.d.ts +0 -1
- package/locale-data/pl.js +0 -12
- package/locale-data/prg.d.ts +0 -1
- package/locale-data/prg.js +0 -11
- package/locale-data/ps.d.ts +0 -1
- package/locale-data/ps.js +0 -8
- package/locale-data/pt-PT.d.ts +0 -1
- package/locale-data/pt-PT.js +0 -11
- package/locale-data/pt.d.ts +0 -1
- package/locale-data/pt.js +0 -11
- package/locale-data/rm.d.ts +0 -1
- package/locale-data/rm.js +0 -8
- package/locale-data/ro.d.ts +0 -1
- package/locale-data/ro.js +0 -11
- package/locale-data/rof.d.ts +0 -1
- package/locale-data/rof.js +0 -8
- package/locale-data/ru.d.ts +0 -1
- package/locale-data/ru.js +0 -12
- package/locale-data/rwk.d.ts +0 -1
- package/locale-data/rwk.js +0 -8
- package/locale-data/sah.d.ts +0 -1
- package/locale-data/sah.js +0 -7
- package/locale-data/saq.d.ts +0 -1
- package/locale-data/saq.js +0 -8
- package/locale-data/sat.d.ts +0 -1
- package/locale-data/sat.js +0 -10
- package/locale-data/sc.d.ts +0 -1
- package/locale-data/sc.js +0 -9
- package/locale-data/scn.d.ts +0 -1
- package/locale-data/scn.js +0 -9
- package/locale-data/sd.d.ts +0 -1
- package/locale-data/sd.js +0 -8
- package/locale-data/sdh.d.ts +0 -1
- package/locale-data/sdh.js +0 -8
- package/locale-data/se.d.ts +0 -1
- package/locale-data/se.js +0 -10
- package/locale-data/seh.d.ts +0 -1
- package/locale-data/seh.js +0 -8
- package/locale-data/ses.d.ts +0 -1
- package/locale-data/ses.js +0 -7
- package/locale-data/sg.d.ts +0 -1
- package/locale-data/sg.js +0 -7
- package/locale-data/sh.d.ts +0 -1
- package/locale-data/sh.js +0 -11
- package/locale-data/shi.d.ts +0 -1
- package/locale-data/shi.js +0 -11
- package/locale-data/si.d.ts +0 -1
- package/locale-data/si.js +0 -9
- package/locale-data/sk.d.ts +0 -1
- package/locale-data/sk.js +0 -12
- package/locale-data/sl.d.ts +0 -1
- package/locale-data/sl.js +0 -12
- package/locale-data/sma.d.ts +0 -1
- package/locale-data/sma.js +0 -10
- package/locale-data/smi.d.ts +0 -1
- package/locale-data/smi.js +0 -10
- package/locale-data/smj.d.ts +0 -1
- package/locale-data/smj.js +0 -10
- package/locale-data/smn.d.ts +0 -1
- package/locale-data/smn.js +0 -10
- package/locale-data/sms.d.ts +0 -1
- package/locale-data/sms.js +0 -10
- package/locale-data/sn.d.ts +0 -1
- package/locale-data/sn.js +0 -8
- package/locale-data/so.d.ts +0 -1
- package/locale-data/so.js +0 -8
- package/locale-data/sq.d.ts +0 -1
- package/locale-data/sq.js +0 -11
- package/locale-data/sr.d.ts +0 -1
- package/locale-data/sr.js +0 -11
- package/locale-data/ss.d.ts +0 -1
- package/locale-data/ss.js +0 -8
- package/locale-data/ssy.d.ts +0 -1
- package/locale-data/ssy.js +0 -8
- package/locale-data/st.d.ts +0 -1
- package/locale-data/st.js +0 -8
- package/locale-data/su.d.ts +0 -1
- package/locale-data/su.js +0 -7
- package/locale-data/sv.d.ts +0 -1
- package/locale-data/sv.js +0 -9
- package/locale-data/sw.d.ts +0 -1
- package/locale-data/sw.js +0 -9
- package/locale-data/syr.d.ts +0 -1
- package/locale-data/syr.js +0 -8
- package/locale-data/ta.d.ts +0 -1
- package/locale-data/ta.js +0 -8
- package/locale-data/te.d.ts +0 -1
- package/locale-data/te.js +0 -8
- package/locale-data/teo.d.ts +0 -1
- package/locale-data/teo.js +0 -8
- package/locale-data/th.d.ts +0 -1
- package/locale-data/th.js +0 -7
- package/locale-data/ti.d.ts +0 -1
- package/locale-data/ti.js +0 -8
- package/locale-data/tig.d.ts +0 -1
- package/locale-data/tig.js +0 -8
- package/locale-data/tk.d.ts +0 -1
- package/locale-data/tk.js +0 -9
- package/locale-data/tl.d.ts +0 -1
- package/locale-data/tl.js +0 -9
- package/locale-data/tn.d.ts +0 -1
- package/locale-data/tn.js +0 -8
- package/locale-data/to.d.ts +0 -1
- package/locale-data/to.js +0 -7
- package/locale-data/tpi.d.ts +0 -1
- package/locale-data/tpi.js +0 -7
- package/locale-data/tr.d.ts +0 -1
- package/locale-data/tr.js +0 -8
- package/locale-data/ts.d.ts +0 -1
- package/locale-data/ts.js +0 -8
- package/locale-data/tzm.d.ts +0 -1
- package/locale-data/tzm.js +0 -9
- package/locale-data/ug.d.ts +0 -1
- package/locale-data/ug.js +0 -8
- package/locale-data/uk.d.ts +0 -1
- package/locale-data/uk.js +0 -12
- package/locale-data/und.d.ts +0 -1
- package/locale-data/und.js +0 -7
- package/locale-data/ur.d.ts +0 -1
- package/locale-data/ur.js +0 -9
- package/locale-data/uz.d.ts +0 -1
- package/locale-data/uz.js +0 -8
- package/locale-data/ve.d.ts +0 -1
- package/locale-data/ve.js +0 -8
- package/locale-data/vi.d.ts +0 -1
- package/locale-data/vi.js +0 -8
- package/locale-data/vo.d.ts +0 -1
- package/locale-data/vo.js +0 -8
- package/locale-data/vun.d.ts +0 -1
- package/locale-data/vun.js +0 -8
- package/locale-data/wa.d.ts +0 -1
- package/locale-data/wa.js +0 -8
- package/locale-data/wae.d.ts +0 -1
- package/locale-data/wae.js +0 -8
- package/locale-data/wo.d.ts +0 -1
- package/locale-data/wo.js +0 -7
- package/locale-data/xh.d.ts +0 -1
- package/locale-data/xh.js +0 -8
- package/locale-data/xog.d.ts +0 -1
- package/locale-data/xog.js +0 -8
- package/locale-data/yi.d.ts +0 -1
- package/locale-data/yi.js +0 -9
- package/locale-data/yo.d.ts +0 -1
- package/locale-data/yo.js +0 -7
- package/locale-data/yue.d.ts +0 -1
- package/locale-data/yue.js +0 -7
- package/locale-data/zh.d.ts +0 -1
- package/locale-data/zh.js +0 -7
- package/locale-data/zu.d.ts +0 -1
- package/locale-data/zu.js +0 -8
- package/polyfill-force.d.ts +0 -2
- package/polyfill-force.d.ts.map +0 -1
- package/polyfill-force.js +0 -9
- package/polyfill.d.ts +0 -2
- package/polyfill.d.ts.map +0 -1
- package/polyfill.iife.js +0 -2753
- package/polyfill.js +0 -12
- package/should-polyfill.d.ts +0 -2
- package/should-polyfill.d.ts.map +0 -1
- package/should-polyfill.js +0 -22
- package/supported-locales.d.ts +0 -2
- package/supported-locales.d.ts.map +0 -1
- package/supported-locales.js +0 -5
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import '@formatjs/intl-getcanonicallocales/polyfill'
|
|
2
|
+
import '@formatjs/intl-locale/polyfill'
|
|
3
|
+
import {PluralRules} from '../'
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import en from './locale-data/en'
|
|
6
|
+
import fr from './locale-data/fr'
|
|
7
|
+
PluralRules.__addLocaleData(en, fr)
|
|
8
|
+
|
|
9
|
+
describe('PluralRules', function () {
|
|
10
|
+
it('default locale', function () {
|
|
11
|
+
expect(new PluralRules().resolvedOptions()).toEqual({
|
|
12
|
+
locale: 'en',
|
|
13
|
+
maximumFractionDigits: 3,
|
|
14
|
+
minimumFractionDigits: 0,
|
|
15
|
+
minimumIntegerDigits: 1,
|
|
16
|
+
pluralCategories: ['one', 'other'],
|
|
17
|
+
type: 'cardinal',
|
|
18
|
+
})
|
|
19
|
+
})
|
|
20
|
+
it('should work for cardinal', function () {
|
|
21
|
+
expect(new PluralRules('en').select(0)).toBe('other')
|
|
22
|
+
expect(new PluralRules('en').select(1)).toBe('one')
|
|
23
|
+
expect(new PluralRules('en').select(2)).toBe('other')
|
|
24
|
+
expect(new PluralRules('en').select(-1)).toBe('one')
|
|
25
|
+
expect(new PluralRules('en').select(-2)).toBe('other')
|
|
26
|
+
})
|
|
27
|
+
it('should deal with en-XX', function () {
|
|
28
|
+
expect(new PluralRules('en-XX').select(0)).toBe('other')
|
|
29
|
+
expect(new PluralRules('en-XX').select(1)).toBe('one')
|
|
30
|
+
})
|
|
31
|
+
it('should deal with en-US', function () {
|
|
32
|
+
expect(new PluralRules('en-US').select(0)).toBe('other')
|
|
33
|
+
expect(new PluralRules('en-US').select(1)).toBe('one')
|
|
34
|
+
})
|
|
35
|
+
it('should not crash for fr', function () {
|
|
36
|
+
expect(new PluralRules('fr').select(1000000)).toBe('many')
|
|
37
|
+
})
|
|
38
|
+
it('should work for ordinal', function () {
|
|
39
|
+
expect(new PluralRules('en', {type: 'ordinal'}).select(0)).toBe('other')
|
|
40
|
+
expect(new PluralRules('en', {type: 'ordinal'}).select(1)).toBe('one')
|
|
41
|
+
expect(new PluralRules('en', {type: 'ordinal'}).select(2)).toBe('two')
|
|
42
|
+
expect(new PluralRules('en', {type: 'ordinal'}).select(3)).toBe('few')
|
|
43
|
+
expect(new PluralRules('en', {type: 'ordinal'}).select(-1)).toBe('one')
|
|
44
|
+
expect(new PluralRules('en', {type: 'ordinal'}).select(-2)).toBe('two')
|
|
45
|
+
expect(new PluralRules('en', {type: 'ordinal'}).select(-3)).toBe('few')
|
|
46
|
+
})
|
|
47
|
+
if ((PluralRules as any).polyfilled) {
|
|
48
|
+
it('should honor minimumFractionDigits', function () {
|
|
49
|
+
expect(
|
|
50
|
+
new PluralRules('en', {minimumFractionDigits: 0} as any).select(1)
|
|
51
|
+
).toBe('one')
|
|
52
|
+
expect(
|
|
53
|
+
new PluralRules('en', {minimumFractionDigits: 2} as any).select(1)
|
|
54
|
+
).toBe('other')
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
})
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/* @generated */
|
|
2
2
|
// prettier-ignore
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
export default {"data":{"categories":{"cardinal":["one","other"],"ordinal":["one","two","few","other"]},"fn":function(n, ord) {
|
|
5
5
|
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);
|
|
6
6
|
if (ord) return n10 == 1 && n100 != 11 ? 'one'
|
|
7
7
|
: n10 == 2 && n100 != 12 ? 'two'
|
|
8
8
|
: n10 == 3 && n100 != 13 ? 'few'
|
|
9
9
|
: 'other';
|
|
10
10
|
return n == 1 && v0 ? 'one' : 'other';
|
|
11
|
-
}},"locale":"en"}
|
|
12
|
-
}
|
|
11
|
+
}},"locale":"en"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/* @generated */
|
|
2
2
|
// prettier-ignore
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
export default {"data":{"categories":{"cardinal":["one","many","other"],"ordinal":["one","other"]},"fn":function(n, ord) {
|
|
5
5
|
var _n = String(n), se = _n.split(/[ce]/), e = se[1] || 0, c = e, s = String(e ? Number(se[0]) * Math.pow(10, e) : _n).split("."), i = s[0], v0 = !s[1], i1000000 = i.slice(-6);
|
|
6
6
|
if (ord) return n == 1 ? 'one' : 'other';
|
|
7
7
|
return n >= 0 && n < 2 ? 'one'
|
|
8
8
|
: e == 0 && i != 0 && i1000000 == 0 && v0 || (e < 0 || e > 5) ? 'many'
|
|
9
9
|
: 'other';
|
|
10
|
-
}},"locale":"fr"}
|
|
11
|
-
}
|
|
10
|
+
}},"locale":"fr"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import '@formatjs/intl-getcanonicallocales/polyfill'
|
|
2
|
+
import '@formatjs/intl-locale/polyfill'
|
|
3
|
+
import {PluralRules} from '../'
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
import zh from './locale-data/zh'
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
PluralRules.__addLocaleData(zh)
|
|
8
|
+
|
|
9
|
+
describe('supportedLocalesOf', function () {
|
|
10
|
+
function test() {
|
|
11
|
+
expect(PluralRules.supportedLocalesOf(['zh', 'en-jj'])).toContain('zh')
|
|
12
|
+
// FIXME: Only run this in Node since in browsers other tests populate PluralRules :(
|
|
13
|
+
if (process.version) {
|
|
14
|
+
expect(PluralRules.supportedLocalesOf(['fr'])).toEqual([])
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if ((PluralRules as any).polyfilled) {
|
|
19
|
+
it('should return correct locales that we only have data for', test)
|
|
20
|
+
} else {
|
|
21
|
+
xit('should return correct locales that we only have data for', test)
|
|
22
|
+
}
|
|
23
|
+
})
|
package/tsconfig.json
ADDED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface OperandsRecord {
|
|
2
|
-
/**
|
|
3
|
-
* Absolute value of the source number (integer and decimals)
|
|
4
|
-
*/
|
|
5
|
-
Number: number;
|
|
6
|
-
/**
|
|
7
|
-
* Number of digits of `number`
|
|
8
|
-
*/
|
|
9
|
-
IntegerDigits: number;
|
|
10
|
-
/**
|
|
11
|
-
* Number of visible fraction digits in [[Number]], with trailing zeroes.
|
|
12
|
-
*/
|
|
13
|
-
NumberOfFractionDigits: number;
|
|
14
|
-
/**
|
|
15
|
-
* Number of visible fraction digits in [[Number]], without trailing zeroes.
|
|
16
|
-
*/
|
|
17
|
-
NumberOfFractionDigitsWithoutTrailing: number;
|
|
18
|
-
/**
|
|
19
|
-
* Number of visible fractional digits in [[Number]], with trailing zeroes.
|
|
20
|
-
*/
|
|
21
|
-
FractionDigits: number;
|
|
22
|
-
/**
|
|
23
|
-
* Number of visible fractional digits in [[Number]], without trailing zeroes.
|
|
24
|
-
*/
|
|
25
|
-
FractionDigitsWithoutTrailing: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-getoperands
|
|
29
|
-
* @param s
|
|
30
|
-
*/
|
|
31
|
-
export declare function GetOperands(s: string): OperandsRecord;
|
|
32
|
-
//# sourceMappingURL=GetOperands.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GetOperands.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-pluralrules/abstract/GetOperands.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,qCAAqC,EAAE,MAAM,CAAA;IAC7C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,6BAA6B,EAAE,MAAM,CAAA;CACtC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAyCrD"}
|
package/abstract/GetOperands.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GetOperands = void 0;
|
|
4
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
|
-
/**
|
|
6
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-getoperands
|
|
7
|
-
* @param s
|
|
8
|
-
*/
|
|
9
|
-
function GetOperands(s) {
|
|
10
|
-
(0, ecma402_abstract_1.invariant)(typeof s === 'string', "GetOperands should have been called with a string");
|
|
11
|
-
var n = (0, ecma402_abstract_1.ToNumber)(s);
|
|
12
|
-
(0, ecma402_abstract_1.invariant)(isFinite(n), 'n should be finite');
|
|
13
|
-
var dp = s.indexOf('.');
|
|
14
|
-
var iv;
|
|
15
|
-
var f;
|
|
16
|
-
var v;
|
|
17
|
-
var fv = '';
|
|
18
|
-
if (dp === -1) {
|
|
19
|
-
iv = n;
|
|
20
|
-
f = 0;
|
|
21
|
-
v = 0;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
iv = s.slice(0, dp);
|
|
25
|
-
fv = s.slice(dp, s.length);
|
|
26
|
-
f = (0, ecma402_abstract_1.ToNumber)(fv);
|
|
27
|
-
v = fv.length;
|
|
28
|
-
}
|
|
29
|
-
var i = Math.abs((0, ecma402_abstract_1.ToNumber)(iv));
|
|
30
|
-
var w;
|
|
31
|
-
var t;
|
|
32
|
-
if (f !== 0) {
|
|
33
|
-
var ft = fv.replace(/0+$/, '');
|
|
34
|
-
w = ft.length;
|
|
35
|
-
t = (0, ecma402_abstract_1.ToNumber)(ft);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
w = 0;
|
|
39
|
-
t = 0;
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
Number: n,
|
|
43
|
-
IntegerDigits: i,
|
|
44
|
-
NumberOfFractionDigits: v,
|
|
45
|
-
NumberOfFractionDigitsWithoutTrailing: w,
|
|
46
|
-
FractionDigits: f,
|
|
47
|
-
FractionDigitsWithoutTrailing: t,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
exports.GetOperands = GetOperands;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PluralRulesInternal, PluralRulesData } from '@formatjs/ecma402-abstract';
|
|
2
|
-
export declare function InitializePluralRules(pl: Intl.PluralRules, locales: string | string[] | undefined, options: Intl.PluralRulesOptions | undefined, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots, }: {
|
|
3
|
-
availableLocales: Set<string>;
|
|
4
|
-
relevantExtensionKeys: string[];
|
|
5
|
-
localeData: Record<string, PluralRulesData | undefined>;
|
|
6
|
-
getDefaultLocale(): string;
|
|
7
|
-
getInternalSlots(pl: Intl.PluralRules): PluralRulesInternal;
|
|
8
|
-
}): Intl.PluralRules;
|
|
9
|
-
//# sourceMappingURL=InitializePluralRules.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InitializePluralRules.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-pluralrules/abstract/InitializePluralRules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAKhB,MAAM,4BAA4B,CAAA;AAGnC,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,kBAAkB,GAAG,SAAS,EAC5C,EACE,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC,CAAA;IACvD,gBAAgB,IAAI,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAA;CAC5D,oBAkCF"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InitializePluralRules = void 0;
|
|
4
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
6
|
-
function InitializePluralRules(pl, locales, options, _a) {
|
|
7
|
-
var availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getInternalSlots = _a.getInternalSlots;
|
|
8
|
-
var requestedLocales = (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales);
|
|
9
|
-
var opt = Object.create(null);
|
|
10
|
-
var opts = (0, ecma402_abstract_1.CoerceOptionsToObject)(options);
|
|
11
|
-
var internalSlots = getInternalSlots(pl);
|
|
12
|
-
internalSlots.initializedPluralRules = true;
|
|
13
|
-
var matcher = (0, ecma402_abstract_1.GetOption)(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
|
|
14
|
-
opt.localeMatcher = matcher;
|
|
15
|
-
internalSlots.type = (0, ecma402_abstract_1.GetOption)(opts, 'type', 'string', ['cardinal', 'ordinal'], 'cardinal');
|
|
16
|
-
(0, ecma402_abstract_1.SetNumberFormatDigitOptions)(internalSlots, opts, 0, 3, 'standard');
|
|
17
|
-
var r = (0, intl_localematcher_1.ResolveLocale)(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
18
|
-
internalSlots.locale = r.locale;
|
|
19
|
-
return pl;
|
|
20
|
-
}
|
|
21
|
-
exports.InitializePluralRules = InitializePluralRules;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PluralRulesInternal, LDMLPluralRule } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { OperandsRecord } from './GetOperands';
|
|
3
|
-
/**
|
|
4
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
5
|
-
* @param pl
|
|
6
|
-
* @param n
|
|
7
|
-
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
|
|
8
|
-
*/
|
|
9
|
-
export declare function ResolvePlural(pl: Intl.PluralRules, n: number, { getInternalSlots, PluralRuleSelect, }: {
|
|
10
|
-
getInternalSlots(pl: Intl.PluralRules): PluralRulesInternal;
|
|
11
|
-
PluralRuleSelect: (locale: string, type: 'cardinal' | 'ordinal', n: number, operands: OperandsRecord) => LDMLPluralRule;
|
|
12
|
-
}): LDMLPluralRule;
|
|
13
|
-
//# sourceMappingURL=ResolvePlural.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResolvePlural.d.ts","sourceRoot":"","sources":["../../../../../../packages/intl-pluralrules/abstract/ResolvePlural.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,cAAc,EAEf,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAc,cAAc,EAAC,MAAM,eAAe,CAAA;AAEzD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,EAChB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAA;IAC3D,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,cAAc,KACrB,cAAc,CAAA;CACpB,GACA,cAAc,CAgBhB"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResolvePlural = void 0;
|
|
4
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
5
|
-
var GetOperands_1 = require("./GetOperands");
|
|
6
|
-
/**
|
|
7
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
8
|
-
* @param pl
|
|
9
|
-
* @param n
|
|
10
|
-
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
|
|
11
|
-
*/
|
|
12
|
-
function ResolvePlural(pl, n, _a) {
|
|
13
|
-
var getInternalSlots = _a.getInternalSlots, PluralRuleSelect = _a.PluralRuleSelect;
|
|
14
|
-
var internalSlots = getInternalSlots(pl);
|
|
15
|
-
(0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(internalSlots) === 'Object', 'pl has to be an object');
|
|
16
|
-
(0, ecma402_abstract_1.invariant)('initializedPluralRules' in internalSlots, 'pluralrules must be initialized');
|
|
17
|
-
(0, ecma402_abstract_1.invariant)((0, ecma402_abstract_1.Type)(n) === 'Number', 'n must be a number');
|
|
18
|
-
if (!isFinite(n)) {
|
|
19
|
-
return 'other';
|
|
20
|
-
}
|
|
21
|
-
var locale = internalSlots.locale, type = internalSlots.type;
|
|
22
|
-
var res = (0, ecma402_abstract_1.FormatNumericToString)(internalSlots, n);
|
|
23
|
-
var s = res.formattedString;
|
|
24
|
-
var operands = (0, GetOperands_1.GetOperands)(s);
|
|
25
|
-
return PluralRuleSelect(locale, type, n, operands);
|
|
26
|
-
}
|
|
27
|
-
exports.ResolvePlural = ResolvePlural;
|
package/get_internal_slots.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get_internal_slots.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-pluralrules/get_internal_slots.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,GAAG,CAAA;AAIlD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,CAAC,EAAE,WAAW,GAAG,mBAAmB,CAO5E"}
|
package/get_internal_slots.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var internalSlotMap = new WeakMap();
|
|
4
|
-
function getInternalSlots(x) {
|
|
5
|
-
var internalSlots = internalSlotMap.get(x);
|
|
6
|
-
if (!internalSlots) {
|
|
7
|
-
internalSlots = Object.create(null);
|
|
8
|
-
internalSlotMap.set(x, internalSlots);
|
|
9
|
-
}
|
|
10
|
-
return internalSlots;
|
|
11
|
-
}
|
|
12
|
-
exports.default = getInternalSlots;
|
package/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { LDMLPluralRule, PluralRulesLocaleData, PluralRulesData, NumberFormatDigitInternalSlots } from '@formatjs/ecma402-abstract';
|
|
2
|
-
export interface PluralRulesInternal extends NumberFormatDigitInternalSlots {
|
|
3
|
-
initializedPluralRules: boolean;
|
|
4
|
-
locale: string;
|
|
5
|
-
type: 'cardinal' | 'ordinal';
|
|
6
|
-
}
|
|
7
|
-
export declare class PluralRules implements Intl.PluralRules {
|
|
8
|
-
constructor(locales?: string | string[], options?: Intl.PluralRulesOptions);
|
|
9
|
-
resolvedOptions(): any;
|
|
10
|
-
select(val: number): LDMLPluralRule;
|
|
11
|
-
toString(): string;
|
|
12
|
-
static supportedLocalesOf(locales?: string | string[], options?: Pick<Intl.PluralRulesOptions, 'localeMatcher'>): string[];
|
|
13
|
-
static __addLocaleData(...data: PluralRulesLocaleData[]): void;
|
|
14
|
-
static localeData: Record<string, PluralRulesData>;
|
|
15
|
-
static availableLocales: Set<string>;
|
|
16
|
-
static __defaultLocale: string;
|
|
17
|
-
static getDefaultLocale(): string;
|
|
18
|
-
static relevantExtensionKeys: never[];
|
|
19
|
-
static polyfilled: boolean;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/intl-pluralrules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,eAAe,EAEf,8BAA8B,EAG/B,MAAM,4BAA4B,CAAA;AAgBnC,MAAM,WAAW,mBAAoB,SAAQ,8BAA8B;IACzE,sBAAsB,EAAE,OAAO,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,UAAU,GAAG,SAAS,CAAA;CAC7B;AAuBD,qBAAa,WAAY,YAAW,IAAI,CAAC,WAAW;gBACtC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,kBAAkB;IAgBnE,eAAe;IA4Bf,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;IAM1C,QAAQ;WAGM,kBAAkB,CAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,OAAO,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC;WAQ5C,eAAe,CAAC,GAAG,IAAI,EAAE,qBAAqB,EAAE;IAS9D,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAK;IACvD,MAAM,CAAC,gBAAgB,cAAoB;IAC3C,MAAM,CAAC,eAAe,SAAK;IAC3B,MAAM,CAAC,gBAAgB;IAGvB,MAAM,CAAC,qBAAqB,UAAK;IACjC,OAAc,UAAU,UAAO;CAChC"}
|
package/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PluralRules = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
|
|
6
|
-
var InitializePluralRules_1 = require("./abstract/InitializePluralRules");
|
|
7
|
-
var ResolvePlural_1 = require("./abstract/ResolvePlural");
|
|
8
|
-
var get_internal_slots_1 = (0, tslib_1.__importDefault)(require("./get_internal_slots"));
|
|
9
|
-
function validateInstance(instance, method) {
|
|
10
|
-
if (!(instance instanceof PluralRules)) {
|
|
11
|
-
throw new TypeError("Method Intl.PluralRules.prototype.".concat(method, " called on incompatible receiver ").concat(String(instance)));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-pluralruleselect
|
|
16
|
-
* @param locale
|
|
17
|
-
* @param type
|
|
18
|
-
* @param _n
|
|
19
|
-
* @param param3
|
|
20
|
-
*/
|
|
21
|
-
function PluralRuleSelect(locale, type, _n, _a) {
|
|
22
|
-
var IntegerDigits = _a.IntegerDigits, NumberOfFractionDigits = _a.NumberOfFractionDigits, FractionDigits = _a.FractionDigits;
|
|
23
|
-
return PluralRules.localeData[locale].fn(NumberOfFractionDigits
|
|
24
|
-
? "".concat(IntegerDigits, ".").concat(FractionDigits)
|
|
25
|
-
: IntegerDigits, type === 'ordinal');
|
|
26
|
-
}
|
|
27
|
-
var PluralRules = /** @class */ (function () {
|
|
28
|
-
function PluralRules(locales, options) {
|
|
29
|
-
// test262/test/intl402/RelativeTimeFormat/constructor/constructor/newtarget-undefined.js
|
|
30
|
-
// Cannot use `new.target` bc of IE11 & TS transpiles it to something else
|
|
31
|
-
var newTarget = this && this instanceof PluralRules ? this.constructor : void 0;
|
|
32
|
-
if (!newTarget) {
|
|
33
|
-
throw new TypeError("Intl.PluralRules must be called with 'new'");
|
|
34
|
-
}
|
|
35
|
-
return (0, InitializePluralRules_1.InitializePluralRules)(this, locales, options, {
|
|
36
|
-
availableLocales: PluralRules.availableLocales,
|
|
37
|
-
relevantExtensionKeys: PluralRules.relevantExtensionKeys,
|
|
38
|
-
localeData: PluralRules.localeData,
|
|
39
|
-
getDefaultLocale: PluralRules.getDefaultLocale,
|
|
40
|
-
getInternalSlots: get_internal_slots_1.default,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
PluralRules.prototype.resolvedOptions = function () {
|
|
44
|
-
validateInstance(this, 'resolvedOptions');
|
|
45
|
-
var opts = Object.create(null);
|
|
46
|
-
var internalSlots = (0, get_internal_slots_1.default)(this);
|
|
47
|
-
opts.locale = internalSlots.locale;
|
|
48
|
-
opts.type = internalSlots.type;
|
|
49
|
-
[
|
|
50
|
-
'minimumIntegerDigits',
|
|
51
|
-
'minimumFractionDigits',
|
|
52
|
-
'maximumFractionDigits',
|
|
53
|
-
'minimumSignificantDigits',
|
|
54
|
-
'maximumSignificantDigits',
|
|
55
|
-
].forEach(function (field) {
|
|
56
|
-
var val = internalSlots[field];
|
|
57
|
-
if (val !== undefined) {
|
|
58
|
-
opts[field] = val;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
opts.pluralCategories = (0, tslib_1.__spreadArray)([], PluralRules.localeData[opts.locale].categories[opts.type], true);
|
|
62
|
-
return opts;
|
|
63
|
-
};
|
|
64
|
-
PluralRules.prototype.select = function (val) {
|
|
65
|
-
var pr = this;
|
|
66
|
-
validateInstance(pr, 'select');
|
|
67
|
-
var n = (0, ecma402_abstract_1.ToNumber)(val);
|
|
68
|
-
return (0, ResolvePlural_1.ResolvePlural)(pr, n, { getInternalSlots: get_internal_slots_1.default, PluralRuleSelect: PluralRuleSelect });
|
|
69
|
-
};
|
|
70
|
-
PluralRules.prototype.toString = function () {
|
|
71
|
-
return '[object Intl.PluralRules]';
|
|
72
|
-
};
|
|
73
|
-
PluralRules.supportedLocalesOf = function (locales, options) {
|
|
74
|
-
return (0, ecma402_abstract_1.SupportedLocales)(PluralRules.availableLocales, (0, ecma402_abstract_1.CanonicalizeLocaleList)(locales), options);
|
|
75
|
-
};
|
|
76
|
-
PluralRules.__addLocaleData = function () {
|
|
77
|
-
var data = [];
|
|
78
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
79
|
-
data[_i] = arguments[_i];
|
|
80
|
-
}
|
|
81
|
-
for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
|
|
82
|
-
var _b = data_1[_a], d = _b.data, locale = _b.locale;
|
|
83
|
-
PluralRules.localeData[locale] = d;
|
|
84
|
-
PluralRules.availableLocales.add(locale);
|
|
85
|
-
if (!PluralRules.__defaultLocale) {
|
|
86
|
-
PluralRules.__defaultLocale = locale;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
PluralRules.getDefaultLocale = function () {
|
|
91
|
-
return PluralRules.__defaultLocale;
|
|
92
|
-
};
|
|
93
|
-
PluralRules.localeData = {};
|
|
94
|
-
PluralRules.availableLocales = new Set();
|
|
95
|
-
PluralRules.__defaultLocale = '';
|
|
96
|
-
PluralRules.relevantExtensionKeys = [];
|
|
97
|
-
PluralRules.polyfilled = true;
|
|
98
|
-
return PluralRules;
|
|
99
|
-
}());
|
|
100
|
-
exports.PluralRules = PluralRules;
|
|
101
|
-
try {
|
|
102
|
-
// IE11 does not have Symbol
|
|
103
|
-
if (typeof Symbol !== 'undefined') {
|
|
104
|
-
Object.defineProperty(PluralRules.prototype, Symbol.toStringTag, {
|
|
105
|
-
value: 'Intl.PluralRules',
|
|
106
|
-
writable: false,
|
|
107
|
-
enumerable: false,
|
|
108
|
-
configurable: true,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
// https://github.com/tc39/test262/blob/master/test/intl402/PluralRules/length.js
|
|
113
|
-
Object.defineProperty(PluralRules, 'length', {
|
|
114
|
-
value: 0,
|
|
115
|
-
writable: false,
|
|
116
|
-
enumerable: false,
|
|
117
|
-
configurable: true,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
// IE 11 sets Function.prototype.length to be non-configurable which will cause the
|
|
122
|
-
// above Object.defineProperty to throw an error.
|
|
123
|
-
}
|
|
124
|
-
// https://github.com/tc39/test262/blob/master/test/intl402/RelativeTimeFormat/constructor/length.js
|
|
125
|
-
Object.defineProperty(PluralRules.prototype.constructor, 'length', {
|
|
126
|
-
value: 0,
|
|
127
|
-
writable: false,
|
|
128
|
-
enumerable: false,
|
|
129
|
-
configurable: true,
|
|
130
|
-
});
|
|
131
|
-
// https://github.com/tc39/test262/blob/master/test/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/length.js
|
|
132
|
-
Object.defineProperty(PluralRules.supportedLocalesOf, 'length', {
|
|
133
|
-
value: 1,
|
|
134
|
-
writable: false,
|
|
135
|
-
enumerable: false,
|
|
136
|
-
configurable: true,
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
catch (ex) {
|
|
140
|
-
// Meta fixes for test262
|
|
141
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export interface OperandsRecord {
|
|
2
|
-
/**
|
|
3
|
-
* Absolute value of the source number (integer and decimals)
|
|
4
|
-
*/
|
|
5
|
-
Number: number;
|
|
6
|
-
/**
|
|
7
|
-
* Number of digits of `number`
|
|
8
|
-
*/
|
|
9
|
-
IntegerDigits: number;
|
|
10
|
-
/**
|
|
11
|
-
* Number of visible fraction digits in [[Number]], with trailing zeroes.
|
|
12
|
-
*/
|
|
13
|
-
NumberOfFractionDigits: number;
|
|
14
|
-
/**
|
|
15
|
-
* Number of visible fraction digits in [[Number]], without trailing zeroes.
|
|
16
|
-
*/
|
|
17
|
-
NumberOfFractionDigitsWithoutTrailing: number;
|
|
18
|
-
/**
|
|
19
|
-
* Number of visible fractional digits in [[Number]], with trailing zeroes.
|
|
20
|
-
*/
|
|
21
|
-
FractionDigits: number;
|
|
22
|
-
/**
|
|
23
|
-
* Number of visible fractional digits in [[Number]], without trailing zeroes.
|
|
24
|
-
*/
|
|
25
|
-
FractionDigitsWithoutTrailing: number;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-getoperands
|
|
29
|
-
* @param s
|
|
30
|
-
*/
|
|
31
|
-
export declare function GetOperands(s: string): OperandsRecord;
|
|
32
|
-
//# sourceMappingURL=GetOperands.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GetOperands.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-pluralrules/abstract/GetOperands.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAA;IAC9B;;OAEG;IACH,qCAAqC,EAAE,MAAM,CAAA;IAC7C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,6BAA6B,EAAE,MAAM,CAAA;CACtC;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,cAAc,CAyCrD"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { invariant, ToNumber } from '@formatjs/ecma402-abstract';
|
|
2
|
-
/**
|
|
3
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-getoperands
|
|
4
|
-
* @param s
|
|
5
|
-
*/
|
|
6
|
-
export function GetOperands(s) {
|
|
7
|
-
invariant(typeof s === 'string', "GetOperands should have been called with a string");
|
|
8
|
-
var n = ToNumber(s);
|
|
9
|
-
invariant(isFinite(n), 'n should be finite');
|
|
10
|
-
var dp = s.indexOf('.');
|
|
11
|
-
var iv;
|
|
12
|
-
var f;
|
|
13
|
-
var v;
|
|
14
|
-
var fv = '';
|
|
15
|
-
if (dp === -1) {
|
|
16
|
-
iv = n;
|
|
17
|
-
f = 0;
|
|
18
|
-
v = 0;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
iv = s.slice(0, dp);
|
|
22
|
-
fv = s.slice(dp, s.length);
|
|
23
|
-
f = ToNumber(fv);
|
|
24
|
-
v = fv.length;
|
|
25
|
-
}
|
|
26
|
-
var i = Math.abs(ToNumber(iv));
|
|
27
|
-
var w;
|
|
28
|
-
var t;
|
|
29
|
-
if (f !== 0) {
|
|
30
|
-
var ft = fv.replace(/0+$/, '');
|
|
31
|
-
w = ft.length;
|
|
32
|
-
t = ToNumber(ft);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
w = 0;
|
|
36
|
-
t = 0;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
Number: n,
|
|
40
|
-
IntegerDigits: i,
|
|
41
|
-
NumberOfFractionDigits: v,
|
|
42
|
-
NumberOfFractionDigitsWithoutTrailing: w,
|
|
43
|
-
FractionDigits: f,
|
|
44
|
-
FractionDigitsWithoutTrailing: t,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PluralRulesInternal, PluralRulesData } from '@formatjs/ecma402-abstract';
|
|
2
|
-
export declare function InitializePluralRules(pl: Intl.PluralRules, locales: string | string[] | undefined, options: Intl.PluralRulesOptions | undefined, { availableLocales, relevantExtensionKeys, localeData, getDefaultLocale, getInternalSlots, }: {
|
|
3
|
-
availableLocales: Set<string>;
|
|
4
|
-
relevantExtensionKeys: string[];
|
|
5
|
-
localeData: Record<string, PluralRulesData | undefined>;
|
|
6
|
-
getDefaultLocale(): string;
|
|
7
|
-
getInternalSlots(pl: Intl.PluralRules): PluralRulesInternal;
|
|
8
|
-
}): Intl.PluralRules;
|
|
9
|
-
//# sourceMappingURL=InitializePluralRules.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InitializePluralRules.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-pluralrules/abstract/InitializePluralRules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,eAAe,EAKhB,MAAM,4BAA4B,CAAA;AAGnC,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,EACtC,OAAO,EAAE,IAAI,CAAC,kBAAkB,GAAG,SAAS,EAC5C,EACE,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,qBAAqB,EAAE,MAAM,EAAE,CAAA;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC,CAAA;IACvD,gBAAgB,IAAI,MAAM,CAAA;IAC1B,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAA;CAC5D,oBAkCF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CanonicalizeLocaleList, CoerceOptionsToObject, GetOption, SetNumberFormatDigitOptions, } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { ResolveLocale } from '@formatjs/intl-localematcher';
|
|
3
|
-
export function InitializePluralRules(pl, locales, options, _a) {
|
|
4
|
-
var availableLocales = _a.availableLocales, relevantExtensionKeys = _a.relevantExtensionKeys, localeData = _a.localeData, getDefaultLocale = _a.getDefaultLocale, getInternalSlots = _a.getInternalSlots;
|
|
5
|
-
var requestedLocales = CanonicalizeLocaleList(locales);
|
|
6
|
-
var opt = Object.create(null);
|
|
7
|
-
var opts = CoerceOptionsToObject(options);
|
|
8
|
-
var internalSlots = getInternalSlots(pl);
|
|
9
|
-
internalSlots.initializedPluralRules = true;
|
|
10
|
-
var matcher = GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
|
|
11
|
-
opt.localeMatcher = matcher;
|
|
12
|
-
internalSlots.type = GetOption(opts, 'type', 'string', ['cardinal', 'ordinal'], 'cardinal');
|
|
13
|
-
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, 'standard');
|
|
14
|
-
var r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
15
|
-
internalSlots.locale = r.locale;
|
|
16
|
-
return pl;
|
|
17
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { PluralRulesInternal, LDMLPluralRule } from '@formatjs/ecma402-abstract';
|
|
2
|
-
import { OperandsRecord } from './GetOperands';
|
|
3
|
-
/**
|
|
4
|
-
* http://ecma-international.org/ecma-402/7.0/index.html#sec-resolveplural
|
|
5
|
-
* @param pl
|
|
6
|
-
* @param n
|
|
7
|
-
* @param PluralRuleSelect Has to pass in bc it's implementation-specific
|
|
8
|
-
*/
|
|
9
|
-
export declare function ResolvePlural(pl: Intl.PluralRules, n: number, { getInternalSlots, PluralRuleSelect, }: {
|
|
10
|
-
getInternalSlots(pl: Intl.PluralRules): PluralRulesInternal;
|
|
11
|
-
PluralRuleSelect: (locale: string, type: 'cardinal' | 'ordinal', n: number, operands: OperandsRecord) => LDMLPluralRule;
|
|
12
|
-
}): LDMLPluralRule;
|
|
13
|
-
//# sourceMappingURL=ResolvePlural.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResolvePlural.d.ts","sourceRoot":"","sources":["../../../../../../../packages/intl-pluralrules/abstract/ResolvePlural.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EACnB,cAAc,EAEf,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAc,cAAc,EAAC,MAAM,eAAe,CAAA;AAEzD;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,IAAI,CAAC,WAAW,EACpB,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,EAChB,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAA;IAC3D,gBAAgB,EAAE,CAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,CAAC,EAAE,MAAM,EACT,QAAQ,EAAE,cAAc,KACrB,cAAc,CAAA;CACpB,GACA,cAAc,CAgBhB"}
|