gopkg.in/essentialkaos/ek.v3@v3.5.1/pluralize/pluralizers.go (about)

     1  package pluralize
     2  
     3  // ////////////////////////////////////////////////////////////////////////////////// //
     4  
     5  // Pluralizer is pluralization rule function
     6  type Pluralizer func(num int) int
     7  
     8  // ////////////////////////////////////////////////////////////////////////////////// //
     9  
    10  // Ach is pluralization rule for Acholi language
    11  var Ach = func(n int) int {
    12  	if n > 1 {
    13  		return 1
    14  	}
    15  
    16  	return 0
    17  }
    18  
    19  // Af is pluralization rule for Afrikaans language
    20  var Af = func(n int) int {
    21  	if n != 1 {
    22  		return 1
    23  	}
    24  
    25  	return 0
    26  }
    27  
    28  // Ak is pluralization rule for Akan language
    29  var Ak = Ach
    30  
    31  // Am is pluralization rule for Amharic language
    32  var Am = Ach
    33  
    34  // An is pluralization rule for Aragonese language
    35  var An = Af
    36  
    37  // Anp is pluralization rule for Angika language
    38  var Anp = Af
    39  
    40  // Ar is pluralization rule for Arabic language
    41  var Ar = func(n int) int {
    42  	switch n {
    43  	case 0, 1, 2:
    44  		return n
    45  	}
    46  
    47  	if n%100 >= 3 && n%100 <= 10 {
    48  		return 3
    49  	}
    50  
    51  	if n%100 >= 11 {
    52  		return 4
    53  	}
    54  
    55  	return 5
    56  }
    57  
    58  // Arn is pluralization rule for Mapudungun language
    59  var Arn = Ach
    60  
    61  // As is pluralization rule for Assamese language
    62  var As = Af
    63  
    64  // Ast is pluralization rule for Asturian language
    65  var Ast = Af
    66  
    67  // Ay is pluralization rule for Aymará language
    68  var Ay = func(n int) int { return 0 }
    69  
    70  // Az is pluralization rule for Azerbaijani language
    71  var Az = Af
    72  
    73  // Be is pluralization rule for Belarusian language
    74  var Be = func(n int) int {
    75  	if n%10 == 1 && n%100 != 11 {
    76  		return 0
    77  	}
    78  
    79  	if n%10 >= 2 && n%10 <= 4 && (n%100 < 10 || n%100 >= 20) {
    80  		return 1
    81  	}
    82  
    83  	return 2
    84  }
    85  
    86  // Bg is pluralization rule for Bulgarian language
    87  var Bg = Af
    88  
    89  // Bn is pluralization rule for Bengali language
    90  var Bn = Af
    91  
    92  // Bo is pluralization rule for Tibetan language
    93  var Bo = Ay
    94  
    95  // Br is pluralization rule for Breton language
    96  var Br = Ach
    97  
    98  // Brx is pluralization rule for Bodo language
    99  var Brx = Af
   100  
   101  // Bs is pluralization rule for Bosnian language
   102  var Bs = Be
   103  
   104  // Ca is pluralization rule for Catalan language
   105  var Ca = Af
   106  
   107  // Cgg is pluralization rule for Chiga language
   108  var Cgg = Ay
   109  
   110  // Cs is pluralization rule for Czech language
   111  var Cs = func(n int) int {
   112  	if n == 1 {
   113  		return 0
   114  	}
   115  
   116  	if n >= 2 && n <= 4 {
   117  		return 1
   118  	}
   119  
   120  	return 2
   121  }
   122  
   123  // Csb is pluralization rule for Kashubian language
   124  var Csb = func(n int) int {
   125  	if n == 1 {
   126  		return 0
   127  	}
   128  
   129  	if n%10 >= 2 && n%10 <= 4 && (n%100 < 10 || n%100 >= 20) {
   130  		return 1
   131  	}
   132  
   133  	return 2
   134  }
   135  
   136  // Cy is pluralization rule for Welsh language
   137  var Cy = func(n int) int {
   138  	switch n {
   139  	case 1, 2:
   140  		return n - 1
   141  	}
   142  
   143  	if n != 8 && n != 11 {
   144  		return 2
   145  	}
   146  
   147  	return 3
   148  }
   149  
   150  // Da is pluralization rule for Danish language
   151  var Da = Af
   152  
   153  // De is pluralization rule for German language
   154  var De = Af
   155  
   156  // Doi is pluralization rule for Dogri language
   157  var Doi = Af
   158  
   159  // Dz is pluralization rule for Dzongkha language
   160  var Dz = Ay
   161  
   162  // El is pluralization rule for Greek language
   163  var El = Af
   164  
   165  // En is pluralization rule for English language
   166  var En = Af
   167  
   168  // Eo is pluralization rule for Esperanto language
   169  var Eo = Af
   170  
   171  // Es is pluralization rule for Spanish language
   172  var Es = Af
   173  
   174  // EsAR is pluralization rule for Argentinean Spanish language
   175  var EsAR = Af
   176  
   177  // Et is pluralization rule for Estonian language
   178  var Et = Af
   179  
   180  // Eu is pluralization rule for Basque language
   181  var Eu = Af
   182  
   183  // Fa is pluralization rule for Persian language
   184  var Fa = Ay
   185  
   186  // Ff is pluralization rule for Fulah language
   187  var Ff = Af
   188  
   189  // Fi is pluralization rule for Finnish language
   190  var Fi = Af
   191  
   192  // Fil is pluralization rule for Filipino language
   193  var Fil = Ach
   194  
   195  // Fo is pluralization rule for Faroese language
   196  var Fo = Af
   197  
   198  // Fr is pluralization rule for French language
   199  var Fr = Ach
   200  
   201  // Fur is pluralization rule for Friulian language
   202  var Fur = Af
   203  
   204  // Fy is pluralization rule for Frisian language
   205  var Fy = Af
   206  
   207  // Ga is pluralization rule for Irish language
   208  var Ga = func(n int) int {
   209  	switch n {
   210  	case 1, 2:
   211  		return n - 1
   212  	}
   213  
   214  	if n > 2 && n < 7 {
   215  		return 2
   216  	}
   217  
   218  	if n > 6 && n < 11 {
   219  		return 3
   220  	}
   221  
   222  	return 4
   223  }
   224  
   225  // Gd is pluralization rule for Scottish Gaelic language
   226  var Gd = func(n int) int {
   227  	if n == 1 || n == 11 {
   228  		return 0
   229  	}
   230  
   231  	if n == 2 || n == 12 {
   232  		return 1
   233  	}
   234  
   235  	if n > 2 && n < 20 {
   236  		return 2
   237  	}
   238  
   239  	return 3
   240  }
   241  
   242  // Gl is pluralization rule for Galician language
   243  var Gl = Af
   244  
   245  // Gu is pluralization rule for Gujarati language
   246  var Gu = Af
   247  
   248  // Gun is pluralization rule for Gun language
   249  var Gun = Ach
   250  
   251  // Ha is pluralization rule for Hausa language
   252  var Ha = Af
   253  
   254  // He is pluralization rule for Hebrew language
   255  var He = Af
   256  
   257  // Hi is pluralization rule for Hindi language
   258  var Hi = Af
   259  
   260  // Hne is pluralization rule for Chhattisgarhi language
   261  var Hne = Af
   262  
   263  // Hr is pluralization rule for Croatian language
   264  var Hr = Be
   265  
   266  // Hu is pluralization rule for Hungarian language
   267  var Hu = Af
   268  
   269  // Hy is pluralization rule for Armenian language
   270  var Hy = Af
   271  
   272  // Ia is pluralization rule for Interlingua language
   273  var Ia = Af
   274  
   275  // Id is pluralization rule for Indonesian language
   276  var Id = Ay
   277  
   278  // Is is pluralization rule for Icelandic language
   279  var Is = func(n int) int {
   280  	if n%10 != 1 || n%100 == 11 {
   281  		return 1
   282  	}
   283  
   284  	return 0
   285  }
   286  
   287  // It is pluralization rule for Italian language
   288  var It = Af
   289  
   290  // Ja is pluralization rule for Japanese language
   291  var Ja = Ay
   292  
   293  // Jbo is pluralization rule for Lojban language
   294  var Jbo = Ay
   295  
   296  // Jv is pluralization rule for Javanese language
   297  var Jv = Af
   298  
   299  // Ka is pluralization rule for Georgian language
   300  var Ka = Ay
   301  
   302  // Kk is pluralization rule for Kazakh language
   303  var Kk = Ay
   304  
   305  // Kl is pluralization rule for Greenlandic language
   306  var Kl = Af
   307  
   308  // Km is pluralization rule for Khmer language
   309  var Km = Ay
   310  
   311  // Kn is pluralization rule for Kannada language
   312  var Kn = Af
   313  
   314  // Ko is pluralization rule for Korean language
   315  var Ko = Ay
   316  
   317  // Ku is pluralization rule for Kurdish language
   318  var Ku = Af
   319  
   320  // Kw is pluralization rule for Cornish language
   321  var Kw = func(n int) int {
   322  	switch n {
   323  	case 1, 2, 3:
   324  		return n - 1
   325  	}
   326  
   327  	return 3
   328  }
   329  
   330  // Ky is pluralization rule for Kyrgyz language
   331  var Ky = Ay
   332  
   333  // Lb is pluralization rule for Letzeburgesch language
   334  var Lb = Af
   335  
   336  // Ln is pluralization rule for Lingala language
   337  var Ln = Ach
   338  
   339  // Lo is pluralization rule for Lao language
   340  var Lo = Ay
   341  
   342  // Lt is pluralization rule for Lithuanian language
   343  var Lt = Be
   344  
   345  // Lv is pluralization rule for Latvian language
   346  var Lv = func(n int) int {
   347  	if n%10 == 1 && n%100 != 11 {
   348  		return 0
   349  	}
   350  
   351  	if n != 0 {
   352  		return 1
   353  	}
   354  
   355  	return 2
   356  }
   357  
   358  // Mai is pluralization rule for Maithili language
   359  var Mai = Af
   360  
   361  // Mfe is pluralization rule for Mauritian Creole language
   362  var Mfe = Ach
   363  
   364  // Mg is pluralization rule for Malagasy language
   365  var Mg = Ach
   366  
   367  // Mi is pluralization rule for Maori language
   368  var Mi = Ach
   369  
   370  // Mk is pluralization rule for Macedonian language
   371  var Mk = func(n int) int {
   372  	if n == 1 || n%10 == 1 {
   373  		return 0
   374  	}
   375  
   376  	return 1
   377  }
   378  
   379  // Ml is pluralization rule for Malayalam language
   380  var Ml = Af
   381  
   382  // Mn is pluralization rule for Mongolian language
   383  var Mn = Af
   384  
   385  // Mni is pluralization rule for Manipuri language
   386  var Mni = Af
   387  
   388  // Mnk is pluralization rule for Mandinka language
   389  var Mnk = func(n int) int {
   390  	switch n {
   391  	case 0, 1:
   392  		return n
   393  	}
   394  
   395  	return 2
   396  }
   397  
   398  // Mr is pluralization rule for Marathi language
   399  var Mr = Af
   400  
   401  // Ms is pluralization rule for Malay language
   402  var Ms = Ay
   403  
   404  // Mt is pluralization rule for Maltese language
   405  var Mt = func(n int) int {
   406  	if n == 1 {
   407  		return 0
   408  	}
   409  
   410  	if n == 0 || (n%100 > 1 && n%100 < 11) {
   411  		return 1
   412  	}
   413  
   414  	if n%100 > 10 && n%100 < 20 {
   415  		return 2
   416  	}
   417  
   418  	return 3
   419  }
   420  
   421  // My is pluralization rule for Burmese language
   422  var My = Ay
   423  
   424  // Nah is pluralization rule for Nahuatl language
   425  var Nah = Af
   426  
   427  // Nap is pluralization rule for Neapolitan language
   428  var Nap = Af
   429  
   430  // Nb is pluralization rule for Norwegian Bokmal language
   431  var Nb = Af
   432  
   433  // Ne is pluralization rule for Nepali language
   434  var Ne = Af
   435  
   436  // Nl is pluralization rule for Dutch language
   437  var Nl = Af
   438  
   439  // Nn is pluralization rule for Norwegian Nynorsk language
   440  var Nn = Af
   441  
   442  // No is pluralization rule for Norwegian (old code) language
   443  var No = Af
   444  
   445  // Nso is pluralization rule for Northern Sotho language
   446  var Nso = Af
   447  
   448  // Oc is pluralization rule for Occitan language
   449  var Oc = Ach
   450  
   451  // Or is pluralization rule for Oriya language
   452  var Or = Af
   453  
   454  // Pa is pluralization rule for Punjabi language
   455  var Pa = Af
   456  
   457  // Pap is pluralization rule for Papiamento language
   458  var Pap = Af
   459  
   460  // Pl is pluralization rule for Polish language
   461  var Pl = Be
   462  
   463  // Pms is pluralization rule for Piemontese language
   464  var Pms = Af
   465  
   466  // Ps is pluralization rule for Pashto language
   467  var Ps = Af
   468  
   469  // Pt is pluralization rule for Portuguese language
   470  var Pt = Af
   471  
   472  // PtBR is pluralization rule for Brazilian Portuguese language
   473  var PtBR = Ach
   474  
   475  // Rm is pluralization rule for Romansh language
   476  var Rm = Af
   477  
   478  // Ro is pluralization rule for Romanian language
   479  var Ro = func(n int) int {
   480  	if n == 1 {
   481  		return 0
   482  	}
   483  
   484  	if n == 0 || (n%100 > 0 && n%100 < 20) {
   485  		return 1
   486  	}
   487  
   488  	return 2
   489  }
   490  
   491  // Ru is pluralization rule for Russian language
   492  var Ru = Be
   493  
   494  // Rw is pluralization rule for Kinyarwanda language
   495  var Rw = Af
   496  
   497  // Sah is pluralization rule for Yakut language
   498  var Sah = Ay
   499  
   500  // Sat is pluralization rule for Santali language
   501  var Sat = Af
   502  
   503  // Sco is pluralization rule for Scots language
   504  var Sco = Af
   505  
   506  // Sd is pluralization rule for Sindhi language
   507  var Sd = Af
   508  
   509  // Se is pluralization rule for Northern Sami language
   510  var Se = Af
   511  
   512  // Si is pluralization rule for Sinhala language
   513  var Si = Af
   514  
   515  // Sk is pluralization rule for Slovak language
   516  var Sk = func(n int) int {
   517  	if n == 1 {
   518  		return 0
   519  	}
   520  
   521  	if n >= 2 && n <= 4 {
   522  		return 1
   523  	}
   524  
   525  	return 2
   526  }
   527  
   528  // Sl is pluralization rule for Slovenian language
   529  var Sl = func(n int) int {
   530  	switch n % 100 {
   531  	case 1:
   532  		return 1
   533  	case 2:
   534  		return 2
   535  	case 3:
   536  		return 3
   537  	}
   538  
   539  	return 0
   540  }
   541  
   542  // So is pluralization rule for Somali language
   543  var So = Af
   544  
   545  // Son is pluralization rule for Songhay language
   546  var Son = Af
   547  
   548  // Sq is pluralization rule for Albanian language
   549  var Sq = Af
   550  
   551  // Sr is pluralization rule for Serbian language
   552  var Sr = Be
   553  
   554  // Su is pluralization rule for Sundanese language
   555  var Su = Ay
   556  
   557  // Sv is pluralization rule for Swedish language
   558  var Sv = Af
   559  
   560  // Sw is pluralization rule for Swahili language
   561  var Sw = Af
   562  
   563  // Ta is pluralization rule for Tamil language
   564  var Ta = Af
   565  
   566  // Te is pluralization rule for Telugu language
   567  var Te = Af
   568  
   569  // Tg is pluralization rule for Tajik language
   570  var Tg = Ach
   571  
   572  // Th is pluralization rule for Thai language
   573  var Th = Ay
   574  
   575  // Ti is pluralization rule for Tigrinya language
   576  var Ti = Ach
   577  
   578  // Tk is pluralization rule for Turkmen language
   579  var Tk = Af
   580  
   581  // Tr is pluralization rule for Turkish language
   582  var Tr = Ach
   583  
   584  // Tt is pluralization rule for Tatar language
   585  var Tt = Ay
   586  
   587  // Ug is pluralization rule for Uyghur language
   588  var Ug = Ay
   589  
   590  // Uk is pluralization rule for Ukrainian language
   591  var Uk = Be
   592  
   593  // Ur is pluralization rule for Urdu language
   594  var Ur = Af
   595  
   596  // Uz is pluralization rule for Uzbek language
   597  var Uz = Ach
   598  
   599  // Vi is pluralization rule for Vietnamese language
   600  var Vi = Ay
   601  
   602  // Wa is pluralization rule for Walloon language
   603  var Wa = Ach
   604  
   605  // Wo is pluralization rule for Wolof language
   606  var Wo = Ay
   607  
   608  // Yo is pluralization rule for Yoruba language
   609  var Yo = Af
   610  
   611  // Zh is pluralization rule for Chinese language
   612  var Zh = Ay