Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluralisation of words that are both countable and uncountable #163

Closed
alcaeus opened this issue May 28, 2020 · 0 comments
Closed

Pluralisation of words that are both countable and uncountable #163

alcaeus opened this issue May 28, 2020 · 0 comments

Comments

@alcaeus
Copy link
Member

alcaeus commented May 28, 2020

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();
@alcaeus alcaeus closed this as completed May 28, 2020
@doctrine doctrine locked as resolved and limited conversation to collaborators May 28, 2020
@alcaeus alcaeus pinned this issue May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant