guptahanu / google-ajax-apis

Automatically exported from code.google.com/p/google-ajax-apis
0 stars 1 forks source link

When passing multiple q values to Translate API v2, the returned translations array is not always in the correct order #578

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Run a translation request through Translate API v2 with multiple q values

What is the expected output? What do you see instead?
If the query string is, for example, 
...&q=hello,%20world&q=How%20are%20you%20today%3F&q=What%20is%20going%20on%3F...

The response should be:

{{{
handleResponse({
 "data": {
  "translations": [
   {
    "translatedText": "hallo, Welt"
   },
   {
    "translatedText": "Wie geht es Ihnen heute?"
   },
   {
    "translatedText": "Was ist los?"
   }
  ]
 }
}
);
}}}
Instead, I get the translations in various orders. E.g.:

{{{
handleResponse({
 "data": {
  "translations": [
   {
    "translatedText": "hallo, Welt"
   },
   {
    "translatedText": "Was ist los?"
   },
   {
    "translatedText": "Wie geht es Ihnen heute?"
   }
  ]
 }
}
);
}}}

What version of the product are you using? On what operating system?

Translate API v2 on OSX, via Google Chrome and Perl.

Please provide any additional information below.

This is problematic because there's no way to reliably match the translation 
back to the original string as it is now. A couple of options come to mind, in 
order of preferability (as I see it):

  # Make sure that multiple translations are returned in the order that they are received in the query string.
  # Return the original string as an additional property of the translation object, as below:

{{{
{
 "translatedText": "Was ist los?",
 "originalText": "What is going on?"
}
}}}

Original issue reported on code.google.com by jrgeer...@gmail.com on 14 Apr 2011 at 4:25

GoogleCodeExporter commented 8 years ago
Well, I thought for sure that this would recognize the wiki markup. Oh well.

Original comment by jrgeer...@gmail.com on 14 Apr 2011 at 4:25

GoogleCodeExporter commented 8 years ago
Hope it will be fixed soon, cause it's very important in my application :(

Original comment by misterbirra.g on 20 Apr 2011 at 8:05

GoogleCodeExporter commented 8 years ago
I just discovered this myself, but the strange thing is that, at least in my 
case, it only seems to mess up on the first call. After that it returns the 
results in the correct order. Also, it seems the larger the amount of text I 
send the more likely it will return results in the correct order. Strange.

Original comment by craig.wa...@gmail.com on 29 Apr 2011 at 7:03

GoogleCodeExporter commented 8 years ago
This is an anything but beautiful workaround: Put your index + dot + space 
before the text and extract the correct index from the result. It seems that 
the number is ignored during translation.

Apfel -> 1. Apfel 
Birne -> 2. Birne
etc.

Original comment by dominik....@googlemail.com on 1 May 2011 at 11:24

GoogleCodeExporter commented 8 years ago
This should now be fixed.  Please let us know if you continue to see problems.

Original comment by adam.fel...@gtempaccount.com on 10 May 2011 at 2:53