GlobalWebIndex / elm-plural-rules / PluralRules.En

English is simple wrt. pluralization: it has just 1 vs "not 1". The main gimmick of this module is adding "s" to the word unless your provided Rules dictionary says it should behave differently.

Usage

Create your own dictionary of "non-s" pluralizations and a helper function that provides that dictionary to the pluralize function. Here's an example (see also the examples/ folder):

module Pluralize exposing (pluralize)

import PluralRules exposing (Cardinal(..), Rules)
import PluralRules.En

rules : Rules
rules =
    PluralRules.fromList
        [ ( "Query"
          , [ ( One, "Query" )
            , ( Other, "Queries" )
            ]
          )
        ]

pluralize : Int -> String -> String
pluralize n word =
    PluralRules.En.pluralize rules n word

pluralize : PluralRules.Rules -> Basics.Int -> String -> String

Pluralization function for English rules (adding "s" in the general case).

Make your own helper function that gives pluralize your rules, so that you don't need to mention them every time!

(See the examples/ folder.)

myPluralize : Int -> String -> String
myPluralize n word =
    PluralRules.En.pluralize rules n word

pluralizeFloat : PluralRules.Rules -> Basics.Float -> String -> String

A Float variant of pluralize.