pluralize

package
v12.90.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2023 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Overview

Package pluralize provides methods for pluralization

Index

Examples

Constants

This section is empty.

Variables

View Source
var Ach = func(n int) int {
	if n > 1 {
		return 1
	}

	return 0
}

Ach is pluralization rule for Acholi language

View Source
var Af = func(n int) int {
	if n != 1 {
		return 1
	}

	return 0
}

Af is pluralization rule for Afrikaans language

View Source
var Ak = Ach

Ak is pluralization rule for Akan language

View Source
var Am = Ach

Am is pluralization rule for Amharic language

View Source
var An = Af

An is pluralization rule for Aragonese language

View Source
var Anp = Af

Anp is pluralization rule for Angika language

View Source
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

View Source
var Arn = Ach

Arn is pluralization rule for Mapudungun language

View Source
var As = Af

As is pluralization rule for Assamese language

View Source
var Ast = Af

Ast is pluralization rule for Asturian language

View Source
var Ay = func(n int) int { return 0 }

Ay is pluralization rule for Aymará language

View Source
var Az = Af

Az is pluralization rule for Azerbaijani language

View Source
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

View Source
var Bg = Af

Bg is pluralization rule for Bulgarian language

View Source
var Bn = Af

Bn is pluralization rule for Bengali language

View Source
var Bo = Ay

Bo is pluralization rule for Tibetan language

View Source
var Br = Ach

Br is pluralization rule for Breton language

View Source
var Brx = Af

Brx is pluralization rule for Bodo language

View Source
var Bs = Be

Bs is pluralization rule for Bosnian language

View Source
var Ca = Af

Ca is pluralization rule for Catalan language

View Source
var Cgg = Ay

Cgg is pluralization rule for Chiga language

View Source
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

View Source
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

View Source
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

View Source
var Da = Af

Da is pluralization rule for Danish language

View Source
var De = Af

De is pluralization rule for German language

View Source
var DefaultPluralizer = En

DefaultPluralizer holds default pluralization function

View Source
var Doi = Af

Doi is pluralization rule for Dogri language

View Source
var Dz = Ay

Dz is pluralization rule for Dzongkha language

View Source
var El = Af

El is pluralization rule for Greek language

View Source
var En = Af

En is pluralization rule for English language

View Source
var Eo = Af

Eo is pluralization rule for Esperanto language

View Source
var Es = Af

Es is pluralization rule for Spanish language

View Source
var EsAR = Af

EsAR is pluralization rule for Argentinean Spanish language

View Source
var Et = Af

Et is pluralization rule for Estonian language

View Source
var Eu = Af

Eu is pluralization rule for Basque language

View Source
var Fa = Ay

Fa is pluralization rule for Persian language

View Source
var Ff = Af

Ff is pluralization rule for Fulah language

View Source
var Fi = Af

Fi is pluralization rule for Finnish language

View Source
var Fil = Ach

Fil is pluralization rule for Filipino language

View Source
var Fo = Af

Fo is pluralization rule for Faroese language

View Source
var Fr = Ach

Fr is pluralization rule for French language

View Source
var Fur = Af

Fur is pluralization rule for Friulian language

View Source
var Fy = Af

Fy is pluralization rule for Frisian language

View Source
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

View Source
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

View Source
var Gl = Af

Gl is pluralization rule for Galician language

View Source
var Gu = Af

Gu is pluralization rule for Gujarati language

View Source
var Gun = Ach

Gun is pluralization rule for Gun language

View Source
var Ha = Af

Ha is pluralization rule for Hausa language

View Source
var He = Af

He is pluralization rule for Hebrew language

View Source
var Hi = Af

Hi is pluralization rule for Hindi language

View Source
var Hne = Af

Hne is pluralization rule for Chhattisgarhi language

View Source
var Hr = Be

Hr is pluralization rule for Croatian language

View Source
var Hu = Af

Hu is pluralization rule for Hungarian language

View Source
var Hy = Af

Hy is pluralization rule for Armenian language

View Source
var Ia = Af

Ia is pluralization rule for Interlingua language

View Source
var Id = Ay

Id is pluralization rule for Indonesian language

View Source
var Is = func(n int) int {
	if n%10 != 1 || n%100 == 11 {
		return 1
	}

	return 0
}

Is is pluralization rule for Icelandic language

View Source
var It = Af

It is pluralization rule for Italian language

View Source
var Ja = Ay

Ja is pluralization rule for Japanese language

View Source
var Jbo = Ay

Jbo is pluralization rule for Lojban language

View Source
var Jv = Af

Jv is pluralization rule for Javanese language

View Source
var Ka = Ay

Ka is pluralization rule for Georgian language

View Source
var Kk = Ay

Kk is pluralization rule for Kazakh language

View Source
var Kl = Af

Kl is pluralization rule for Greenlandic language

View Source
var Km = Ay

Km is pluralization rule for Khmer language

View Source
var Kn = Af

Kn is pluralization rule for Kannada language

View Source
var Ko = Ay

Ko is pluralization rule for Korean language

View Source
var Ku = Af

Ku is pluralization rule for Kurdish language

View Source
var Kw = func(n int) int {
	switch n {
	case 1, 2, 3:
		return n - 1
	}

	return 3
}

Kw is pluralization rule for Cornish language

View Source
var Ky = Ay

Ky is pluralization rule for Kyrgyz language

View Source
var Lb = Af

