I try to make translit function from Ukrainian to English on php. Is this correct especially for apostroph sign. And what about translit function from English to Ukrainian? Any ideas or link
function translit($s) {
$s = (string) $s;
$s = trim($s);
$s = strtr($s, array('зг'=>'zgh','а'=>'a','б'=>'b','в'=>'v','г'=>'h','ґ'=>'g','д'=>'d','е'=>'e','є'=>'ie','ж'=>'zh','з'=>'z','и'=>'y','і'=>'i','ї'=>'i','й'=>'i','к'=>'k','л'=>'l','м'=>'m','н'=>'n','о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t','у'=>'u','ф'=>'f','х'=>'kh','ц'=>'ts','ч'=>'ch','ш'=>'sh','щ'=>'shch','ю'=>'iu','я'=>'ia','`'=>'','ь'=>'','Зг'=>'Zgh','А'=>'A','Б'=>'B','В'=>'V','Г'=>'H','Ґ'=>'G','Д'=>'D','Е'=>'E','Є'=>'Ye','Ж'=>'Zh','З'=>'Z','И'=>'Y','І'=>'I','Ї'=>'Yi','Й'=>'Y','К'=>'K','Л'=>'L','М'=>'M','Н'=>'N','О'=>'O','П'=>'P','Р'=>'R','С'=>'S','Т'=>'T','У'=>'U','Ф'=>'F','Х'=>'Kh','Ц'=>'Ts','Ч'=>'Ch','Ш'=>'Sh','Щ'=>'Shch','Ю'=>'Yu','Я'=>'Ya')); // згідно Паспорта (КМУ 2010)
return $s; // повертаємо результат
}
Not every apostrophe is removed from the text :(
Also I'm interesting in correct English to Ukrainian translitiration - if you have
You don't need to write your own logic or maintain your own database:
For
повертаємо результатit producespovertaemo rezul'tat.Demo and documentation.