Solved

How can I prevent Google Translate from altering my email address?

Svitlana_11
Shopify Partner
3 1 0

I am looking for a solution to exclude the email info@vanea-barfussschuhe.com from translating when using Google Translate on the entire shopify store. The reason is, it becomes info@vanea-barfussschuh.com and does not match the data in GMC (google merchant center), which results in a policy violation… I am using the Sense theme from Shopify. 

 

I have already tried the following, but none worked or maybe I did it incorrectly, I have limited experience but I must resolve this, so any help would be highly appreciated. 

 

  1. Writing the address as an HTML entity info@vanea-barfussschuhe.com
  2. Adding the class “no translate” in the different .json shopify files, always came back with an error “unexpected token”...

DeutschCorrect.PNGenglish.PNG

Accepted Solution (1)

Svitlana_11
Shopify Partner
3 1 0

This is an accepted solution.

Found the solution. If anyone is interested, here's how I achieved it for all instances (footer, rich text h4, and mailto links)

 

<script>
document.addEventListener('DOMContentLoaded', function() {
    // Handle instances of the email address and URL within <p> tags
    var pElements = document.body.querySelectorAll('p');
    pElements.forEach(function(el) {
        if (el.innerHTML.includes('info@vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('info@vanea-barfussschuhe.com', '<span class="notranslate"> info@vanea-barfussschuhe.com </span>');
        }
        if (el.innerHTML.includes('https://vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('https://vanea-barfussschuhe.com', '<span class="notranslate">https://vanea-barfussschuhe.com</span>');
        }
    });

    // Handle the <h4> tag in the .rich-text__text class on the homepage
    var h4Elements = document.body.querySelectorAll('.rich-text__text h4');
    h4Elements.forEach(function(el) {
        if (el.innerHTML.includes('info@vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('info@vanea-barfussschuhe.com', '<span class="notranslate">info@vanea-barfussschuhe.com</span>');
        }
    });

    // Handle the email links in a.c-link
    var linkElements = document.body.querySelectorAll('a.c-link');
    linkElements.forEach(function(el) {
        if (el.innerHTML.includes('info@vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('info@vanea-barfussschuhe.com', '<span class="notranslate"> info@vanea-barfussschuhe.com</span>');
        }
    });
});
</script>

in theme.liquid at the very end ^ 

View solution in original post

Reply 1 (1)

Svitlana_11
Shopify Partner
3 1 0

This is an accepted solution.

Found the solution. If anyone is interested, here's how I achieved it for all instances (footer, rich text h4, and mailto links)

 

<script>
document.addEventListener('DOMContentLoaded', function() {
    // Handle instances of the email address and URL within <p> tags
    var pElements = document.body.querySelectorAll('p');
    pElements.forEach(function(el) {
        if (el.innerHTML.includes('info@vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('info@vanea-barfussschuhe.com', '<span class="notranslate"> info@vanea-barfussschuhe.com </span>');
        }
        if (el.innerHTML.includes('https://vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('https://vanea-barfussschuhe.com', '<span class="notranslate">https://vanea-barfussschuhe.com</span>');
        }
    });

    // Handle the <h4> tag in the .rich-text__text class on the homepage
    var h4Elements = document.body.querySelectorAll('.rich-text__text h4');
    h4Elements.forEach(function(el) {
        if (el.innerHTML.includes('info@vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('info@vanea-barfussschuhe.com', '<span class="notranslate">info@vanea-barfussschuhe.com</span>');
        }
    });

    // Handle the email links in a.c-link
    var linkElements = document.body.querySelectorAll('a.c-link');
    linkElements.forEach(function(el) {
        if (el.innerHTML.includes('info@vanea-barfussschuhe.com')) {
            el.innerHTML = el.innerHTML.replace('info@vanea-barfussschuhe.com', '<span class="notranslate"> info@vanea-barfussschuhe.com</span>');
        }
    });
});
</script>

in theme.liquid at the very end ^