Is my transliteration of the URL from Cyrillic to Latin correct?
I decided to transliterate the URL from Cyrillic to Latin. In the file utils.inc.php I added:
function uriFilter ($s, $aParams = [])
{
$sEmpty = isset($aParams['empty']) ? $aParams['empty'] : '-';
$sDivider = isset($aParams['divider']) ? $aParams['divider'] : '-';
// --- transliterate ---
$aFrom = array(
'а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ъ','ы','ь','э','ю','я',
'і','ї','є','ґ',
'ў','ґ','ћ','đ','џ','č','ć','ž','š',
'ә','ң','ғ','ү','ұ','қ','һ','ө','ұ'
);
$aTo = 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',
'i','yi','ye','g',
'u','g','c','dj','dz','c','c','z','s',
'a','n','g','u','u','k','h','o','u'
);
$s = str_replace($aFrom, $aTo, mb_strtolower($s, 'UTF-8'));
Is everything I did correct — does anyone know? Will this solution cause any errors in operation? And is there any way to prevent my code changes from being removed during the next update?
-
- · Ivan Mishchenko
- ·
If this solution is correct, it would be better to include it in the next update. Cyrillic URLs sometimes cause errors and look odd to users when a link like that is shared. In general, it's better to always use URLs in Latin characters.
-
- · PavelS
- ·
Good idea, makes sense. Thanks for sharing it! I will definitely try it sometime.