"people" " /> "people" " /> "people" "/>

Kotlin extension to pluralize and singularize strings

Overview

kotlin-pluralizer

kotlin extension to pluralize and singularize strings

Build Status Release

Show some love

GitHub followers Twitter Follow

Usage

Pluralization:

"people" "post".pluralize() # => "posts" "sheep".pluralize() # => "sheep" "foot".pluralize() # => "feet"">
"person".pluralize()        # => "people"
"post".pluralize()          # => "posts"
"sheep".pluralize()         # => "sheep"
"foot".pluralize()          # => "feet"

Singularization:

"word" "octopi".singularize() # => "octopus" "people".singularize() # => "person" "feet".singularize() # => "foot"">
"words".singularize()       # => "word"
"octopi".singularize()      # => "octopus"
"people".singularize()      # => "person"
"feet".singularize()        # => "foot"

Quantities:

"person" "person".pluralize(2) # => "people"">
"person".pluralize(1)       # => "person"
"person".pluralize(2)       # => "people"

Install

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 first, before filing an issue.
  6. Have fun!

## Credits

The pluralize and singularize methods are based on the code found in the following places.

Created & Maintained By

Cesar Ferreira (@cesarmcferreira)

You might also like...
Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock
Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock

This kata is a Kotlin multiplatform version of the kata KataTODOApiClientKotlin of Karumi. We are here to practice integration testing using HTTP stub

Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin Gradle DSL.

SampleCompose Modular Android architecture which showcase Kotlin, MVVM, Navigation, Hilt, Coroutines, Jetpack compose, Retrofit, Unit test and Kotlin

Spring-kotlin - Learning API Rest with Kotlin, Spring and PostgreSQL

Kotlin, Spring, PostgreSQL and Liquibase Database Migrations Learning Kotlin for

FlowExt is a Kotlin Multiplatform library, that provides many operators and extensions to Kotlin Coroutines Flow

FlowExt | Kotlinx Coroutines Flow Extensions | Kotlinx Coroutines Flow Extensions. Extensions to the Kotlin Flow library | kotlin-flow-extensions | Coroutines Flow Extensions | Kotlin Flow extensions | kotlin flow extensions | Flow extensions

Clean Android multi-module offline-first scalable app in 2022. Including Jetpack Compose, MVI, Kotlin coroutines/Flow, Kotlin serialization, Hilt and Room.

Android Kotlin starter project - 2022 edition Android starter project, described precisely in this article. Purpose To show good practices using Kotli

This Kotlin Multiplatform library is for accessing the TMDB API to get movie and TV show content. Using for Android, iOS, and JS projects.

Website | Forum | Documentation | TMDb 3 API Get movie and TV show content from TMDb in a fast and simple way. TMDb API This library gives access to T

High performance and fully asynchronous pulsar client with Kotlin and Vert.x

pulsarkt High performance pulsar client with Kotlin and Vert.x Features Basic Producer/Consumer API Partitioned topics Batching Chunking Compression T

Microservices-demo - Microservices demo project using Spring, Kotlin, RabbitMQ, PostgreSQL and Gradle and deployed to Azure Kubernetes An investigation and comparison between Kotlin and Java on an engineering level
An investigation and comparison between Kotlin and Java on an engineering level

An investigation and comparison between Kotlin and Java on an engineering level. Since beauty is in the eye of the beholder, this repository is not meant to evaluate Java or Kotlin on an aesthetic level.

