Translate Widget - Some words are not translated

I’ve just installed the Widget, and I’m noticing that some words aren’t translated.
my site is in French with English translation.
The main menu has an NOS SOLUTIONS entry that should be translated as OUR SOLUTIONS, but it doesn’t work.
As for the footer, I have a newsletter sign-up button and it’s still written in French (S’inscrire). EN = Sign up

Thank you for your help - Aurélien.

2 Likes

Hi there, @Aurelien_Penel :wave:

I am really sorry about this issue!

You request is with our devs now and I’ll let you know once the issue is fixed :slightly_smiling_face:

Hi there, @Aurelien_Penel :wave:

Apologies for the delayed response!

Devs investigated the issue that Google considers Nos Solutions to be the name of the brand and doesn’t translate it.

To translate this phrase, we’ve added the code below to the Custom JS field on the Settings tab of your widget’s settings:

const SEPARATOR = '%$#';

const dictionary = {
  'NOS SOLUTIONS': `NOS${SEPARATOR} SOLUTIONS`
};

function transformValue(value) {
  const parts = value.split(SEPARATOR);
  const firstPart = parts.shift();
  const wrappedParts = parts.map(part => `<span>${part}</span>`);
  return [firstPart, ...wrappedParts].join('');
}

function replaceText(rootNode) {
  const walker = document.createTreeWalker(rootNode, NodeFilter.SHOW_TEXT, null, false);
  const textNodes = [];
  while (walker.nextNode()) {
    textNodes.push(walker.currentNode);
  }
  textNodes.forEach(textNode => {
    let text = textNode.nodeValue;
    for (let key in dictionary) {
      if (text.includes(key)) {
        text = text.split(key).join(transformValue(dictionary[key]));
      }
    }
    if (text !== textNode.nodeValue) {
      const span = document.createElement('span');
      span.innerHTML = text;
      textNode.parentNode.replaceChild(span, textNode);
    }
  });
}

replaceText(document.body);

You may wonder why it’s translated as Us solutions instead of Our solutions. The thing is, that it’s now based on the Google Translate, and this is the exact result we get from the Google Translate directly. So, unfortunately, there is no way to change it.

We agree that the translation could use some improvement, and we already have a couple of ideas in our Wishlist:

Hopefully, we’ll be able to improve the translation quality in the future.

Regarding the button text, we’ve fixed the issue, and now it’s translated. Please check it out and let me know how it works on your end :slightly_smiling_face: