git clone ''

(ql:quickload :cl-inflector)


A common lisp library to easily pluralize and singularize English and Portuguese words.

This is a port of the ruby ActiveSupport Inflector module.


Just use Quicklisp:

> (ql:quickload 'cl-inflector)


Example Usage:

> (use-package :cl-inflector)
> (let ((dollars 1.7)
        (users 34)
        (purchases 1))
       (format nil "The site has ~D ~A, with a total of ~D ~A and $~D ~A"  
               users (pluralize users "user") 
               purchases (pluralize purchases "purchase") 
               dollars (pluralize dollars "dollar")))
"The site has 34 users, with a total of 1 purchase and $1.7 dollars"

Basic Usage, plural-of and singular-of:

> (plural-of "octopus") 
> (plural-of "datum")
> (singular-of "children")
> (singular-of "cats")
> (singular-of "data")

Basic Usage, pluralize:

> (pluralize 2 "octopus")
> (pluralize 1 "octopus")

You can pass in the default plural to be used. If not, the inflector is used to determine the plural.

> (pluralize 2 "tooth" "teeth")
> (pluralize 2 "tooth")

Use irregular to add an irregular:

> (singular-of "feet")
> (irregular "foot" "feet")
> (singular-of "feet")
> (plural-of "foot")

Use uncountable to add an uncountable:

> (plural-of "advice")
> (singular-of "advice")
> (singular-of "advices")
> (uncountable "advice")
> (plural-of "advice")

You can also pluralize/singularize symbols (very useful for writing macros):

> (symbol-plural-of 'book)
> (symbol-singular-of 'pages)

Internationalization support

Currently, cl-inflector has built-in support for english(en_US) and brazilian portuguese(pt_BR), and it also offers a simple API to change between languages:

> (available-languages)
> (current-language-name)

For changing between languages, use set-language!:

> (plural-of "país")
> (set-language! :pt_BR)
> (plural-of "país")

You can add irregular words and uncountable in the same way as presented above, but you still does not support adding a whole new language.

For more examples, check the tests source. License —————

Released under the MIT license, please see LICENSE for more details