How can I do a bilingual ng-repeat filter in javascript?

53 views Asked by At

I want to write a filter for ng-repeat that is bilingual for both English and Farsi. Does anyone know how to do this? I've tried the normal way but it doesn't work for Farsi (my regular expressions used in the filter function I wrote).

$scope.myFilter = function(item) {

var replaced = $scope.filter.search.split(' ').join('.*');

var regex = new RegExp('.*'+replaced, 'g');

return regex.test(item.FileDescription) };

Basically I am matching any fileDescription that contains anything that is typed in the filter. For example, if I type "Paper plane" it will search for all filedescriptions that contain paper AND plane anywhere in the sentence (words searched are separated by space) but I can't get this working with Farsi for some reason and I was hoping someone could help. For example, if I enter “20 انباری”, then it should show the ones like these: “20 ٬ آسانسور انباری” but it doesn't, I think the encoding of Farsi is switching my .* wildcards backwards causing it not to search correctly and I don't know how to fix it.

0

There are 0 answers