Hi
I tried to use the Elfsight Translation widget and exclude some words from being translated.
My website: premiumportraits.ai
I would like to exclude “HEADSHOTS” for example - in the navigation or somewhere else on the page. (The translation in German is “Kopfschuss” which has quite a different meaning - except I offer this service in the darknet ha ha)
Unfortunately I didn’t succeed even with trying several things. Can you help me?
Thank you very much in advance.
best regards, Phil
ignore-GENERATE HEADSHOT
ignore-create headshot
KI-KOPFSCHÜSSE
ignore-GENERATE HEADSHOTS
headshots
Headshot
HEADSHOTS
ignore-headshot
ignore - headshot
Some of the variants I tried
Hi @user20292
The correct class for this phrase is .ww_menu_link_text. However, 40 more elements on your website have the same class.
To apply the exclusion to the AI Headshot only, we’ve added this script to the Custom JS section on the Settings tab of your widget’s settings:
const targetSelector = '.ww_menu_link_text';
const waitForElement = (selector, root = document) =>
new Promise((res) => {
let i = 0;
const check = () => {
const component = root.querySelectorAll(selector);
if (component) {
res(component);
} else if (i !== 150) {
setTimeout(check, 100);
i++;
}
};
check();
});
waitForElement(targetSelector).then((targets) => {
targets.forEach((target) => {
if (target.textContent === 'AI HEADSHOT') {
target.classList.add('exclude-translation');
}
});
});
This script assigns the unique class .to ww_menu_link_text and only “AI Headshot” is excluded from the translation:
Please check your website and let me know if you like the result
Hi Max
Thank you very much for your fast reply and help. Amazing!
That is already great.
If I want to add some more words or translations - can I do that myself and if so, how?
Is is not possible to do so in the “classic” exception part?
Only possible through JS section?
I saw for example a text that is not translated properly and would like to change that.
VORTEILE GEGENÜBER EINEM
ECHTES FOTOSHOOTING
This should be: VORTEILE GEGENÜBER EINEM ECHTEN FOTOSHOOTING
This is just one example. Is there any technique or anything I can adjust the correct version?
Thank you so much!
have a wonderful day
best regards
Phil
Unfortunately, it’s impossible to adjust translations or add more words. I am really sorry!
We already have a request for this feature on the Wishlist. Feel free to upvote it here - Custom translation
Thank you so much!
But the normal “Translation Exclusion” doesn’t work? Can I not write: exclude-WORD
Translation Exclusions section works great.
The thing is that “AI Headshot” has the same class as 40 other elements on your website. If we just added this class to the Translation Exclusions, other 40 elements with this class wouldn’t be translated either.
To apply the exclusion to “AI Headshot”, we’ve added the script to the Custom JS field. Thus, if the word/phrase has a unique class, you should add it right to the Translation Exclusions.
To find the needed class, right-click the word/phrase you’d like to exclude, choose Inspect and you’ll see the class name:
Thank you very much for your help. Have a wonderful day
No problem!
Have a great day too