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 Link icon

    • getReadyState Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

      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 Link icon

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