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
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: