3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.ui
.translation
;
13 import com
.google
.api
.translate
.Translate
;
15 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
18 * <p>GoogleLanguageApiWrapper class.</p>
21 * @created Oct 21, 2010
23 * @deprecated Should not be used as the Google translation service is not free anymore
25 public class GoogleLanguageApiWrapper
implements ITranslationServiceWrapper
{
28 * @see eu.etaxonomy.taxeditor.editor.translation.ITranslationServiceWrapper#translate(java.lang.String, eu.etaxonomy.cdm.model.common.Language, eu.etaxonomy.cdm.model.common.Language)
32 public String
translate(String text
, Language source
, Language target
) throws LanguageNotSupportedException
{
33 // TODO make this configurable in preferences
34 Translate
.setHttpReferrer("http://wp5.e-taxonomy.eu");
38 translated
= Translate
.execute(text
, getLanguageEquivalent(source
), getLanguageEquivalent(target
));
39 } catch (Exception e
) {
40 throw new LanguageNotSupportedException(e
.getMessage());
49 * @throws LanguageNotSupportedException
51 private com
.google
.api
.translate
.Language
getLanguageEquivalent(
52 Language language
) throws LanguageNotSupportedException
{
55 if(language
.equals(Language
.ENGLISH())){
56 return com
.google
.api
.translate
.Language
.ENGLISH
;
58 else if(language
.equals(Language
.FRENCH())){
59 return com
.google
.api
.translate
.Language
.FRENCH
;
61 else if(language
.equals(Language
.GERMAN())){
62 return com
.google
.api
.translate
.Language
.GERMAN
;
64 else if(language
.equals(Language
.SPANISH_CASTILIAN())){
65 return com
.google
.api
.translate
.Language
.SPANISH
;
67 else if(language
.equals(Language
.AFRIKAANS())){
68 return com
.google
.api
.translate
.Language
.AFRIKAANS
;
70 else if(language
.equals(Language
.ALBANIAN())){
71 return com
.google
.api
.translate
.Language
.ALBANIAN
;
73 else if(language
.equals(Language
.AMHARIC())){
74 return com
.google
.api
.translate
.Language
.AMHARIC
;
76 else if(language
.equals(Language
.ARABIC())){
77 return com
.google
.api
.translate
.Language
.ARABIC
;
79 else if(language
.equals(Language
.ARMENIAN())){
80 return com
.google
.api
.translate
.Language
.ARMENIAN
;
82 else if(language
.equals(Language
.AZERBAIJANI())){
83 return com
.google
.api
.translate
.Language
.AZERBAIJANI
;
85 else if(language
.equals(Language
.BASQUE())){
86 return com
.google
.api
.translate
.Language
.BASQUE
;
88 else if(language
.equals(Language
.BENGALI())){
89 return com
.google
.api
.translate
.Language
.BENGALI
;
91 else if(language
.equals(Language
.BIHARI())){
92 return com
.google
.api
.translate
.Language
.BIHARI
;
94 else if(language
.equals(Language
.BULGARIAN())){
95 return com
.google
.api
.translate
.Language
.BULGARIAN
;
97 else if(language
.equals(Language
.BURMESE())){
98 return com
.google
.api
.translate
.Language
.BURMESE
;
100 else if(language
.equals(Language
.CHEROKEE())){
101 return com
.google
.api
.translate
.Language
.CHEROKEE
;
103 else if(language
.equals(Language
.CHINESE())){
104 return com
.google
.api
.translate
.Language
.CHINESE
;
106 else if(language
.equals(Language
.CROATIAN())){
107 return com
.google
.api
.translate
.Language
.CROATIAN
;
109 else if(language
.equals(Language
.CZECH())){
110 return com
.google
.api
.translate
.Language
.CZECH
;
112 else if(language
.equals(Language
.DANISH())){
113 return com
.google
.api
.translate
.Language
.DANISH
;
115 else if(language
.equals(Language
.DUTCH_MIDDLE())){
116 return com
.google
.api
.translate
.Language
.DUTCH
;
118 else if(language
.equals(Language
.ESPERANTO())){
119 return com
.google
.api
.translate
.Language
.ESPERANTO
;
121 else if(language
.equals(Language
.ESTONIAN())){
122 return com
.google
.api
.translate
.Language
.ESTONIAN
;
124 else if(language
.equals(Language
.FILIPINO())){
125 return com
.google
.api
.translate
.Language
.FILIPINO
;
127 else if(language
.equals(Language
.FINNISH())){
128 return com
.google
.api
.translate
.Language
.FINNISH
;
130 else if(language
.equals(Language
.GALICIAN())){
131 return com
.google
.api
.translate
.Language
.GALICIAN
;
133 else if(language
.equals(Language
.GEORGIAN())){
134 return com
.google
.api
.translate
.Language
.GEORGIAN
;
136 else if(language
.equals(Language
.GREEK_MODERN())){
137 return com
.google
.api
.translate
.Language
.GREEK
;
139 else if(language
.equals(Language
.GUARANI())){
140 return com
.google
.api
.translate
.Language
.GUARANI
;
142 else if(language
.equals(Language
.GUJARATI())){
143 return com
.google
.api
.translate
.Language
.GUJARATI
;
145 else if(language
.equals(Language
.HEBREW())){
146 return com
.google
.api
.translate
.Language
.HEBREW
;
148 else if(language
.equals(Language
.HINDI())){
149 return com
.google
.api
.translate
.Language
.HINDI
;
151 else if(language
.equals(Language
.HUNGARIAN())){
152 return com
.google
.api
.translate
.Language
.HUNGARIAN
;
154 else if(language
.equals(Language
.ICELANDIC())){
155 return com
.google
.api
.translate
.Language
.ICELANDIC
;
157 else if(language
.equals(Language
.INDONESIAN())){
158 return com
.google
.api
.translate
.Language
.INDONESIAN
;
160 else if(language
.equals(Language
.INUKTITUT())){
161 return com
.google
.api
.translate
.Language
.INUKTITUT
;
163 else if(language
.equals(Language
.IRISH())){
164 return com
.google
.api
.translate
.Language
.IRISH
;
166 else if(language
.equals(Language
.ITALIAN())){
167 return com
.google
.api
.translate
.Language
.ITALIAN
;
169 else if(language
.equals(Language
.JAPANESE())){
170 return com
.google
.api
.translate
.Language
.JAPANESE
;
172 else if(language
.equals(Language
.KANNADA())){
173 return com
.google
.api
.translate
.Language
.KANNADA
;
175 else if(language
.equals(Language
.KAZAKH())){
176 return com
.google
.api
.translate
.Language
.KAZAKH
;
178 else if(language
.equals(Language
.KOREAN())){
179 return com
.google
.api
.translate
.Language
.KOREAN
;
181 else if(language
.equals(Language
.KURDISH())){
182 return com
.google
.api
.translate
.Language
.KURDISH
;
184 else if(language
.equals(Language
.KIRGHIZ_KYRGYZ())){
185 return com
.google
.api
.translate
.Language
.KYRGYZ
;
187 else if(language
.equals(Language
.LAO())){
188 return com
.google
.api
.translate
.Language
.LAOTHIAN
;
190 else if(language
.equals(Language
.LATVIAN())){
191 return com
.google
.api
.translate
.Language
.LATVIAN
;
193 else if(language
.equals(Language
.LITHUANIAN())){
194 return com
.google
.api
.translate
.Language
.LITHUANIAN
;
196 else if(language
.equals(Language
.MACEDONIAN())){
197 return com
.google
.api
.translate
.Language
.MACEDONIAN
;
199 else if(language
.equals(Language
.MALAY())){
200 return com
.google
.api
.translate
.Language
.MALAY
;
202 else if(language
.equals(Language
.MALAYALAM())){
203 return com
.google
.api
.translate
.Language
.MALAYALAM
;
205 else if(language
.equals(Language
.MALTESE())){
206 return com
.google
.api
.translate
.Language
.MALTESE
;
208 else if(language
.equals(Language
.MARATHI())){
209 return com
.google
.api
.translate
.Language
.MARATHI
;
211 else if(language
.equals(Language
.MARATHI())){
212 return com
.google
.api
.translate
.Language
.MONGOLIAN
;
214 else if(language
.equals(Language
.MARATHI())){
215 return com
.google
.api
.translate
.Language
.NEPALI
;
217 else if(language
.equals(Language
.NORWEGIAN())){
218 return com
.google
.api
.translate
.Language
.NORWEGIAN
;
220 else if(language
.equals(Language
.ORIYA())){
221 return com
.google
.api
.translate
.Language
.ORIYA
;
223 else if(language
.equals(Language
.PUSHTO())){
224 return com
.google
.api
.translate
.Language
.PASHTO
;
226 else if(language
.equals(Language
.PERSIAN())){
227 return com
.google
.api
.translate
.Language
.PERSIAN
;
229 else if(language
.equals(Language
.PERSIAN())){
230 return com
.google
.api
.translate
.Language
.POLISH
;
232 else if(language
.equals(Language
.PORTUGUESE())){
233 return com
.google
.api
.translate
.Language
.PORTUGUESE
;
235 else if(language
.equals(Language
.PANJABI_PUNJABI())){
236 return com
.google
.api
.translate
.Language
.PUNJABI
;
238 else if(language
.equals(Language
.ROMANIAN())){
239 return com
.google
.api
.translate
.Language
.ROMANIAN
;
241 else if(language
.equals(Language
.RUSSIAN())){
242 return com
.google
.api
.translate
.Language
.RUSSIAN
;
244 else if(language
.equals(Language
.SANSKRIT())){
245 return com
.google
.api
.translate
.Language
.SANSKRIT
;
247 else if(language
.equals(Language
.SERBIAN())){
248 return com
.google
.api
.translate
.Language
.SERBIAN
;
250 else if(language
.equals(Language
.SINDHI())){
251 return com
.google
.api
.translate
.Language
.SINDHI
;
253 else if(language
.equals(Language
.SINDHI())){
254 return com
.google
.api
.translate
.Language
.SINHALESE
;
256 else if(language
.equals(Language
.SLOVAK())){
257 return com
.google
.api
.translate
.Language
.SLOVAK
;
259 else if(language
.equals(Language
.SLOVENIAN())){
260 return com
.google
.api
.translate
.Language
.SLOVENIAN
;
262 else if(language
.equals(Language
.SWAHILI())){
263 return com
.google
.api
.translate
.Language
.SWAHILI
;
265 else if(language
.equals(Language
.SWEDISH())){
266 return com
.google
.api
.translate
.Language
.SWEDISH
;
268 else if(language
.equals(Language
.TAGALOG())){
269 return com
.google
.api
.translate
.Language
.TAGALOG
;
271 else if(language
.equals(Language
.TAJIK())){
272 return com
.google
.api
.translate
.Language
.TAJIK
;
274 else if(language
.equals(Language
.TAMIL())){
275 return com
.google
.api
.translate
.Language
.TAMIL
;
277 else if(language
.equals(Language
.TELUGU())){
278 return com
.google
.api
.translate
.Language
.TELUGU
;
280 else if(language
.equals(Language
.THAI())){
281 return com
.google
.api
.translate
.Language
.THAI
;
283 else if(language
.equals(Language
.TIBETAN())){
284 return com
.google
.api
.translate
.Language
.TIBETAN
;
286 else if(language
.equals(Language
.TURKISH())){
287 return com
.google
.api
.translate
.Language
.TURKISH
;
289 else if(language
.equals(Language
.UIGHUR_UYGHUR())){
290 return com
.google
.api
.translate
.Language
.UIGHUR
;
292 else if(language
.equals(Language
.UKRAINIAN())){
293 return com
.google
.api
.translate
.Language
.UKRANIAN
;
295 else if(language
.equals(Language
.URDU())){
296 return com
.google
.api
.translate
.Language
.URDU
;
298 else if(language
.equals(Language
.UZBEK())){
299 return com
.google
.api
.translate
.Language
.UZBEK
;
301 else if(language
.equals(Language
.VIETNAMESE())){
302 return com
.google
.api
.translate
.Language
.VIETNAMESE
;
304 else if(language
.equals(Language
.WELSH())){
305 return com
.google
.api
.translate
.Language
.WELSH
;
307 else if(language
.equals(Language
.YIDDISH())){
308 return com
.google
.api
.translate
.Language
.YIDDISH
;
311 throw new LanguageNotSupportedException("The language " + language
.getDescription() + " is not supported");