Package com.iizix.translate
Interface ITranslationEngine
- All Known Implementing Classes:
- EditorTranslationEngine,- TestEngine,- TranslationEngine
public interface ITranslationEngine
The translation engine interface.
- Author:
- Christopher Mindus
- Field SummaryFieldsModifier and TypeFieldDescription- static final intType of request: normal POST.- static final intType of request: POST with "X-HTTP-Method-Override" to GET.
- Method SummaryModifier and TypeMethodDescription- void- cancel()Cancels pending or running translation job.- boolean- canTranslate- (String sourceLanguageCode, String targetLanguageCode) Checks if a translation is handled between two language codes.- void- configureProxy- (HttpURLConnection urlConnection) Configures a Http(s)URLConnection for proxy information.Gets a proxy to use for an URL.Gets the translation queues.Gets the ready state of this translation engine.- getTranslator- (String sourceLanguageCode, String targetLanguageCode) Gets the translator to use for a particular language combination.- boolean- isLanguageHandled- (String languageCode) Verifies if a Language Code is handled by this translator.Requests a function using HTTPS POST, configured for proxy as specified in Eclipse or the Server.Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- requestJSON- (String httpRequest, Map<String, - String> params, Map<String, - String> headers, int type, int sizeLimit) Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- requestString- (String httpRequest, String params, Map<String, - String> headers, int type, int sizeLimit) Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- requestString- (String httpRequest, Map<String, - String> params, Map<String, - String> headers, int type, int sizeLimit) Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- boolean- translate- (KString sourceText, String sourceLanguageCode, String targetLanguageCode, ITranslationReply replyCallback) Translates a text in plain text or HTML.
- Field Details- REQTYPE_POSTstatic final int REQTYPE_POSTType of request: normal POST.- See Also:
 
- REQTYPE_POST_OVERRIDES_GETstatic final int REQTYPE_POST_OVERRIDES_GETType of request: POST with "X-HTTP-Method-Override" to GET.- See Also:
 
 
- Method Details- getTranslatorGets the translator to use for a particular language combination.- Parameters:
- sourceLanguageCode- The source language code, null for automatic detection.
- targetLanguageCode- The target language code.
- Returns:
- The translator, null for not found or not configured.
 
- getQueuesTranslationQueue[] getQueues()Gets the translation queues.- Returns:
- The array of translation queues.
 
- getReadyStateString getReadyState()Gets the ready state of this translation engine.- Returns:
- An error message describing the state (e.g. "Not configured"), or null for OK.
 
- isLanguageHandledVerifies if a Language Code is handled by this translator.- Parameters:
- languageCode- The language code.
- Returns:
- true if supported, false if not.
 
- canTranslateChecks if a translation is handled between two language codes.- Parameters:
- sourceLanguageCode- The source language code, null for automatic detection.
- targetLanguageCode- The target language code.
- Returns:
- true if supported, false if not.
 
- translateboolean translate- (KString sourceText, String sourceLanguageCode, String targetLanguageCode, ITranslationReply replyCallback) Translates a text in plain text or HTML.- Parameters:
- sourceText- The source text to translate.
- sourceLanguageCode- The source language code, null for automatic detection.
- targetLanguageCode- The target language code.
- replyCallback- Callback when translation completes.
- Returns:
- true for success, false for failure (error is logged).
 
- cancelvoid cancel()Cancels pending or running translation job.
- getProxyGets a proxy to use for an URL.- Parameters:
- url- The URL.
- Returns:
- The Proxy to use.
 
- configureProxyConfigures a Http(s)URLConnection for proxy information.- Parameters:
- urlConnection- The HttpURLConnection or HttpsURLConnection.
 
- requestJSONJSONObject requestJSON- (String httpRequest, Map<String, - String> params, Map<String, throws IOException, JSONException- String> headers, int type, int sizeLimit) Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The parsed JSON object.
- Throws:
- IOException- For I/O errors.
- JSONException- For JSON exceptions.
 
- requestJSONJSONObject requestJSON- (String httpRequest, String params, Map<String, - String> headers, int type, int sizeLimit) throws IOException, JSONExceptionRequests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The parsed JSON object.
- Throws:
- IOException- For I/O errors.
- JSONException- For JSON exceptions.
 
- requestStringString requestString- (String httpRequest, Map<String, - String> params, Map<String, throws IOException- String> headers, int type, int sizeLimit) Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The reply string.
- Throws:
- IOException- For I/O errors.
 
- requestStringString requestString- (String httpRequest, String params, Map<String, - String> headers, int type, int sizeLimit) throws IOExceptionRequests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The reply string.
- Throws:
- IOException- For I/O errors.
 
- postRequestJSONString postRequestJSON- (String httpRequest, Map<String, - String> headers, String data) throws IOExceptionRequests a function using HTTPS POST, configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- headers- The HTTP headers, never null.
- data- The data string.
- Returns:
- The reply string.
- Throws:
- IOException- For I/O errors.