gr2m / initials

extract initials from and add initials to names
https://gr2m.github.io/initials
MIT License
44 stars 14 forks source link

Fix initials for names containing apostrophes #29

Closed ghost closed 6 years ago

ghost commented 7 years ago

So far just added the tests. I didn't manage to add a test, yet. Just adding the ' to the nonLetters doesn't seem to work, though.

gr2m commented 7 years ago

It treats the apostroph as a word separator. By default, initials(name) gives you the first letters of each word. I’d say JOD is a good default initial for John O'Doe, but then I don’t know if the convention is to ignore the middle letter for initials in that case. Is this based on feeling for yourself or is there some information on it somewhere?

ghost commented 7 years ago

@gr2m I don't have exactly proof, just some hints and the feedback of our customers.

gr2m commented 7 years ago

I’d like to do some more research myself first, but am currently on holidays (yeah I shouldn’t even be here right now :) Thanks for linking the discussion on stack exchange.

How about you add a workaround to your codebase for now by doing something like this

initials(name.replace(/O['’]/i, ''))

if name is John O'Doe, that workaround should return JD. Is that good enough for now?

ghost commented 7 years ago

@gr2m Oh, enjoy your holidays! Workaround directly in our codebase won't work, since initials is a dependency of another dependency we have.

Let's see if we can find a proper solution once you return from holidays? :)

ghost commented 7 years ago

@gr2m any news on this?

gr2m commented 7 years ago

No, I’m sorry to let you wait for so long. I’d be okay to move forward with this. How about we add a special case for O’ and D’ and remove these before calculating the initials, so they don’t become a part of it?

There is another comment that makes a lot of sense to me from someone who has O’ in their own name:

We use COD for Christine O'Driscoll. Each capital letter gets an initial letter. Grace McDonnell would be GMD.

But that’s our current behaviour, right?

My fear is that we change behaviour here and people will complain about it.

Another option would be to allow passing a custom option which would be a function that manipulates a string before calculating initials. But the library you use of which initials is a dependency would need to support to pass in that option.

This is very tricky :/

gr2m commented 6 years ago

closing due to inactivity