Hello Couch users and admins.
I suppose many people faced the problem of auto-transforming article's title into article's name (this is possible for English titles only by default). I've created a simple solution for that like follow (for Couch 1.4):
1. Open "functions.php" in Couch folder. You see on line 236:
2. Change it to:
3. Save the file into UTF-8 (without BOM) encoding.
So, that's it for Russian transliteration. I suppose you can easily find a chart for trasliting your language.
This is simple enough but if admins could suggest a way without modifying the core file, it will be great.
Thanks
I suppose many people faced the problem of auto-transforming article's title into article's name (this is possible for English titles only by default). I've created a simple solution for that like follow (for Couch 1.4):
1. Open "functions.php" in Couch folder. You see on line 236:
- Code: Select all
function get_clean_url( $title ){
$title = strip_tags( $title ); // remove html tags
$title = preg_replace('/%([0-9a-fA-F][0-9a-fA-F])/', '', $title); // remove encoded octets
$title = preg_replace('/&.+?;/', '', $title); // remove html_entities
$title = $this->remove_accents( $title );
$title = str_replace( '/', '-', $title );
$title = preg_replace( '/[^0-9a-zA-Z-_ \.]/', '', $title );
$title = strtolower( $title );
$title = str_replace( ' ', '-', $title );
$title = str_replace( '.', '-', $title );
$title = preg_replace( '/-+/', '-', $title);
$title = trim( $title, '-' );
return $title;
}
2. Change it to:
- Code: Select all
function get_clean_url( $title ){
$title = strip_tags( $title ); // remove html tags
$title = preg_replace('/%([0-9a-fA-F][0-9a-fA-F])/', '', $title); // remove encoded octets
$title = preg_replace('/&.+?;/', '', $title); // remove html_entities
$title = $this->translit( $title ); // performing transliteration
$title = $this->remove_accents( $title );
$title = str_replace( '/', '-', $title );
$title = preg_replace( '/[^0-9a-zA-Z-_ \.]/', '', $title );
$title = strtolower( $title );
$title = str_replace( ' ', '-', $title );
$title = str_replace( '.', '-', $title );
$title = preg_replace( '/-+/', '-', $title);
$title = trim( $title, '-' );
return $title;
}
function translit($string) {
$charlist = array(
"А"=>"A","Б"=>"B","В"=>"V","Г"=>"G",
"Д"=>"D","Е"=>"E","Ж"=>"J","З"=>"Z","И"=>"I",
"Й"=>"Y","К"=>"K","Л"=>"L","М"=>"M","Н"=>"N",
"О"=>"O","П"=>"P","Р"=>"R","С"=>"S","Т"=>"T",
"У"=>"U","Ф"=>"F","Х"=>"H","Ц"=>"TS","Ч"=>"CH",
"Ш"=>"SH","Щ"=>"SCH","Ъ"=>"","Ы"=>"YI","Ь"=>"",
"Э"=>"E","Ю"=>"YU","Я"=>"YA","а"=>"a","б"=>"b",
"в"=>"v","г"=>"g","д"=>"d","е"=>"e","ж"=>"j",
"з"=>"z","и"=>"i","й"=>"y","к"=>"k","л"=>"l",
"м"=>"m","н"=>"n","о"=>"o","п"=>"p","р"=>"r",
"с"=>"s","т"=>"t","у"=>"u","ф"=>"f","х"=>"h",
"ц"=>"ts","ч"=>"ch","ш"=>"sh","щ"=>"sch","ъ"=>"y",
"ы"=>"yi","ь"=>"","э"=>"e","ю"=>"yu","я"=>"ya"
);
return strtr($string,$charlist);
}
3. Save the file into UTF-8 (without BOM) encoding.
So, that's it for Russian transliteration. I suppose you can easily find a chart for trasliting your language.
This is simple enough but if admins could suggest a way without modifying the core file, it will be great.
Thanks