Monday, May 20, 2024
15
rated 0 times [  18] [ 3]  / answers: 1 / hits: 15251  / 14 Years ago, thu, february 3, 2011, 12:00:00

I've added the Google Translation Bar to our website but due to how the layout works if the translation on the main navigation is longer than English is pushes some links down to the next row and starts to cover up other elements. I've got some Javascript that detects if the translation bar is in use and makes the containing div for the menu and search box wider to compensate, while this does affect the layout it is by far preferable to covering parts of the page.



However Chrome now has translation built in to the browser, if someone uses this they obviously won't be using the embedded version and so I can't detect it to apply my width fix. Is there any way to detect if Chrome's built in translation is being used?


More From » google-chrome

 Answers
7

Maybe try using js to detect if menu content has changed and then apply new styles.



UPDATE



When Chrome translates a page it adds several elements to a page:




  • two script elements to head tag

  • global object window.google

  • class = translated-ltr to html tag

  • div id=goog-gt-tt to body tag



You can watch for changes in DOM to find out when content is translated:



document.addEventListener('DOMSubtreeModified', function (e) {
if(e.target.tagName === 'HTML' && window.google) {
if(e.target.className.match('translated')) {
// page has been translated
} else {
// page has been translated and translation was canceled
}
}
}, true);

[#93918] Wednesday, February 2, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
karivictoriab

Total Points: 530
Total Questions: 90
Total Answers: 95

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;