My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
ExampleUsage  
A quick example application knocked up in Netbeans which demonstrates usage of the API.
Updated Jul 31, 2009 by rich.mid...@gmail.com

Translator source

This has now been incorporated into the library and is run as the main class. You can view the latest source code here.

Details

This code took barely two minutes to knock up in Netbeans 6 and demonstrates the API usage in a realistic environment. Although it's a simple example, it's pratical enough to realistically use.

Requires JDK 1.6.

Comment by mmr...@gmail.com, Mar 6, 2008

Hi Rich, Thanks for this API. I will use it in Merlin project, at http://merlin.dev.java.net -- mmrack@gmail.com

Comment by gentydjo...@hotmail.com, May 6, 2008

Helo Rich, II would like to thank you for you exemple..it is very interesting and elp me to much..sorry for english.

Comment by selvan....@gmail.com, May 8, 2008

It shows the following error, whats the issues

java.lang.Exception: [google-api-translate-java] Error retrieving translation.

at com.google.api.translate.Translate.retrieveTranslation(Translate.java:144) at com.google.api.translate.Translate.translate(Translate.java:107) at Main.main(Main.java:8)
Caused by: java.net.ConnectException?: Connection timed out: connect
at sun.reflect.NativeConstructorAccessorImpl?.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl?.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl?.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source) at java.security.AccessController?.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at com.google.api.translate.Translate.retrieveTranslation(Translate.java:140) ... 2 more
Caused by: java.net.ConnectException?: Connection timed out: connect
at java.net.PlainSocketImpl?.socketConnect(Native Method) at java.net.PlainSocketImpl?.doConnect(Unknown Source) at java.net.PlainSocketImpl?.connectToAddress(Unknown Source) at java.net.PlainSocketImpl?.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient?.doConnect(Unknown Source) at sun.net.www.http.HttpClient?.openServer(Unknown Source) at sun.net.www.http.HttpClient?.openServer(Unknown Source) at sun.net.www.http.HttpClient?.<init>(Unknown Source) at sun.net.www.http.HttpClient?.New(Unknown Source) at sun.net.www.http.HttpClient?.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at com.google.api.translate.Translate.retrieveTranslation(Translate.java:132) ... 2 more

Comment by project member rich.mid...@gmail.com, May 11, 2008

That looks like your connection is being blocked, possibly by a firewall or maybe you use a proxy that you're not configured with.

Comment by qianha...@gmail.com, Jun 7, 2008

Why did I can not translate Chinese to English use it??? 我把这个程序改了下,为什么不能把中文翻译成英文啊?其他的都可以

Comment by vazdauta...@gmail.com, Sep 27, 2008

Hello.I tryed this and it is really good.But i have a problem. When i am entring large texts,it show me errors.yes,i can to divide text in some smaller parts and then, to translate it. but i thank, maybe is any other method?

Comment by haixu.hu...@gmail.com, Jan 3, 2009

I've transformed the Language.java into the Java 5 Enum style like this:

/**
 * Language.java Copyright (C) 2007, Richard Midwinter This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will
 * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General
 * Public License along with this program. if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite
 * 330, Boston, MA 02111-1307, USA.
 */
package com.google.api.translate;

/**
 * Defines language information for the Google Translate API.
 * 
 * @author Richard Midwinter
 */

public enum Language
{
    ARABIC("ar", "العربية"), BULGARIAN("bg"), CATALAN("ca"), CHINESE("zh", "中文"), CHINESE_SIMPLIFIED("zh-CN", "简体中文"),
    CHINESE_TRADITIONAL("zh-TW", "正體中文"), CROATIAN("hr"), CZECH("cs"), DANISH("da"), DUTCH("nl"), ENGLISH("en", "English"),
    FILIPINO("tl"), FINNISH("fi"), FRENCH("fr", "Français"), GERMAN("de", "Deutsch"), GREEK("el", "Ελληνικά"), HEBREW("iw", "עברית"), HINDI("hi"),
    INDONESIAN("id"), ITALIAN("it", "Italiano"), JAPANESE("ja", "日本語"), KOREAN("ko", "한국어"), LATVIAN("lv"), LITHUANIAN("lt"), NORWEGIAN("no"),
    POLISH("pl"), PORTUGESE("pt"), ROMANIAN("ro"), RUSSIAN("ru"), SERBIAN("sr"), SLOVAK("sk"), SLOVENIAN("sl"),
    SPANISH("es"), SWEDISH("sv"), UKRANIAN("uk"), VIETNAMESE("vi", "Việt");

