Skip to content

Instantly share code, notes, and snippets.

@susameca
Created January 13, 2023 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save susameca/204d2dcdfa34fdeb499a57ae3cda3e71 to your computer and use it in GitHub Desktop.
Save susameca/204d2dcdfa34fdeb499a57ae3cda3e71 to your computer and use it in GitHub Desktop.
transliteration
class Transliteration {
public static function latin2cyrillic( $word ) {
$cyr = [
'ч', 'Ч', 'щ', 'Щ', 'ш', 'Ш',
'ц', 'Ц', 'ц', 'Ц',
'ю', 'Ю', 'ю', 'Ю',
'я', 'Я', 'я', 'Я',
'а', 'А', 'б', 'Б', 'в', 'В', 'в', 'В',
'г', 'Г', 'д', 'Д', 'е', 'Е',
'ж', 'Ж', 'ж', 'Ж', 'з', 'З',
'и', 'И',
//'й', 'Й',
'к', 'К', 'л', 'Л', 'м', 'М', 'н', 'Н',
'о', 'О', 'п', 'П', 'р', 'Р', 'с', 'С',
'т', 'Т', 'у', 'У', 'ф', 'Ф', 'х', 'Х',
'ъ', 'Ъ',
//'ь',
];
$lat = [
'ch', 'CH', 'sht', 'SHT', 'sh', 'SH',
'c', 'C', 'ts', 'TS',
'iu', 'IU', 'yu', 'YU',
'q', 'Q', 'ya', 'YA',
'a', 'A', 'b', 'B', 'v', 'V', 'w', 'W',
'g', 'G', 'd', 'D', 'e', 'E',
'zh', 'ZH', 'j', 'J', 'z', 'Z',
'i', 'I',
//'', '',
'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N',
'o', 'O', 'p', 'P', 'r', 'R', 's', 'S',
't', 'T', 'u', 'U', 'f', 'F', 'h', 'H',
'y', 'Y',
//'',
];
$textcyr = str_replace($lat, $cyr, $word);
return $textcyr;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment