Forum Archive - How to Configure Google Translate API v2 on localhost

How to Configure Google Translate API v2 on localhost
Apr 9, 2014 1:46 pm by E.Ogunkeye
Hi, I am trying to translate text on my basic webpage that I created on localhost However, I always keep receiving the Access Not Configured. Please enable the Google API error. I have already enabled the Translate API in my Google Developer account, I created both a server and browser API key (any suggestions on what I should add in my referers would be great thanks, my screen dump link underneath may help you with the option). I was wondering if there is any alternative way I can get this API v2 to work on my localhost machine? Please see screen dump link for error. Here on the website, I am trying to translate the UK word on google, with the Translate API V2 enabled and the browser key running in the background of the application I am using for this process, the UK word should translate to a language of my choice, however, as shown below, an error pops up. Here is the link that shows screen dump - I am running the script through WAMPDeveloper on my local machine. In the referrer section within the APIs & auth --> Credentials on my Google Developer account I added the following localhost URL paths hoping that it would work: ***** However I received no luck. Any one that can help me with this issue, or if you have any further questions please let let me know? Your assistance is much appreciated. Thanks
Re: How to Configure Google Translate API v2 on localhost
Apr 9, 2014 1:50 pm by Edvard
Hi, Your topic seems to be not related to this forum. However I may try to help you. Please describe what you want to do and may be share some of your code here, so I can understand and try to help you. Thanks!
Re: How to Configure Google Translate API v2 on localhost
Apr 9, 2014 2:31 pm by E.Ogunkeye
Hi, My apologies for the irrelevant topic as I thought I would be able to find some solutions to my issue here. I will give it a shot in describing my objective. Basically I am trying to producing a system that translates any duplicated webpage through a one-word one-click/one-press mode. The idea is I grab the URL of a link, put it within the system and the output will show a duplicated version of the link, with a small pop-up box showing the translated version of a word as soon as I move my cursor to that specific word and press the SHIFT key. The idea of this project is not originally mine, I am trying to implement it with reference from: and (I have contacted the author that created the system, he has managed to help me through half of the process, but the difficulty lies in actually showing the translated words from localhost machine, the author did not use localhost, he paid for hosting which I currently cannot afford due to financial difficulties). My apologies if my response does not make sense, if you need me to clarify even further I am happy to do so. Any help/assistance would be greatly appreciated. Thanks
Re: How to Configure Google Translate API v2 on localhost
Apr 9, 2014 2:51 pm by Edvard
OK I understand you, it doesn't matter if your script which translates words is located on your localhost, it should work without issues. Can you post the part of your script which communicates with Google Translate through the API, so I can help you? Thanks!
Re: How to Configure Google Translate API v2 on localhost
Apr 9, 2014 3:27 pm by E.Ogunkeye
Here are some of the parts I think you are referring to from the dictionarylookup20a.js file, referenced. I avoided inserting it further list of coding that I thought was not relevant to your question so that you do not end up looking at a long list. var SCGoogleAPIKeyV2 = "API Key Here"; // put your own Google language API V2 key here. var SCtextDetect=""; function SCGoogleDetectV2(text,wholetext) { SCtextDetect = wholetext; var sourceText = encodeURIComponent(text); var source = '' + SCGoogleAPIKeyV2 /*+'&source='+SCtranslateFrom*/+'&target=' + SCtranslateTo + '&callback=SCDetectedText&q=' + sourceText ; SCimportScriptURI(source); } var SCgoogletranslate = ""; function SCgoogleLookup(text,label) { SClabel = label; SCtext = text; if(typeof SCbaseurl != "undefined") { SCgoogletranslate = "" + "&tl=" + SCtranslateTo +"&u=" + encodeURIComponent(SCbaseurl + "?" + SCbaseparamlist); } else { SCgoogletranslate = "" + "&tl=" + SCtranslateTo +"&u=" + encodeURIComponent(document.location.href); } var sourceText = encodeURIComponent(text); var source1 = '' + SCGoogleAPIKeyV2 +'&target=' + SCtranslateTo + '&callback=SCTranslatedText&q=' + sourceText ; SCimportScriptURI(source1); }
Re: How to Configure Google Translate API v2 on localhost
Apr 9, 2014 3:35 pm by Edvard
OK, I see a couple of design problems here. I guess you got this script from somewhere. In the past Google Translate API has been free with some limits, so people were not aware using javascript to get translations. Currently using Google Translate API key is not free and you need to pay for translations, so using your API key in javascript file is not safe, since people can see your API key and use it without your knowledge. You need to write a server side script for translations trough the Google Translate API and refer to it with javascript to get a translation, you need to think also to be able to protect yourself from unauthorized use of your service. Let me know if this info was helpful. Thanks!


Google stopped providing website translator widgetsFeb 28, 2019 2:43 pmReplies: 0Post by: Edvard
wordpress amp link not translateDec 31, 2016 10:11 amReplies: 12Post by: besybuy
Translate website to any specific language, on page loadJan 19, 2019 6:49 amReplies: 1Post by: Leaon7756
Best way to translate a page in WordPress?Jan 7, 2019 11:10 amReplies: 3Post by: Tonnystark
GTranslated Post Redirects To Google HomepageDec 31, 2018 12:36 pmReplies: 1Post by: theseoulofkorea

Try GTranslate with a free 15 day trial