Search code examples
google-chromegoogle-chrome-extensionlanguage-detection

Detecting the current tab language using Chrome extension?


Is there a way to use chrome API to detect the language of the current content in the current tab?


Solution

  • Use the Chrome Tabs API to select the current tab, then get the language.

    Sample usage:

    //Get language of current tab
    chrome.tabs.getSelected(null, function(tab) {
      chrome.tabs.detectLanguage(tab.id, function(language) {
        console.log(language);
      });
    });