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 Details

    • getReadyState

      String getReadyState()
      Gets the ready state of this translator.
      Returns:
      An error message describing the state (e.g. "Missing API key"), or null for OK.
    • getName

      String getName()
      Returns the name of this translator.
      Returns:
      A String with the name of the translator, e.g. "Google Translate" or "Azure Cognitive Services".
    • updateSupportedLanguages

      void 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.
    • isLanguageHandled

      boolean isLanguageHandled(String languageCode)
      Verifies if a Language Code is handled by this translator.
      Parameters:
      languageCode - The language code.
      Returns:
      true if supported, false if not.
    • getLanguageCode

      String getLanguageCode(String languageCode)
      Gets 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.
    • getLanguageDescription

      String getLanguageDescription(String languageCode)
      Gets 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).
    • canTranslate

      boolean canTranslate(String sourceLanguageCode, String targetLanguageCode)
      Checks 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.
    • translate

      Translation 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.
    • deconfigure

      void deconfigure()
      Deconfigures the translator to "lose" the API key(s).