    Language(String language)
    {
        this(language, "");
    }

    Language(String language, String alias)
    {
        this.lang = language;
        this.alias = alias;
    }
    public static Language validate(String language)
    {
        for (Language item : Language.values())
            if (item.lang.equalsIgnoreCase(language))
                return item;
        return null;
    }

    /**
     * Checks a given language is available to use with Google Translate.
     * 
     * @param language The language code to check for.
     * @return true if this language is available to use with Google Translate, false otherwise.
     */
    public static boolean isValidLanguage(String language)
    {
        return (validate(language) != null);
    }

    /**
     * Return the global name of Language
     * @return the global name of Language
     */
    @Override
    public String toString() {
        return lang;
    }
    
    public String getAlias() {
        return alias.equals("") ?
                name().toUpperCase().charAt(0)
                + name().toLowerCase().substring(1)
                : alias;
    }
    private String lang, alias;
}

and then, the Language enum can use freely on iterator or anything like that.

Comment by senior.w...@gmail.com, Feb 2, 2009

Thanks for this!

Comment by vmoha...@gmail.com, Feb 5, 2009

I tried Engligh to french for "north station" and I get "gare du nord" which is correct. But when I changed the option to french to english and entered the text "gare du nord" I get Nordbahnhof - which sounds german for north station.

has anyone else experienced this?

Comment by isai...@gmail.com, Feb 6, 2009

I need traduce the very big text with a html contents.

But i receive a IOException... The api acess one Url .. but this url returns a 404 code.

The String of my content its totally aded a url of a get method, this method have a limit of character..

If i access the google language pages, the content is traduced correctly.

See:

<a onblur='try {parent.deselectBloggerImageGracefully();} catch(e) {}' href='http://2.bp.blogspot.com/_5ss_oa9GP7A/SYwbQMsLAKI/AAAAAAAAA_I/IjYJ9BpvZVk/s1600-h/images.jpg'><img style='float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 106px; height: 79px;' src='http://2.bp.blogspot.com/_5ss_oa9GP7A/SYwbQMsLAKI/AAAAAAAAA_I/IjYJ9BpvZVk/s320/images.jpg' border='0' alt=''id='BLOGGER_PHOTO_ID_5299640826606583970' /></a><br />Brenner, Pareci, Guarani e Picanha seguem no Bolamar<br /><br />O Bolamar, futebol praiano disputado na beira da praia de Tramandaí, teve mais uma rodada empolgante no último final de semana. Foram jogos decisivos, que apontaram os 16 classificados para as oitavas-de-final. Entre as 22 equipes inscritas na categoria principal, haviam cinco do Vale do Caí e apenas uma não passou para a próxima fase. O ABC/RM Refrigeração/Atacado Ledur/De Cristal Floricultura, mesmo tendo realizado mais um jogo equilibrado, foi derrotado pela Prefeitura de Gravataí. Foi a terceira derrota e a consequente eliminação da competição.<br /><br />Já o outro time caiense, do Guarani, que tem como base o antigo CMD Caí, tinha uma tarefa muito difícil. Também com duas derrotas e numa posição ainda pior do que o ABC, teve pela frente a forte equipe do Palmeiras, vice-campeão de 2008 e que vinha de duas vitórias. Os caienses fizeram um ótimo primeiro tempo e chegaram a abrir uma vantagem de 4 a 0, mas depois o Palmeiras reagiu e marcou três gols. A vitória por 4 a 3 garantiu o time do técnico Clóvis Duarte na 16ª colocação, classificando-se pelo critério de disciplina.<br /><br />No próximo sábado, dia 7, às 9h30min, o Guarani enfrenta o Bandeirantes, de Canoas, que foi o primeiro colocado na fase classificatória.<br /><br />O CMD Pareci Novo, que havia obtido duas vitórias, desta vez foi derrotado pelo campeão do ano passado, o Bortolini Móveis, de Garibaldi, por 2 a 0. Mesmo com a derrota, o time do técnico Choco fez uma boa campanha na primeira fase, o que lhe garantiu o quarto lugar. O próximo adversário, ao meio-dia de sábado, será o Vila Branca, de Gravataí.<br /><br />Os dois times de Montenegro se classificaram e vão se enfrentar na próxima fase. O Picanha na Chapa/Flytour perdeu de 5 a 4 para o Aliança, de Encruzilhada. Pela combinação de resultados, inclusive auxiliado pela vitória da Brenner Ford/BV Financeira/Nova Geração, o Picanha, do técnico Julinho, classificou-se na 15ª colocação. Já a Brenner, campeã de 2007, fez a melhor campanha da região, ficando em segundo lugar com três vitórias. A equipe do técnico Fábio Gallas chegou a estar perdendo por 2 a 0, mas conseguiu mais uma virada espetacular em 4 a 3. No próximo sábado, o clássico montenegrino entre Brenner e Picanha na Chapa acontece às 10h20min da manhã, com transmissão ao vivo da Rádio América.<br /><br />Na categoria sênior, os montenegrinos da equipe Lojas Sensação/Esquadrias Ávila/Locadora Anderson, que vinha de duas vitórias, foi goleado em 9 a 1 pelo Sete de Setembro, de Lajeado.<br /><br />Mesmo assim, garantiu classificação para as semifinais, onde no próximo domingo, às 11h15min, enfrenta a Associação Schimidt, de Gravataí. E no próximo final de semana também iniciam os jogos da Série Prata do Bolamar, com a participação de equipes da região nas categorias mirim, infantil e juvenil.<br /><br /><br /><br />FONTE: guilherme.baptista@fatonovo.com

