Using the nontranslate tag for some parts of the site
Nov 12, 2017 9:10 am by m2ecomm
Nov 12, 2017 9:10 am by m2ecomm
We are quite satisfied with GTranslate but we want to exclude some parts of our website from being automatically translated. We already accomplished that by placing the <span class="notranslate">Span</span> span manually in some contents and in the respective template files. Now we want to exclude the content of only one specific category from beeing translated.
I think there is some way to do that in WordPress by using the $category parameter similar to the following example:
function is_category( $category = '' ) {
global $wp_query;
if ( ! isset( $wp_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $wp_query->is_category( $category );
}
But we don't know how to wrap the content into the "notranslate" Span. Do you have any solution for that?
Thanks and best regards!
Re: Using the nontranslate tag for some parts of the site
Nov 12, 2017 10:29 am by m2ecomm
Nov 12, 2017 10:29 am by m2ecomm
After checking further I found out that using an action hook probably would be the best method to achieve this but I don't know how to correctly insert the NoTranslate span only for the product description:
add_action( 'wp', 'disable_translation' );
function disable_translation() {
// If a product in the 'Cookware' category is being viewed...
if ( is_product() && has_term( 'Cookware', 'product_cat' ) ) {
//... Wrap the product description into notranslate span to disable the translation
<span class="notranslate">???????????????????</span>
}
}
Could anybody kindly tell me how to do this? Thanks a lot!
Re: Using the nontranslate tag for some parts of the site
Nov 14, 2017 1:03 pm by Yana
Nov 14, 2017 1:03 pm by Yana
Hi,
You can try to add notranslate class using javascript code .
SIMILAR TOPICS
how to translate site right to left for arabic in WordPress | Dec 26, 2018 9:02 am | Replies: 1 | Post by: Hammond753 |
Would you share your site URL? | Dec 3, 2018 4:57 pm | Replies: 1 | Post by: BevVincent |
Can I Translate Only Few Elements Of My Site? | Aug 16, 2018 1:31 pm | Replies: 1 | Post by: riyagupta |
SSL for my site has been expired, please renew it | Mar 21, 2018 1:48 pm | Replies: 1 | Post by: besybuy |
Googlebot seeing desktop version of site instead of mobilel | Mar 16, 2018 3:06 am | Replies: 5 | Post by: natastna2 |