当前位置: 首页>>代码示例>>PHP>>正文


PHP ICL_Pro_Translation::server_languages_map方法代码示例

本文整理汇总了PHP中ICL_Pro_Translation::server_languages_map方法的典型用法代码示例。如果您正苦于以下问题:PHP ICL_Pro_Translation::server_languages_map方法的具体用法?PHP ICL_Pro_Translation::server_languages_map怎么用?PHP ICL_Pro_Translation::server_languages_map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICL_Pro_Translation的用法示例。


在下文中一共展示了ICL_Pro_Translation::server_languages_map方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _icl_translation_send_strings_icanlocalize

function _icl_translation_send_strings_icanlocalize($string_ids, $target)
{
    global $wpdb, $sitepress, $sitepress_settings;
    if (!$sitepress_settings['st']['strings_language']) {
        $sitepress_settings['st']['strings_language'] = $sitepress->get_default_language();
    }
    $target_details = $sitepress->get_language_details($target);
    // get all the untranslated strings
    $untranslated = array();
    foreach ($string_ids as $st_id) {
        $status = $wpdb->get_var($wpdb->prepare("SELECT status FROM {$wpdb->prefix}icl_string_translations WHERE string_id=%d and language=%s", $st_id, $target));
        if ($status != ICL_STRING_TRANSLATION_COMPLETE) {
            $untranslated[] = $st_id;
        }
    }
    if (sizeof($untranslated) > 0) {
        // Something to translate.
        $target_for_server = array(ICL_Pro_Translation::server_languages_map($target_details['english_name']));
        //filter some language names to match the names on the server
        $data = array('url' => '', 'target_languages' => $target_for_server);
        $string_values = array();
        foreach ($untranslated as $st_id) {
            $string = $wpdb->get_row($wpdb->prepare("SELECT context, name, value FROM {$wpdb->prefix}icl_strings WHERE id=%d", $st_id));
            $string_values[$st_id] = $string->value;
            $data['contents']['string-' . $st_id . '-context'] = array('translate' => 0, 'data' => base64_encode(htmlspecialchars($string->context)), 'format' => 'base64');
            $data['contents']['string-' . $st_id . '-name'] = array('translate' => 0, 'data' => base64_encode(htmlspecialchars($string->name)), 'format' => 'base64');
            $data['contents']['string-' . $st_id . '-value'] = array('translate' => 1, 'data' => base64_encode(htmlspecialchars($string->value)), 'format' => 'base64');
        }
        $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
        $orig_lang = $sitepress->get_language_details($sitepress_settings['st']['strings_language']);
        $orig_lang_for_server = ICL_Pro_Translation::server_languages_map($orig_lang['english_name']);
        $timestamp = date('Y-m-d H:i:s');
        $xml = $iclq->build_cms_request_xml($data, $orig_lang_for_server);
        $args = array('xml' => $xml, 'title' => "String translations", 'to_languages' => $target_for_server, 'orig_language' => $orig_lang_for_server);
        $res = $iclq->send_request($args);
        if ($res > 0) {
            foreach ($string_values as $st_id => $value) {
                $wpdb->insert($wpdb->prefix . 'icl_string_status', array('rid' => $res, 'string_translation_id' => $st_id, 'timestamp' => $timestamp, 'md5' => md5($value)));
                //insert rid
            }
            $wpdb->insert($wpdb->prefix . 'icl_core_status', array('rid' => $res, 'origin' => $orig_lang['code'], 'target' => $target, 'status' => CMS_REQUEST_WAITING_FOR_PROJECT_CREATION));
            return $res;
        } else {
            return 0;
        }
    }
}
开发者ID:besimhu,项目名称:LDF-site,代码行数:47,代码来源:functions.php