Comment by isai...@gmail.com, Feb 6, 2009

to resolve it.. use part of text ant Traduce in 1500 at next 1500 chars.

NOT its a best solution.. but.. temporally its resolve the problem.

See:

//when desc is a string with the all contents

try {

String printStr = ""; StringBuffer? completeString = new StringBuffer?();
int total = 0;
while ( total <= desc.length() ) {
try {
printStr = desc.substring(total,(total+1500)); completeString.append(Translate.translate( printStr, Language.PORTUGESE, Language.ENGLISH));
} catch (Exception e) {
// apropriate tratament
} total = total + 1500;
} try {
printStr = desc.substring((total-1500),(desc.length()-1)); completeString.append(Translate.translate( printStr, Language.PORTUGESE, Language.ENGLISH));
} catch (Exception e) {
// apropriate tratament
}
out.print(completeString.toString());
} catch (Exception exclang) {
exclang.printStackTrace(); out.print("Erro para traduzir." + exclang.getMessage());
}

Thanks my friend..

Comment by mikenere...@gmail.com, Apr 3, 2009

Well done. Thanks.

Comment by thirdy.d...@gmail.com, May 4, 2009

so easy to use! I'm using it in my simple tool, http://code.google.com/p/warriorpig/ thanks!

Comment by vempatis...@gmail.com, May 29, 2009

HI,

I want to translate English to Telugu. Can you please help me out how to do this ? On the website http://code.google.com/apis/ajaxlanguage/documentation/ under supported language Telugu is mentioned but in the code which is available on this site i could not find that option. Please help me.

~Siva~

Comment by rasa.sti...@gmail.com, May 30, 2009

I wrote a simple program to translate an english word to hindi. But it is giving some exception. I am pasting the code and exception please guid me to find the solution. Code:

import com.google.api.translate.Language; import com.google.api.translate.Translate;

public class TestTranslator? {

/
  • @param args
public static void main(String args) {
// TODO Auto-generated method stub try {
String translatedText = Translate.translate("How are you?",
Language.ENGLISH, Language.HINDI);

System.out.println(translatedText); } catch (Exception ex) { ex.printStackTrace(); } }

}

Exception while execution

java.lang.Exception: [google-api-translate-java] Error retrieving translation.

