Search code examples
google-chrome-extensionlocalecontent-script

How to detect page language/locale in a Chrome extension content script?


I would like my Chrome extension content script to detect the language or locale of the page's content (not the browser language/locale). I assume there is a method for this in the Chrome extension API, but should I be using standard Javascript libraries instead?


Solution

  • This is the Chrome extension method: chrome.tabs.detectLanguage(...). From the description:

    Detects the primary language of the content in a tab.