From dd457ee571b6c7404f304bef69149563174c93e6 Mon Sep 17 00:00:00 2001 From: bamboo2panda Date: Fri, 11 Oct 2019 13:53:26 +0300 Subject: [PATCH] Transliteration of cyrillic characters --- admin/helpers/componentbuilder.php | 52 ++++++++++++++---------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 954088b3a..5e47d1584 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -4982,34 +4982,32 @@ abstract class ComponentbuilderHelper // http://stackoverflow.com/a/2021729/1429677 return preg_replace('/\s+/', ' ', $string); } - // transliterate cyrillic characters - $transliterationTable = array( - 'а' => 'a', 'б' => 'b', 'в' => 'v', - 'г' => 'g', 'д' => 'd', 'е' => 'e', - 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', - 'и' => 'i', 'й' => 'y', 'к' => 'k', - 'л' => 'l', 'м' => 'm', 'н' => 'n', - 'о' => 'o', 'п' => 'p', 'р' => 'r', - 'с' => 's', 'т' => 't', 'у' => 'u', - 'ф' => 'f', 'х' => 'h', 'ц' => 'c', - 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', - 'ь' => '', 'ы' => 'y', 'ъ' => '', - 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', - - 'А' => 'A', 'Б' => 'B', 'В' => 'V', - 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', - 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', - 'И' => 'I', 'Й' => 'Y', 'К' => 'K', - 'Л' => 'L', 'М' => 'M', 'Н' => 'N', - 'О' => 'O', 'П' => 'P', 'Р' => 'R', - 'С' => 'S', 'Т' => 'T', 'У' => 'U', - 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', - 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch', - 'Ь' => '', 'Ы' => 'Y', 'Ъ' => '', - 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', - ); - $string = strtr($string, $transliterationTable); + $transliterationTable = array( + 'а' => 'a', 'б' => 'b', 'в' => 'v', + 'г' => 'g', 'д' => 'd', 'е' => 'e', + 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', + 'и' => 'i', 'й' => 'y', 'к' => 'k', + 'л' => 'l', 'м' => 'm', 'н' => 'n', + 'о' => 'o', 'п' => 'p', 'р' => 'r', + 'с' => 's', 'т' => 't', 'у' => 'u', + 'ф' => 'f', 'х' => 'h', 'ц' => 'c', + 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'sch', + 'ь' => '', 'ы' => 'y', 'ъ' => '', + 'э' => 'e', 'ю' => 'yu', 'я' => 'ya', + 'А' => 'A', 'Б' => 'B', 'В' => 'V', + 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', + 'Ё' => 'E', 'Ж' => 'Zh', 'З' => 'Z', + 'И' => 'I', 'Й' => 'Y', 'К' => 'K', + 'Л' => 'L', 'М' => 'M', 'Н' => 'N', + 'О' => 'O', 'П' => 'P', 'Р' => 'R', + 'С' => 'S', 'Т' => 'T', 'У' => 'U', + 'Ф' => 'F', 'Х' => 'H', 'Ц' => 'C', + 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Sch', + 'Ь' => '', 'Ы' => 'Y', 'Ъ' => '', + 'Э' => 'E', 'Ю' => 'Yu', 'Я' => 'Ya', + ); + $string = strtr($string, $transliterationTable); // remove all other characters $string = trim($string);