at com.google.api.translate.Translate.retrieveTranslation(Translate.java:92) at com.google.api.translate.Translate.translate(Translate.java:59) at TestTranslator?.main(TestTranslator?.java:12)
Caused by: java.net.UnknownHostException?: ajax.googleapis.com
at sun.reflect.NativeConstructorAccessorImpl?.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl?.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl?.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source) at java.security.AccessController?.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at com.google.api.translate.Translate.retrieveTranslation(Translate.java:88) ... 2 more
Caused by: java.net.UnknownHostException?: ajax.googleapis.com
at java.net.PlainSocketImpl?.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at sun.net.NetworkClient?.doConnect(Unknown Source) at sun.net.www.http.HttpClient?.openServer(Unknown Source) at sun.net.www.http.HttpClient?.openServer(Unknown Source) at sun.net.www.http.HttpClient?.<init>(Unknown Source) at sun.net.www.http.HttpClient?.New(Unknown Source) at sun.net.www.http.HttpClient?.New(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at com.google.api.translate.Translate.retrieveTranslation(Translate.java:82) ... 2 more

Comment by jashawn.peng, Jun 23, 2009

Hello, Rich, I just have a requirement of transliteration, I have no idea this moment, do you have any suggestions?

Comment by cw010...@gmail.com, Jun 28, 2009

When I try to substitute a string for Language.FRENCH in my code as in your example code (see below):

String fromLang="Language.French"; String translatedText = Translate.translate("Bonjour le monde", fromLang, Language.ENGLISH);

I get the error message:

translate(java.lang.String,com.google.api.translate.Language,com.google.api.translate.Language) in com.google.api.translate.Translate cannot be applied to (java.lang.String,java.lang.String,com.google.api.translate.Language)

How can I correct this?

Comment by txema.be...@gmail.com, Jul 18, 2009

I want to detect the language of a text using Java... Can I use this API for it??...

other solutions??

Thanks!!

Comment by dhanyanv...@gmail.com, Sep 28, 2009

Is this code be used online only?

Comment by OGameAut...@gmail.com, Oct 24, 2009

Please, can you add a new constructor to Language class and support java.util.Local Because we can get the current language with this : Locale language = new Locale(Locale.getDefault().getLanguage()); And translate automatically from English to 'language', in will be very useful ;)

Thanks in advance

Comment by alexcapu...@gmail.com, Nov 3, 2009

hi,

Brilliant API thanks.

Quick question, can this api be used as part of an app which is sold? For example, could someone make an iphone app or android app (what ever) which uses this api as part of its services and actually sell the app?

thanks

Comment by paulo.si...@gmail.com, Nov 18, 2009

Can I use de voice feature with this API?

Comment by mailtos...@gmail.com, Dec 2, 2009

Hi can i use this api for transliteration?

Comment by xeus....@gmail.com, Dec 11, 2009

cool api.. i used it in TranslateBlip? Google wave robot.. http://translateblip.appspot.com

Comment by fengying...@gmail.com, Mar 22, 2010

i have the same question about detection

Comment by mukandag...@gmail.com, Apr 17, 2010

I wanted not only the translated text but also the whole dictionary of words which is showed when i use google translate webpage. How can i do this . Tell me anyway either through java or web ????????

Comment by vipin.al...@gmail.com, Sep 1, 2010

Hi Everyone, I used this api for translating my records from English to Hindi and then displayed those Hindi Texts on the Swing Components. But the problem is when i try to navigate from one page to another then the JVM crashes and produce an error log. Can anyone tell me why this happens with Hindi Fonts as it is running perfectly With English Fonts.

Thanks

Comment by mayankm...@gmail.com, Nov 15, 2010

Hi,

I want to translate English to Tamil. Can you please guide me out how to do this? It's there in supported languages, but using API I am not able to convert English to Tamil. Also which are other Indian languages support by Google API except Hindi?.

- Mayank

Comment by Mahesh.K...@gmail.com, Dec 11, 2010

hi mahesh

Comment by pna1...@gmail.com, Dec 15, 2010

Hi,

I want to translate English to Tamil. Can you please guide me out how to do this? It's there in supported languages, but using API I am not able to convert English to Tamil. Also which are other Indian languages support by Google API except Hindi?.

- Nithyanandam

Comment by qinyujue, Mar 1, 2011

Hi,I am wondering if this api could help me with a large amounts of data.I'm trying to use it to translate about 150000 words in my excel table.But after translating about 1000 words . An exception stops the program says:Google returned the following error: 403? Suspected Terms of Service Abuse. Please see http://code.google.com/apis/errors are there any methods to solve the problem?