Lb is pluralization rule for Letzeburgesch language

View Source
var Ln = Ach

Ln is pluralization rule for Lingala language

View Source
var Lo = Ay

Lo is pluralization rule for Lao language

View Source
var Lt = Be

Lt is pluralization rule for Lithuanian language

View Source
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

View Source
var Mai = Af

Mai is pluralization rule for Maithili language

View Source
var Mfe = Ach

Mfe is pluralization rule for Mauritian Creole language

View Source
var Mg = Ach

Mg is pluralization rule for Malagasy language

View Source
var Mi = Ach

Mi is pluralization rule for Maori language

View Source
var Mk = func(n int) int {
	if n == 1 || n%10 == 1 {
		return 0
	}

	return 1
}

Mk is pluralization rule for Macedonian language

View Source
var Ml = Af

Ml is pluralization rule for Malayalam language

View Source
var Mn = Af

Mn is pluralization rule for Mongolian language

View Source
var Mni = Af

Mni is pluralization rule for Manipuri language

View Source
var Mnk = func(n int) int {
	switch n {
	case 0, 1:
		return n
	}

	return 2
}

Mnk is pluralization rule for Mandinka language

View Source
var Mr = Af

Mr is pluralization rule for Marathi language

View Source
var Ms = Ay

Ms is pluralization rule for Malay language

View Source
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

View Source
var My = Ay

My is pluralization rule for Burmese language

View Source
var Nah = Af

Nah is pluralization rule for Nahuatl language

View Source
var Nap = Af

Nap is pluralization rule for Neapolitan language

View Source
var Nb = Af

Nb is pluralization rule for Norwegian Bokmal language

View Source
var Ne = Af

Ne is pluralization rule for Nepali language

View Source
var Nl = Af

Nl is pluralization rule for Dutch language

View Source
var Nn = Af

Nn is pluralization rule for Norwegian Nynorsk language

View Source
var No = Af

No is pluralization rule for Norwegian (old code) language

View Source
var Nso = Af

Nso is pluralization rule for Northern Sotho language

View Source
var Oc = Ach

Oc is pluralization rule for Occitan language

View Source
var Or = Af

Or is pluralization rule for Oriya language

View Source
var Pa = Af

Pa is pluralization rule for Punjabi language

View Source
var Pap = Af

Pap is pluralization rule for Papiamento language

View Source
var Pl = Be

Pl is pluralization rule for Polish language

View Source
var Pms = Af

Pms is pluralization rule for Piemontese language

View Source
var Ps = Af

Ps is pluralization rule for Pashto language

View Source
var Pt = Af

Pt is pluralization rule for Portuguese language

View Source
var PtBR = Ach

PtBR is pluralization rule for Brazilian Portuguese language

View Source
var Rm = Af

Rm is pluralization rule for Romansh language

View Source
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

View Source
var Ru = Be

Ru is pluralization rule for Russian language

View Source
var Rw = Af

Rw is pluralization rule for Kinyarwanda language

View Source
var Sah = Ay

Sah is pluralization rule for Yakut language

View Source
var Sat = Af

Sat is pluralization rule for Santali language

View Source
var Sco = Af

Sco is pluralization rule for Scots language

View Source
var Sd = Af

Sd is pluralization rule for Sindhi language

View Source
var Se = Af

Se is pluralization rule for Northern Sami language

View Source
var Si = Af

Si is pluralization rule for Sinhala language

View Source
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

View Source
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

View Source
var So = Af

So is pluralization rule for Somali language

View Source
var Son = Af

Son is pluralization rule for Songhay language

View Source
var Sq = Af

Sq is pluralization rule for Albanian language

View Source
var Sr = Be

Sr is pluralization rule for Serbian language

View Source
var Su = Ay

Su is pluralization rule for Sundanese language

View Source
var Sv = Af

Sv is pluralization rule for Swedish language

View Source
var Sw = Af

Sw is pluralization rule for Swahili language

View Source
var Ta = Af

Ta is pluralization rule for Tamil language

View Source
var Te = Af

Te is pluralization rule for Telugu language

View Source
var Tg = Ach

Tg is pluralization rule for Tajik language

View Source
var Th = Ay

Th is pluralization rule for Thai language

View Source
var Ti = Ach

Ti is pluralization rule for Tigrinya language

View Source
var Tk = Af

Tk is pluralization rule for Turkmen language

View Source
var Tr = Ach

Tr is pluralization rule for Turkish language

View Source
var Tt = Ay

Tt is pluralization rule for Tatar language

View Source
var Ug = Ay

Ug is pluralization rule for Uyghur language

View Source
var Uk = Be

Uk is pluralization rule for Ukrainian language

View Source
var Ur = Af

Ur is pluralization rule for Urdu language

View Source
var Uz = Ach

Uz is pluralization rule for Uzbek language

View Source
var Vi = Ay

Vi is pluralization rule for Vietnamese language

View Source
var Wa = Ach

Wa is pluralization rule for Walloon language

View Source
var Wo = Ay

Wo is pluralization rule for Wolof language

View Source
var Yo = Af

Yo is pluralization rule for Yoruba language

View Source
var Zh = Ay

Zh is pluralization rule for Chinese language

Functions

func P

func P(format string, n any, data ...string) string

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

func Pluralize(n int, data ...string) string

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:

яблоко
яблок

Types

type Pluralizer

type Pluralizer func(num int) int

Pluralizer is pluralization rule function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL