WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Russian letters in options plugin (1 post)

  1. Mihail Semjonov
    Member
    Posted 11 months ago #

    Hello everyone. I know it's not the right place to post these, but i'm to lazy to register on ACF website atc..
    So, my problem was I could'n create options page that was on russian locale ( "Шапка" for example ) it gave me http://myweb.ru/wp-admin/admin.php?page=acf-options-шапка So i went to code and started looking what's wrong.. and found that slug for subpage comes from Title of page.
    So in ACF Options plugin there is a hook to make translated strings.. That is if you are using "cyr-to-lat" plugin for example than these plugin will automaticaly translate your cyrilyc name to latinic and everithing will work fine, but if you'r not using these plugin than you will get an error.

    To solve these error place these code in your functions.php:

    function acf_options_pages_translate( $title ) {
    
    	$iso9_table = array(
    		'А' => 'A',   'Б' => 'B',     'В' => 'V',     'Г' => 'G',     'Ѓ' => 'G`',
    		'Ґ' => 'G`',  'Д' => 'D',     'Е' => 'E',     'Ё' => 'YO',    'Є' => 'YE',
    		'Ж' => 'ZH',  'З' => 'Z',     'Ѕ' => 'Z',     'И' => 'I',     'Й' => 'J',
    		'Ј' => 'J',   'І' => 'I',     'Ї' => 'YI',    'К' => 'K',     'Ќ' => 'K`',
    		'Л' => 'L',   'Љ' => 'L',     'М' => 'M',     'Н' => 'N',     'Њ' => 'N`',
    		'О' => 'O',   'П' => 'P',     'Р' => 'R',     'С' => 'S',     'Т' => 'T',
    		'У' => 'U',   'Ў' => 'U`',    'Ф' => 'F',     'Х' => 'H',     'Ц' => 'TS',
    		'Ч' => 'CH',  'Џ' => 'DH',    'Ш' => 'SH',    'Щ' => 'SHH',   'Ъ' => '',
    		'Ы' => 'Y',  'Ь' => '',     'Э' => 'E`',    'Ю' => 'YU',    'Я' => 'YA',
    		'а' => 'a',   'б' => 'b',     'в' => 'v',     'г' => 'g',     'ѓ' => 'g',
    		'ґ' => 'g',   'д' => 'd',     'е' => 'e',     'ё' => 'yo',    'є' => 'ye',
    		'ж' => 'zh',  'з' => 'z',     'ѕ' => 'z',     'и' => 'i',     'й' => 'j',
    		'ј' => 'j',   'і' => 'i',     'ї' => 'yi',    'к' => 'k',     'ќ' => 'k`',
    		'л' => 'l',   'љ' => 'l',     'м' => 'm',     'н' => 'n',     'њ' => 'n`',
    		'о' => 'o',   'п' => 'p',     'р' => 'r',     'с' => 's',     'т' => 't',
    		'у' => 'u',   'ў' => 'u`',    'ф' => 'f',     'х' => 'h',     'ц' => 'ts',
    		'ч' => 'ch',  'џ' => 'dh',    'ш' => 'sh',    'щ' => 'shh',   'ъ' => '',
    		'ы' => 'y',  'ь' => '',     'э' => 'e`',    'ю' => 'yu',    'я' => 'ya'
    	);
    	$geo2lat = array(
    		'ა' => 'a',   'ბ' => 'b',     'გ' => 'g',     'დ' => 'd',     'ე' => 'e',     'ვ' => 'v',
    		'ზ' => 'z',   'თ' => 'th',    'ი' => 'i',     'კ' => 'k',     'ლ' => 'l',    'მ' => 'm',
    		'ნ' => 'n',   'ო' => 'o',     'პ' => 'p',     'ჟ' => 'zh',    'რ' => 'r',     'ს' => 's',
    		'ტ' => 't',   'უ' => 'u',     'ფ' => 'ph',    'ქ' => 'q',     'ღ' => 'gh',    'ყ' => 'qh',
    		'შ' => 'sh',  'ჩ' => 'ch',    'ც' => 'ts',    'ძ' => 'dz',    'წ' => 'ts',    'ჭ' => 'tch',
    		'ხ' => 'kh',  'ჯ' => 'j',     'ჰ' => 'h'
    	);
    	$iso9_table = array_merge($iso9_table, $geo2lat);
    
    	$locale = get_locale();
    	switch ( $locale ) {
    		case 'bg_BG':
    			$iso9_table['Щ'] = 'SHT';
    			$iso9_table['щ'] = 'sht';
    			$iso9_table['Ъ'] = 'A`';
    			$iso9_table['ъ'] = 'a`';
    			break;
    		case 'uk':
    			$iso9_table['И'] = 'Y`';
    			$iso9_table['и'] = 'y`';
    			break;
    	}
    
        $title = strtr( $title, apply_filters('cal_table', $iso9_table) );
        if (function_exists('iconv')){
            $title = iconv( 'UTF-8', 'UTF-8//TRANSLIT//IGNORE', $title );
        }
    
    	return $title;
    }
    add_filter('sanitize_title', 'acf_options_pages_translate', 9);
    

    http://wordpress.org/plugins/advanced-custom-fields/

Reply

You must log in to post.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 11 months ago by Mihail Semjonov
  • This topic is not resolved
  • WordPress version: 3.6.1