Comment by vasanth....@gmail.com, Mar 10, 2011

do anybody have an idea how can I overcome the following error, many have posted it, but anyone solved it? if yes,how?

java.lang.Exception: [google-api-translate-java] Error retrieving translation.

Comment by gummadi....@gmail.com, Mar 15, 2011

i got this error please tell me i added the json-20090211.jar,google-api-translate-java-0.95.jar and i used the Main class as it but it is giving the following error can some body post me what is wrong thanks in advance Exception in thread "main" java.lang.Exception: [google-api-translate-java] Error retrieving translation.

at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:131) at com.google.api.translate.Translate.execute(Translate.java:69) at internationlization.Main.main(Main.java:20)
Caused by: java.net.ConnectException?: Connection timed out
at java.net.PlainSocketImpl?.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl?.doConnect(AbstractPlainSocketImpl?.java:327) at java.net.AbstractPlainSocketImpl?.connectToAddress(AbstractPlainSocketImpl?.java:193) at java.net.AbstractPlainSocketImpl?.connect(AbstractPlainSocketImpl?.java:180) at java.net.SocksSocketImpl?.connect(SocksSocketImpl?.java:384) at java.net.Socket.connect(Socket.java:546) at java.net.Socket.connect(Socket.java:495) at sun.net.NetworkClient?.doConnect(NetworkClient?.java:178) at sun.net.www.http.HttpClient?.openServer(HttpClient?.java:409) at sun.net.www.http.HttpClient?.openServer(HttpClient?.java:530) at sun.net.www.http.HttpClient?.<init>(HttpClient?.java:240) at sun.net.www.http.HttpClient?.New(HttpClient?.java:321) at sun.net.www.http.HttpClient?.New(HttpClient?.java:338) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:935) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:876) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:801) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:979) at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:115) ... 2 more
Java Result: 1 BUILD SUCCESSFUL (total time: 22 seconds)

Comment by shakd...@gmail.com, Mar 19, 2011

Hi. Thanks. I am using your API to make application for android smartphone. But I wonder if I could get a polysemous word mean. I want to use your API like dictionary, but I alway can see a only one mean. for example, If I find 'take' means to Korean, It show only one mean. How can I get various means?

Comment by Vishal.p...@gmail.com, Mar 21, 2011

hi please tell me that how the translation was happened?

can you give me code of English to marathi or hindi translator in java.......

Comment by vasanth....@gmail.com, Mar 23, 2011

java.lang.Exception: google-api-translate-java? Error retrieving translation.

The above error is because of firewall....install firewal client and u can go ahead.

Thank u

Comment by adnan1...@gmail.com, Apr 24, 2011

I have a Question that can I use a Google Translator API for my desktop application? Second questoin is that can I use Google Translator API without accessig the Internet?

Comment by IT.fat....@gmail.com, May 1, 2011

Hi, I don't know why I can't get the program to run properly when I've initialized a TranslatorFrame? object. This is my program:

import com.google.api.translate.TranslatorFrame?; import com.google.api.translate.Language.; public class Main {

/
  • @param args the command line arguments
public static void main(String args) throws Exception {
// TODO code application logic here TranslatorFrame? tfr = new TranslatorFrame?(); tfr.setVisible(true);
}

}

And when I run the program, a frame doesn't appear as it's supposed to. This is the output when I ran it with NetBeans? 6.9:

Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) Could not load class (org.apache.tools.ant.taskdefs.repository.MavenRepository?) for type mavenrepository Could not load a dependent class (jdepend/xmlui/JDepend) for type jdepend Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.Ejbc) for type ejbc Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.WLStop) for type wlstop Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.WLRun) for type wlrun Could not load a dependent class (javax/media/jai/PlanarImage?) for type image Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.DDCreator) for type ddcreator Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckin?) for type stcheckin Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckout?) for type stcheckout Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamLabel?) for type stlabel Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamList?) for type stlist Could not load class (org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut?) for type starteam Could not load class (org.apache.tools.ant.taskdefs.repository.MavenRepository?) for type mavenrepository Could not load a dependent class (jdepend/xmlui/JDepend) for type jdepend Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.Ejbc) for type ejbc Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.WLStop) for type wlstop Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.WLRun) for type wlrun Could not load a dependent class (javax/media/jai/PlanarImage?) for type image Could not load class (org.apache.tools.ant.taskdefs.optional.ejb.DDCreator) for type ddcreator Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckin?) for type stcheckin Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamCheckout?) for type stcheckout Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamLabel?) for type stlabel Could not load class (org.apache.tools.ant.taskdefs.optional.starteam.StarTeamList?) for type stlist Could not load class (org.apache.tools.ant.taskdefs.optional.scm.AntStarTeamCheckOut?) for type starteam

