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;
 }