Search code examples
javascripthtmllocale

Locale independent string search in Javascript


Is there a way for searching / comparing strings without consideration of locale?

I mean: if I have two input sources on my keyboard (Russian and English) and I start typing - I want to search word without consideration what input source is active at the moment.

And I'll find string contained "Search" without metter what I've typed "search" or "ыуфкср"

Thanks.


Solution

  • You would simply need to do search by two phrases: the original input and the result of conversion to another keyboard layout. You would have a conversion map like this:

    {
        a: 'ф',
        s: 'ы',
        d: 'в',
        f: 'а',
        ...
    }