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

Ignore accents #181

Closed
MatthiasRMS opened this issue Aug 1, 2017 · 6 comments
Closed

Ignore accents #181

MatthiasRMS opened this issue Aug 1, 2017 · 6 comments

Comments

@MatthiasRMS
Copy link

MatthiasRMS commented Aug 1, 2017

Is there an option to ignore accents ?
Example:

items: [{name: "Référence"}, {name: "Dénomination}]

If I search for reference, it won't find Référence

Is this already possible?

Nb: it does work if you only have those two options, but with a large amount, it doesn't.

@robozevel
Copy link

I'd recommend adding an extra key, and using speakingurl to normalize it (remove diacritics and such)

const getSlug = require('speakingurl')
// returns "Schoener Titel laesst gruessen!? Bel ete !"
let normalized = getSlug('Schöner Titel läßt grüßen!? Bel été !', {
  separator: ' ',
  mark: true,
  uric: true,
  uricNoSlash: true,
  maintainCase: true
})

@MatthiasRMS
Copy link
Author

@robozevel thanks for the advice, I can indeed to this!
However, wouldn't it be nice to have this built in ?

I'd be happy to work on this and make a PR.
@krisk would you accept a PR to add an option ignoring diacritics ?

@ejames17
Copy link

actually an option to ignore any pattern would be super awesome as well

@omarciovsena
Copy link

I solved this:

const removeSpecialCharacters = str => {
  return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
}
const list = suggestions.map(suggestion => ({
  value: suggestion.value,
  noSpecialCharacters: removeSpecialCharacters(suggestion.value)
}))

let opts = {
  keys: ['value', 'noSpecialCharacters']
  ...
}

but I agree it could be a parameter. I will try to contribute to this if it is in your interest.

@Startouf
Copy link

Definitely interesting to cover many languages. The default should be to not be accent-insensitive through to not introduce breaking changes

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

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

No branches or pull requests

6 participants