-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hello and thank you so much for the awesome transliteration class!
I have been able to use it almost out of the box with a transliteration from Cyrillic (Bulgarian letters) to Devanagari. However when I used it I noticed a bug. It always transliterated 'ma' (written in Cyrillic letters looks like this "ма") to 'म्' not 'म' and it did that for all syllables (ta, ka, pa etc.).
So I found a bug and fixed it for myself in a hardcode copy I did in my project. I post it here so you might want to fix it for use of non-roman schemes. Probably you will have a better solution because you know your code much better than I do, of course. But here is my hacky solution.
in this
if ($hadConsonant) {
if (isset($marks[$token])) {
$buf[] = $marks[$token];
} else if ($token !== 'a') {
$buf[] = $virama;
$buf[] = $letters[$token];
}
} else {
$buf[] = $letters[$token];
}
i replaced the
'a' (latin 'a' letter) which was hardcoded with
} else if ($token !== array_keys($map['letters'])[0]) /* latin "a" was hardcoded here, but can be latin or cyrillic or other, so use it from the $map*/ {
It's a hack. I know but... it worked since it now takes the 'a' letter from my Cyrillic scheme instead of latin 'a'
the scheme I used looks like this
$scheme = array(
"vowels" => array("а", "аа", "и", "ии", "у", "уу", "R", "RR", "lR", "lRR", "", "е", "аи", "", "о", "ау"),
"other_marks" => array(".", ":", "",),
"virama" => array(""),
"consonants" => array("к", "кх", "г", "гх", "гг", "ч", "чх", "з", "зх", "Н2", "Т" /*त्*/, "Тх", "Д", "Дх", "Н", "т", "тх", "д", "дх", "н", "п", "пх", "б", "бх", "м", "й", "р", "л", "в", "ш"/*श*/, "Ш" /*ष*/, "с", "х", "Л" /*ळ*/, "кш", "зн"/*ज्ञ*/),
"symbols" => array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "УМ.", "S" /*ऽ*/, "|", "||")
);
only the above fix was needed to run it all