Merge pull request #261 from expsa/fix_normalization_dev_odex25_base
[FIX] text normalization on arabic text
This commit is contained in:
commit
abba88d838
|
|
@ -29,9 +29,28 @@ odoo.define('fims_row_no_header_fix_tree_view.list_search', function (require) {
|
||||||
var count_row = 0;
|
var count_row = 0;
|
||||||
var $el = $(this.$el)
|
var $el = $(this.$el)
|
||||||
$(".oe_table_search tr:not(:first)").filter(function() {
|
$(".oe_table_search tr:not(:first)").filter(function() {
|
||||||
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
|
$(this).toggle(arabicCaseInsensitiveSearch($(this).text(),value))
|
||||||
count_row = $(this).text().toLowerCase().indexOf(value) > -1 ? count_row+1 : count_row
|
count_row = arabicCaseInsensitiveSearch($(this).text(),value) ? count_row+1 : count_row
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function normalizeArabic(text) {
|
||||||
|
// Normalizing Arabic text by removing common variations
|
||||||
|
return text
|
||||||
|
.replace(/[\u064B-\u065F]/g, '') // Remove diacritics
|
||||||
|
.replace(/[\u0660-\u0669]/g, (d) => String.fromCharCode(d.charCodeAt(0) - 0x0660 + 0x0030)) // Convert Arabic-Indic digits to Latin digits
|
||||||
|
.replace(/[\u06F0-\u06F9]/g, (d) => String.fromCharCode(d.charCodeAt(0) - 0x06F0 + 0x0030)) // Convert Extended Arabic-Indic digits to Latin digits
|
||||||
|
.replace(/[\u0622\u0623\u0625\u0627]/g, 'ا') // Normalize different forms of Alef
|
||||||
|
.replace(/[\u0629]/g, 'ه') // Normalize Teh Marbuta to Heh
|
||||||
|
.replace(/[\u064A\u0626]/g, 'ي') // Normalize different forms of Yeh
|
||||||
|
.replace(/[\u0624\u0648]/g, 'و'); // Normalize Waw and its variants
|
||||||
|
}
|
||||||
|
|
||||||
|
function arabicCaseInsensitiveSearch(text, searchTerm) {
|
||||||
|
const normalizedText = normalizeArabic(text).toLowerCase();
|
||||||
|
const normalizedSearchTerm = normalizeArabic(searchTerm).toLowerCase();
|
||||||
|
return normalizedText.indexOf(normalizedSearchTerm) > -1;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue