固定链接中的非拉丁字符

时间:2010-10-26 作者:Ünsal Korkmaz

7个月前,我开始了这个想法:
http://wordpress.org/extend/ideas/topic/non-latin-characters-need-love
我仍然找不到解决办法。

Simply what i want?
想在permalinks/Slug中使用“şŞİıĞĞÜÖççç”土耳其字符。

1 个回复
最合适的回答,由SO网友:bueltge 整理而成

您必须了解语言函数界面。请参见我的德国用户示例:http://wordpress-buch.bueltge.de/wp-content/uploads/2010/05/de_DE.phps我们还必须为我们语言中的角色建立永久性的差异

    /* define it global */
    $umlaut_chars[\'in\']    = array( chr(196), chr(228), chr(214), chr(246), chr(220), chr(252), chr(223) );
    $umlaut_chars[\'ecto\']  = array( \'Ä\', \'ä\', \'Ö\', \'ö\', \'Ü\', \'ü\', \'ß\' );
    $umlaut_chars[\'html\']  = array( \'Ä\', \'ä\', \'Ö\', \'ö\', \'Ü\', \'ü\', \'ß\' );
    $umlaut_chars[\'feed\']  = array( \'Ä\', \'ä\', \'Ö\', \'ö\', \'Ü\', \'ü\', \'ß\' );
    $umlaut_chars[\'utf8\']  = array( utf8_encode( \'Ä\' ), utf8_encode( \'ä\' ), utf8_encode( \'Ö\' ), utf8_encode( \'ö\' ),utf8_encode( \'Ü\' ), utf8_encode( \'ü\' ), utf8_encode( \'ß\' ) );
    $umlaut_chars[\'perma\'] = array( \'Ae\', \'ae\', \'Oe\', \'oe\', \'Ue\', \'ue\', \'ss\' );

    /* sanitizes the titles to get qualified german permalinks with  correct transliteration */
    function de_DE_umlaut_permalinks($title) {
        global $umlaut_chars;

        if ( seems_utf8($title) ) {
            $invalid_latin_chars = array( chr(197).chr(146) => \'OE\', chr(197).chr(147) => \'oe\', chr(197).chr(160) => \'S\', chr(197).chr(189) => \'Z\', chr(197).chr(161) => \'s\', chr(197).chr(190) => \'z\', chr(226).chr(130).chr(172) => \'E\' );
            $title = utf8_decode( strtr($title, $invalid_latin_chars) );
        }

        $title = str_replace($umlaut_chars[\'ecto\'], $umlaut_chars[\'perma\'], $title );
        $title = str_replace($umlaut_chars[\'in\'], $umlaut_chars[\'perma\'], $title );
        $title = str_replace($umlaut_chars[\'html\'], $umlaut_chars[\'perma\'], $title );
        $title = sanitize_title_with_dashes($title);

        return $title;
    }
add_filter( \'sanitize_title\', \'de_DE_umlaut_permalinks\' );

结束

相关推荐