Latest 0.0.1
Homepage https://github.com/mattt/InflectorKit
License MIT
Authors

Efficiently Singularize and Pluralize Strings

InflectorKit ports the string inflection functionality of Rails ActiveSupport to Foundation.

InflectorKit joins FormatterKit & TransformerKit in providing well-designed APIs for manipulating user-facing content.

Usage

#import "NSString+InflectorKit.h"

for (NSString *singular in @[@"person", @"tomato", @"matrix", @"octopus", @"fish"]) {
  NSLog(@"%@: %@", singular, [singular pluralizedString]);
}
person: people
tomato: tomatoes
matrix: matrices
octopus: octopi
fish: fish

You can also add pluralization rules, including irregular and uncountable words:

#import "TTTStringInflector.h"

TTTStringInflector *inflector = [TTTStringInflector defaultInflector];
[inflector addPluralRule:@"^i(Pod|Pad)( Mini)?$" withReplacement:@"i$1s$2"];
[inflector addIrregularWithSingular:@"lol" plural:@"lolz"];
[inflector addUncountable:@"Herokai"];

for (NSString *singular in @[@"iPad Mini", @"lol", @"Herokai"]) {
  NSLog(@"%@: %@", singular, [singular pluralizedString]);
}
iPad Mini: iPads Mini
lol: lolz
Herokai: Herokai

Contact

Mattt Thompson

License

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

Latest podspec

{
    "name": "InflectorKit",
    "version": "0.0.1",
    "license": "MIT",
    "summary": "Efficiently Singularize and Pluralize Strings.",
    "homepage": "https://github.com/mattt/InflectorKit",
    "authors": {
        "Mattt Thompson": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mattt/InflectorKit.git",
        "tag": "0.0.1"
    },
    "source_files": "InflectorKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This