Interface IExternalTranslationProvider

All Known Implementing Classes:
AbstractStorageTranslationProvider, CamelCaseProvider, ComputedStringsProvider, ContextDefExternalTranslationProvider, ContextStorageTranslationProvider, DbViewExternalTranslationProvider, DictionaryStorageTranslationProvider, ExternalTranslationProvider, GoogleTranslateProvider, MicrosoftTranslatorProvider, MockedExternalTranslationProvider, TranslitExternalTranslationProvider, YandexTranslateProvider

public interface IExternalTranslationProvider
Provides translating of strings by external translation services.
  • Field Details

    • EXTENSION_POINT_ID

      static final String EXTENSION_POINT_ID
      The id of extension point that contains reference to this interface.
      See Also:
  • Method Details

    • translate

      List<String> translate(String text, String sourceLocale, String targetLocale)
      Translates text from a given language to another given language.
      Parameters:
      text - the string to translate
      sourceLocale - the code of language to translate from
      targetLocale - the code of language to translate to
      Returns:
      the list of possible translations for given text
      Throws:
      IllegalArgumentException - if text is null
      TranslationServiceException - if errors occur while translating
    • translate

      Map<String,List<String>> translate(List<String> texts, String sourceLocale, String targetLocale)
      Translates text from a given language to another given language. In contrast to translate(String, String, String) this method allows to translate a list of strings for one query to translation service.
      Parameters:
      texts - the list of strings to translate in the same language
      sourceLocale - the code of language to translate from
      targetLocale - the code language to translate to
      Returns:
      the map where keys are elements of the given list with strings and values are possible translations for every key in the map
      Throws:
      IllegalArgumentException - if list of texts is null or any element of list is null
      TranslationServiceException - if errors occur while translating
    • getLanguageCodes

      Set<String> getLanguageCodes()
      Returns the set of supported language codes by this service.
      Returns:
      the set of supported language codes
      Throws:
      TranslationServiceException - if errors occur while getting set of supported language codes
    • getLanguages

      Map<String,String> getLanguages(String targetLocale)
      Returns a map of supported language codes and localized names of languages using the given target language or null if service doesn't support the given language.
      Parameters:
      targetLocale - the locale to localize names of languages
      Returns:
      map with language codes and localized names of languages
    • isActive

      @Deprecated default boolean isActive()
      Deprecated.
      Returns true if this provider is active.
      Returns:
      true if this provider is active
    • translate

      default List<String> translate(IContextTranslationQuery query)
      Returns a list of translations by the given query.

      Default implementation of this method uses translate(String, String, String) with the following arguments:

      Parameters:
      query - the query for translating
      Returns:
      a list of translations
    • getTranslationItemImageName

      default String getTranslationItemImageName()