"""Module containing plural rules of various languages."""## (C) Pywikibot team, 2011-2022## Distributed under the terms of the MIT license.#from__future__importannotationsfromtypingimportTYPE_CHECKING,CallableifTYPE_CHECKING:PluralRule=dict[str,int|Callable[[int],bool|int]]plural_rules:dict[str,PluralRule]={'_default':{'nplurals':2,'plural':lambdan:(n!=1)},'ar':{'nplurals':6,'plural':lambdan:0if(n==0)else1if(n==1)else2if(n==2)else3if(3<=(n%100)<=10)else4if(11<=(n%100)<=99)else5},'cs':{'nplurals':3,'plural':lambdan:0if(n==1)else1if(2<=n<=4)else2},'cy':{'nplurals':4,'plural':lambdan:0if(n==1)else1if(n==2)else2ifnnotin(8,11)else3},'ga':{'nplurals':5,'plural':lambdan:0if(n==1)else1if(n==2)else2if(n<7)else3if(n<11)else4},'gd':{'nplurals':4,'plural':lambdan:0ifnin(1,11)else1ifnin(2,12)else2if(2<n<20)else3},'is':{'nplurals':2,'plural':lambdan:(n%10!=1orn%100==11)},'kw':{'nplurals':4,'plural':lambdan:0if(n==1)else1if(n==2)else2if(n==3)else3},'lt':{'nplurals':3,'plural':lambdan:0if(n%10==1andn%100!=11)else1if(n%10>=2and(n%100<10orn%100>=20))else2},'lv':{'nplurals':3,'plural':lambdan:0if(n%10==1andn%100!=11)else1if(n!=0)else2},'mk':{'nplurals':2,'plural':lambdan:0ifn%10==1else1},'mnk':{'nplurals':3,'plural':lambdan:0if(n==0)else1ifn==1else2},'mt':{'nplurals':4,'plural':lambdan:0if(n==1)else1if(n==0or(1<(n%100)<11))else2if(10<(n%100)<20)else3},'pl':{'nplurals':3,'plural':lambdan:0if(n==1)else1if(2<=(n%10)<=4)and(n%100<10orn%100>=20)else2},'ro':{'nplurals':3,'plural':lambdan:0if(n==1)else1if(n==0or(0<(n%100)<20))else2},'sk':{'nplurals':3,'plural':lambdan:0if(n==1)else1if(2<=n<=4)else2},'sl':{'nplurals':4,'plural':lambdan:0if(n%100==1)else1if(n%100==2)else2ifn%100in(3,4)else3},}plural_rules.update(dict.fromkeys(['ay','bo','cgg','dz','fa','id','ja','jbo','ka','kk','km','ko','ky','lo','ms','my','sah','su','th','tt','ug','vi','wo','zh','zh-hans','zh-hant','zh-tw'],{'nplurals':1,'plural':0}))plural_rules.update(dict.fromkeys(['ach','ak','am','arn','br','fil','fr','gun','ln','mfe','mg','mi','oc','pt-br','ti','tr','uz','wa'],{'nplurals':2,'plural':lambdan:(n>1)}))plural_rules.update(dict.fromkeys(['be','bs','csb','hr','ru','sr','uk'],{'nplurals':3,'plural':lambdan:0ifn%10==1andn%100!=11else1if(2<=(n%10)<=4)and(n%100<10orn%100>=20)else2}))
[docs]defplural_rule(lang:str)->PluralRule:"""Return the plural rule for a given lang. .. versionadded:: 4.3 """returnplural_rules.get(lang,plural_rules['_default'])