Detecting Google Chrome Translation

前端 未结 4 2191
难免孤独
难免孤独 2020-12-15 20:39

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 d

4条回答
  •  爱一瞬间的悲伤
    2020-12-15 21:19

    I just wrote an article on detecting automatic machine-translations in Google Chrome, Yandex Browser, and Microsoft Translate Extension. I haven’t figured out how to detect Naver Whale browser yet, which is the last browser with a built-in page translation feature.

    The short and sweet of it is watching out for the following DOM markers:

    !!document.querySelector("html.translated-ltr, head.translated-rtl, ya-tr-span, *[_msttexthash]");
    

    You can detect web-based proxy translation services from a list of domain names (found in the linked article.)

提交回复
热议问题