https://github.com/cesarferreira/kotlin-pluralizer
☀️ Kotlin extension to pluralize and singularize strings
https://github.com/cesarferreira/kotlin-pluralizer
library pluralization pluralize
Last synced: 21 days ago
JSON representation
☀️ Kotlin extension to pluralize and singularize strings
- Host: GitHub
- URL: https://github.com/cesarferreira/kotlin-pluralizer
- Owner: cesarferreira
- License: mit
- Created: 2016-09-04T12:10:17.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-24T10:00:35.000Z (almost 2 years ago)
- Last Synced: 2025-03-28T07:21:49.622Z (about 1 month ago)
- Topics: library, pluralization, pluralize
- Language: Kotlin
- Homepage:
- Size: 127 KB
- Stars: 50
- Watchers: 2
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kotlin-pluralizer
**kotlin extension** to **pluralize** and **singularize** strings
[](https://travis-ci.org/cesarferreira/kotlin-pluralizer) [](https://jitpack.io/#cesarferreira/kotlin-pluralizer)
### Show some love
[](https://github.com/cesarferreira/kotlin-pluralizer) [](https://twitter.com/cesarmcferreira)## Usage
**Pluralization:**
```kotlin
"person".pluralize() # => "people"
"post".pluralize() # => "posts"
"sheep".pluralize() # => "sheep"
"foot".pluralize() # => "feet"
```**Singularization:**
```kotlin
"words".singularize() # => "word"
"octopi".singularize() # => "octopus"
"people".singularize() # => "person"
"feet".singularize() # => "foot"
```**Quantities:**
```kotlin
"person".pluralize(1) # => "person"
"person".pluralize(2) # => "people"
```## Install
```groovy
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
compile 'com.github.cesarferreira:kotlin-pluralizer:1.0.0'
}
```## Contributing
I welcome and encourage all pull requests. It usually will take me within 24-48 hours to respond to any issue or request. Here are some basic rules to follow to ensure timely addition of your request:
1. Match coding style (braces, spacing, etc.) This is best achieved using `CMD`+`Option`+`L` (Reformat code) on Mac (not sure for Windows) with Android Studio defaults.
2. If its a feature, bugfix, or anything please only change code to what you specify.
3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)
4. Pull requests _must_ be made against `develop` branch. Any other branch (unless specified by the maintainers) will get rejected.
5. Check for existing [issues](https://github.com/cesarferreira/kotlin-pluralizer/issues) first, before filing an issue.
6. Have fun!## Credits
The pluralize and singularize methods are based on the code found in the following places.
- https://github.com/rails/rails/blob/26698fb91d88dca0f860adcb80528d8d3f0f6285/activesupport/lib/active_support/inflector/inflections.rb
- https://github.com/atteo/evo-inflector/blob/master/src/main/java/org/atteo/evo/inflector/English.java
- http://www.java2s.com/Tutorial/Java/0040__Data-Type/Transformswordstosingularpluralhumanizedhumanreadableunderscorecamelcaseorordinalform.htm
- https://github.com/MehdiK/Humanizer.jvm### Created & Maintained By
[Cesar Ferreira](https://github.com/cesarferreira) ([@cesarmcferreira](https://www.twitter.com/cesarmcferreira))