• Hello I tried two plugins but I got the same error. Those plugins converts the cyrillic characters used in the post slug into latin chars.
    However the result is like “aaaaaiaaaaa” and other similar.
    Those are the two plugins :
    Any help is appreciated

    add_filter('name_save_pre', 'cyr_slugs', 0);
    
    function cyr_slugs($slug) {
        $cyrillic = array('?','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','?','σ','τ','υ','φ','χ','ψ','ω','?','?','?','?','?','?');
        $translit = array('a','b','v','g','d','e','zh','z','i','i','k','l','m','n','o','p','r','s','t','u','f','h','c','ch','sh','sht','u','y','y','e','yu','ya');
    
        // We don't want to change an existing slug
    	if ($slug) return $slug;
    
    	global $wpdb;
    	$cyr_slug = cyr_strtolower(strtolower(stripslashes($_POST['post_title'])));
    	$cyr_slug = str_replace($cyrillic, $translit, $cyr_slug);
    	$cyr_slug = str_replace(" ", "-", $cyr_slug);
    
    	return $cyr_slug;
    }
    
    function cyr_strtolower($a) {
    	// Just in case standard strtolower doesn't work
            $offset=32;
            $m=array();
            for($i=192;$i<224;$i++)$m[chr($i)]=chr($i+$offset);
            return strtr($a,$m);
    }
    ?>
    class Cyr2LatSlug
    {
    	var $translit_table = array(
    	"?"=>'a',
    	"α"=>'b',
    	"β"=>'v',
    	"γ"=>'g',
    	"δ"=>'d',
    	"ε"=>'e',
    	"ζ"=>'zh',
    	"η"=>'z',
    	"θ"=>'i',
    	"ι"=>'j',
    	"κ"=>'k',
    	"λ"=>'l',
    	"μ"=>'m',
    	"ν"=>'n',
    	"ξ"=>'o',
    	"ο"=>'p',
    	"π"=>'r',
    	"ρ"=>'s',
    	"?"=>'t',
    	"σ"=>'u',
    	"τ"=>'f',
    	"υ"=>'h',
    	"φ"=>'c',
    	"χ"=>'ch',
    	"ψ"=>'sh',
    	"ω"=>'sch',
    	"?"=>'',
    	"?"=>'y',
    	"?"=>'',
    	"?"=>'e',
    	"?"=>'yu',
    	"?"=>'ya',
    	"?"=>'e',
    	"?"=>'g',
    	"?"=>"e",
    	"?"=>'yi',
    	"3"=>'i',
    	"¨"=>'e',
    	"¥"=>'g',
    	"?"=>"e",
    	"―"=>'yi',
    	"2"=>'i',
    	" "=>'-');
    
    	function Cyr2LatSlug() {
    		add_filter('name_save_pre', array(&$this, 'doCyr2LatSlug'), 1);
    	}
    
    	function doCyr2LatSlug($slug) {
    		global $wpdb;
    		//setlocale(LC_ALL, 'en_US.UTF8');
    
    	    // We don't want to change an existing slug
    		if (!empty($slug)) {return $slug;}
    
    		$s = trim($_POST['post_title']);
    		$s = iconv('utf-8', 'windows-1251', $s);
    		//$s = mb_strtolower($s, 'windows-1251');
    		$s = $this->cyr_strtolower(strtolower(stripslashes($s)));
    		$s = strtr($s, $this->translit_table);
    		return $s;
    	}
    
    	function cyr_strtolower($a) {
    		// Just in case standard strtolower doesn't work
    		// this function is written by Petko Bossakov
    		$offset=32;
    		$m=array();
    		for($i=192;$i<224;$i++){$m[chr($i)]=chr($i+$offset);}
    		return strtr($a,$m);
    	}
    }
    $Cyr2LatSlug = new Cyr2LatSlug();
    ?>
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How can I make correct this character conversion’ is closed to new replies.