PDA

View Full Version : [CLOSED] Filtering using FilterHeader plugin and Turkish language



metci
Aug 20, 2014, 12:26 PM
Hi,
I have an issue with using the FilterHeader plugin in a page where the language used is Turkish. In the Turkish character set, there are two types of I's:

1) Dotted: i İ
2) Undotted: ı I

In the case of the FilterHeader plugin though, the filter fields cannot seem to make the correct distinction between the two types. I have added an image with the screenshots to show the problem. The list being filtered is a list of cities in Turkey. All the city names are capitalized, but the filter field is NOT case-sensitive.

http://forums.ext.net/attachment.php?attachmentid=14691&stc=1

FILTERING WITH LOWERCASE DOTTED i (FILTERVALUE="i", OPERATOR="+") :

Filtering should return İstanbul and İzmir only. But it also returns the record starting with uppercase undotted "I" -India.


FILTERING WITH UPPERCASE DOTTED İ (FILTERVALUE="İ", OPERATOR="*"):

Filtering should return İstanbul, İzmir and India, which all contain a dotted "i", uppercase and/or lowercase. But "India" is not returned.



FILTERING WITH LOWERCASE UNDOTTED ı (FILTERVALUE="ı", OPERATOR="*"):

Filtering should return both Dıyarbakır and India, but India, which has an uppercase undotted "I", is not returned.


FILTERING WITH UPPERCASE UNDOTTED "I" (FILTERVALUE="I", OPERATOR="*"):

Filtering should return India and Dıyarbakır only, yet Dıyarbakır is not returned. Furthermore, İstanbul and İzmir are returned, which have dotted i's.



The sample code is quite simple, but let me know if you still require it, and I will post it here. Any help will be much appreciated.

Daniil
Aug 20, 2014, 7:18 PM
Hi @metci,

I've found this.
http://stackoverflow.com/questions/1850232/turkish-case-conversion-in-javascript

I've tried the suggestion of Serkan Yersen (http://stackoverflow.com/users/85094/serkan-yersen) and it appears to fix all the test cases that you mentioned.

Please add this script into the page's <head>.

<script>
String.prototype.turkishToUpper = function () {
var string = this;
var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "?": "?", "?": "?", "?": "?", "ı": "I" };
string = string.replace(/(([iışğ???]))+/g, function (letter) { return letters[letter]; })
return string.toUpperCase();
}

String.prototype.turkishToLower = function () {
var string = this;
var letters = { "İ": "i", "I": "ı", "Ş": "ş", "Ğ": "ğ", "?": "?", "?": "?", "?": "?" };
string = string.replace(/(([İIŞĞ???]))+/g, function (letter) { return letters[letter]; })
return string.toLowerCase();
}

Ext.net.FilterHeader.behaviour.getStrValue = function (value) {
return Ext.net.FilterHeader.behaviour.getOption("caseSensitive") || !value || Ext.net.FilterHeader.behaviour.isRemote() ? value : value.turkishToLower();
}
</script>

You can see that I've overridden the Ext.net.FilterHeader.behaviour.getStrValue function to use the turkishToLower function instead of the native toLowerCase function.

metci
Aug 22, 2014, 7:17 AM
Thank you very much Daniil. Solution works well.

Daniil
Aug 22, 2014, 9:46 AM
The sample code is quite simple, but let me know if you still require it, and I will post it here.

We are very happy if a member posts a standalone runnable test case in the original post.