Skip to content

Pluralization of russian words for golang

License

Notifications You must be signed in to change notification settings

rb-go/plural-ru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plural-ru

Go Reference GitHub release (latest SemVer) GitHub go.mod Go version Go Report Card Coverage Status license

Package Pluralization of russian words for golang with generics for int | int32 | int64 | uint | uint32 | uint64 types

Usage

package main

import (
    "log"

    "github.com/rb-go/plural-ru"
)

func main() {
    log.Println(1, plural.Noun(1, "день", "дня", "дней"))
    log.Println(2, plural.Noun(2, "день", "дня", "дней"))
    log.Println(3, plural.Noun(3, "день", "дня", "дней"))
    log.Println(4, plural.Noun(4, "день", "дня", "дней"))
    log.Println(5, plural.Noun(5, "день", "дня", "дней"))
    log.Println(8, plural.Noun(8, "день", "дня", "дней"))
    log.Println(11, plural.Noun(11, "день", "дня", "дней"))
    log.Println(1111, plural.Noun(1111, "день", "дня", "дней"))
    log.Println(121, plural.Noun(121, "день", "дня", "дней"))

    cnt := 100500
    log.Println(plural.Verb(cnt, "нашелся", "нашлись", "нашлось"), cnt, plural.Noun(cnt, "идея", "идеи", "идей"))
}

will print in console:

2022/10/28 17:27:09 1 день
2022/10/28 17:27:09 2 дня
2022/10/28 17:27:09 3 дня
2022/10/28 17:27:09 4 дня
2022/10/28 17:27:09 5 дней
2022/10/28 17:27:09 8 дней
2022/10/28 17:27:09 11 дней
2022/10/28 17:27:09 1111 дней
2022/10/28 17:27:09 121 день
2022/10/28 17:27:09 нашлось 100500 идей