File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ data Inflection
4949pluralize :: Text -> Text
5050pluralize = pluralizeWith mapping
5151 where
52- mapping = defaultIrregulars ++ defaultUncountables ++ defaultPlurals
52+ mapping = defaultUncountables ++ defaultPlurals ++ irregularPluralsAsUncountables ++ defaultIrregulars
5353
5454-- | singularize a word given a default mapping
5555singularize :: Text -> Text
@@ -149,3 +149,8 @@ regexPattern pat = toMaybe reg
149149headMaybe :: [a ] -> Maybe a
150150headMaybe [] = Nothing
151151headMaybe (x: _) = Just x
152+
153+ -- Treat irregular plurals as uncountables to avoid double pluralization
154+ irregularPluralsAsUncountables :: [Inflection ]
155+ irregularPluralsAsUncountables =
156+ makeUncountableMapping (map snd defaultIrregulars')
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ matchingCases = do
4646 pluralize " ox" `shouldBe` " oxen"
4747 pluralize " vertex" `shouldBe` " vertices"
4848
49+ it " can doesn't pluralize plurals a second time" $
50+ pluralize " people" `shouldBe` " people"
51+
4952 describe " singularize" $ do
5053 it " singularizes regex cases" $ do
5154 singularize " mice" `shouldBe` " mouse"
@@ -59,4 +62,4 @@ matchingCases = do
5962irregularCases :: Spec
6063irregularCases =
6164 it " can singularize irregulars" $
62- singularize " people" `shouldBe` " person"
65+ singularize " people" `shouldBe` " person"
You can’t perform that action at this time.
0 commit comments