Skip to content

Pluralisation of words that are both countable and uncountable #163

@alcaeus

Description

@alcaeus

A few words in the English language can both be countable and uncountable at the same time. Amongst these, we have:

  • homework
  • research
  • weather
  • travel

and potentially more. In Inflector 1.3, many of these words were pluralised, even though the common plural for the words is the word itself. In Inflector 1.4, this was rectified, as we want to make the library more grammatically correct. As such, we will not be fixing these inflections.

If you need to pluralise such words differently, you can use custom rules. Please follow the instructions below depending on the Inflector API you are using. Note that due to a bug these custom rules will only work reliably in 1.4.3 and 2.0.3 and newer.

Legacy API (Inflector <= 1.4)

In the legacy API, use Inflector::rules to add a custom rule:

Inflector::rules('plural', ['/travel/i' => 'travels']);

New API (Inflector >= 1.4)

In the new API, custom rules must be added to the factory before creating the inflector:

$customPluralizations = new Ruleset(
    new Transformations(new Transformation(new Pattern('travel'), 'travels')),
    new Patterns(),
    new Substitutions()
);

$factory = InflectorFactory::create();
$factory->withPluralRules($customPluralizations);
$inflector = $factory->build();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions