Package com.iizix.translate
Interface ITranslator
- All Known Subinterfaces:
- IEditorTranslator
- All Known Implementing Classes:
- AzureCognitiveServices,- AzureCognitiveServices,- AzureCognitiveServicesTest,- GoogleTranslate,- GoogleTranslate,- TestGoogleTranslate
public interface ITranslator
The translator interface.
- Author:
- Christopher Mindus
- Method SummaryModifier and TypeMethodDescription- boolean- canTranslate- (String sourceLanguageCode, String targetLanguageCode) Checks if a translation is handled between two language codes.- voidDeconfigures the translator to "lose" the API key(s).- getLanguageCode- (String languageCode) Gets the "real" language code, no matter the input case.- getLanguageDescription- (String languageCode) Gets the language description for a language code, e.g.- getName()Returns the name of this translator.Gets the ready state of this translator.- boolean- isLanguageHandled- (String languageCode) Verifies if a Language Code is handled by this translator.Translates a text in plain text or HTML.- voidUpdates the translator with the supported languages by means of requesting the information from the service.
- Method Details- getReadyStateString getReadyState()Gets the ready state of this translator.- Returns:
- An error message describing the state (e.g. "Missing API key"), or null for OK.
 
- getNameString getName()Returns the name of this translator.- Returns:
- A String with the name of the translator, e.g. "Google Translate" or "Azure Cognitive Services".
 
- updateSupportedLanguagesvoid updateSupportedLanguages()Updates the translator with the supported languages by means of requesting the information from the service. If the request fails, it will be logged in the server.
- isLanguageHandledVerifies if a Language Code is handled by this translator.- Parameters:
- languageCode- The language code.
- Returns:
- true if supported, false if not.
 
- getLanguageCodeGets the "real" language code, no matter the input case.- Parameters:
- languageCode- The language code.
- Returns:
- The potentially changed language code if the case was wrong, or null if language is not supported.
 
- getLanguageDescriptionGets the language description for a language code, e.g. "sv" would be "Swedish".- Parameters:
- languageCode- The language code.
- Returns:
- The language description the current Eclipse + IIZI language (English only for now).
 
- canTranslateChecks if a translation is handled between two language codes.- Parameters:
- sourceLanguageCode- The source language code.
- targetLanguageCode- The target language code.
- Returns:
- true if supported, false if not.
 
- translateTranslation translate- (KString sourceText, String sourceLanguageCode, String targetLanguageCode) throws TranslationException, RequestException 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.
- Returns:
- The translation.
- Throws:
- RequestException- If the translation web service failed.
- TranslationException- An exception for translation failure.
 
- deconfigurevoid deconfigure()Deconfigures the translator to "lose" the API key(s).