GithubHelp home page GithubHelp logo

namespace issue about bing_translator-gem HOT 21 CLOSED

relrod avatar relrod commented on August 16, 2024
namespace issue

from bing_translator-gem.

Comments (21)

relrod avatar relrod commented on August 16, 2024

I can't reproduce this on RHEL 6, ruby 1.8.7p352, bing_translator 2.0.0, nokogiri 1.5.5 -- except for the peer certificate warning.

Can you provide any more detail about your environment? What ruby version, what distro/os?

from bing_translator-gem.

crm114 avatar crm114 commented on August 16, 2024

I'm receiving the same error.

ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux] via RVM and Ubuntu 12.04.
nokogiri 1.5.5

from bing_translator-gem.

crm114 avatar crm114 commented on August 16, 2024

Authentication seems to be failing:

irb(main):006:0> t.send(:get_access_token)
=> {"error"=>"invalid_client", "error_description"=>"ACS50012: Authentication failed. \r\nTrace ID: 66446f52-7d09-41c3-b84b-13d741f18366\r\nTimestamp: 2012-07-22 19:09:04Z", "expires_at"=>2012-07-22 19:09:03 +0000}

from bing_translator-gem.

crm114 avatar crm114 commented on August 16, 2024

@vova4kin I was able to resolve my problem by changing the Client secret for the app by going to https://datamarket.azure.com/developer/applications/edit/#{app_name}

from bing_translator-gem.

relrod avatar relrod commented on August 16, 2024

