Latest 0.1.4
Homepage https://github.com/blob8129/NumeralEndings
License MIT
Platforms ios 8.0
Authors

Version
License
Platform

A tiny library helping to correctly modify Russian words depending on the count.

Features

Library extends integer type to return a correct form of a word.
Russian words a spelled diffently in this cases:

  • Quantity ends in 1 – As per position in the sentence.
  • Quantity ends in 2,3,4 – Genitive Singular.
  • Quantity ends in 5,6,7,8,9,0,11,12 etc. – Genitive Plural

Pros

  • Very flexible
  • Small
  • 100% unit tested

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

NumeralEndings is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "NumeralEndings"

Examples


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 яблок

Authors

Anton Lagutin, Andrey Volobyev [email protected]

License

NumeralEndings is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "NumeralEndings",
    "version": "0.1.4",
    "summary": "A tiny library helping to correctly modify Russian words depending on the count.",
    "description": "Russian words a spelled diffently in this cases:nQuantity ends in 1 - As per position in the sentence.nQuantity ends in 2,3,4 - Genitive Singular.nQuantity ends in 5,6,7,8,9,0,11,12 etc.  - Genitive PluralnLibrary extends integer type to return a correct form of a word.",
    "homepage": "https://github.com/blob8129/NumeralEndings",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "[email protected]"
    },
    "source": {
        "git": "https://github.com/blob8129/NumeralEndings.git",
        "tag": "0.1.4"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "NumeralEndings/Classes/**/*",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This