GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Wrong translate token with multiply words · Issue #73 · lkuza2/java-speech-api

Wrong translate token with multiply words #73

New issue
Copy link
New issue
Copy link
Closed
Closed
Wrong translate token with multiply words#73
Copy link

Description

@saroyama
saroyama
opened on Jan 18, 2016
Issue body actions

Thanks for you job. I try to use GoogleTranslate class, when i use one keyword all works excelent, but if i try to translate two or more words, token is wrong and google return 403 error. Although @helen5106 php version generate correct token with multiply words, for example:
green=764880.885612
green apple=367137.242333 // correct
and java generated tokens:
green=764880.885612
green apple=80012.462896 // wrong

Activity

  1. Skylion007 commented on Jan 18, 2016

    @Skylion007
    Skylion007
    on Jan 18, 2016
    Collaborator
    More actions

    @dean1510 What are your thoughts on this issue? @saroyama Let me know if you can find where exactly the codes are differing (via a debugger or something) it likely has to due with a difference of order of operations between PHP and Java.

    Unfortunately, I did not work too much on the token generation, but if you can find exactly at what line the code begins to differ, that would prove most helpful.

  2. dean1510 commented on Jan 19, 2016

    @dean1510
    dean1510
    on Jan 19, 2016
    Collaborator
    More actions

    Problem isn't related to TK calculation algorithm. You should run it on original string:
    String encoded = URLEncoder.encode(text, "UTF-8"); //Encode
    At this time "green apple" is converted to "green+apple"
    ...
    sb.append(generateToken(encoded));
    TK is calculated on converted string, not original source => You get an error.

    Try use
    sb.append(generateToken(text));
    instead.

  3. Skylion007
    added a commit that references this issue on Jan 19, 2016

    Fixed bug in Google Translate. #73

    cf0752b
  4. Skylion007 commented on Jan 19, 2016

    @Skylion007
    Skylion007
    on Jan 19, 2016
    Collaborator
    More actions

    Thanks for the info. I submitted a bugfix and uploaded the latest binaries.

  5. Skylion007
    closed this as completedon Jan 19, 2016
  6. saroyama commented on Jan 19, 2016

    @saroyama
    saroyama
    on Jan 19, 2016
    Author
    More actions

    @dean1510 I'm doing it exactly as you wrote, and i using original GoogleTranslate class without any changes from my side.
    But first url ok:
    http://translate.google.com/translate_a/single?client=t&hl=en&sl=en&tl=es&text=green&multires=1&otf=0&pc=0&trs=1&ssel=0&tsel=0&sc=1&dt=t&ie=UTF-8&oe=UTF-8&tk=825315.704312
    Second, not:
    http://translate.google.com/translate_a/single?client=t&hl=en&sl=en&tl=es&text=green+apple&multires=1&otf=0&pc=0&trs=1&ssel=0&tsel=0&sc=1&dt=t&ie=UTF-8&oe=UTF-8&tk=514818.127961

  7. Skylion007 commented on Jan 19, 2016

    @Skylion007
    Skylion007
    on Jan 19, 2016
    Collaborator
    More actions

    @saroyama New binaries seem to be working for me. Green Apple is returning manzana verde. Maybe we need to update generateB to use the West Coast locale? I am using it right now and it appears to be working.

  8. dean1510 commented on Jan 19, 2016

    @dean1510
    dean1510
    on Jan 19, 2016
    Collaborator
    More actions

    @saroyama
    ensure you're calling TK exactly on "green apple".
    I've changed "+" in your URL to "%20" but it also returns error.

  9. saroyama commented on Jan 19, 2016

    @saroyama
    saroyama
    on Jan 19, 2016
    Author
    More actions

    @dean1510
    System.out.println(generateURL("en", "es", "green apple"));
    return this url:
    http://translate.google.com/translate_a/single?client=t&hl=en&sl=en&tl=es&text=green+apple&multires=1&otf=0&pc=0&trs=1&ssel=0&tsel=0&sc=1&dt=t&ie=UTF-8&oe=UTF-8&tk=514818.127961
    and it return 403 error

  10. saroyama commented on Jan 19, 2016

    @saroyama
    saroyama
    on Jan 19, 2016
    Author
    More actions

    @dean1510 Sorry, i get new class, now all works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.