示例2: process_forms

 function process_forms()
 {
     global $wpdb;
     require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
     require_once ICL_PLUGIN_PATH . '/lib/xml2array.php';
     require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
     if (isset($_POST['icl_post_action'])) {
         switch ($_POST['icl_post_action']) {
             case 'save_theme_localization':
                 $locales = array();
                 foreach ($_POST as $k => $v) {
                     if (0 !== strpos($k, 'locale_file_name_') || !trim($v)) {
                         continue;
                     }
                     $locales[str_replace('locale_file_name_', '', $k)] = $v;
                 }
                 if (!empty($locales)) {
                     $this->set_locale_file_names($locales);
                 }
                 break;
         }
         return;
     }
     $create_account = isset($_POST['icl_create_account_nonce']) && $_POST['icl_create_account_nonce'] == wp_create_nonce('icl_create_account');
     $create_account_and_transfer = isset($_POST['icl_create_account_and_transfer_nonce']) && $_POST['icl_create_account_and_transfer_nonce'] == wp_create_nonce('icl_create_account_and_transfer');
     $config_account = isset($_POST['icl_configure_account_nonce']) && $_POST['icl_configure_account_nonce'] == wp_create_nonce('icl_configure_account');
     $create_support_account = isset($_POST['icl_create_support_account_nonce']) && $_POST['icl_create_support_account_nonce'] == wp_create_nonce('icl_create_support_account');
     $config_support_account = isset($_POST['icl_configure_support_account_nonce']) && $_POST['icl_configure_support_account_nonce'] == wp_create_nonce('icl_configure_support_account');
     $use_existing_account = isset($_POST['icl_use_account_nonce']) && $_POST['icl_use_account_nonce'] == wp_create_nonce('icl_use_account');
     $transfer_to_account = isset($_POST['icl_transfer_account_nonce']) && $_POST['icl_transfer_account_nonce'] == wp_create_nonce('icl_transfer_account');
     if ($create_account || $config_account || $create_support_account || $config_support_account) {
         if (isset($_POST['icl_content_trans_setup_back_2'])) {
             // back button in wizard mode.
             $this->settings['content_translation_setup_wizard_step'] = 2;
             $this->save_settings();
         } else {
             $user = $_POST['user'];
             $user['create_account'] = isset($_POST['icl_create_account_nonce']) || isset($_POST['icl_create_support_account_nonce']) ? 1 : 0;
             $user['platform_kind'] = 2;
             $user['cms_kind'] = 1;
             $user['blogid'] = $wpdb->blogid ? $wpdb->blogid : 1;
             $user['url'] = get_home_url();
             $user['title'] = get_option('blogname');
             $user['description'] = $this->settings['icl_site_description'];
             $user['is_verified'] = 1;
             if ($user['create_account'] && defined('ICL_AFFILIATE_ID') && defined('ICL_AFFILIATE_KEY')) {
                 $user['affiliate_id'] = ICL_AFFILIATE_ID;
                 $user['affiliate_key'] = ICL_AFFILIATE_KEY;
             }
             $user['interview_translators'] = $this->settings['interview_translators'];
             $user['project_kind'] = $this->settings['website_kind'];
             /*
              if(is_null($user['project_kind']) || $user['project_kind']==''){
             	$_POST['icl_form_errors'] = __('Please select the kind of website','sitepress');
             	return;
             }
             */
             $user['pickup_type'] = intval($this->settings['translation_pickup_method']);
             $notifications = 0;
             if ($this->settings['icl_notify_complete']) {
                 $notifications += 1;
             }
             if ($this->settings['alert_delay']) {
                 $notifications += 2;
             }
             $user['notifications'] = $notifications;
             // prepare language pairs
             $pay_per_use = $this->settings['translator_choice'] == 1;
             $language_pairs = $this->settings['language_pairs'];
             $lang_pairs = array();
             if (isset($language_pairs)) {
                 foreach ($language_pairs as $k => $v) {
                     $english_fr = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                     $pay_per_use_increment = 0;
                     foreach ($v as $k => $v) {
                         $pay_per_use_increment++;
                         $english_to = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                         $lang_pairs['from_language' . $pay_per_use_increment] = ICL_Pro_Translation::server_languages_map($english_fr);
                         $lang_pairs['to_language' . $pay_per_use_increment] = ICL_Pro_Translation::server_languages_map($english_to);
                         if ($pay_per_use) {
                             $lang_pairs['pay_per_use' . $pay_per_use_increment] = 1;
                         }
                     }
                 }
             }
             $icl_query = new ICanLocalizeQuery();
             list($site_id, $access_key) = $icl_query->createAccount(array_merge($user, $lang_pairs));
             if (!$site_id) {
                 $user['pickup_type'] = ICL_PRO_TRANSLATION_PICKUP_POLLING;
                 list($site_id, $access_key) = $icl_query->createAccount(array_merge($user, $lang_pairs));
             }
             if (!$site_id) {
                 if ($access_key) {
                     $_POST['icl_form_errors'] = $access_key;
                 } else {
                     $_POST['icl_form_errors'] = __('An unknown error has occurred when communicating with the ICanLocalize server. Please try again.', 'sitepress');
                     // We will force the next try to be http.
                     update_option('_force_mp_post_http', 1);
                 }
             } else {
//.........这里部分代码省略.........
开发者ID:pablomarsan,项目名称:iftheme-docs,代码行数:101,代码来源:sitepress.class.php

示例3: send_comment_to_translation

 function send_comment_to_translation($comment_id, $to_language)
 {
     global $wpdb, $sitepress_settings, $sitepress;
     $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
     $from_lang = $sitepress->get_language_details($this->user_language);
     $to_lang = $sitepress->get_language_details($to_language);
     $from_lang_server = ICL_Pro_Translation::server_languages_map($from_lang['english_name']);
     $to_lang_server = ICL_Pro_Translation::server_languages_map($to_lang['english_name']);
     $body = $wpdb->get_var("SELECT comment_content FROM {$wpdb->comments} WHERE comment_ID={$comment_id}");
     $rid = $iclq->cms_create_message($body, $from_lang_server, $to_lang_server);
     if ($rid > 0) {
         // does this comment already exist in the messages status queue?
         $msid = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}icl_message_status WHERE object_type='comment' AND object_id={$comment_id}");
         if ($msid) {
             $wpdb->update($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'md5' => md5($body), 'status' => MESSAGE_TRANSLATION_IN_PROGRESS), array('id' => $msid));
         } else {
             $wpdb->insert($wpdb->prefix . 'icl_message_status', array('rid' => $rid, 'object_id' => $comment_id, 'from_language' => $this->user_language, 'to_language' => $to_language, 'md5' => md5($body), 'object_type' => 'comment', 'status' => MESSAGE_TRANSLATION_IN_PROGRESS));
         }
     }
 }
开发者ID:batruji,项目名称:metareading,代码行数:20,代码来源:functions.php

示例4: ICanLocalizeQuery

     //break;
 //break;
 case 'icl_cms_id_fix':
     $iclq = new ICanLocalizeQuery($sitepress_settings['site_id'], $sitepress_settings['access_key']);
     $p = $wpdb->get_row("SELECT t.* FROM {$wpdb->prefix}icl_translations t JOIN {$wpdb->prefix}icl_translation_status s ON t.translation_id=s.translation_id\n                WHERE t.element_type LIKE 'post\\_%' AND t.source_language_code IS NOT NULL AND s.translation_service='icanlocalize' LIMIT {$_REQUEST['offset']}, 1");
     if (!empty($p)) {
         $original_id = $wpdb->get_var($wpdb->prepare("SELECT element_id FROM {$wpdb->prefix}icl_translations WHERE trid=%d AND source_language_code IS NULL", $p->trid));
         if ($p->element_type == 'post_page') {
             $permalink = get_option('home') . '?page_id=' . $original_id;
         } else {
             $permalink = get_option('home') . '?p=' . $original_id;
         }
         $_lang_details = $sitepress->get_language_details($p->source_language_code);
         $from_language = ICL_Pro_Translation::server_languages_map($_lang_details['english_name']);
         $_lang_details = $sitepress->get_language_details($p->language_code);
         $to_language = ICL_Pro_Translation::server_languages_map($_lang_details['english_name']);
         $cms_id = sprintf('%s_%d_%s_%s', preg_replace('#^post_#', '', $p->element_type), $original_id, $p->source_language_code, $p->language_code);
         $ret = $iclq->update_cms_id(compact('permalink', 'from_language', 'to_language', 'cms_id'));
         if ($ret != $cms_id && $iclq->error()) {
             echo json_encode(array('errors' => 1, 'message' => $iclq->error(), 'cont' => 0));
         } else {
             echo json_encode(array('errors' => 0, 'message' => 'OK', 'cont' => 1));
         }
     } else {
         echo json_encode(array('errors' => 0, 'message' => __('Done', 'sitepress'), 'cont' => 0));
     }
     exit;
     //break;
 //break;
 case 'icl_cleanup':
     global $sitepress, $wpdb, $wp_post_types;
开发者ID:GaryJones,项目名称:TPWP,代码行数:31,代码来源:troubleshooting.php

示例5: isset

// included from Sitepress::reminder_popups
//
// NOTE: this is also used for other popup links to ICanLocalize
global $wpdb;
$target = $_GET['target'];
$auto_resize = isset($_GET['auto_resize']) && $_GET['auto_resize'];
$unload_cb = isset($_GET['unload_cb']) ? $_GET['unload_cb'] : false;
if (preg_match('|^@select-translators;([^;]+);([^;]+)@|', $target, $matches)) {
    $from_lang = $matches[1];
    $to_lang = $matches[2];
    require_once ICL_PLUGIN_PATH . '/lib/Snoopy.class.php';
    require_once ICL_PLUGIN_PATH . '/lib/xml2array.php';
    require_once ICL_PLUGIN_PATH . '/lib/icl_api.php';
    $icl_query = new ICanLocalizeQuery();
    foreach ($this->get_active_languages() as $lang) {
        $lang_server[$lang['code']] = ICL_Pro_Translation::server_languages_map($lang['english_name']);
    }
    if (!$this->icl_account_configured()) {
        $user['create_account'] = 1;
        $user['anon'] = 1;
        $user['platform_kind'] = 2;
        $user['cms_kind'] = 1;
        $user['blogid'] = $wpdb->blogid ? $wpdb->blogid : 1;
        $user['url'] = get_option('siteurl');
        $user['title'] = get_option('blogname');
        $user['description'] = @strval($this->settings['icl_site_description']);
        $user['is_verified'] = 1;
        if (defined('ICL_AFFILIATE_ID') && defined('ICL_AFFILIATE_KEY')) {
            $user['affiliate_id'] = ICL_AFFILIATE_ID;
            $user['affiliate_key'] = ICL_AFFILIATE_KEY;
        }
开发者ID:besimhu,项目名称:LDF-site,代码行数:31,代码来源:icl-reminder-popup.php

示例6: send_translation_snapshots

 /** * Creates and sends translation snapshots.  *
  * Called by the scheduled cron event.
  */
 function send_translation_snapshots()
 {
     if (!defined('ICL_PLUGIN_PATH')) {
         return;
     }
     require_once ICL_PLUGIN_PATH . '/inc/translation-management/pro-translation.class.php';
     global $sitepress, $sitepress_settings;
     if (isset($sitepress_settings['site_id'])) {
         $jobs = $this->get_translation_jobs();
         $total_word_count = $this->get_translation_word_count($jobs);
         // Do not send snapshots when nothing changed
         $icl_settings = $sitepress->get_settings();
         if (isset($icl_settings['snapshot_word_count']) and $icl_settings['snapshot_word_count'] == $total_word_count) {
             return;
         } else {
             $icl_settings['snapshot_word_count'] = $total_word_count;
             $sitepress->save_settings($icl_settings);
         }
         $datetime = new DateTime();
         if (!empty($total_word_count['total'])) {
             foreach ($total_word_count['total'] as $from => $to_list) {
                 foreach ($to_list as $to => $value) {
                     // Convert language names to icanlocalize format
                     $from_language_name = ICL_Pro_Translation::server_languages_map($from);
                     $to_language_name = ICL_Pro_Translation::server_languages_map($to);
                     $params = array('date' => $datetime->format("Y-m-d\\TH:i:s-P"), 'from_language_name' => $from_language_name, 'to_language_name' => $to_language_name, 'words_to_translate' => $value, 'translated_words' => $total_word_count['finished'][$from][$to]);
                     $this->send_translation_snapshot_to_icl($params);
                 }
             }
         }
     }
 }
开发者ID:ascarius,项目名称:wordpress-bootstrap,代码行数:35,代码来源:translation-analytics.class.php

示例7: __

                $sitepress->save_settings(array('quote-get' => $saved));
                echo __('An unknown error has occurred when communicating with the ICanLocalize server. Please try again.', 'sitepress') . '<br /><br />';
                require_once ICL_PLUGIN_PATH . '/inc/quote/quote-get.php';
                exit;
            }
        }
        /**
         * Set URL query
         */
        $language_pairs = array($saved['from'] => $saved['to']);
        $lang_pairs = array();
        $incr = 1;
        $query = '';
        if (isset($language_pairs)) {
            foreach ($language_pairs as $k => $v) {
                $english_from = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                $query .= '&to_lang_num=' . count($v);
                $query .= '&from_language_name=' . $english_from;
                foreach ($v as $k => $v) {
                    $english_to = $wpdb->get_var("SELECT english_name FROM {$wpdb->prefix}icl_languages WHERE code='{$k}' ");
                    $query .= '&to_language_name_' . $incr . '=' . ICL_Pro_Translation::server_languages_map($english_to);
                    $incr++;
                }
            }
        }
        $url = ICL_API_ENDPOINT . '/websites/' . $site_id . '/quote?accesskey=' . $access_key . '&locale=' . $sitepress->get_default_language() . $query . '&compact=1';
        // Call reopen JS
        echo '<script type="text/javascript">icl_thickbox_reopen(\'' . $url . '\');</script>';
        exit;
    }
}
开发者ID:santikrass,项目名称:apache,代码行数:31,代码来源:quote-get-submit.php


注:本文中的ICL_Pro_Translation::server_languages_map方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。