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


PHP MO::translate方法代码示例

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


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

示例1: foreach

 function translate_category_base($termlink, $term, $taxonomy)
 {
     global $sitepress_settings, $sitepress, $wp_rewrite, $wpdb, $woocommerce;
     static $no_recursion_flag;
     // handles product categories, product tags and attributes
     $wc_taxonomies = wc_get_attribute_taxonomies();
     foreach ($wc_taxonomies as $k => $v) {
         $wc_taxonomies_wc_format[] = 'pa_' . $v->attribute_name;
     }
     if (($taxonomy == 'product_cat' || $taxonomy == 'product_tag' || !empty($wc_taxonomies_wc_format) && in_array($taxonomy, $wc_taxonomies_wc_format)) && !$no_recursion_flag) {
         $cache_key = 'termlink#' . $taxonomy . '#' . $term->term_id;
         if ($link = wp_cache_get($cache_key, 'terms')) {
             $termlink = $link;
         } else {
             $no_recursion_flag = false;
             $strings_language = $sitepress_settings['st']['strings_language'];
             $term_language = $sitepress->get_element_language_details($term->term_taxonomy_id, 'tax_' . $taxonomy);
             if (!empty($term_language)) {
                 $permalinks = get_option('woocommerce_permalinks');
                 $base = $taxonomy == 'product_tag' ? $permalinks['tag_base'] : ($taxonomy == 'product_cat' ? $permalinks['category_base'] : $permalinks['attribute_base']);
                 if ($base === '') {
                     // handle exception - default woocommerce category and tag bases used
                     // get translation from WooCommerce mo files?
                     $base_sl = $taxonomy == 'product_tag' ? 'product-tag' : 'product-category';
                     // strings language
                     if ($term_language->language_code == $strings_language) {
                         $base = _x($base_sl, 'slug', 'woocommerce');
                         $base_translated = $base_sl;
                     } else {
                         $base = _x($base_sl, 'slug', 'woocommerce');
                         $mo_file = $woocommerce->plugin_path() . '/i18n/languages/woocommerce-' . $sitepress->get_locale($term_language->language_code) . '.mo';
                         if (file_exists($mo_file)) {
                             $mo = new MO();
                             $mo->import_from_file($mo_file);
                             $base_translated = $mo->translate($base_sl, 'slug');
                         } else {
                             $base_translated = $base_sl;
                         }
                     }
                 } else {
                     $string_identifier = $taxonomy == 'product_tag' || $taxonomy == 'product_cat' ? $taxonomy : 'attribute';
                     //
                     if ($term_language->language_code != $strings_language) {
                         $base_translated = $wpdb->get_var("\n                                            SELECT t.value \n                                            FROM {$wpdb->prefix}icl_strings s    \n                                            JOIN {$wpdb->prefix}icl_string_translations t ON t.string_id = s.id\n                                            WHERE s.value='" . esc_sql($base) . "' \n                                                AND s.language = '{$strings_language}' \n                                                AND s.name LIKE 'Url {$string_identifier} slug:%' \n                                                AND t.language = '{$term_language->language_code}'\n                            ");
                     } else {
                         $base_translated = $base;
                     }
                 }
                 if (!empty($base_translated) && $base_translated != $base) {
                     $buff = $wp_rewrite->extra_permastructs[$taxonomy]['struct'];
                     $wp_rewrite->extra_permastructs[$taxonomy]['struct'] = str_replace($base, $base_translated, $wp_rewrite->extra_permastructs[$taxonomy]['struct']);
                     $no_recursion_flag = true;
                     $termlink = get_term_link($term, $taxonomy);
                     $wp_rewrite->extra_permastructs[$taxonomy]['struct'] = $buff;
                 }
             }
             $no_recursion_flag = false;
             wp_cache_add($cache_key, $termlink, 'terms', 0);
         }
     }
     return $termlink;
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:62,代码来源:terms.class.php


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