jQuery-ListMenu icon indicating copy to clipboard operation
jQuery-ListMenu copied to clipboard

Add diacritics to main character

Open typometre opened this issue 9 years ago • 1 comments

Hi, I have found how to avoid letters with diacritics to be sorted in the other category. Changing the regex for

if (/\P{L}/.test(firstChar)) firstChar = '-'; 

I also have figured that I could add letter in the menu but that not exactly my need.

What is desired is that diacritics are sorted with their main character base. So word starting with à, á, â, ä… will be sorted as if they were just a regular a. It will also be needed for ligatures as in french, you would sort œin the o category.

I haven't find how I could add an array of acceptable first letter for each category.

Thanks for your help.

typometre avatar Jun 06 '15 20:06 typometre

OK, I found a way adding this after the statement I ever change

if (/[ÀÁÂÃÄÅÃĀĂĄǍǞǠǺȀȂȦÆàáâãäåãāăąǎǟǡǻȁȃȧæ]/.test(firstChar)) firstChar = 'a'; 
                    if (/[Çç]/.test(firstChar)) firstChar = 'c'; 
                    if (/[ÈÉÊËĒĔĖĘĚȄȆȨèéêëēĕėęěȅȇȩ]/.test(firstChar)) firstChar = 'e';
                    if (/[ÌÍÎÏĨĪĬĮİƗǏȈȊìíîïĩīĭįi̇ɨǐȉȋ]/.test(firstChar)) firstChar = 'i';
                    if (/[Ññ]/.test(firstChar)) firstChar = 'n';
                    if (/[ÒÓÔÕÖÕØŌŎŐƠǑǪǬǾȌȎȪȬȮȰŒòóôõöõøōŏőơǒǫǭǿȍȏȫȭȯȱœ]/.test(firstChar)) firstChar = 'o';  
                    if (/[ÙÚÛÜŨŪŬŮŰŲƯǓǕǗǙǛȔȖùúûüũūŭůűųưǔǖǘǚǜȕȗ]/.test(firstChar)) firstChar = 'u'; 
                    if (/[ÝŸýÿ]/.test(firstChar)) firstChar = 'y'; 
                    if (/[ßẞ]/.test(firstChar)) firstChar = 's';

It should be ok for most latin european languages. There is a lot of other letters but I think there should be a better way to do it.

Another problem, I still have is that words with such diacritics aren't sorted correctly with other words of the category. Is anybody have an idea?

typometre avatar Jun 06 '15 21:06 typometre