Using the nontranslate tag for some parts of the site

Popular automatic website translation tool

Using the nontranslate tag for some parts of the site

Postby m2ecomm » Sun Nov 12, 2017 1:10 pm

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
Code: Select all
<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:
Code: Select all
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!
m2ecomm
 
Posts: 4
Joined: Mon Sep 04, 2017 1:40 pm

Re: Using the nontranslate tag for some parts of the site

Postby m2ecomm » Sun Nov 12, 2017 2:29 pm

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:

Code: Select all
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!
m2ecomm
 
Posts: 4
Joined: Mon Sep 04, 2017 1:40 pm

Re: Using the nontranslate tag for some parts of the site

Postby Yana » Tue Nov 14, 2017 5:03 pm

Hi,

You can try to add notranslate class using javascript code .
Regards,

Yana Ghahramanyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Yana
 
Posts: 4483
Joined: Thu Jan 12, 2012 6:21 pm


  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest

2GLux