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

Abbreviated words #49

Open
Daut opened this issue Feb 6, 2017 · 4 comments
Open

Abbreviated words #49

Daut opened this issue Feb 6, 2017 · 4 comments
Labels

Comments

@Daut
Copy link

Daut commented Feb 6, 2017

Hey,

I'm currently working on a project that needs to support pluralization of the abbreviated words, so I need to add lowercase 's' letter to the end of these words (e.g. VIP => VIPs, currently I get VIPS).

Are you planning to add this feature to your library? Something like pluralize.addAbbreviatedRule() or similar.

Regards

P.S. Thanks for the great library!

@blakeembrey
Copy link
Collaborator

I thought there had been a previous discussion around this sort of thing, but I can't recall it now. I think it's reasonable to want to do this, but in reality I'd need to know a lot more about the context to figure out if it's something that should be here. Can you give more information? An abbreviated rule is pretty similar to an irregular rule, what would be the main difference? Is it just how to handle casing, in which case is there perhaps a better way (maybe a case-sensitivity flag?) that doesn't change the core behaviour?

@Daut
Copy link
Author

Daut commented Feb 7, 2017

Yes, In my use case only difference between an abbreviated rule and irregular rule is case handling. So something like addIrregularRule(single, plural, preserveCase) will do the trick for me.

@davidcalhoun
Copy link

davidcalhoun commented Jan 9, 2018

Just ran into the same issue - also with the string id.

Example:

pluralize('Foo ID', 2);
// -> 'Foo IDS'

In this case I want to control the output so it can instead return 'Foo IDs'.

Thanks in advance!

@baerrach
Copy link

I've hacked around it.

const plural = word => {
  const result = pluralize.plural(word);
  if (word === word.toUpperCase()) {
    // Pluralize https://github.com/blakeembrey/pluralize/issues/49 doesn't
    // handle abbreviations or initialisms
    // Hack around it as there is no way to change the strategy in pluralize::restoreCase()
    const suffix = result.substr(word.length);

    return word   suffix.toLowerCase();
  }

  return result;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants