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

Accents #7

Open
jacmaes opened this issue Oct 19, 2012 · 4 comments
Open

Accents #7

jacmaes opened this issue Oct 19, 2012 · 4 comments

Comments

@jacmaes
Copy link

jacmaes commented Oct 19, 2012

Hi there,

I love this plugin, but I have one request. Would it be possible to broaden the search for accented characters in foreign language?

Let me explain with one concrete example:

In Spanish, I want to look for the word "adaptation", which would translate to "adaptación". If I type "adaptación", it works as expected. Now if I type "adaptacion", .i.e. without the accent on the "a", it fails to recognize that term.

In Spanish it is (unfortunately) a common practice to omit accents when searching for something because it requires for extra keystroke, and people are lazy.

Thanks.

@awbush
Copy link
Owner

awbush commented Oct 19, 2012

Good idea, and it's possible.

Probably the way to solve it is to replace the accents (latinize?) in the search cache on first load, and replace them in search term too right before querying (in case anyone does use them).

@pcout
Copy link

pcout commented Jun 7, 2014

Hi there,

Can you give an example of how to accomplish this ?

Thanks.

@Thunderlab
Copy link

+1

@rodolfosaraiva
Copy link

Hi, add this code to the plugin:

        var rExps = [{
            re: /[\xC0-\xC6]/g,
            ch: "A"
        }, {
            re: /[\xE0-\xE6]/g,
            ch: "a"
        }, {
            re: /[\xC8-\xCB]/g,
            ch: "E"
        }, {
            re: /[\xE8-\xEB]/g,
            ch: "e"
        }, {
            re: /[\xCC-\xCF]/g,
            ch: "I"
        }, {
            re: /[\xEC-\xEF]/g,
            ch: "i"
        }, {
            re: /[\xD2-\xD6]/g,
            ch: "O"
        }, {
            re: /[\xF2-\xF6]/g,
            ch: "o"
        }, {
            re: /[\xD9-\xDC]/g,
            ch: "U"
        }, {
            re: /[\xF9-\xFC]/g,
            ch: "u"
        }, {
            re: /[\xC7-\xE7]/g,
            ch: "c"
        }, {
            re: /[\xD1]/g,
            ch: "N"
        }, {
            re: /[\xF1]/g,
            ch: "n"
        }];
        $.each(rExps, function() {
            filter = filter.replace(this.re, this.ch);
            innerText = innerText.replace(this.re, this.ch);
        });

before :

if (innerText.toLowerCase().indexOf(filter) >= 0) {

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

No branches or pull requests

5 participants