Comments
  • Added pluralize/singularize functions based on an int count.

    Added pluralize/singularize functions based on an int count.

    "person".pluralize(1)  # => "person"
    "person".pluralize(2)  # => "people"
    

    That was needed.

    Additionally, you might want to look at Plural.kt. It might be a useful generic pattern.

    Ultimately, I'd like to see the patterns, etc. included in resources instead of hard-coded. That will make it a lot easier for people to add/modify rules, and use the library with other languages. Have you looked at Quantity Strings?

    Hope this helps,

    E.

    opened by ethauvin 1
  • pluralize/singularize with quantity doesn't work at all

    pluralize/singularize with quantity doesn't work at all

    "test".pluralize(2)
    res2: kotlin.String = test 
    
    "tests".pluralize(2)
    res3: kotlin.String = tests
    
    "tests".pluralize(1)
    res4: kotlin.String = tests
    
    "people".pluralize(1)
    res6: kotlin.String = peoples
    
    "people".pluralize(2)
    res7: kotlin.String = people
    
    "person".pluralize(1)
    res8: kotlin.String = people
    
    "person".pluralize(2)
    res9: kotlin.String = person
    

    I might have some time on the weekend to have a look at the implementation and send a PR.

    opened by miikeat 0
  • Publish to maven central

    Publish to maven central

    I have another library using this as dependency. Many users do not trust jitpack and would rather not add it to their build. Please also publish to maven central.

    opened by F43nd1r 0
  • Develop branch is missing in this repo

    Develop branch is missing in this repo

    You have this in Readme:

    Pull requests must be made against develop branch. Any other branch (unless specified by the maintainers) will get rejected.

    But there is no develop branch in this repo. Also, the same is true for https://github.com/cesarferreira/monzo-cli, https://github.com/cesarferreira/gito and maybe some other repos too.

    opened by vkotovv 0
Releases(1.0.0)
  • 1.0.0(Jan 18, 2021)

    • 4efea3f Merge pull request #5 from ghost/improvements
    • 46462e6 Typo fix
    • 76dd8c2 Handling some words mentioned in #4
    • e1f9882 Adding basic unit tests

    https://github.com/cesarferreira/kotlin-pluralizer/compare/0.2.9...1.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
César Ferreira
Senior Android Developer, currently working as a Tech Lead @GlueHome
César Ferreira
Kotlin extension function provides a facility to "add" methods to class without inheriting a class or using any type of design pattern

What is Kotlin Extension Function ? Kotlin extension function provides a facility to "add" methods to class without inheriting a class or using any ty

mohsen 21 Dec 3, 2022
Exktor - Extension modules for Ktor

Extension modules for Ktor ExKtor - it's set of extension libraries for Ktor tha

Simone Stefani 0 Sep 11, 2022
Ktorm KSP extension to help generate boilerplate code.

Ktorm KSP extension to help generate boilerplate code. It can automatically generate Table objects through entity classes, while making entities defined by data classes easier to use, and supports custom extension code generation logic.

KTORM.ORG 24 Dec 30, 2022
Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP)

Mockative Mocking for Kotlin/Native and Kotlin Multiplatform using the Kotlin Symbol Processing API (KSP). Installation Mockative uses KSP to generate

Mockative 121 Dec 26, 2022
Kotlin microservices with REST, and gRPC using BFF pattern. This repository contains backend services. Everything is dockerized and ready to "Go" actually "Kotlin" :-)

Microservices Kotlin gRPC Deployed in EC2, Check it out! This repo contains microservices written in Kotlin with BFF pattern for performing CRUD opera

Oguzhan 18 Apr 21, 2022
🎲 Kotlin Symbol Processor to auto-generate extensive sealed classes and interfaces for Android and Kotlin.

SealedX ?? Kotlin Symbol Processor to auto-generate extensive sealed classes and interfaces for Android and Kotlin. Why SealedX? SealedX generates ext

Jaewoong Eum 236 Nov 30, 2022
Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Kotlin_practice_problems Repo: Programming problems with solutions in Kotlin to help avid Kotlin learners to get a strong hold on Kotlin programming.

Aman 0 Oct 14, 2021
Kotlin-oop - Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura.

Projeto React OOP Repositório criado para ser utilizado pelo projeto de Kotlin OOP desenvolvido em Kotlin nas aulas feitas através da plataforma Alura

Marcos Felipe 1 Jan 5, 2022
Kotlin-koans - Kotlin Koans are a series of exercises to get you familiar with the Kotlin Syntax

kotlin-koans-edu Kotlin Koans are a series of exercises to get you familiar with

null 1 Jan 11, 2022
Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

Jetpack Compose for Desktop and Web, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.

JetBrains 10k Jan 7, 2023