WordPress.org

Ready to get started?Download WordPress

Forums

WP FullCalendar
Addition of Chinese + new hook to add params to ajaxurl (1 post)

  1. leoloso
    Member
    Posted 1 year ago #

    Hi,

    thanks for the plugin, it is awesome!!!

    I have added Mandarin language for Mainland China, I hope you can add it to your code:

    $calendar_languages = array(
    	'zh_CN'=>array('closeText'=>'关闭','prevText'=>'<上月','nextText'=>'下月>','currentText'=>'今天','monthNames'=>array('一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'),'monthNamesShort'=>array('一','二','三','四','五','六','七','八','九','十','十一','十二'),'dayNames'=>array('星期日','星期一','星期二','星期三','星期四','星期五','星期六'),'dayNamesShort'=>array('周日','周一','周二','周三','周四','周五','周六'),'dayNamesMin'=>array('日','一','二','三','四','五','六'),'weekHeader'=>'周','dateFormat'=>'yy/mm/dd','firstDay'=>1,'isRTL'=>false,'showMonthAfterYear'=>true,'yearSuffix'=>'年')
    );
    //extra WP FUllCalendar translations here please:
    $wp_fullcalendar_languages = array(
    	'zh_CN' => array('buttonText' => array('today'=>'今天','month'=>'月','week'=>'周','day'=>'日'))
    );

    Right now there is an issue though. My website is bilingual English / Chinese, using qTranslate. Right now the content in the calendar is always brought in English, because the admin-ajax.php call to bring all the Events does not carry with it the language information, so on the server it always retrieves back the default language. But by adding a param "lang" then it is alright. So I have modified your code adding a hook to add this param, I hope you can also add it to the code:

    function localize_script(){
    	$js_vars = array();
    	$js_vars['ajaxurl'] = apply_filters('wpfc_admin_url', admin_url('admin-ajax.php'));
    ...
    }

    Then in my website I implement that filter:

    add_filter('wpfc_admin_url', function($url) {
    
    	if (function_exists('qtrans_getLanguage')) {
    		return add_query_arg('lang', qtrans_getLanguage(), $url);
    	}
    
    	return $url;
    });

    This will make the ajaxurl be wp-admin/admin-ajax.php url become wp-admin/admin-ajax.php?lang=zh, then the content is brought in Chinese

    Thanks!

    http://wordpress.org/extend/plugins/wp-fullcalendar/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.