• Resolved manuelputmans

    (@manuelputmans)


    Got this advise from GTranslate but that does not work

    <script type="text/javascript">
    var myNewTag = document.getElementsById("product_title");
    for(var i = 0; i < myNewTag.length; i++) {
     if(myNewTag) {
     myNewTag[i].classList.add("notranslate");
     }
    }
    </script>
    
    Please add this code in footer.php file before the </body> closing tag. This will prevent translation of #product_title ID.

    Daley Blind is in french f.e.: Daley Aveugle

    How should I make this work…

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author edo888

    (@edo888)

    Hi,

    Not sure where you got that code, but it is wrong, it should be something like this:

    <script type="text/javascript">
    var myNewTag = document.getElementsByClassName("product_title");
    for(var i = 0; i < myNewTag.length; i++) {
     if(myNewTag) {
       myNewTag[i].classList.add("notranslate");
     }
    }
    </script>

    I would recommend you to edit your theme/plugin and add notranslate directly into it instead:

    <h1 class="product_title entry-title">...</h1>

    <h1 class="product_title entry-title notranslate">...</h1>

    Thanks! ??

    • This reply was modified 3 years ago by edo888.
    • This reply was modified 3 years ago by edo888.
    Thread Starter manuelputmans

    (@manuelputmans)

    Got it from a colleague of you in the chat.

    This script also gives this reslutlt: https://www.football-cards.eu/product/panini-fifa-365-adrenalyn-xl-2017-2018-073-daley-blind/

    Where should I place this code: <h1 class=”product_title entry-title notranslate”>…</h1> directly in the theme (Divi) or plugin?

    Thread Starter manuelputmans

    (@manuelputmans)

    Where should I add this:

    `I would recommend you to edit your theme/plugin and add notranslate directly into it instead:

    <h1 class=”product_title entry-title”>…</h1>

    <h1 class=”product_title entry-title notranslate”>…</h1>

    Thanks!

    Plugin Author edo888

    (@edo888)

    I do not see that you have updated the code I have provided.

    If you want to follow my recommendation then you can search inside your files and see where is the h1 with product_title and you will know which file to edit. In that case you will not need the javascript code.

    Thanks! ??

    Thread Starter manuelputmans

    (@manuelputmans)

    Hello Edo,
    Thanks!
    I made a mistake in the footer.php itself….Now it works

    Is it also possible to stop this from translating by putting this in te same script;
    1. woocommerce-loop-product__title
    2. search results in the search file for woocommerce titles
    3. Home in the menu…. only ‘Home’

    Plugin Author edo888

    (@edo888)

    Hi,

    Yes, you can use a better javascript and use CSS selectors to add the notranslate class. As always, my recommendation is to have the notranslate directly into HTML source code, instead of adding it using javascript.

    <script>
    var itemsArr = document.querySelectorAll(".product_title,.woocommerce-loop-product__title");
    for(var i = 0; i < itemsArr.length; i++)
        itemsArr[i].classList.add("notranslate");
    </script>

    Make sure to write correct CSS selectors separated by comma. You better consult your developer about it.

    Thanks! ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Stop Product title from translating’ is closed to new replies.