Hm, I've been using the same client secret for a few months and couldn't reproduce this. :(

@crm114 Thanks for looking into this and sending #3.

I'll leave this open to see if changing the client secret works for @vova4kin. If it does/if I don't hear anything, I'll close this out in a few days.

Thanks guys.

from bing_translator-gem.

vova4kin avatar vova4kin commented on August 16, 2024

@crm114 thank you! there was really strange issue with token.
Looks like for new accounts you need to edit token once after automatically assigned

from bing_translator-gem.

adamtao avatar adamtao commented on August 16, 2024

Sorry to bring up an old issue. I'm having the problem: "Undefined namespace prefix: //xmlns:string"

Oddly, it worked great for me one day, then started acting up the next day. I'm using ruby 1.9.3p125, nokogiri 1.5.9. I also tried with nokogiri 1.5.5 since that was mentioned in this thread, but no luck. I tried bing_translator 3.0.0 and also tried pulling the latest from github.

It does seem to pull the @access_token fine. After attempting the translation, if I inspect my "translator" instance, there is an access_token.

I'm not sure what @vova4kin means by editing the token. I tried logging in to Azure and edited my application, but still no luck.

Any ideas what I've missed? Thanks!

from bing_translator-gem.

adamtao avatar adamtao commented on August 16, 2024

Nevermind. It looks like my over-eager testing used up my character quota on the service.

from bing_translator-gem.

relrod avatar relrod commented on August 16, 2024

We should probably handle that case and raise something more informative. I'll look into this.

from bing_translator-gem.

maxdec avatar maxdec commented on August 16, 2024

I'm having this issue from time to time and I still have plenty of remaining characters (like 1M+). The basic example (spanish = translator.translate 'Hello. This will be translated!', :from => 'en', :to => 'es') worked 5 minutes ago and now it doesn't work anymore.

from bing_translator-gem.

relrod avatar relrod commented on August 16, 2024

Really weird, I haven't been able to reproduce this yet. I will keep trying.

from bing_translator-gem.

maxdec avatar maxdec commented on August 16, 2024

I'm using bing_translator 3.2.0 and nokogiri 1.5.9 with Ruby 1.9.3p194 on Ubuntu 12.10. #detect works but #translate returns:

Nokogiri::XML::XPath::SyntaxError: Undefined namespace prefix: //xmlns:string
    from /var/lib/gems/1.9.1/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:159:in `evaluate'
    from /var/lib/gems/1.9.1/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:159:in `block in xpath'
    from /var/lib/gems/1.9.1/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:150:in `map'
    from /var/lib/gems/1.9.1/gems/nokogiri-1.5.9/lib/nokogiri/xml/node.rb:150:in `xpath'
    from /var/lib/gems/1.9.1/gems/bing_translator-3.2.0/lib/bing_translator.rb:45:in `translate'
    from (irb):68
    from /usr/bin/irb:12:in `<main>'

And I just generated a new token as said previously. translator.send(:get_access_token) seems to work fine.

from bing_translator-gem.

maxdec avatar maxdec commented on August 16, 2024

Ok it was a kind of bug on Microsoft/Azure side. I reset my Microsoft account with a now token (again) and now everything seems fine.

I don't know why but I was able to use the online api address (with HTTP auth) but something was wrong with the client_secret and I couldn't get a OAuth token through the API (I had to create my own wrapper around to find out).

New secret and it's working again.

from bing_translator-gem.

hanaguma avatar hanaguma commented on August 16, 2024

Hi, I had the same error returned for certain requests, reproducibly, but not all. Since it occurs when passing the result that comes back from the translation API, I added a line to save the response body, and saw that the reason was "Error 414 - URL too long". This probably means that the amount of text that can be sent in a GET request was exceeded.

That explains why I had the problem intermittently - I was sending text of varying size!

Maybe that was the case for some of you, too, or it was another error that was not passed on by the Ruby gem.
The Ruby gem should really return the actual error instead of a secondary one. Also, I think a POST request can be used for a higher text size limit, but I haven't tried yet.

from bing_translator-gem.

relrod avatar relrod commented on August 16, 2024

@hanaguma Are you able to post one of the failing/long requests?

I think you're right, if we can POST instead, that's better - and you're right about the error. If I can get something that consistently reproduces I'll look into the error thing right away. The POST thing will be slightly more, but not terribly, complex.

from bing_translator-gem.

esad avatar esad commented on August 16, 2024

I'm having this issue too. The response body was:

<html><body><h1>Argument Exception</h1><p>Method: Translate()</p><p>Parameter: from</p><p>Message: 'from' must be a valid language&#xD;
Parameter name: from</p><code></code><p>message id=2241.V2_Rest.Translate.1CA05878</p></body></html>

I was using the sample without a "from" parameter to test autodetection.

from bing_translator-gem.

esad avatar esad commented on August 16, 2024

It seems that there's a disparity between languages supported for autodetection and languages supported for the actual translation in the Bing API.

Following:

translator.detect 'Dobar dan'

will detect the sentence (correctly) to be in croatian, however translating this sentence via

translator.translate 'Dobar dan', :to => :en

will fail with the above response.

from bing_translator-gem.

relrod avatar relrod commented on August 16, 2024

Huh, that's interesting and sounds like a bug upstream. I'll look into making this throw a more reasonable and descriptive exception, though.

from bing_translator-gem.

relrod avatar relrod commented on August 16, 2024

I've released 3.3.0 which makes the exception more descriptive.

from bing_translator-gem.

maxdec avatar maxdec commented on August 16, 2024

Actually Bing Translator can detect (almost?) all the languages but can only translate a few ones.
We can have the full list with translator.supported_language_codes:

["ar", "bg", "ca", "zh-CHS", "zh-CHT", "cs", "da", "nl", "en", "et", "fi", "fr", "de", "el", "ht",
 "he", "hi", "mww", "hu", "id", "it", "ja", "tlh", "tlh-QON", "ko", "lv", "lt", "ms", "no", "fa",
 "pl", "pt", "ro", "ru", "sk", "sl", "es", "sv", "th", "tr", "uk", "ur", "vi"]

:hr (croatian) is none of them. Moreover when I'm translating tweets with only hashtags, Bing detects :eu which is not in the list either.

from bing_translator-gem.

relrod avatar relrod commented on August 16, 2024

Going to close this for now, if it still happens with the 4.2.0 release, feel free to re-open. :)

from bing_translator-gem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.