google-translate-api icon indicating copy to clipboard operation
google-translate-api copied to clipboard

Getting an error from Ionic Angular

Open guyjoules opened this issue 8 years ago • 9 comments

Hi, Trying to use the module from Ionic over Angular, I'm getting an error as in the link below. Any ideas?

Cheers.

https://cdn-enterprise.discourse.org/ionicframework/uploads/default/original/3X/0/c/0c47de6f934ffce6fdb8b9f738e0a4cd87fe68b0.png

guyjoules avatar Aug 17 '17 14:08 guyjoules

Same issue when trying to import into React app. Works perfectly well if trying in node environment. Is it meant to work in browser at all?

EternallLight avatar Aug 20 '17 19:08 EternallLight

Try my "fork" at https://www.npmjs.com/package/google-translate-api-without-node -- I've been successfully using this in a webpacked browser app without issues, uses jQuery for requests.

Ironically enough though, it started producing an error a little while back, maybe a few months ago. Perhaps I need to sync up with the main repo again?

Edit: I merged upstream and everything works fine now 👍

dennislysenko avatar Aug 21 '17 15:08 dennislysenko

Thanks deniiislysenko. Tried it and now I get -

XMLHttpRequest cannot load https://translate.google.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.

Tried from Chrome as well as from Cordova on IPad.

Any idea?

guyjoules avatar Aug 22 '17 08:08 guyjoules

Same issue here - since translate.google.com does not send CORS header, it won't work from any other domain.

EternallLight avatar Aug 25 '17 18:08 EternallLight

I am using it in a chrome extension and I think there is a way to avoid CORS issues with that. Not sure about your use case.

On Fri, Aug 25, 2017, 11:56 Andrey Gruniov [email protected] wrote:

Same issue here - since translate.google.com does not send CORS header, it won't work from any other domain.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matheuss/google-translate-api/issues/32#issuecomment-325008657, or mute the thread https://github.com/notifications/unsubscribe-auth/AE4I_5APt-9VJTUaemfeQIp8RCGQnRvvks5sbxj6gaJpZM4O6Xyu .

dennislysenko avatar Aug 25 '17 19:08 dennislysenko

Not sure. I tried it a while ago with no success. As a quick workaround, I'm going to use this module in a small express app and serve the result to front end.

EternallLight avatar Aug 25 '17 19:08 EternallLight

If you install the CORS Chrome extension, it will work. When deployed to mobile using cordova, it won't.

On Sat, Aug 26, 2017 at 2:43 AM, Andrey Gruniov [email protected] wrote:

Not sure. I tried it a while ago with no success. As a quick workaround, I'm going to use this module in a small express app and serve the result to front end.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/matheuss/google-translate-api/issues/32#issuecomment-325017959, or mute the thread https://github.com/notifications/unsubscribe-auth/AdIKCyAN8KN6-8qtS0erUjVe1h5t6uA9ks5sbyPFgaJpZM4O6Xyu .

guyjoules avatar Aug 26 '17 05:08 guyjoules

I created a simple server with express using google-translate-api, so make a deploy on heroku, wedeploy, etc and solve the problem with prototype and cors. Here the project: https://github.com/brenopolanski/server-google-translate-api

brenopolanski avatar Sep 09 '17 17:09 brenopolanski

I want to implement it in my Ionic(v1) app. How can I manage to do that? any sample codes? or is it a normal http request?..

anicache08 avatar Oct 17 '17 03:10 anicache08