TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jun 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Andrey Volobuev.
A tiny library helping to correctly modify Russian words depending on the count.
Library extends integer type to return a correct form of a word. Russian words a spelled diffently in this cases:
To run the example project, clone the repo, and run pod install
from the Example directory first.
NumeralEndings is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "NumeralEndings"
let count: Int
let counted = count.toNumeralEndingString(commonPart: "организаци", oneOf:"я", twoOf: "ии", fiveOf: "ий")
"В нашем каталоге \(count) \(counted)"
// "В нашем каталоге 1 орагнизация"
// "В нашем каталоге 2 орагнизации"
// "В нашем каталоге 100 орагнизаций"
let counted = count.toNumeralEndingString(commonPart: "час", twoOf: "а", fiveOf: "ов")
"Длительность \(count) \(counted)"
// "Длительность 1 час"
// "Длительность 2 часа"
// "Длительность 5 часов"
let counted = count.toNumeralEndingString(oneOf: "день", twoOf: "дня", fiveOf: "дней")
"До конца отпуска \(count) \(counted)"
// До конца отпуска 1 день
// До конца отпуска 2 дня
// До конца отпуска 36 дней
let counted = count.toNumeralEndingString(oneOf: "год", twoOf: "года", fiveOf: "лет")
"До сингулярности \(count) \(counted)"
// До сингулярности 1 год
// До сингулярности 2 года
// До сингулярности 36 лет
let counted = count.toNumeralEndingString(format: "1год 2года 5лет")
"До сингулярности \(count) \(counted)"
// До сингулярности 1 год
// До сингулярности 2 года
// До сингулярности 36 лет
let counted = count.toNumeralEndingString(format: "яблок 1о 2а")
"У вас \(count) \(counted)"
// У вас 1 яблоко
// У вас 2 яблока
// У вас 36 яблок
Anton Lagutin, Andrey Volobyev [email protected]
NumeralEndings is available under the MIT license. See the LICENSE file for more info.