I don't know where I went wrong. Any suggestions and guidance would be greatly appreciated. Thanks!

Comment by mhd.fa...@gmail.com, Jun 14, 2011

how to handle special character worlds such as étudiant, université ?? there translation ends up with an error??

Comment by weyo...@gmail.com, Sep 7, 2011

how do i use the api in j2me project

Comment by surendra...@gmail.com, Sep 7, 2011

i want to translate from english to telugu in my desktop application.So please help me how to do that.

Comment by harish.a...@gmail.com, Nov 5, 2011

I'm getting the following error with .97 version. Any suggestion:

11-05 22:25:18.344: W/System.err(13846): com.google.api.GoogleAPIException: java.lang.Exception: [google-api-translate-java] Error retrieving translation. 11-05 22:25:18.348: W/System.err(13846): at com.google.api.translate.TranslateV2?.execute(TranslateV2?.java:68) 11-05 22:25:18.352: W/System.err(13846): at app.ramesp.letus.util.SpeakUtil?$5.doInBackground(SpeakUtil?.java:325) 11-05 22:25:18.356: W/System.err(13846): at app.ramesp.letus.util.SpeakUtil?$5.doInBackground(SpeakUtil?.java:1) 11-05 22:25:18.384: W/System.err(13846): at android.os.AsyncTask?$2.call(AsyncTask?.java:185) 11-05 22:25:18.384: W/System.err(13846): at java.util.concurrent.FutureTask?$Sync.innerRun(FutureTask?.java:306) 11-05 22:25:18.384: W/System.err(13846): at java.util.concurrent.FutureTask?.run(FutureTask?.java:138) 11-05 22:25:18.384: W/System.err(13846): at java.util.concurrent.ThreadPoolExecutor?.runWorker(ThreadPoolExecutor?.java:1088) 11-05 22:25:18.388: W/System.err(13846): at java.util.concurrent.ThreadPoolExecutor?$Worker.run(ThreadPoolExecutor?.java:581) 11-05 22:25:18.388: W/System.err(13846): at java.lang.Thread.run(Thread.java:1019) 11-05 22:25:18.388: W/System.err(13846): Caused by: java.lang.Exception: [google-api-translate-java] Error retrieving translation. 11-05 22:25:18.392: W/System.err(13846): at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:99) 11-05 22:25:18.392: W/System.err(13846): at com.google.api.translate.TranslateV2?.execute(TranslateV2?.java:62) 11-05 22:25:18.392: W/System.err(13846): ... 8 more 11-05 22:25:18.392: W/System.err(13846): Caused by: java.io.FileNotFoundException?: https://www.googleapis.com/language/translate/v2?key=MY_KEY=Bonjour+le+monde&target=en&source=fr 11-05 22:25:18.412: W/System.err(13846): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:521) 11-05 22:25:18.412: W/System.err(13846): at org.apache.harmony.luni.internal.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:258) 11-05 22:25:18.416: W/System.err(13846): at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93) 11-05 22:25:18.416: W/System.err(13846): ... 9 more

Comment by harish.a...@gmail.com, Nov 5, 2011

I get the error during call to "final JSONObject json = retrieveJSON(url);"

I might be missing something basic here.

Comment by kong...@gmail.com, Dec 10, 2011

Version 0.95 used to work like a charm for language detection, but we now upgraded to 0.97 in order to use the billed Google API with our key. Now we only get errors:

org.json.JSONException: JSONObject["responseData"] is not a JSONObject.

The code is:

Detect.setHttpReferrer("http://www.feedfabrik.com");
Detect.setKey(apiKey);
DetectResult dr = Detect.execute(text);
Locale locale = new Locale(dr.getLanguage().toString());

What am I missing here?

Comment by claudio....@techedgegroup.com, Jan 18, 2012

