Revision a3fdfdf4
Added by Patrick Plitzner about 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/translation/GoogleLanguageApiWrapper.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
21 | 21 |
* @version 1.0 |
22 | 22 |
* @deprecated Should not be used as the Google translation service is not free anymore |
23 | 23 |
*/ |
24 |
@Deprecated |
|
24 | 25 |
public class GoogleLanguageApiWrapper implements ITranslationServiceWrapper { |
25 | 26 |
|
26 | 27 |
/* (non-Javadoc) |
... | ... | |
30 | 31 |
@Override |
31 | 32 |
public String translate(String text, Language source, Language target) throws LanguageNotSupportedException { |
32 | 33 |
// TODO make this configurable in preferences |
33 |
Translate.setHttpReferrer("http://wp5.e-taxonomy.eu");
|
|
34 |
|
|
34 |
Translate.setHttpReferrer("http://cybertaxonomy.eu");
|
|
35 |
|
|
35 | 36 |
String translated; |
36 | 37 |
try { |
37 | 38 |
translated = Translate.execute(text, getLanguageEquivalent(source), getLanguageEquivalent(target)); |
38 | 39 |
} catch (Exception e) { |
39 | 40 |
throw new LanguageNotSupportedException(e.getMessage()); |
40 | 41 |
} |
41 |
|
|
42 |
|
|
42 | 43 |
return translated; |
43 | 44 |
} |
44 | 45 |
|
45 | 46 |
/** |
46 | 47 |
* @param source |
47 | 48 |
* @return |
48 |
* @throws LanguageNotSupportedException
|
|
49 |
* @throws LanguageNotSupportedException |
|
49 | 50 |
*/ |
50 | 51 |
private com.google.api.translate.Language getLanguageEquivalent( |
51 | 52 |
Language language) throws LanguageNotSupportedException { |
52 |
|
|
53 |
|
|
53 |
|
|
54 |
|
|
54 | 55 |
if(language.equals(Language.ENGLISH())){ |
55 | 56 |
return com.google.api.translate.Language.ENGLISH; |
56 | 57 |
} |
Also available in: Unified diff
ref #6158 avoid URL redirects