Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8875071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:53:05+00:00 2026-06-14T18:53:05+00:00

Hi, I am developing a Google Chrome extension: It is a dictionary that uses

  • 0

Hi, I am developing a Google Chrome extension:
It is a dictionary that uses the Google translate API,
When the user selects a text on the page I would like a popup to appear and show the selected text definition,

I have this code in my js file :

var req = new XMLHttpRequest();
req.open(
    "GET",
    "https://www.googleapis.com/language/translate/v2?" +
    "format=html" +
    "q=" + get_text_selection() + // Source Text
"source=en&" + // Source Language
"target=fa&" + // Target Language
true);
req.send(null);

function get_text_selection() {

    if (window.getSelection)

    return window.getSelection();

    if (document.getSelection)

    return document.getSelection();

    if (document.selection)

    return document.selection.createRange().text;

    return '';

}

and this code in my Manifest.json file :

{
  "name": "Google Translator",
  "version": "1.0",
  "manifest_version": 2,
  "description": "This Extention helps you to translate text in your page",
  "browser_action": {
    "default_icon": "Dictionary-Book-icon.png",
    "default_popup": "popup.html"
  },
  "permissions": [ "http://*/*", "https://*/*", "tabs" ]
}

and this code in my html file :

<!doctype html>
<html>
  <head>
    <title>Getting Started Extension's Popup</title>
    <style>
      body {
        min-width:357px;
        overflow-x:hidden;
      }

    </style>
    <!-- JavaScript and HTML must be in separate files for security. -->
    <script src="popup.js"></script>
  </head>
  <body>
  </body>
</html>

but it’s not working?
Where is my problem?
Thanks for your advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:53:06+00:00Added an answer on June 14, 2026 at 6:53 pm

    First of all Google Translate API is a paid service now. To use Google Translate API you need to get an API key from Google, you can get more information from here. After you get an API key your url should be like

    "https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&source=en&target=fa&q=Hello%20world" // "Hello world" is query here
    

    Which is in your case

    "https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY" + "&format=html" + "&source=en" +"&target=fa" + "&q=" + get_text_selection()
    

    Using following request (using my valid key from the browser address bar)

    "https://www.googleapis.com/language/translate/v2?key=my_valid_key&format=html&q=home&source=en&target=fa" // I've replaced my key with my_valid_key
    

    I’ve got this result

    {  "error": {   "errors": [    {
        "domain": "usageLimits",
        "reason": "dailyLimitExceeded",
        "message": "Daily Limit Exceeded"    }   ],
        "code": 403,   
        "message": "Daily Limit Exceeded"  
      }
    }
    

    Google Translate API no longer free and Translate API FAQ.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an extension for Google Chrome that generates an mp3 file and saves
I am developing a simple page action extension in google chrome and it has
I am developing a Google Chrome extension. When a popup is clicked, I would
I'm developing a Google Chrome extension that makes heavy use of the context menu,
I'm developing a Google Chrome extension I'd like to track the locations (pixel coordinates)
I am developing a Google Chrome Extension which has a content-script, a background page,
I am developing a Google chrome extension where user uploads a file manually. I
I've just started developing a Google Chrome extension using the chrome.* API. I'm trying
I'd like to start developing Google Chrome extension using node.js (since I've already written
I am developing a Google Chrome extension, and need to use the chrome.experimental.webRequest API.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.