vikassharma27 / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

execute X lines from X languages to Y languages #76

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Regarding this method:

public static String[] execute(final String[] text, final Language from[],
final Language[] to) throws Exception

at 

http://code.google.com/p/google-api-translate-java/source/browse/trunk/src/com/g
oogle/api/translate/Translate.java#126

The method requires that the same number of texts, inputs, and outputs are
supplied. To me, the method should be able to accept:

execute("Hello", Language.ENGLISH, Language[] {Language.SPANISH,
Language.FRENCH, Language.GERMAN})

which would return three responses.

OR

execute(new String(){} {"Hello", "Goodbye"}, Language.ENGLISH, Language[]
{Language.SPANISH})

which would return 2 responses.

I only checked the source code. I have not run this. I may be wrong. Thanks.

Original issue reported on code.google.com by mikenere...@gmail.com on 30 Oct 2009 at 1:47

GoogleCodeExporter commented 8 years ago
Thanks Mike, I think the use case you mention should be covered by this method, 
which 
should also exist:

public static String[] execute(final String text, final Language from, final 
Language[] to) throws Exception;

http://code.google.com/p/google-api-translate-
java/source/browse/trunk/src/com/google/api/translate/Translate.java#106

Marking as done for now. Thanks.

Original comment by rich.mid...@gmail.com on 2 Nov 2009 at 9:00

GoogleCodeExporter commented 8 years ago
public static String[] execute(final String text, final Language from, final 
Language[] to) throws Exception;

would handle the first use case

execute("Hello", Language.ENGLISH, Language[] {Language.SPANISH,
Language.FRENCH, Language.GERMAN})

But I don't see a method that would handle the second use case

execute(new String(){} {"Hello", "Goodbye"}, Language.ENGLISH, Language[]
{Language.SPANISH})

I'm not saying the API should necessarily support the second use case, I just 
wanted 
to point out that it doesn't. And if I were to update to the trunk version I 
would 
need to write support for that method myself because I prefer to use the one 
call 
over many calls.

Thanks Rich.

Original comment by mikenere...@gmail.com on 2 Nov 2009 at 9:38

GoogleCodeExporter commented 8 years ago
Ah, sorry, I missed the second one somehow!

I agree that API call is missing. I'll have a think about it, I'm not sure I'll 
add 
it at the moment as the returned Array of Strings wouldn't necessarily be in an 
intuitive order if more than one target Language is supplied. Should still be 
possible to make one API call using the one which takes an Array for each 
parameter.

I've been trying to avoid returning a more complex object than a String[], at 
least 
without more thought than I've yet given it, but perhaps this is another case 
for 
that. Thanks.

Original comment by rich.mid...@gmail.com on 2 Nov 2009 at 10:22

GoogleCodeExporter commented 8 years ago
I like that they all return String[]. You could return String[]{Phrase1Lang1,
Phrase1Lang2, Phrase2Lang1, Phrase2Lang2, etc}

Original comment by mikenere...@gmail.com on 2 Nov 2009 at 10:32