There is a function to search. Now filtering goes according to words with the appropriate language keyboard layout. I would like to add a function: even if a word with an English layout falls into the search, and in the data array the words are Russian, filter the array in the same way. For example, when typing the word "ghbdtn" in the form, the array was filtered and understood that I meant "hello"

let filtered = this.movies; filtered = this.movies.filter( m => m.film.toLowerCase().indexOf(this.search) > -1); return filtered; 

  • And if I write in German, should I be? - Stepan Kasyanenko
  • I specifically spelled out about the spread of the keyboard, about the language, I did not say anything. Practically - it is possible to realize something similar with 2 languages: Russian and English, for example (English is the international language, almost everyone understands it). This kind of filtering is now on any search engine, where regardless of the keyboard layout, the filter will still show you what you wanted (regardless of the layout again). The question is how to add a search function so that the filter works for me anyway - nbelle
  • Duck it is necessary to write a check for compliance of each key of Cyrillic letters in English letters on the keyboard. Here's a hint to you, and then it's really nothing heavy, but I personally am too lazy to write, sorry) - Sonic Myst
  • @nbelle write a function that will do the check, and then the words convert English to Russian and then it should be clear. - Sonic Myst
  • Well, I have 3 layouts on my keyboard. Russian, English, German. Do I need to search for the German layout? - Stepan Kasyanenko

1 answer 1

You can use this feature!

 function auto_layout_keyboard( str ) { replacer = { "q":"й", "w":"ц", "e":"у", "r":"к", "t":"е", "y":"н", "u":"г", "i":"ш", "o":"щ", "p":"з", "[":"х", "]":"ъ", "a":"ф", "s":"ы", "d":"в", "f":"а", "g":"п", "h":"р", "j":"о", "k":"л", "l":"д", ";":"ж", "'":"э", "z":"я", "x":"ч", "c":"с", "v":"м", "b":"и", "n":"т", "m":"ь", ",":"б", ".":"ю", "/":"." }; return str.replace(/[Az/,.;\'\]\[]/g, function ( x ){ return x == x.toLowerCase() ? replacer[ x ] : replacer[ x.toLowerCase() ].toUpperCase(); }); }