HI i've got this error in the log....?!?!?

org.json.JSONException: JSONObject["responseData"] is not a JSONArray.

at org.json.JSONObject.getJSONArray(JSONObject.java:503) at com.google.api.translate.Translate.execute(Translate.java:170) at com.google.api.translate.Translate.execute(Translate.java:125) at com.pirelli.stickeradmin.StickerAdminManager?.localizeName(StickerAdminManager?.java:190) at com.pirelli.stickeradmin.StickerAdminManager?.saveSticker(StickerAdminManager?.java:156) at sun.reflect.NativeMethodAccessorImpl?.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl?.invoke(NativeMethodAccessorImpl?.java:39) at sun.reflect.DelegatingMethodAccessorImpl?.invoke(DelegatingMethodAccessorImpl?.java:25)

What is this???

Comment by ashnajai...@gmail.com, Apr 21, 2012

I am using the code for a java application but I'm getting this : Error: [google-api-translate-java] Error retrieving translation. Exception in thread "main" com.google.api.GoogleAPIException: java.lang.Exception: [google-api-translate-java] Error retrieving translation.

at com.google.api.translate.TranslateV2?.execute(TranslateV2?.java:68) at translater.Translater.main(Translater.java:39)
Caused by: java.lang.Exception: [google-api-translate-java] Error retrieving translation.
at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:99) at com.google.api.translate.TranslateV2?.execute(TranslateV2?.java:62) ... 1 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.googleapis.com/language/translate/v2?key=AIzaSyB0E91O1PDQBVB1C75GCjNm1CR9c32SKIE&q=Bonjour+le+monde&target=en&source=fr
at sun.reflect.NativeConstructorAccessorImpl?.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl?.newInstance(NativeConstructorAccessorImpl?.java:39) at sun.reflect.DelegatingConstructorAccessorImpl?.newInstance(DelegatingConstructorAccessorImpl?.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491) at java.security.AccessController?.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234) at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93) ... 2 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.googleapis.com/language/translate/v2?key=AIzaSyB0E91O1PDQBVB1C75GCjNm1CR9c32SKIE&q=Bonjour+le+monde&target=en&source=fr
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234) at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:89) ... 2 more
Java Result: 1

Can you please help me with this?

Comment by vickycha...@gmail.com, May 23, 2013

How to run this code please write with an Main function i m not able to understand the concept,It will be very helpful to me.

Comment by mfc4...@gmail.com, May 23, 2013

book

Comment by bhushanb...@gmail.com, Jul 26, 2013

I see below error happening because of Proxy or FireWall? Bloack .. Can any body aware of how to remove this error by setting proxy . Please let me know code to handle proxy too . Please

I am using the code for a java application but I'm getting this : Error: [google-api-translate-java] Error retrieving translation. Exception in thread "main" com.google.api.GoogleAPIException: java.lang.Exception: [google-api-translate-java] Error retrieving translation.

at com.google.api.translate.TranslateV2??.execute(TranslateV2??.java:68) at translater.Translater.main(Translater.java:39)

Caused by: java.lang.Exception: [google-api-translate-java] Error retrieving translation.

at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:99) at com.google.api.translate.TranslateV2??.execute(TranslateV2??.java:62) ... 1 more

Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.googleapis.com/language/translate/v2?key=AIzaSyB0E91O1PDQBVB1C75GCjNm1CR9c32SKIE&q=Bonjour+le+monde&target=en&source=fr

at sun.reflect.NativeConstructorAccessorImpl??.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl??.newInstance(NativeConstructorAccessorImpl??.java:39) at sun.reflect.DelegatingConstructorAccessorImpl??.newInstance(DelegatingConstructorAccessorImpl??.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491) at java.security.AccessController??.doPrivileged(Native Method) at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234) at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:93) ... 2 more

Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://www.googleapis.com/language/translate/v2?key=AIzaSyB0E91O1PDQBVB1C75GCjNm1CR9c32SKIE&q=Bonjour+le+monde&target=en&source=fr

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234) at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:89) ... 2 more

Java Result: 1

Can you please help me with this?

Comment by satyucev...@gmail.com, Jan 22, 2014

i need a java code for translating the Msword document from tamil to english language.can anyone help me out there?


Sign in to add a comment
Powered by Google Project Hosting