Documentation ¶
Overview ¶
Package pluralize provides methods for pluralization
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Ach = func(n int) int {
if n > 1 {
return 1
}
return 0
}
Ach is pluralization rule for Acholi language
var Af = func(n int) int {
if n != 1 {
return 1
}
return 0
}
Af is pluralization rule for Afrikaans language
var Ak = Ach
Ak is pluralization rule for Akan language
var Am = Ach
Am is pluralization rule for Amharic language
var An = Af
An is pluralization rule for Aragonese language
var Anp = Af
Anp is pluralization rule for Angika language
var Ar = func(n int) int {
switch n {
case 0, 1, 2:
return n
}
if n%100 >= 3 && n%100 <= 10 {
return 3
}
if n%100 >= 11 {
return 4
}
return 5
}
Ar is pluralization rule for Arabic language
var Arn = Ach
Arn is pluralization rule for Mapudungun language
var As = Af
As is pluralization rule for Assamese language
var Ast = Af
Ast is pluralization rule for Asturian language
var Ay = func(n int) int { return 0 }
Ay is pluralization rule for Aymará language
var Az = Af
Az is pluralization rule for Azerbaijani language
var Be = func(n int) int {
if n%10 == 1 && n%100 != 11 {
return 0
}
if n%10 >= 2 && n%10 <= 4 && (n%100 < 10 || n%100 >= 20) {
return 1
}
return 2
}
Be is pluralization rule for Belarusian language
var Bg = Af
Bg is pluralization rule for Bulgarian language
var Bn = Af
Bn is pluralization rule for Bengali language
var Bo = Ay
Bo is pluralization rule for Tibetan language
var Br = Ach
Br is pluralization rule for Breton language
var Brx = Af
Brx is pluralization rule for Bodo language
var Bs = Be
Bs is pluralization rule for Bosnian language
var Ca = Af
Ca is pluralization rule for Catalan language
var Cgg = Ay
Cgg is pluralization rule for Chiga language
var Cs = func(n int) int {
if n == 1 {
return 0
}
if n >= 2 && n <= 4 {
return 1
}
return 2
}
Cs is pluralization rule for Czech language
var Csb = func(n int) int {
if n == 1 {
return 0
}
if n%10 >= 2 && n%10 <= 4 && (n%100 < 10 || n%100 >= 20) {
return 1
}
return 2
}
Csb is pluralization rule for Kashubian language
var Cy = func(n int) int {
switch n {
case 1, 2:
return n - 1
}
if n != 8 && n != 11 {
return 2
}
return 3
}
Cy is pluralization rule for Welsh language
var Da = Af
Da is pluralization rule for Danish language
var De = Af
De is pluralization rule for German language
var DefaultPluralizer = En
DefaultPluralizer holds default pluralization function
var Doi = Af
Doi is pluralization rule for Dogri language
var Dz = Ay
Dz is pluralization rule for Dzongkha language
var El = Af
El is pluralization rule for Greek language
var En = Af
En is pluralization rule for English language
var Eo = Af
Eo is pluralization rule for Esperanto language
var Es = Af
Es is pluralization rule for Spanish language
var EsAR = Af
EsAR is pluralization rule for Argentinean Spanish language
var Et = Af
Et is pluralization rule for Estonian language
var Eu = Af
Eu is pluralization rule for Basque language
var Fa = Ay
Fa is pluralization rule for Persian language
var Ff = Af
Ff is pluralization rule for Fulah language
var Fi = Af
Fi is pluralization rule for Finnish language
var Fil = Ach
Fil is pluralization rule for Filipino language
var Fo = Af
Fo is pluralization rule for Faroese language
var Fr = Ach
Fr is pluralization rule for French language
var Fur = Af
Fur is pluralization rule for Friulian language
var Fy = Af
Fy is pluralization rule for Frisian language
var Ga = func(n int) int {
switch n {
case 1, 2:
return n - 1
}
if n > 2 && n < 7 {
return 2
}
if n > 6 && n < 11 {
return 3
}
return 4
}
Ga is pluralization rule for Irish language
var Gd = func(n int) int {
if n == 1 || n == 11 {
return 0
}
if n == 2 || n == 12 {
return 1
}
if n > 2 && n < 20 {
return 2
}
return 3
}
Gd is pluralization rule for Scottish Gaelic language
var Gl = Af
Gl is pluralization rule for Galician language
var Gu = Af
Gu is pluralization rule for Gujarati language
var Gun = Ach
Gun is pluralization rule for Gun language
var Ha = Af
Ha is pluralization rule for Hausa language
var He = Af
He is pluralization rule for Hebrew language
var Hi = Af
Hi is pluralization rule for Hindi language
var Hne = Af
Hne is pluralization rule for Chhattisgarhi language
var Hr = Be
Hr is pluralization rule for Croatian language
var Hu = Af
Hu is pluralization rule for Hungarian language
var Hy = Af
Hy is pluralization rule for Armenian language
var Ia = Af
Ia is pluralization rule for Interlingua language
var Id = Ay
Id is pluralization rule for Indonesian language
var Is = func(n int) int {
if n%10 != 1 || n%100 == 11 {
return 1
}
return 0
}
Is is pluralization rule for Icelandic language
var It = Af
It is pluralization rule for Italian language
var Ja = Ay
Ja is pluralization rule for Japanese language
var Jbo = Ay
Jbo is pluralization rule for Lojban language
var Jv = Af
Jv is pluralization rule for Javanese language
var Ka = Ay
Ka is pluralization rule for Georgian language
var Kk = Ay
Kk is pluralization rule for Kazakh language
var Kl = Af
Kl is pluralization rule for Greenlandic language
var Km = Ay
Km is pluralization rule for Khmer language
var Kn = Af
Kn is pluralization rule for Kannada language
var Ko = Ay
Ko is pluralization rule for Korean language
var Ku = Af
Ku is pluralization rule for Kurdish language
var Kw = func(n int) int {
switch n {
case 1, 2, 3:
return n - 1
}
return 3
}
Kw is pluralization rule for Cornish language
var Ky = Ay
Ky is pluralization rule for Kyrgyz language
var Lb = Af
Lb is pluralization rule for Letzeburgesch language
var Ln = Ach
Ln is pluralization rule for Lingala language
var Lo = Ay
Lo is pluralization rule for Lao language
var Lt = Be
Lt is pluralization rule for Lithuanian language
var Lv = func(n int) int {
if n%10 == 1 && n%100 != 11 {
return 0
}
if n != 0 {
return 1
}
return 2
}
Lv is pluralization rule for Latvian language
var Mai = Af
Mai is pluralization rule for Maithili language
var Mfe = Ach
Mfe is pluralization rule for Mauritian Creole language
var Mg = Ach
Mg is pluralization rule for Malagasy language
var Mi = Ach
Mi is pluralization rule for Maori language
var Mk = func(n int) int {
if n == 1 || n%10 == 1 {
return 0
}
return 1
}
Mk is pluralization rule for Macedonian language
var Ml = Af
Ml is pluralization rule for Malayalam language
var Mn = Af
Mn is pluralization rule for Mongolian language
var Mni = Af
Mni is pluralization rule for Manipuri language
var Mnk = func(n int) int {
switch n {
case 0, 1:
return n
}
return 2
}
Mnk is pluralization rule for Mandinka language
var Mr = Af
Mr is pluralization rule for Marathi language
var Ms = Ay
Ms is pluralization rule for Malay language
var Mt = func(n int) int {
if n == 1 {
return 0
}
if n == 0 || (n%100 > 1 && n%100 < 11) {
return 1
}
if n%100 > 10 && n%100 < 20 {
return 2
}
return 3
}
Mt is pluralization rule for Maltese language
var My = Ay
My is pluralization rule for Burmese language
var Nah = Af
Nah is pluralization rule for Nahuatl language
var Nap = Af
Nap is pluralization rule for Neapolitan language
var Nb = Af
Nb is pluralization rule for Norwegian Bokmal language
var Ne = Af
Ne is pluralization rule for Nepali language
var Nl = Af
Nl is pluralization rule for Dutch language
var Nn = Af
Nn is pluralization rule for Norwegian Nynorsk language
var No = Af
No is pluralization rule for Norwegian (old code) language
var Nso = Af
Nso is pluralization rule for Northern Sotho language
var Oc = Ach
Oc is pluralization rule for Occitan language
var Or = Af
Or is pluralization rule for Oriya language
var Pa = Af
Pa is pluralization rule for Punjabi language
var Pap = Af
Pap is pluralization rule for Papiamento language
var Pl = Be
Pl is pluralization rule for Polish language
var Pms = Af
Pms is pluralization rule for Piemontese language
var Ps = Af
Ps is pluralization rule for Pashto language
var Pt = Af
Pt is pluralization rule for Portuguese language
var PtBR = Ach
PtBR is pluralization rule for Brazilian Portuguese language
var Rm = Af
Rm is pluralization rule for Romansh language
var Ro = func(n int) int {
if n == 1 {
return 0
}
if n == 0 || (n%100 > 0 && n%100 < 20) {
return 1
}
return 2
}
Ro is pluralization rule for Romanian language
var Ru = Be
Ru is pluralization rule for Russian language
var Rw = Af
Rw is pluralization rule for Kinyarwanda language
var Sah = Ay
Sah is pluralization rule for Yakut language
var Sat = Af
Sat is pluralization rule for Santali language
var Sco = Af
Sco is pluralization rule for Scots language
var Sd = Af
Sd is pluralization rule for Sindhi language
var Se = Af
Se is pluralization rule for Northern Sami language
var Si = Af
Si is pluralization rule for Sinhala language
var Sk = func(n int) int {
if n == 1 {
return 0
}
if n >= 2 && n <= 4 {
return 1
}
return 2
}
Sk is pluralization rule for Slovak language
var Sl = func(n int) int {
switch n % 100 {
case 1:
return 1
case 2:
return 2
case 3:
return 3
}
return 0
}
Sl is pluralization rule for Slovenian language
var So = Af
So is pluralization rule for Somali language
var Son = Af
Son is pluralization rule for Songhay language
var Sq = Af
Sq is pluralization rule for Albanian language
var Sr = Be
Sr is pluralization rule for Serbian language
var Su = Ay
Su is pluralization rule for Sundanese language
var Sv = Af
Sv is pluralization rule for Swedish language
var Sw = Af
Sw is pluralization rule for Swahili language
var Ta = Af
Ta is pluralization rule for Tamil language
var Te = Af
Te is pluralization rule for Telugu language
var Tg = Ach
Tg is pluralization rule for Tajik language
var Th = Ay
Th is pluralization rule for Thai language
var Ti = Ach
Ti is pluralization rule for Tigrinya language
var Tk = Af
Tk is pluralization rule for Turkmen language
var Tr = Ach
Tr is pluralization rule for Turkish language
var Tt = Ay
Tt is pluralization rule for Tatar language
var Ug = Ay
Ug is pluralization rule for Uyghur language
var Uk = Be
Uk is pluralization rule for Ukrainian language
var Ur = Af
Ur is pluralization rule for Urdu language
var Uz = Ach
Uz is pluralization rule for Uzbek language
var Vi = Ay
Vi is pluralization rule for Vietnamese language
var Wa = Ach
Wa is pluralization rule for Walloon language
var Wo = Ay
Wo is pluralization rule for Wolof language
var Yo = Af
Yo is pluralization rule for Yoruba language
var Zh = Ay
Zh is pluralization rule for Chinese language
Functions ¶
func P ¶
P pluralizes a word based on the passed number with custom format
Example ¶
fmt.Println(P("I have %d %s", 1, "apple", "apples")) fmt.Println(P("I have %d %s", 5, "apple", "apples"))
Output: I have 1 apple I have 5 apples
func PS ¶
func PS(p Pluralizer, format string, n any, data ...string) string
PS pluralizes a word based on the passed number with custom pluralizer and format
Example ¶
fmt.Println(PS(Ru, "У меня %d %s", 1, "яблоко", "яблока", "яблок")) fmt.Println(PS(Ru, "У меня %d %s", 5, "яблоко", "яблока", "яблок"))
Output: У меня 1 яблоко У меня 5 яблок
func Pluralize ¶
Pluralize pluralizes a word based on the passed number
Example ¶
fmt.Println(Pluralize(1, "apple", "apples")) fmt.Println(Pluralize(5, "apple", "apples"))
Output: apple apples
func PluralizeSpecial ¶
func PluralizeSpecial(p Pluralizer, n int, data ...string) string
PluralizeSpecial pluralizes a word based on the passed number with custom pluralizer
Example ¶
fmt.Println(PluralizeSpecial(Ru, 1, "яблоко", "яблока", "яблок")) fmt.Println(PluralizeSpecial(Ru, 5, "яблоко", "яблока", "яблок"))
Output: яблоко яблок