Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fix (greek omega used has no diacritic) #5464

Merged
merged 1 commit into from Mar 19, 2019

Conversation

tgogos
Copy link
Contributor

@tgogos tgogos commented Mar 14, 2019

replaced \u03C9 (GREEK SMALL LETTER OMEGA: ω)
with \u03CE (GREEK SMALL LETTER OMEGA WITH TONOS: ώ)

This pull request includes a

  • Bug fix
  • New feature
  • Translation

The following changes were made

  • replaced \u03C9 (GREEK SMALL LETTER OMEGA: ω)
    with \u03CE (GREEK SMALL LETTER OMEGA WITH TONOS: ώ)

If this is related to an existing ticket, include a link to it as well.

replaced \u03C9 (GREEK SMALL LETTER OMEGA: ω)
with \u03CE (GREEK SMALL LETTER OMEGA WITH TONOS: ώ)
@kevin-brown kevin-brown merged commit 5977856 into select2:develop Mar 19, 2019
@tgogos
Copy link
Contributor Author

tgogos commented Mar 19, 2019

@kevin-brown have you ever considered replacing the diacritics.js file with the use of String.prototype.normalize() to remove diacritics?

I was dealing with this issue (regarding the greek language) back in 2014 (see Javascript - normalize accented greek characters) and I was "manually" doing the following replacements:

Greek and Coptic (Range: 0370— 03FF) 
ΆΑά -> α
ΈΕέ -> ε
ΉΗή -> η
ΊΪΙίΐ -> ι
ΌΟό -> ο
ΎΫΥΰϋύ -> υ
ΏΩώ -> ω

Greek Extended (Range: 1F00— 1FFF)
ἀἁἂἃἄἅἆἇὰάᾀᾁᾂᾃᾄᾅᾆᾇᾰᾱᾲᾳᾴᾶᾷἈἉἊἋἌἍἎἏᾈᾉᾊᾋᾌᾍᾎᾏᾸᾹᾺΆᾼ -> α
ἐἑἒἓἔἕὲέἘἙἚἛἜἝῈΈ -> ε
ἠἡἢἣἤἥἦἧὴήᾐᾑᾒᾓᾔᾕᾖᾗῂῃῄῆῇἨἩἪἫἬἭἮἯᾘᾙᾚᾛᾜᾝᾞᾟῊΉῌ -> η
ἰἱἲἳἴἵἶἷὶίῐῑῒΐῖῗἸἹἺἻἼἽἾἿῘῙῚΊ -> ι
ὀὁὂὃὄὅὸόὈὉὊὋὌὍῸΌ -> ο
ὐὑὒὓὔὕὖὗὺύῠῡῢΰῦῧὙὛὝὟῨῩῪΎ -> υ
ὠὡὢὣὤὥὦὧὼώᾠᾡᾢᾣᾤᾥᾦᾧῲῳῴῶῷὨὩὪὫὬὭὮὯᾨᾩᾪᾫᾬᾭᾮᾯῺΏῼ -> ω
ῤῥῬ -> ρ

I believe the complexity gets worse as you add more languages... Some years later, I found a way to do the same thing with the normalize() function and without keeping lists of characters.

Example:

"ἀἁἂἃἄἅἆἇὰάᾀᾁᾂᾃᾄᾅᾆᾇᾰᾱᾲᾳᾴᾶᾷἈἉἊἋἌἍἎἏᾈᾉᾊᾋᾌᾍᾎᾏᾸᾹᾺΆᾼ".normalize('NFD').replace(/[\u0300-\u036f]/g, "");
"αααααααααααααααααααααααααΑΑΑΑΑΑΑΑΑΑΑΑΑΑΑΑΑΑΑΑΑ"

How it works:

With .normalize('NFD') where NFD means Normalization Form Canonical Decomposition accented characters are decomposed to:

  • the character itself
  • followed by the equivalent Combining Diacritical Mark (see: range [0300-036f])
  • which can then be easily removed with .replace(/[\u0300-\u036f]/g, "")

@kevin-brown
Copy link
Member

The problem that we run into with String.prototype.normalize() is that it is not supported by IE, which unfortunately Select2 currently supports.

When we eventually decide to drop support for IE and older versions of browsers, this is one of the first things I'm looking to replace with something native.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants