keyboard: match transliterated letters
[sheet.git] / keyboard.plp
index 1ad932462261c95f2360079d18be299e9cba822a..2fe9c073bf656fc2db61df1a262b468d05343b56 100644 (file)
@@ -15,6 +15,7 @@ Html({
 <:
 use Shiar_Sheet::Keyboard 2.07;
 use Unicode::Normalize qw( NFKD );
+use Text::Unidecode qw( unidecode );
 
 my @usintrows = (
        [  'a' ..                                            'z'],
@@ -38,9 +39,10 @@ my $keys = Shiar_Sheet::Keyboard->new({
                                my $class = (
                                          !defined $row[2] || $row[0] eq $row[2] ? 1 # identical
                                        : NFKD($row[2]) =~ $row[0] ? 2 # decomposed equivalent
-                                       : $row[2] =~ /^\p{Latin}/ ? 3 # latin script
-                                       : $row[2] =~ /^\p{Mn}/ ? 5 # combining accent
-                                       : 4
+                                       : $row[2] =~ /^\p{Latin}/ ? 4 # latin script
+                                       : unidecode($row[2]) =~ /^\W*\Q$row[0]/ ? 5 # transliterated
+                                       : $row[2] =~ /^\p{Mn}/ ? 8 # combining accent
+                                       : 7
                                );
                                $row[0] => "g$class"
                        } @usint
@@ -54,9 +56,9 @@ my $keys = Shiar_Sheet::Keyboard->new({
        flag => {
                g1 => ['unaltered'],
                g2 => ['accented'],
-               g3 => ['latin'],
-               g4 => ['other'],
-               g5 => ['combining'],
+               g4 => ['latin'],
+               g7 => ['other'],
+               g8 => ['combining'],
        },
 });
 $keys->map($get{map}) or undef $get{map};