com.google.api.GoogleAPI Java Examples
The following examples show how to use
com.google.api.GoogleAPI.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MachineTranslationPreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 访问goolge api以验证 Key是否可用。 ; */ private void googleValidator() { final String googleKey = googleKeyText.getText(); BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { public void run() { // TODO Auto-generated method stub if (googleKey != null && !googleKey.trim().equals("")) { GoogleAPI.setHttpReferrer("http://www.heartsome.net"); GoogleAPI.setKey(googleKey); try { String result = Translate.DEFAULT.execute("test", GoogleTransUtils.processLanguage("en-US"), GoogleTransUtils.processLanguage("zh-CN")); if (result.equals("测试")) { googleState = true; } } catch (GoogleAPIException e) { googleState = false; } } else { googleState = false; } } }); }
Example #2
Source File: GooglePreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * 访问api以验证 Key是否可用。 ; */ private void validator() { final String googleKey = googleKeyText.getText(); BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { public void run() { // TODO Auto-generated method stub if (googleKey != null && !googleKey.trim().equals("")) { GoogleAPI.setHttpReferrer("http://www.heartsome.net"); GoogleAPI.setKey(googleKey); try { String result = Translate.DEFAULT.execute("test", GoogleTransUtils.processLanguage("en-US"), GoogleTransUtils.processLanguage("zh-CN")); if (result.equals("测试")) { state = true; } } catch (GoogleAPIException e) { state = false; } } else { state = false; } } }); }
Example #3
Source File: GooglePreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 访问api以验证 Key是否可用。 ; */ private void validator() { final String googleKey = googleKeyText.getText(); BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() { public void run() { // TODO Auto-generated method stub if (googleKey != null && !googleKey.trim().equals("")) { GoogleAPI.setHttpReferrer("http://www.heartsome.net"); GoogleAPI.setKey(googleKey); try { String result = Translate.DEFAULT.execute("test", GoogleTransUtils.processLanguage("en-US"), GoogleTransUtils.processLanguage("zh-CN")); if (result.equals("测试")) { state = true; } } catch (GoogleAPIException e) { state = false; } } else { state = false; } } }); }
Example #4
Source File: GoogleTranslateBox.java From wandora with GNU General Public License v3.0 | 5 votes |
public static String translate(String text, Language sourceLang, Language targetLang, boolean markTranslation) { String translatedText = null; if(text != null && sourceLang != null && targetLang != null) { try { System.out.println("Google Translating '"+text+"' from '"+sourceLang+"' to '"+targetLang+"'"); GoogleAPI.setHttpReferrer("http://wandora.org"); if(apikey == null || apikey.length() == 0) { apikey = WandoraOptionPane.showInputDialog(Wandora.getWandora(), "Give your Google Translate API key?", "", "Give your Google Translate API key?"); if(apikey != null) apikey = apikey.trim(); } if(apikey != null) { GoogleAPI.setKey(apikey); translatedText = Translate.DEFAULT.execute(text, sourceLang, targetLang); if(translatedText != null && translatedText.length() == 0) { translatedText = null; } if(translatedText != null && markTranslation) { translatedText += " [GOOGLE TRANSLATION]"; } } } catch(Exception e) { Wandora.getWandora().handleError(e); //e.printStackTrace(); } } return translatedText; }
Example #5
Source File: SimpleMatcherGoogleImpl.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * */ public SimpleMatcherGoogleImpl() { String googleKey = this.parameters.getGoolgeKey(); GoogleAPI.setHttpReferrer("http://www.heartsome.net"); GoogleAPI.setKey(googleKey); }
Example #6
Source File: SimpleMatcherGoogleImpl.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * */ public SimpleMatcherGoogleImpl() { String googleKey = this.parameters.getKey(); GoogleAPI.setHttpReferrer("http://www.heartsome.net"); GoogleAPI.setKey(googleKey); }
Example #7
Source File: SimpleMatcherGoogleImpl.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * */ public SimpleMatcherGoogleImpl() { String googleKey = this.parameters.getKey(); GoogleAPI.setHttpReferrer("http://www.heartsome.net"); GoogleAPI.setKey(googleKey); }