UNPKG

fast-plural-rules

Version:

Evaluates locale-specific plural rules to identify the right plural form for a cardinal number, which represents an item count.

3 lines (2 loc) 3.89 kB
let _={rules:[()=>0,_=>1===_?0:1,_=>_<=1?0:1,_=>_%10==1&&_%100!=11?1:_%10!=0?2:0,_=>1===_||11===_?0:2===_||12===_?1:_>2&&_<20?2:3,_=>1===_?0:0===_||_%100>0&&_%100<20?1:2,_=>_%10==1&&_%100!=11?0:_%10>=2&&(_%100<10||_%100>=20)?2:1,_=>_%10==1&&_%100!=11?0:_%10>=2&&_%10<=4&&(_%100<10||_%100>=20)?1:2,_=>1===_?0:_>=2&&_<=4?1:2,_=>1===_?0:_%10>=2&&_%10<=4&&(_%100<10||_%100>=20)?1:2,_=>_%100==1?0:_%100==2?1:_%100==3||_%100==4?2:3,_=>1===_?0:2===_?1:_>2&&_<7?2:_>6&&_<11?3:4,_=>1===_?0:2===_?1:_%100>=3&&_%100<=10?2:_%100>=11?3:0!==_?4:5,_=>1===_?0:0===_||_%100>0&&_%100<11?1:_%100>10&&_%100<20?2:3,_=>_%10==1?0:_%10==2?1:2,_=>_%10==1&&_%100!=11?0:1,_=>_%10==1&&_%100!=11&&_%100!=71&&_%100!=91?0:_%10==2&&_%100!=12&&_%100!=72&&_%100!=92?1:(_%10==3||_%10==4||_%10==9)&&_%100!=13&&_%100!=73&&_%100!=93&&_%100!=14&&_%100!=74&&_%100!=94&&_%100!=19&&_%100!=79&&_%100!=99?2:0!==_&&_%1e6==0?3:4,_=>0!==_?1:0,_=>1===_?1:2===_?2:3===_?3:6===_?4:0!==_?5:0,_=>1===_?0:_%10>=2&&_%10<=4&&(_%100<10||_%100>=20)?1:2,_=>1===_?0:2===_?1:3===_?2:3,_=>_%10==1&&_%100!=11?0:_%10>=2&&_%10<=4&&(_%100<10||_%100>=20)?1:2,_=>0===_?0:1===_?1:2],rulesByLocale:{ach:2,af:1,ak:2,am:2,an:1,anp:1,ar:12,arn:2,as:1,ast:1,ay:0,az:1,be:7,bg:1,bn:1,bo:0,br:2,brx:1,bs:7,ca:1,cgg:0,cs:8,csb:19,cy:18,da:1,de:1,doi:1,dz:0,el:1,en:1,eo:1,es:1,"es-ar":1,et:1,eu:1,fa:2,ff:1,fi:1,fil:2,fo:1,fr:2,fur:1,fy:1,ga:11,gd:4,gl:1,gu:1,gun:2,ha:1,he:1,hi:1,hne:1,hr:7,hu:1,hy:1,ia:1,id:0,is:15,it:1,ja:0,jbo:0,jv:17,ka:0,kk:1,kl:1,km:0,kn:1,ko:0,ku:1,kw:20,ky:1,lb:1,ln:2,lo:0,lt:6,lv:3,mai:1,me:21,mfe:2,mg:2,mi:2,mk:15,ml:1,mn:1,mni:1,mnk:22,mr:1,ms:0,mt:13,my:0,nah:1,nap:1,nb:1,ne:1,nl:1,nn:1,no:1,nso:1,oc:2,or:1,pa:1,pap:1,pl:9,pms:1,ps:1,pt:1,"pt-br":2,rm:1,ro:5,ru:7,rw:1,sah:0,sat:1,sco:1,sd:1,se:1,si:1,sk:8,sl:10,so:1,son:1,sq:1,sr:7,su:0,sv:1,sw:1,ta:1,te:1,tg:2,th:0,ti:2,tk:1,tr:2,tt:0,ug:0,uk:7,ur:1,uz:2,vi:0,wa:2,wo:0,yo:1,"zh-cn":0,"zh-tw":2},formsByIndex:[["other"],["one","other"],["one","other"],["zero","one","other"],["one","two","few","other"],["one","few","other"],["one","few","other"],["one","few","other"],["one","few","other"],["one","few","other"],["one","two","few","other"],["one","two","few","many","other"],["one","two","few","many","other","zero"],["one","few","many","other"],["one","few","other"],["one","other"],["one","two","few","many","other"],["zero","other"],["zero","one","two","few","many","other"],["one","few","other"],["one","two","few","other"],["one","few","other"],["zero","one","other"]]},{rules:$,rulesByLocale:r,formsByIndex:e}=_;function n(_){return _.toLowerCase().replace("_","-")}function t(_){let $=_.indexOf("-");return $>0?_.substr(0,$):_}function o(_){let $=r[_=n(_)];if(void 0===$){let e=t(_);$=r[e]}if(void 0===$)throw Error(`Unrecognized locale: "${_}".`);return $}function l(_,$){let r=e[$];return function($){return r[_($)]}}function a(_){let r=o(_);return $[r]}function u(_){let r=$[_];if(void 0===r)throw Error(`Invalid index: "${_}".`);return r}function i(_){let r=o(_);return l($[r],r)}function s(_){let r=$[_];if(void 0===r)throw Error(`Invalid index: "${_}".`);return l($[_],_)}function c(_,$){let r=a(_);return r($)}function d(_,$){let r=u(_);return r($)}function f(_,$){let r=i(_);return r($)}function m(_,$){let r=s(_);return r($)}let g;function F(){return g||(g=Object.keys(r)),g}function y(_){let $=r[_];if(void 0!==$)return e[$].length}function h(_){let $=r[_];if(void 0!==$)return e[$]}export{y as getPluralFormCountForLocale,d as getPluralFormForCardinalByIndex,c as getPluralFormForCardinalByLocale,m as getPluralFormNameForCardinalByIndex,f as getPluralFormNameForCardinalByLocale,h as getPluralFormNamesForLocale,u as getPluralRuleForCardinalsByIndex,a as getPluralRuleForCardinalsByLocale,s as getPluralRuleForNamedFormsForCardinalsByIndex,i as getPluralRuleForNamedFormsForCardinalsByLocale,F as getSupportedLocales} //# sourceMappingURL=index.min.mjs.map